1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#ifndef RIGCOMMANDER_H
#define RIGCOMMANDER_H
#include <QObject>
#include <QMutexLocker>
#include <QSettings>
#include <QRegularExpression>
#include <QDebug>
#include "wfviewtypes.h"
#include "commhandler.h"
#include "pttyhandler.h"
#include "udphandler.h"
#include "rigidentities.h"
#include "repeaterattributes.h"
#include "freqmemory.h"
#include "tcpserver.h"
#include "cachingqueue.h"
// This file figures out what to send to the comm and also
// parses returns into useful things.
// 0xE1 is new default, 0xE0 was before.
// note: using a define because switch case doesn't even work with const quint8. Surprised me.
#define compCivAddr 0xE1
//#define DEBUG_PARSE // Enable to output Info messages every 10s with command parse timing.
typedef QHash<quint8, rigInfo> rigTypedef;
class rigCommander : public QObject
{
Q_OBJECT
public:
explicit rigCommander(QObject* parent=nullptr);
explicit rigCommander(quint8 guid[GUIDLEN], QObject* parent = nullptr);
~rigCommander();
bool usingLAN();
quint8* getGUID();
public slots:
// Most slots are virtual, but some simply pass data along so are common.
// These slots are handled by the parent class:
void receiveAudioData(const audioPacket& data);
void handlePortError(errorType err);
void handleStatusUpdate(const networkStatus status);
void handleNetworkAudioLevels(networkAudioLevels);
void changeLatency(const quint16 value);
void radioSelection(QList<radio_cap_packet> radios);
void radioUsage(quint8 radio, bool admin, quint8 busy, QString name, QString ip);
void setCurrentRadio(quint8 radio);
void getDebug();
void dataFromServer(QByteArray data);
virtual void process();
virtual void commSetup(rigTypedef rigList, quint8 rigCivAddr, QString rigSerialPort, quint32 rigBaudRate, QString vsp, quint16 tcp, quint8 wf);
virtual void commSetup(rigTypedef rigList, quint8 rigCivAddr, udpPreferences prefs, audioSetup rxSetup, audioSetup txSetup, QString vsp, quint16 tcp);
virtual void closeComm();
virtual void setPTTType(pttType_t ptt);
// Power:
virtual void powerOn();
virtual void powerOff();
// Rig ID and CIV:
virtual void setRigID(quint8 rigID);
virtual void setCIVAddr(quint8 civAddr);
// UDP:
virtual void handleNewData(const QByteArray& data);
virtual void receiveBaudRate(quint32 baudrate);
// Housekeeping:
virtual void receiveCommand(funcs func, QVariant value, uchar receiver);
signals:
// Right now, all signals are defined here as they should be rig agnostic.
// Communication:
void commReady();
void havePortError(errorType err);
void haveStatusUpdate(const networkStatus status);
void haveNetworkAudioLevels(const networkAudioLevels l);
void dataForComm(const QByteArray &outData);
void haveDataFromRig(const QByteArray &outData);
void setHalfDuplex(bool en);
// UDP:
void haveChangeLatency(quint16 value);
void haveDataForServer(QByteArray outData);
void haveAudioData(audioPacket data);
void initUdpHandler();
void haveSetVolume(quint8 level);
void haveBaudRate(quint32 baudrate);
// Spectrum:
void haveSpectrumData(QByteArray spectrum, double startFreq, double endFreq); // pass along data to UI
void haveSpectrumBounds();
void haveScopeSpan(freqt span, bool isSub);
void havespectrumMode_t(spectrumMode_t spectmode);
void haveScopeEdge(char edge);
// Rig ID:
void haveRigID(rigCapabilities rigCaps);
void discoveredRigID(rigCapabilities rigCaps);
// Repeater:
void haveDuplexMode(duplexMode_t);
void haveTone(quint16 tone);
void haveTSQL(quint16 tsql);
void haveDTCS(quint16 dcscode, bool tinv, bool rinv);
void haveRptOffsetFrequency(freqt f);
void haveMemory(memoryType mem);
// Housekeeping:
void requestRadioSelection(QList<radio_cap_packet> radios);
void setRadioUsage(quint8 radio, bool admin, quint8 busy, QString user, QString ip);
void selectedRadio(quint8 radio);
void getMoreDebug();
void finished();
void haveReceivedValue(funcs func, QVariant value);
protected:
// These are common between all sub-classes, so define here
cachingQueue* queue;
udpPreferences prefs;
audioSetup rxSetup;
audioSetup txSetup;
double getMeterCal(meter_t meter,int value);
void printHex(const QByteArray &pdata);
void printHex(const QByteArray &pdata, bool printVert, bool printHoriz);
quint8 guid[GUIDLEN] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
bool usingNativeLAN;
bool rigPoweredOn = false; // Assume the radio is not powered-on until we know otherwise.
struct rigCapabilities rigCaps;
bool haveRigCaps=false;
QHash<quint8,rigInfo> rigList;
bool isRadioAdmin = true;
commandErrorType lastCommand;
private:
// rigCommander should have no private vars as it is only ever subclassed.
};
#endif // RIGCOMMANDER_H
|