2016-10-19 12:42:57 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 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 //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_FILESINKOUTPUT_H
|
|
|
|
#define INCLUDE_FILESINKOUTPUT_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
|
2016-10-20 19:21:17 -04:00
|
|
|
#include "dsp/devicesamplesink.h"
|
|
|
|
#include "filesinksettings.h"
|
|
|
|
|
2016-10-19 12:42:57 -04:00
|
|
|
class FileSinkThread;
|
2016-10-22 15:47:59 -04:00
|
|
|
class DeviceSinkAPI;
|
2016-10-19 12:42:57 -04:00
|
|
|
|
|
|
|
class FileSinkOutput : public DeviceSampleSink {
|
|
|
|
public:
|
|
|
|
class MsgConfigureFileSink : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-10-20 19:21:17 -04:00
|
|
|
const FileSinkSettings& getSettings() const { return m_settings; }
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2016-10-20 19:21:17 -04:00
|
|
|
static MsgConfigureFileSink* create(const FileSinkSettings& settings)
|
2016-10-19 12:42:57 -04:00
|
|
|
{
|
|
|
|
return new MsgConfigureFileSink(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-10-20 19:21:17 -04:00
|
|
|
FileSinkSettings m_settings;
|
2016-10-19 12:42:57 -04:00
|
|
|
|
2016-10-20 19:21:17 -04:00
|
|
|
MsgConfigureFileSink(const FileSinkSettings& settings) :
|
2016-10-19 12:42:57 -04:00
|
|
|
Message(),
|
|
|
|
m_settings(settings)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureFileSinkName : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString& getFileName() const { return m_fileName; }
|
|
|
|
|
|
|
|
static MsgConfigureFileSinkName* create(const QString& fileName)
|
|
|
|
{
|
|
|
|
return new MsgConfigureFileSinkName(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_fileName;
|
|
|
|
|
|
|
|
MsgConfigureFileSinkName(const QString& fileName) :
|
|
|
|
Message(),
|
|
|
|
m_fileName(fileName)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureFileSinkWork : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool isWorking() const { return m_working; }
|
|
|
|
|
|
|
|
static MsgConfigureFileSinkWork* create(bool working)
|
|
|
|
{
|
|
|
|
return new MsgConfigureFileSinkWork(working);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_working;
|
|
|
|
|
|
|
|
MsgConfigureFileSinkWork(bool working) :
|
|
|
|
Message(),
|
|
|
|
m_working(working)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureFileSinkStreamTiming : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static MsgConfigureFileSinkStreamTiming* create()
|
|
|
|
{
|
|
|
|
return new MsgConfigureFileSinkStreamTiming();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MsgConfigureFileSinkStreamTiming() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportFileSinkGeneration : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getAcquisition() const { return m_acquisition; }
|
|
|
|
|
|
|
|
static MsgReportFileSinkGeneration* create(bool acquisition)
|
|
|
|
{
|
|
|
|
return new MsgReportFileSinkGeneration(acquisition);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_acquisition;
|
|
|
|
|
|
|
|
MsgReportFileSinkGeneration(bool acquisition) :
|
|
|
|
Message(),
|
|
|
|
m_acquisition(acquisition)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportFileSinkStreamTiming : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::size_t getSamplesCount() const { return m_samplesCount; }
|
|
|
|
|
|
|
|
static MsgReportFileSinkStreamTiming* create(std::size_t samplesCount)
|
|
|
|
{
|
|
|
|
return new MsgReportFileSinkStreamTiming(samplesCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::size_t m_samplesCount;
|
|
|
|
|
|
|
|
MsgReportFileSinkStreamTiming(std::size_t samplesCount) :
|
|
|
|
Message(),
|
|
|
|
m_samplesCount(samplesCount)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-10-22 15:47:59 -04:00
|
|
|
FileSinkOutput(DeviceSinkAPI *deviceAPI, const QTimer& masterTimer);
|
2016-10-19 12:42:57 -04:00
|
|
|
virtual ~FileSinkOutput();
|
|
|
|
|
2017-04-13 21:44:49 -04:00
|
|
|
virtual bool start();
|
2016-10-19 12:42:57 -04:00
|
|
|
virtual void stop();
|
|
|
|
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
std::time_t getStartingTimeStamp() const;
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
|
|
|
private:
|
2016-10-22 15:47:59 -04:00
|
|
|
DeviceSinkAPI *m_deviceAPI;
|
2016-10-19 12:42:57 -04:00
|
|
|
QMutex m_mutex;
|
2016-10-20 19:21:17 -04:00
|
|
|
FileSinkSettings m_settings;
|
2016-10-19 12:42:57 -04:00
|
|
|
std::ofstream m_ofstream;
|
2016-10-19 16:32:14 -04:00
|
|
|
FileSinkThread* m_fileSinkThread;
|
2016-10-19 12:42:57 -04:00
|
|
|
QString m_deviceDescription;
|
|
|
|
QString m_fileName;
|
|
|
|
std::time_t m_startingTimeStamp;
|
|
|
|
const QTimer& m_masterTimer;
|
|
|
|
|
|
|
|
void openFileStream();
|
2016-10-20 19:21:17 -04:00
|
|
|
void applySettings(const FileSinkSettings& settings, bool force = false);
|
2016-10-19 12:42:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_FILESINKOUTPUT_H
|