2014-05-18 15:52:39 +00:00
|
|
|
#ifndef INCLUDE_PRESET_H
|
|
|
|
#define INCLUDE_PRESET_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMetaType>
|
|
|
|
|
|
|
|
class Preset {
|
|
|
|
public:
|
|
|
|
struct ChannelConfig {
|
2017-11-23 00:19:32 +00:00
|
|
|
QString m_channelIdURI; //!< Channel type ID in URI form
|
|
|
|
QString m_channelId; //!< Channel type ID in short form from object name TODO: use in the future
|
2014-05-18 15:52:39 +00:00
|
|
|
QByteArray m_config;
|
|
|
|
|
2017-11-23 00:19:32 +00:00
|
|
|
ChannelConfig(const QString& channelIdURI, const QByteArray& config) :
|
|
|
|
m_channelIdURI(channelIdURI),
|
2014-05-18 15:52:39 +00:00
|
|
|
m_config(config)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
typedef QList<ChannelConfig> ChannelConfigs;
|
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
struct DeviceConfig
|
2015-10-01 06:54:56 +00:00
|
|
|
{
|
2016-10-18 22:07:42 +00:00
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceSerial;
|
|
|
|
int m_deviceSequence;
|
2015-10-01 06:54:56 +00:00
|
|
|
QByteArray m_config;
|
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
DeviceConfig(const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence,
|
2015-10-01 06:54:56 +00:00
|
|
|
const QByteArray& config) :
|
2016-10-18 22:07:42 +00:00
|
|
|
m_deviceId(deviceId),
|
|
|
|
m_deviceSerial(deviceSerial),
|
|
|
|
m_deviceSequence(deviceSequence),
|
2015-10-01 06:54:56 +00:00
|
|
|
m_config(config)
|
|
|
|
{ }
|
|
|
|
};
|
2016-10-18 22:07:42 +00:00
|
|
|
typedef QList<DeviceConfig> DeviceeConfigs;
|
2015-10-01 06:54:56 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
Preset();
|
|
|
|
|
|
|
|
void resetToDefaults();
|
2016-10-18 22:07:42 +00:00
|
|
|
|
|
|
|
void setSourcePreset(bool isSourcePreset) { m_sourcePreset = isSourcePreset; }
|
|
|
|
bool isSourcePreset() const { return m_sourcePreset; }
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
QByteArray serialize() const;
|
|
|
|
bool deserialize(const QByteArray& data);
|
|
|
|
|
|
|
|
void setGroup(const QString& group) { m_group = group; }
|
|
|
|
const QString& getGroup() const { return m_group; }
|
|
|
|
void setDescription(const QString& description) { m_description = description; }
|
|
|
|
const QString& getDescription() const { return m_description; }
|
|
|
|
void setCenterFrequency(const quint64 centerFrequency) { m_centerFrequency = centerFrequency; }
|
|
|
|
quint64 getCenterFrequency() const { return m_centerFrequency; }
|
|
|
|
|
|
|
|
void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; }
|
|
|
|
const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; }
|
|
|
|
|
|
|
|
void setLayout(const QByteArray& data) { m_layout = data; }
|
|
|
|
const QByteArray& getLayout() const { return m_layout; }
|
|
|
|
|
|
|
|
void clearChannels() { m_channelConfigs.clear(); }
|
|
|
|
void addChannel(const QString& channel, const QByteArray& config) { m_channelConfigs.append(ChannelConfig(channel, config)); }
|
|
|
|
int getChannelCount() const { return m_channelConfigs.count(); }
|
|
|
|
const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); }
|
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
void setDeviceConfig(const QString& deviceId, const QString& deviceSerial, int deviceSequence, const QByteArray& config)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2016-10-18 22:07:42 +00:00
|
|
|
addOrUpdateDeviceConfig(deviceId, deviceSerial, deviceSequence, config);
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
void addOrUpdateDeviceConfig(const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence,
|
2015-10-01 06:54:56 +00:00
|
|
|
const QByteArray& config);
|
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
const QByteArray* findBestDeviceConfig(const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence) const;
|
2015-10-01 06:54:56 +00:00
|
|
|
|
2016-09-11 16:58:40 +00:00
|
|
|
static bool presetCompare(const Preset *p1, Preset *p2)
|
|
|
|
{
|
2017-11-25 10:14:52 +00:00
|
|
|
if (p1->m_group != p2->m_group)
|
|
|
|
{
|
|
|
|
return p1->m_group < p2->m_group;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (p1->m_centerFrequency != p2->m_centerFrequency) {
|
|
|
|
return p1->m_centerFrequency < p2->m_centerFrequency;
|
|
|
|
} else {
|
|
|
|
return p1->m_description < p2->m_description;
|
|
|
|
}
|
2016-09-11 16:58:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
protected:
|
2016-10-18 22:07:42 +00:00
|
|
|
bool m_sourcePreset;
|
|
|
|
|
|
|
|
// group and preset description
|
2014-05-18 15:52:39 +00:00
|
|
|
QString m_group;
|
|
|
|
QString m_description;
|
|
|
|
quint64 m_centerFrequency;
|
|
|
|
|
|
|
|
// general configuration
|
|
|
|
QByteArray m_spectrumConfig;
|
|
|
|
|
2015-09-30 01:46:46 +00:00
|
|
|
// dc offset and i/q imbalance correction TODO: move it into the source data
|
2014-05-18 15:52:39 +00:00
|
|
|
bool m_dcOffsetCorrection;
|
|
|
|
bool m_iqImbalanceCorrection;
|
|
|
|
|
|
|
|
// sample source and sample source configuration
|
2015-09-30 04:57:40 +00:00
|
|
|
QString m_sourceId;
|
|
|
|
QString m_sourceSerial;
|
|
|
|
int m_sourceSequence;
|
2014-05-18 15:52:39 +00:00
|
|
|
QByteArray m_sourceConfig;
|
|
|
|
|
|
|
|
// channels and configurations
|
|
|
|
ChannelConfigs m_channelConfigs;
|
|
|
|
|
2016-10-18 22:07:42 +00:00
|
|
|
// devices and configurations
|
|
|
|
DeviceeConfigs m_deviceConfigs;
|
2015-10-01 06:54:56 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
// screen and dock layout
|
|
|
|
QByteArray m_layout;
|
|
|
|
};
|
|
|
|
|
2015-05-09 08:51:02 +00:00
|
|
|
Q_DECLARE_METATYPE(const Preset*);
|
|
|
|
Q_DECLARE_METATYPE(Preset*);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
#endif // INCLUDE_PRESET_H
|