2021-12-01 10:01:05 +00:00
|
|
|
#ifndef RIGSTATEH
|
|
|
|
#define RIGSTATEH
|
2021-11-23 00:39:10 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QMutex>
|
2021-12-01 10:01:05 +00:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QCache>
|
2021-11-23 00:39:10 +00:00
|
|
|
|
|
|
|
#include "rigcommander.h"
|
2021-12-04 19:21:23 +00:00
|
|
|
#include "rigidentities.h"
|
2021-11-23 00:39:10 +00:00
|
|
|
|
|
|
|
// Meters at the end as they are ALWAYS updated from the rig!
|
2021-12-07 14:52:47 +00:00
|
|
|
enum stateTypes { VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL,
|
2021-11-23 00:39:10 +00:00
|
|
|
PREAMP, AGC, ATTENUATOR, MODINPUT, AFGAIN, RFGAIN, SQUELCH, TXPOWER, MICGAIN, COMPLEVEL, MONITORLEVEL, VOXGAIN, ANTIVOXGAIN,
|
|
|
|
FAGCFUNC, NBFUNC, COMPFUNC, VOXFUNC, TONEFUNC, TSQLFUNC, SBKINFUNC, FBKINFUNC, ANFFUNC, NRFUNC, AIPFUNC, APFFUNC, MONFUNC, MNFUNC,RFFUNC,
|
|
|
|
AROFUNC, MUTEFUNC, VSCFUNC, REVFUNC, SQLFUNC, ABMFUNC, BCFUNC, MBCFUNC, RITFUNC, AFCFUNC, SATMODEFUNC, SCOPEFUNC,
|
2021-12-07 12:32:51 +00:00
|
|
|
NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, RIGINPUT, POWERONOFF, RITVALUE,
|
2021-12-01 10:01:05 +00:00
|
|
|
RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER
|
|
|
|
};
|
2021-11-23 00:39:10 +00:00
|
|
|
|
2021-12-01 10:01:05 +00:00
|
|
|
struct value {
|
|
|
|
quint64 _value=0;
|
|
|
|
bool _valid = false;
|
|
|
|
bool _updated = false;
|
|
|
|
QDateTime _dateUpdated;
|
|
|
|
};
|
2021-11-23 00:39:10 +00:00
|
|
|
|
|
|
|
class rigstate
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2021-12-01 10:01:05 +00:00
|
|
|
void invalidate(stateTypes s) { map[s]._valid = false; }
|
|
|
|
bool isValid(stateTypes s) { return map[s]._valid; }
|
|
|
|
bool isUpdated(stateTypes s) { return map[s]._updated; }
|
|
|
|
QDateTime whenUpdated(stateTypes s) { return map[s]._dateUpdated; }
|
|
|
|
|
|
|
|
void set(stateTypes s, quint64 x, bool u) {
|
|
|
|
if (x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
2021-12-07 12:32:51 +00:00
|
|
|
void set(stateTypes s, qint32 x, bool u) {
|
2021-12-01 10:01:05 +00:00
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void set(stateTypes s, quint16 x, bool u) {
|
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void set(stateTypes s, quint8 x, bool u) {
|
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void set(stateTypes s, bool x, bool u) {
|
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void set(stateTypes s, duplexMode x, bool u) {
|
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-04 19:21:23 +00:00
|
|
|
void set(stateTypes s, rigInput x, bool u) {
|
|
|
|
if ((quint64)x != map[s]._value) {
|
|
|
|
_mutex.lock();
|
|
|
|
map[s]._value = (quint64)x;
|
|
|
|
map[s]._valid = true;
|
|
|
|
map[s]._updated = u;
|
|
|
|
map[s]._dateUpdated = QDateTime::currentDateTime();
|
|
|
|
_mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-01 10:01:05 +00:00
|
|
|
bool getBool(stateTypes s) { return map[s]._value != 0; }
|
2021-12-07 12:32:51 +00:00
|
|
|
quint8 getChar(stateTypes s) { return (quint8)map[s]._value; }
|
|
|
|
quint16 getInt16(stateTypes s) { return (qint16)map[s]._value; }
|
|
|
|
qint32 getInt32(stateTypes s) { return (qint32)map[s]._value; }
|
2021-12-01 10:01:05 +00:00
|
|
|
quint64 getInt64(stateTypes s) { return map[s]._value; }
|
|
|
|
duplexMode getDuplex(stateTypes s) { return(duplexMode)map[s]._value; }
|
2021-12-04 19:21:23 +00:00
|
|
|
rigInput getInput(stateTypes s) { return(rigInput)map[s]._value; }
|
2021-12-01 10:01:05 +00:00
|
|
|
QMap<stateTypes, value> map;
|
2021-11-23 00:39:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2021-12-01 10:01:05 +00:00
|
|
|
//std::map<stateTypes, std::unique_ptr<valueBase> > values;
|
2021-11-23 00:39:10 +00:00
|
|
|
QMutex _mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|