@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// Copyright (C) 2015-2019 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@ -23,7 +23,7 @@
@@ -23,7 +23,7 @@
# include <QBuffer>
# include "SWGDeviceSettings.h"
# include "SWGFileSource InputSettings.h"
# include "SWGFileInputSettings.h"
# include "SWGDeviceState.h"
# include "SWGDeviceReport.h"
@ -34,25 +34,25 @@
@@ -34,25 +34,25 @@
# include "dsp/filerecord.h"
# include "device/deviceapi.h"
# include "filesource input.h"
# include "filesource thread.h"
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgConfigureFileSource , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgConfigureFileSourceName , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgConfigureFileSource Work , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgConfigureFileSourceSeek , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgConfigureFileSource StreamTiming , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgStartStop , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgPlayPause , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgReportFileSourceAcquisition , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgReportFileSource StreamData , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgReportFileSource StreamTiming , Message )
MESSAGE_CLASS_DEFINITION ( FileSource Input : : MsgReportHeaderCRC , Message )
FileSource Input : : FileSourc eInput ( DeviceAPI * deviceAPI ) :
# include "fileinput.h"
# include "fileinput thread.h"
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgConfigureFileInput , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgConfigureFileSourceName , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgConfigureFileInput Work , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgConfigureFileSourceSeek , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgConfigureFileInput StreamTiming , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgStartStop , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgPlayPause , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgReportFileSourceAcquisition , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgReportFileInput StreamData , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgReportFileInput StreamTiming , Message )
MESSAGE_CLASS_DEFINITION ( FileInput : : MsgReportHeaderCRC , Message )
FileInput : : FileInput ( DeviceAPI * deviceAPI ) :
m_deviceAPI ( deviceAPI ) ,
m_settings ( ) ,
m_fileSourceThread ( NULL ) ,
m_fileInputThread ( nullptr ) ,
m_deviceDescription ( ) ,
m_fileName ( " ... " ) ,
m_sampleRate ( 0 ) ,
@ -62,16 +62,16 @@ FileSourceInput::FileSourceInput(DeviceAPI *deviceAPI) :
@@ -62,16 +62,16 @@ FileSourceInput::FileSourceInput(DeviceAPI *deviceAPI) :
m_startingTimeStamp ( 0 )
{
m_deviceAPI - > setNbSourceStreams ( 1 ) ;
qDebug ( " FileSource Input::FileSourc eInput: device source engine: %p " , m_deviceAPI - > getDeviceSourceEngine ( ) ) ;
qDebug ( " FileSource Input::FileSourc eInput: device source engine message queue: %p " , m_deviceAPI - > getDeviceEngineInputMessageQueue ( ) ) ;
qDebug ( " FileSource Input::FileSourc eInput: device source: %p " , m_deviceAPI - > getDeviceSourceEngine ( ) - > getSource ( ) ) ;
qDebug ( " FileInput::FileInput: device source engine: %p " , m_deviceAPI - > getDeviceSourceEngine ( ) ) ;
qDebug ( " FileInput::FileInput: device source engine message queue: %p " , m_deviceAPI - > getDeviceEngineInputMessageQueue ( ) ) ;
qDebug ( " FileInput::FileInput: device source: %p " , m_deviceAPI - > getDeviceSourceEngine ( ) - > getSource ( ) ) ;
m_networkManager = new QNetworkAccessManager ( ) ;
connect ( m_networkManager , SIGNAL ( finished ( QNetworkReply * ) ) , this , SLOT ( networkManagerFinished ( QNetworkReply * ) ) ) ;
m_masterTimer . setTimerType ( Qt : : PreciseTimer ) ;
m_masterTimer . start ( 50 ) ;
}
FileSource Input : : ~ FileSourc eInput ( )
FileInput : : ~ FileInput ( )
{
m_masterTimer . stop ( ) ;
disconnect ( m_networkManager , SIGNAL ( finished ( QNetworkReply * ) ) , this , SLOT ( networkManagerFinished ( QNetworkReply * ) ) ) ;
@ -80,12 +80,12 @@ FileSourceInput::~FileSourceInput()
@@ -80,12 +80,12 @@ FileSourceInput::~FileSourceInput()
stop ( ) ;
}
void FileSource Input : : destroy ( )
void FileInput : : destroy ( )
{
delete this ;
}
void FileSource Input : : openFileStream ( )
void FileInput : : openFileStream ( )
{
//stopInput();
@ -113,12 +113,12 @@ void FileSourceInput::openFileStream()
@@ -113,12 +113,12 @@ void FileSourceInput::openFileStream()
if ( crcOK )
{
qDebug ( " FileSource Input::openFileStream: CRC32 OK for header: %s " , qPrintable ( crcHex ) ) ;
qDebug ( " FileInput::openFileStream: CRC32 OK for header: %s " , qPrintable ( crcHex ) ) ;
m_recordLength = ( fileSize - sizeof ( FileRecord : : Header ) ) / ( ( m_sampleSize = = 24 ? 8 : 4 ) * m_sampleRate ) ;
}
else
{
qCritical ( " FileSource Input::openFileStream: bad CRC32 for header: %s " , qPrintable ( crcHex ) ) ;
qCritical ( " FileInput::openFileStream: bad CRC32 for header: %s " , qPrintable ( crcHex ) ) ;
m_recordLength = 0 ;
}
@ -132,7 +132,7 @@ void FileSourceInput::openFileStream()
@@ -132,7 +132,7 @@ void FileSourceInput::openFileStream()
m_recordLength = 0 ;
}
qDebug ( ) < < " FileSource Input::openFileStream: " < < m_fileName . toStdString ( ) . c_str ( )
qDebug ( ) < < " FileInput::openFileStream: " < < m_fileName . toStdString ( ) . c_str ( )
< < " fileSize: " < < fileSize < < " bytes "
< < " length: " < < m_recordLength < < " seconds "
< < " sample rate: " < < m_sampleRate < < " S/s "
@ -140,7 +140,7 @@ void FileSourceInput::openFileStream()
@@ -140,7 +140,7 @@ void FileSourceInput::openFileStream()
< < " sample size: " < < m_sampleSize < < " bits " ;
if ( getMessageQueueToGUI ( ) ) {
MsgReportFileSource StreamData * report = MsgReportFileSource StreamData : : create ( m_sampleRate ,
MsgReportFileInput StreamData * report = MsgReportFileInput StreamData : : create ( m_sampleRate ,
m_sampleSize ,
m_centerFrequency ,
m_startingTimeStamp ,
@ -153,36 +153,36 @@ void FileSourceInput::openFileStream()
@@ -153,36 +153,36 @@ void FileSourceInput::openFileStream()
}
}
void FileSource Input : : seekFileStream ( int seekMillis )
void FileInput : : seekFileStream ( int seekMillis )
{
QMutexLocker mutexLocker ( & m_mutex ) ;
if ( ( m_ifstream . is_open ( ) ) & & m_fileSource Thread & & ! m_fileSource Thread - > isRunning ( ) )
if ( ( m_ifstream . is_open ( ) ) & & m_fileInput Thread & & ! m_fileInput Thread - > isRunning ( ) )
{
quint64 seekPoint = ( ( m_recordLength * seekMillis ) / 1000 ) * m_sampleRate ;
m_fileSource Thread - > setSamplesCount ( seekPoint ) ;
m_fileInput Thread - > setSamplesCount ( seekPoint ) ;
seekPoint * = ( m_sampleSize = = 24 ? 8 : 4 ) ; // + sizeof(FileSink::Header)
m_ifstream . clear ( ) ;
m_ifstream . seekg ( seekPoint + sizeof ( FileRecord : : Header ) , std : : ios : : beg ) ;
}
}
void FileSource Input : : init ( )
void FileInput : : init ( )
{
DSPSignalNotification * notif = new DSPSignalNotification ( m_settings . m_sampleRate , m_settings . m_centerFrequency ) ;
m_deviceAPI - > getDeviceEngineInputMessageQueue ( ) - > push ( notif ) ;
}
bool FileSource Input : : start ( )
bool FileInput : : start ( )
{
if ( ! m_ifstream . is_open ( ) )
{
qWarning ( " FileSource Input::start: file not open. not starting " ) ;
qWarning ( " FileInput::start: file not open. not starting " ) ;
return false ;
}
QMutexLocker mutexLocker ( & m_mutex ) ;
qDebug ( ) < < " FileSource Input::start " ;
qDebug ( ) < < " FileInput::start " ;
if ( m_ifstream . tellg ( ) ! = ( std : : streampos ) 0 ) {
m_ifstream . clear ( ) ;
@ -194,13 +194,13 @@ bool FileSourceInput::start()
@@ -194,13 +194,13 @@ bool FileSourceInput::start()
return false ;
}
m_fileSourceThread = new FileSource Thread ( & m_ifstream , & m_sampleFifo , m_masterTimer , & m_inputMessageQueue ) ;
m_fileSource Thread - > setSampleRateAndSize ( m_settings . m_accelerationFactor * m_sampleRate , m_sampleSize ) ; // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
m_fileSource Thread - > startWork ( ) ;
m_deviceDescription = " FileSource " ;
m_fileInputThread = new FileInput Thread ( & m_ifstream , & m_sampleFifo , m_masterTimer , & m_inputMessageQueue ) ;
m_fileInput Thread - > setSampleRateAndSize ( m_settings . m_accelerationFactor * m_sampleRate , m_sampleSize ) ; // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
m_fileInput Thread - > startWork ( ) ;
m_deviceDescription = " FileInput " ;
mutexLocker . unlock ( ) ;
qDebug ( " FileSource Input::startInput: started " ) ;
qDebug ( " FileInput::startInput: started " ) ;
if ( getMessageQueueToGUI ( ) ) {
MsgReportFileSourceAcquisition * report = MsgReportFileSourceAcquisition : : create ( true ) ; // acquisition on
@ -210,16 +210,16 @@ bool FileSourceInput::start()
@@ -210,16 +210,16 @@ bool FileSourceInput::start()
return true ;
}
void FileSource Input : : stop ( )
void FileInput : : stop ( )
{
qDebug ( ) < < " FileSource Input::stop " ;
qDebug ( ) < < " FileInput::stop " ;
QMutexLocker mutexLocker ( & m_mutex ) ;
if ( m_fileSourceThread ! = 0 )
if ( m_fileInputThread )
{
m_fileSource Thread - > stopWork ( ) ;
delete m_fileSource Thread ;
m_fileSourceThread = 0 ;
m_fileInput Thread - > stopWork ( ) ;
delete m_fileInput Thread ;
m_fileInputThread = nullptr ;
}
m_deviceDescription . clear ( ) ;
@ -230,12 +230,12 @@ void FileSourceInput::stop()
@@ -230,12 +230,12 @@ void FileSourceInput::stop()
}
}
QByteArray FileSource Input : : serialize ( ) const
QByteArray FileInput : : serialize ( ) const
{
return m_settings . serialize ( ) ;
}
bool FileSource Input : : deserialize ( const QByteArray & data )
bool FileInput : : deserialize ( const QByteArray & data )
{
bool success = true ;
@ -245,59 +245,59 @@ bool FileSourceInput::deserialize(const QByteArray& data)
@@ -245,59 +245,59 @@ bool FileSourceInput::deserialize(const QByteArray& data)
success = false ;
}
MsgConfigureFileSource * message = MsgConfigureFileSource : : create ( m_settings , true ) ;
MsgConfigureFileInput * message = MsgConfigureFileInput : : create ( m_settings , true ) ;
m_inputMessageQueue . push ( message ) ;
if ( getMessageQueueToGUI ( ) )
{
MsgConfigureFileSource * messageToGUI = MsgConfigureFileSource : : create ( m_settings , true ) ;
MsgConfigureFileInput * messageToGUI = MsgConfigureFileInput : : create ( m_settings , true ) ;
getMessageQueueToGUI ( ) - > push ( messageToGUI ) ;
}
return success ;
}
const QString & FileSource Input : : getDeviceDescription ( ) const
const QString & FileInput : : getDeviceDescription ( ) const
{
return m_deviceDescription ;
}
int FileSource Input : : getSampleRate ( ) const
int FileInput : : getSampleRate ( ) const
{
return m_sampleRate ;
}
quint64 FileSource Input : : getCenterFrequency ( ) const
quint64 FileInput : : getCenterFrequency ( ) const
{
return m_centerFrequency ;
}
void FileSource Input : : setCenterFrequency ( qint64 centerFrequency )
void FileInput : : setCenterFrequency ( qint64 centerFrequency )
{
FileSource InputSettings settings = m_settings ;
FileInputSettings settings = m_settings ;
settings . m_centerFrequency = centerFrequency ;
MsgConfigureFileSource * message = MsgConfigureFileSource : : create ( m_settings , false ) ;
MsgConfigureFileInput * message = MsgConfigureFileInput : : create ( m_settings , false ) ;
m_inputMessageQueue . push ( message ) ;
if ( getMessageQueueToGUI ( ) )
{
MsgConfigureFileSource * messageToGUI = MsgConfigureFileSource : : create ( m_settings , false ) ;
MsgConfigureFileInput * messageToGUI = MsgConfigureFileInput : : create ( m_settings , false ) ;
getMessageQueueToGUI ( ) - > push ( messageToGUI ) ;
}
}
quint64 FileSource Input : : getStartingTimeStamp ( ) const
quint64 FileInput : : getStartingTimeStamp ( ) const
{
return m_startingTimeStamp ;
}
bool FileSource Input : : handleMessage ( const Message & message )
bool FileInput : : handleMessage ( const Message & message )
{
if ( MsgConfigureFileSource : : match ( message ) )
if ( MsgConfigureFileInput : : match ( message ) )
{
MsgConfigureFileSource & conf = ( MsgConfigureFileSource & ) message ;
FileSource InputSettings settings = conf . getSettings ( ) ;
MsgConfigureFileInput & conf = ( MsgConfigureFileInput & ) message ;
FileInputSettings settings = conf . getSettings ( ) ;
applySettings ( settings ) ;
return true ;
}
@ -308,17 +308,17 @@ bool FileSourceInput::handleMessage(const Message& message)
@@ -308,17 +308,17 @@ bool FileSourceInput::handleMessage(const Message& message)
openFileStream ( ) ;
return true ;
}
else if ( MsgConfigureFileSource Work : : match ( message ) )
else if ( MsgConfigureFileInput Work : : match ( message ) )
{
MsgConfigureFileSource Work & conf = ( MsgConfigureFileSource Work & ) message ;
MsgConfigureFileInput Work & conf = ( MsgConfigureFileInput Work & ) message ;
bool working = conf . isWorking ( ) ;
if ( m_fileSource Thread ! = 0 )
if ( m_fileInput Thread ! = 0 )
{
if ( working ) {
m_fileSource Thread - > startWork ( ) ;
m_fileInput Thread - > startWork ( ) ;
} else {
m_fileSource Thread - > stopWork ( ) ;
m_fileInput Thread - > stopWork ( ) ;
}
}
@ -332,15 +332,15 @@ bool FileSourceInput::handleMessage(const Message& message)
@@ -332,15 +332,15 @@ bool FileSourceInput::handleMessage(const Message& message)
return true ;
}
else if ( MsgConfigureFileSource StreamTiming : : match ( message ) )
else if ( MsgConfigureFileInput StreamTiming : : match ( message ) )
{
MsgReportFileSource StreamTiming * report ;
MsgReportFileInput StreamTiming * report ;
if ( m_fileSource Thread ! = 0 )
if ( m_fileInput Thread ! = 0 )
{
if ( getMessageQueueToGUI ( ) )
{
report = MsgReportFileSource StreamTiming : : create ( m_fileSource Thread - > getSamplesCount ( ) ) ;
report = MsgReportFileInput StreamTiming : : create ( m_fileInput Thread - > getSamplesCount ( ) ) ;
getMessageQueueToGUI ( ) - > push ( report ) ;
}
}
@ -350,7 +350,7 @@ bool FileSourceInput::handleMessage(const Message& message)
@@ -350,7 +350,7 @@ bool FileSourceInput::handleMessage(const Message& message)
else if ( MsgStartStop : : match ( message ) )
{
MsgStartStop & cmd = ( MsgStartStop & ) message ;
qDebug ( ) < < " FileSource Input::handleMessage: MsgStartStop: " < < ( cmd . getStartStop ( ) ? " start " : " stop " ) ;
qDebug ( ) < < " FileInput::handleMessage: MsgStartStop: " < < ( cmd . getStartStop ( ) ? " start " : " stop " ) ;
if ( cmd . getStartStop ( ) )
{
@ -370,21 +370,21 @@ bool FileSourceInput::handleMessage(const Message& message)
@@ -370,21 +370,21 @@ bool FileSourceInput::handleMessage(const Message& message)
return true ;
}
else if ( FileSource Thread : : MsgReportEOF : : match ( message ) )
else if ( FileInput Thread : : MsgReportEOF : : match ( message ) )
{
qDebug ( ) < < " FileSource Input::handleMessage: MsgReportEOF " ;
m_fileSource Thread - > stopWork ( ) ;
qDebug ( ) < < " FileInput::handleMessage: MsgReportEOF " ;
m_fileInput Thread - > stopWork ( ) ;
if ( getMessageQueueToGUI ( ) )
{
MsgReportFileSource StreamTiming * report = MsgReportFileSource StreamTiming : : create ( m_fileSource Thread - > getSamplesCount ( ) ) ;
MsgReportFileInput StreamTiming * report = MsgReportFileInput StreamTiming : : create ( m_fileInput Thread - > getSamplesCount ( ) ) ;
getMessageQueueToGUI ( ) - > push ( report ) ;
}
if ( m_settings . m_loop )
{
seekFileStream ( 0 ) ;
m_fileSource Thread - > startWork ( ) ;
m_fileInput Thread - > startWork ( ) ;
}
else
{
@ -403,7 +403,7 @@ bool FileSourceInput::handleMessage(const Message& message)
@@ -403,7 +403,7 @@ bool FileSourceInput::handleMessage(const Message& message)
}
}
bool FileSource Input : : applySettings ( const FileSourc eInputSettings & settings , bool force )
bool FileInput : : applySettings ( const FileInputSettings & settings , bool force )
{
QList < QString > reverseAPIKeys ;
@ -415,14 +415,14 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
@@ -415,14 +415,14 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
{
reverseAPIKeys . append ( " accelerationFactor " ) ;
if ( m_fileSource Thread )
if ( m_fileInput Thread )
{
QMutexLocker mutexLocker ( & m_mutex ) ;
if ( ! m_sampleFifo . setSize ( m_settings . m_accelerationFactor * m_sampleRate * sizeof ( Sample ) ) ) {
qCritical ( " FileSource Input::applySettings: could not reallocate sample FIFO size to %lu " ,
qCritical ( " FileInput::applySettings: could not reallocate sample FIFO size to %lu " ,
m_settings . m_accelerationFactor * m_sampleRate * sizeof ( Sample ) ) ;
}
m_fileSource Thread - > setSampleRateAndSize ( settings . m_accelerationFactor * m_sampleRate , m_sampleSize ) ; // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
m_fileInput Thread - > setSampleRateAndSize ( settings . m_accelerationFactor * m_sampleRate , m_sampleSize ) ; // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
}
}
@ -446,54 +446,54 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
@@ -446,54 +446,54 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
return true ;
}
int FileSource Input : : webapiSettingsGet (
int FileInput : : webapiSettingsGet (
SWGSDRangel : : SWGDeviceSettings & response ,
QString & errorMessage )
{
( void ) errorMessage ;
response . setFileSource InputSettings ( new SWGSDRangel : : SWGFileSourc eInputSettings ( ) ) ;
response . getFileSource InputSettings ( ) - > init ( ) ;
response . setFileInputSettings ( new SWGSDRangel : : SWGFileInputSettings ( ) ) ;
response . getFileInputSettings ( ) - > init ( ) ;
webapiFormatDeviceSettings ( response , m_settings ) ;
return 200 ;
}
int FileSource Input : : webapiSettingsPutPatch (
int FileInput : : webapiSettingsPutPatch (
bool force ,
const QStringList & deviceSettingsKeys ,
SWGSDRangel : : SWGDeviceSettings & response , // query + response
QString & errorMessage )
{
( void ) errorMessage ;
FileSource InputSettings settings = m_settings ;
FileInputSettings settings = m_settings ;
if ( deviceSettingsKeys . contains ( " fileName " ) ) {
settings . m_fileName = * response . getFileSource InputSettings ( ) - > getFileName ( ) ;
settings . m_fileName = * response . getFileInputSettings ( ) - > getFileName ( ) ;
}
if ( deviceSettingsKeys . contains ( " accelerationFactor " ) ) {
settings . m_accelerationFactor = response . getFileSource InputSettings ( ) - > getAccelerationFactor ( ) ;
settings . m_accelerationFactor = response . getFileInputSettings ( ) - > getAccelerationFactor ( ) ;
}
if ( deviceSettingsKeys . contains ( " loop " ) ) {
settings . m_loop = response . getFileSource InputSettings ( ) - > getLoop ( ) ! = 0 ;
settings . m_loop = response . getFileInputSettings ( ) - > getLoop ( ) ! = 0 ;
}
if ( deviceSettingsKeys . contains ( " useReverseAPI " ) ) {
settings . m_useReverseAPI = response . getFileSource InputSettings ( ) - > getUseReverseApi ( ) ! = 0 ;
settings . m_useReverseAPI = response . getFileInputSettings ( ) - > getUseReverseApi ( ) ! = 0 ;
}
if ( deviceSettingsKeys . contains ( " reverseAPIAddress " ) ) {
settings . m_reverseAPIAddress = * response . getFileSource InputSettings ( ) - > getReverseApiAddress ( ) ;
settings . m_reverseAPIAddress = * response . getFileInputSettings ( ) - > getReverseApiAddress ( ) ;
}
if ( deviceSettingsKeys . contains ( " reverseAPIPort " ) ) {
settings . m_reverseAPIPort = response . getFileSource InputSettings ( ) - > getReverseApiPort ( ) ;
settings . m_reverseAPIPort = response . getFileInputSettings ( ) - > getReverseApiPort ( ) ;
}
if ( deviceSettingsKeys . contains ( " reverseAPIDeviceIndex " ) ) {
settings . m_reverseAPIDeviceIndex = response . getFileSource InputSettings ( ) - > getReverseApiDeviceIndex ( ) ;
settings . m_reverseAPIDeviceIndex = response . getFileInputSettings ( ) - > getReverseApiDeviceIndex ( ) ;
}
MsgConfigureFileSource * msg = MsgConfigureFileSource : : create ( settings , force ) ;
MsgConfigureFileInput * msg = MsgConfigureFileInput : : create ( settings , force ) ;
m_inputMessageQueue . push ( msg ) ;
if ( m_guiMessageQueue ) // forward to GUI if any
{
MsgConfigureFileSource * msgToGUI = MsgConfigureFileSource : : create ( settings , force ) ;
MsgConfigureFileInput * msgToGUI = MsgConfigureFileInput : : create ( settings , force ) ;
m_guiMessageQueue - > push ( msgToGUI ) ;
}
@ -501,7 +501,7 @@ int FileSourceInput::webapiSettingsPutPatch(
@@ -501,7 +501,7 @@ int FileSourceInput::webapiSettingsPutPatch(
return 200 ;
}
int FileSource Input : : webapiRunGet (
int FileInput : : webapiRunGet (
SWGSDRangel : : SWGDeviceState & response ,
QString & errorMessage )
{
@ -510,7 +510,7 @@ int FileSourceInput::webapiRunGet(
@@ -510,7 +510,7 @@ int FileSourceInput::webapiRunGet(
return 200 ;
}
int FileSource Input : : webapiRun (
int FileInput : : webapiRun (
bool run ,
SWGSDRangel : : SWGDeviceState & response ,
QString & errorMessage )
@ -529,43 +529,43 @@ int FileSourceInput::webapiRun(
@@ -529,43 +529,43 @@ int FileSourceInput::webapiRun(
return 200 ;
}
int FileSource Input : : webapiReportGet (
int FileInput : : webapiReportGet (
SWGSDRangel : : SWGDeviceReport & response ,
QString & errorMessage )
{
( void ) errorMessage ;
response . setFileSource InputReport ( new SWGSDRangel : : SWGFileSourc eInputReport ( ) ) ;
response . getFileSource InputReport ( ) - > init ( ) ;
response . setFileInputReport ( new SWGSDRangel : : SWGFileInputReport ( ) ) ;
response . getFileInputReport ( ) - > init ( ) ;
webapiFormatDeviceReport ( response ) ;
return 200 ;
}
void FileSource Input : : webapiFormatDeviceSettings ( SWGSDRangel : : SWGDeviceSettings & response , const FileSourc eInputSettings & settings )
void FileInput : : webapiFormatDeviceSettings ( SWGSDRangel : : SWGDeviceSettings & response , const FileInputSettings & settings )
{
response . getFileSource InputSettings ( ) - > setFileName ( new QString ( settings . m_fileName ) ) ;
response . getFileSource InputSettings ( ) - > setAccelerationFactor ( settings . m_accelerationFactor ) ;
response . getFileSource InputSettings ( ) - > setLoop ( settings . m_loop ? 1 : 0 ) ;
response . getFileInputSettings ( ) - > setFileName ( new QString ( settings . m_fileName ) ) ;
response . getFileInputSettings ( ) - > setAccelerationFactor ( settings . m_accelerationFactor ) ;
response . getFileInputSettings ( ) - > setLoop ( settings . m_loop ? 1 : 0 ) ;
response . getFileSource InputSettings ( ) - > setUseReverseApi ( settings . m_useReverseAPI ? 1 : 0 ) ;
response . getFileInputSettings ( ) - > setUseReverseApi ( settings . m_useReverseAPI ? 1 : 0 ) ;
if ( response . getFileSource InputSettings ( ) - > getReverseApiAddress ( ) ) {
* response . getFileSource InputSettings ( ) - > getReverseApiAddress ( ) = settings . m_reverseAPIAddress ;
if ( response . getFileInputSettings ( ) - > getReverseApiAddress ( ) ) {
* response . getFileInputSettings ( ) - > getReverseApiAddress ( ) = settings . m_reverseAPIAddress ;
} else {
response . getFileSource InputSettings ( ) - > setReverseApiAddress ( new QString ( settings . m_reverseAPIAddress ) ) ;
response . getFileInputSettings ( ) - > setReverseApiAddress ( new QString ( settings . m_reverseAPIAddress ) ) ;
}
response . getFileSource InputSettings ( ) - > setReverseApiPort ( settings . m_reverseAPIPort ) ;
response . getFileSource InputSettings ( ) - > setReverseApiDeviceIndex ( settings . m_reverseAPIDeviceIndex ) ;
response . getFileInputSettings ( ) - > setReverseApiPort ( settings . m_reverseAPIPort ) ;
response . getFileInputSettings ( ) - > setReverseApiDeviceIndex ( settings . m_reverseAPIDeviceIndex ) ;
}
void FileSource Input : : webapiFormatDeviceReport ( SWGSDRangel : : SWGDeviceReport & response )
void FileInput : : webapiFormatDeviceReport ( SWGSDRangel : : SWGDeviceReport & response )
{
qint64 t_sec = 0 ;
qint64 t_msec = 0 ;
quint64 samplesCount = 0 ;
if ( m_fileSource Thread ) {
samplesCount = m_fileSource Thread - > getSamplesCount ( ) ;
if ( m_fileInput Thread ) {
samplesCount = m_fileInput Thread - > getSamplesCount ( ) ;
}
if ( m_sampleRate > 0 )
@ -577,42 +577,42 @@ void FileSourceInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& res
@@ -577,42 +577,42 @@ void FileSourceInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& res
QTime t ( 0 , 0 , 0 , 0 ) ;
t = t . addSecs ( t_sec ) ;
t = t . addMSecs ( t_msec ) ;
response . getFileSource InputReport ( ) - > setElapsedTime ( new QString ( t . toString ( " HH:mm:ss.zzz " ) ) ) ;
response . getFileInputReport ( ) - > setElapsedTime ( new QString ( t . toString ( " HH:mm:ss.zzz " ) ) ) ;
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL ;
QDateTime dt = QDateTime : : fromMSecsSinceEpoch ( startingTimeStampMsec ) ;
dt = dt . addSecs ( t_sec ) ;
dt = dt . addMSecs ( t_msec ) ;
response . getFileSource InputReport ( ) - > setAbsoluteTime ( new QString ( dt . toString ( " yyyy-MM-dd HH:mm:ss.zzz " ) ) ) ;
response . getFileInputReport ( ) - > setAbsoluteTime ( new QString ( dt . toString ( " yyyy-MM-dd HH:mm:ss.zzz " ) ) ) ;
QTime recordLength ( 0 , 0 , 0 , 0 ) ;
recordLength = recordLength . addSecs ( m_recordLength ) ;
response . getFileSource InputReport ( ) - > setDurationTime ( new QString ( recordLength . toString ( " HH:mm:ss " ) ) ) ;
response . getFileInputReport ( ) - > setDurationTime ( new QString ( recordLength . toString ( " HH:mm:ss " ) ) ) ;
response . getFileSource InputReport ( ) - > setFileName ( new QString ( m_fileName ) ) ;
response . getFileSource InputReport ( ) - > setSampleRate ( m_sampleRate ) ;
response . getFileSource InputReport ( ) - > setSampleSize ( m_sampleSize ) ;
response . getFileInputReport ( ) - > setFileName ( new QString ( m_fileName ) ) ;
response . getFileInputReport ( ) - > setSampleRate ( m_sampleRate ) ;
response . getFileInputReport ( ) - > setSampleSize ( m_sampleSize ) ;
}
void FileSource Input : : webapiReverseSendSettings ( QList < QString > & deviceSettingsKeys , const FileSourc eInputSettings & settings , bool force )
void FileInput : : webapiReverseSendSettings ( QList < QString > & deviceSettingsKeys , const FileInputSettings & settings , bool force )
{
SWGSDRangel : : SWGDeviceSettings * swgDeviceSettings = new SWGSDRangel : : SWGDeviceSettings ( ) ;
swgDeviceSettings - > setDirection ( 0 ) ; // single Rx
swgDeviceSettings - > setOriginatorIndex ( m_deviceAPI - > getDeviceSetIndex ( ) ) ;
swgDeviceSettings - > setDeviceHwType ( new QString ( " FileSource " ) ) ;
swgDeviceSettings - > setFileSource InputSettings ( new SWGSDRangel : : SWGFileSourc eInputSettings ( ) ) ;
SWGSDRangel : : SWGFileSource InputSettings * swgFileSourc eInputSettings = swgDeviceSettings - > getFileSourc eInputSettings ( ) ;
swgDeviceSettings - > setDeviceHwType ( new QString ( " FileInput " ) ) ;
swgDeviceSettings - > setFileInputSettings ( new SWGSDRangel : : SWGFileInputSettings ( ) ) ;
SWGSDRangel : : SWGFileInputSettings * swgFileInputSettings = swgDeviceSettings - > getFileInputSettings ( ) ;
// transfer data that has been modified. When force is on transfer all data except reverse API data
if ( deviceSettingsKeys . contains ( " accelerationFactor " ) | | force ) {
swgFileSource InputSettings - > setAccelerationFactor ( settings . m_accelerationFactor ) ;
swgFileInputSettings - > setAccelerationFactor ( settings . m_accelerationFactor ) ;
}
if ( deviceSettingsKeys . contains ( " loop " ) | | force ) {
swgFileSource InputSettings - > setLoop ( settings . m_loop ) ;
swgFileInputSettings - > setLoop ( settings . m_loop ) ;
}
if ( deviceSettingsKeys . contains ( " fileName " ) | | force ) {
swgFileSource InputSettings - > setFileName ( new QString ( settings . m_fileName ) ) ;
swgFileInputSettings - > setFileName ( new QString ( settings . m_fileName ) ) ;
}
QString deviceSettingsURL = QString ( " http://%1:%2/sdrangel/deviceset/%3/device/settings " )
@ -633,12 +633,12 @@ void FileSourceInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKe
@@ -633,12 +633,12 @@ void FileSourceInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKe
delete swgDeviceSettings ;
}
void FileSource Input : : webapiReverseSendStartStop ( bool start )
void FileInput : : webapiReverseSendStartStop ( bool start )
{
SWGSDRangel : : SWGDeviceSettings * swgDeviceSettings = new SWGSDRangel : : SWGDeviceSettings ( ) ;
swgDeviceSettings - > setDirection ( 0 ) ; // single Rx
swgDeviceSettings - > setOriginatorIndex ( m_deviceAPI - > getDeviceSetIndex ( ) ) ;
swgDeviceSettings - > setDeviceHwType ( new QString ( " FileSource " ) ) ;
swgDeviceSettings - > setDeviceHwType ( new QString ( " FileInput " ) ) ;
QString deviceSettingsURL = QString ( " http://%1:%2/sdrangel/deviceset/%3/device/run " )
. arg ( m_settings . m_reverseAPIAddress )
@ -661,13 +661,13 @@ void FileSourceInput::webapiReverseSendStartStop(bool start)
@@ -661,13 +661,13 @@ void FileSourceInput::webapiReverseSendStartStop(bool start)
delete swgDeviceSettings ;
}
void FileSource Input : : networkManagerFinished ( QNetworkReply * reply )
void FileInput : : networkManagerFinished ( QNetworkReply * reply )
{
QNetworkReply : : NetworkError replyError = reply - > error ( ) ;
if ( replyError )
{
qWarning ( ) < < " FileSource Input::networkManagerFinished: "
qWarning ( ) < < " FileInput::networkManagerFinished: "
< < " error( " < < ( int ) replyError
< < " ): " < < replyError
< < " : " < < reply - > errorString ( ) ;
@ -676,5 +676,5 @@ void FileSourceInput::networkManagerFinished(QNetworkReply *reply)
@@ -676,5 +676,5 @@ void FileSourceInput::networkManagerFinished(QNetworkReply *reply)
QString answer = reply - > readAll ( ) ;
answer . chop ( 1 ) ; // remove last \n
qDebug ( " FileSource Input::networkManagerFinished: reply: \n %s " , answer . toStdString ( ) . c_str ( ) ) ;
qDebug ( " FileInput::networkManagerFinished: reply: \n %s " , answer . toStdString ( ) . c_str ( ) ) ;
}