From c5d2ecb79333fa5565a4891cc92414e5a91ea88d Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 23 Nov 2021 00:39:10 +0000 Subject: [PATCH 01/32] Change rigstate to a class --- rigcommander.cpp | 559 +++++++++++++++++++++++++++++++++++------------ rigcommander.h | 101 +++------ rigctld.cpp | 364 +++++++++++++++--------------- rigctld.h | 12 +- rigstate.h | 264 ++++++++++++++++++++++ wfmain.cpp | 7 +- wfmain.h | 3 +- 7 files changed, 916 insertions(+), 394 deletions(-) create mode 100644 rigstate.h diff --git a/rigcommander.cpp b/rigcommander.cpp index ed75bf9..c161171 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -22,20 +22,16 @@ rigCommander::rigCommander() { - rigState.mutex = new QMutex(); - QMutexLocker locker(rigState.mutex); - rigState.filter = 0; - rigState.mode = 0; - rigState.ptt = 0; - rigState.currentVfo = 0; - rigState.duplex = dmSplitOff; - + state.filter(0,NONE); + state.mode(0,NONE); + state.ptt(0,NONE); + state.currentVfo(0,NONE); + state.duplex(dmSplitOff,NONE); } rigCommander::~rigCommander() { closeComm(); - delete rigState.mutex; } @@ -572,16 +568,12 @@ void rigCommander::setFrequency(unsigned char vfo, freqt freq) cmdPayload.append(freqPayload); if (vfo == 0) { - rigState.mutex->lock(); - rigState.vfoAFreq = freq; - rigState.mutex->unlock(); + state.vfoAFreq(freq.Hz,NONE); cmdPayload.prepend('\x00'); } else { - rigState.mutex->lock(); - rigState.vfoBFreq = freq; - rigState.mutex->unlock(); + state.vfoBFreq(freq.Hz,NONE); cmdPayload.prepend(vfo); cmdPayload.prepend('\x25'); } @@ -709,10 +701,6 @@ void rigCommander::setMode(mode_info m) payload.append(m.filter); prepDataAndSend(payload); - - QMutexLocker locker(rigState.mutex); - rigState.mode = m.reg; - rigState.filter = m.filter; } void rigCommander::setMode(unsigned char mode, unsigned char modeFilter) @@ -742,10 +730,6 @@ void rigCommander::setMode(unsigned char mode, unsigned char modeFilter) } prepDataAndSend(payload); - QMutexLocker locker(rigState.mutex); - rigState.mode = mode; - rigState.filter = modeFilter; - } } @@ -763,8 +747,6 @@ void rigCommander::setDataMode(bool dataOn, unsigned char filter) payload.append("\x00\x00", 2); // data mode off, bandwidth not defined per ICD. } prepDataAndSend(payload); - QMutexLocker locker(rigState.mutex); - rigState.datamode = dataOn; } void rigCommander::getFrequency() @@ -1008,9 +990,9 @@ void rigCommander::getPTT() //{ // emit havePTTStatus(comm->rtsStatus()); //} else { - QByteArray payload; - payload.setRawData("\x1C\x00", 2); - prepDataAndSend(payload); + QByteArray payload; + payload.setRawData("\x1C\x00", 2); + prepDataAndSend(payload); //} } @@ -1031,8 +1013,6 @@ void rigCommander::setPTT(bool pttOn) QByteArray payload("\x1C\x00", 2); payload.append((char)pttOn); prepDataAndSend(payload); - QMutexLocker locker(rigState.mutex); - rigState.ptt = pttOn; } } @@ -1253,22 +1233,16 @@ void rigCommander::parseCommand() break; case '\x0F': emit haveDuplexMode((duplexMode)(unsigned char)payloadIn[1]); - rigState.mutex->lock(); - rigState.duplex = (duplexMode)(unsigned char)payloadIn[1]; - rigState.mutex->unlock(); + state.duplex((duplexMode)(unsigned char)payloadIn[1],NONE); break; case '\x11': emit haveAttenuator((unsigned char)payloadIn.at(1)); - rigState.mutex->lock(); - rigState.attenuator = (unsigned char)payloadIn.at(1); - rigState.mutex->unlock(); + state.attenuator((unsigned char)payloadIn.at(1),NONE); break; case '\x12': emit haveAntenna((unsigned char)payloadIn.at(1), (bool)payloadIn.at(2)); - rigState.mutex->lock(); - rigState.antenna = (unsigned char)payloadIn.at(1); - rigState.rxAntenna = (bool)payloadIn.at(2); - rigState.mutex->unlock(); + state.antenna((unsigned char)payloadIn.at(1),NONE); + state.rxAntenna((bool)payloadIn.at(2),NONE); break; case '\x14': // read levels @@ -1372,24 +1346,18 @@ void rigCommander::parseLevels() // AF level - ignore if LAN connection. if (udp == Q_NULLPTR) { emit haveAfGain(level); - rigState.mutex->lock(); - rigState.afGain = level; - rigState.mutex->unlock(); + state.afGain(level,NONE); } break; case '\x02': // RX RF Gain emit haveRfGain(level); - rigState.mutex->lock(); - rigState.rfGain = level; - rigState.mutex->unlock(); + state.rfGain(level,NONE); break; case '\x03': // Squelch level - emit haveSql(level); - rigState.mutex->lock(); - rigState.squelch = level; - rigState.mutex->unlock(); + emit haveSql(level); + state.squelch(level,NONE); break; case '\x07': // Twin BPF Inner, or, IF-Shift level @@ -1408,16 +1376,12 @@ void rigCommander::parseLevels() case '\x0A': // TX RF level emit haveTxPower(level); - rigState.mutex->lock(); - rigState.txPower = level; - rigState.mutex->unlock(); + state.txPower(level,NONE); break; case '\x0B': // Mic Gain emit haveMicGain(level); - rigState.mutex->lock(); - rigState.micGain = level; - rigState.mutex->unlock(); + state.micGain(level,NONE); break; case '\x0C': // CW Keying Speed - ignore for now @@ -1428,9 +1392,7 @@ void rigCommander::parseLevels() case '\x0E': // compressor level emit haveCompLevel(level); - rigState.mutex->lock(); - rigState.compLevel = level; - rigState.mutex->unlock(); + state.compLevel(level,NONE); break; case '\x12': // NB level - ignore for now @@ -1438,23 +1400,17 @@ void rigCommander::parseLevels() case '\x15': // monitor level emit haveMonitorLevel(level); - rigState.mutex->lock(); - rigState.monitorLevel = level; - rigState.mutex->unlock(); + state.monitorLevel(level,NONE); break; case '\x16': // VOX gain emit haveVoxGain(level); - rigState.mutex->lock(); - rigState.voxGain = level; - rigState.mutex->unlock(); + state.voxGain(level,NONE); break; case '\x17': // anti-VOX gain emit haveAntiVoxGain(level); - rigState.mutex->lock(); - rigState.antiVoxGain = level; - rigState.mutex->unlock(); + state.antiVoxGain(level,NONE); break; default: @@ -1472,58 +1428,42 @@ void rigCommander::parseLevels() case '\x02': // S-Meter emit haveMeter(meterS, level); - rigState.mutex->lock(); - rigState.sMeter = level; - rigState.mutex->unlock(); + state.sMeter(level,NONE); break; case '\x04': // Center (IC-R8600) emit haveMeter(meterCenter, level); - rigState.mutex->lock(); - rigState.sMeter = level; - rigState.mutex->unlock(); + state.sMeter(level,NONE); break; case '\x11': // RF-Power meter emit haveMeter(meterPower, level); - rigState.mutex->lock(); - rigState.powerMeter = level; - rigState.mutex->unlock(); + state.powerMeter(level,NONE); break; case '\x12': // SWR emit haveMeter(meterSWR, level); - rigState.mutex->lock(); - rigState.swrMeter = level; - rigState.mutex->unlock(); + state.swrMeter(level,NONE); break; case '\x13': // ALC emit haveMeter(meterALC, level); - rigState.mutex->lock(); - rigState.alcMeter = level; - rigState.mutex->unlock(); + state.alcMeter(level,NONE); break; case '\x14': // COMP dB reduction emit haveMeter(meterComp, level); - rigState.mutex->lock(); - rigState.compMeter = level; - rigState.mutex->unlock(); + state.compMeter(level,NONE); break; case '\x15': // VD (12V) emit haveMeter(meterVoltage, level); - rigState.mutex->lock(); - rigState.voltageMeter = level; - rigState.mutex->unlock(); + state.voltageMeter(level,NONE); break; case '\x16': // ID emit haveMeter(meterCurrent, level); - rigState.mutex->lock(); - rigState.currentMeter = level; - rigState.mutex->unlock(); + state.currentMeter(level,NONE); break; default: @@ -2430,8 +2370,7 @@ void rigCommander::parsePTT() // PTT on emit havePTTStatus(true); } - QMutexLocker locker(rigState.mutex); - rigState.ptt = (bool)payloadIn[2]; + state.ptt((bool)payloadIn[2],NONE); } @@ -2450,7 +2389,6 @@ void rigCommander::parseRegisters1A() // "INDEX: 00 01 02 03 04 " // "DATA: 1a 06 01 03 fd " (data mode enabled, filter width 3 selected) - QMutexLocker locker(rigState.mutex); switch(payloadIn[01]) { @@ -2461,6 +2399,9 @@ void rigCommander::parseRegisters1A() // band stacking register parseBandStackReg(); break; + case '\x04': + state.agc(payloadIn[02],AGC); + break; case '\x06': // data mode // emit havedataMode( (bool) payloadIn[somebit]) @@ -2471,7 +2412,7 @@ void rigCommander::parseRegisters1A() // YY: filter selected, 01 through 03.; // if YY is 00 then XX was also set to 00 emit haveDataMode((bool)payloadIn[03]); - rigState.datamode = (bool)payloadIn[03]; + state.datamode((bool)payloadIn[03],NONE); break; case '\x07': // IP+ status @@ -2493,32 +2434,24 @@ void rigCommander::parseRegister1B() // "Repeater tone" tone = decodeTone(payloadIn); emit haveTone(tone); - rigState.mutex->lock(); - rigState.ctcss = tone; - rigState.mutex->unlock(); + state.ctcss(tone,NONE); break; case '\x01': // "TSQL tone" tone = decodeTone(payloadIn); emit haveTSQL(tone); - rigState.mutex->lock(); - rigState.tsql = tone; - rigState.mutex->unlock(); + state.tsql(tone,NONE); break; case '\x02': // DTCS (DCS) tone = decodeTone(payloadIn, tinv, rinv); emit haveDTCS(tone, tinv, rinv); - rigState.mutex->lock(); - rigState.dtcs = tone; - rigState.mutex->unlock(); + state.dtcs(tone,NONE); break; case '\x07': // "CSQL code (DV mode)" tone = decodeTone(payloadIn); - rigState.mutex->lock(); - rigState.csql = tone; - rigState.mutex->unlock(); + state.csql(tone,NONE); break; default: break; @@ -2539,9 +2472,49 @@ void rigCommander::parseRegister16() case '\x02': // Preamp emit havePreamp((unsigned char)payloadIn.at(2)); - rigState.mutex->lock(); - rigState.preamp = (unsigned char)payloadIn.at(2); - rigState.mutex->unlock(); + state.preamp((unsigned char)payloadIn.at(2),NONE); + break; + case '\x22': + state.nbFunc((bool)payloadIn.at(2), NONE); + break; + case '\x40': + state.nrFunc((bool)payloadIn.at(2), NONE); + break; + case '\x41': // Auto notch + state.anfFunc((bool)payloadIn.at(2), NONE); + break; + case '\x42': + state.toneFunc((bool)payloadIn.at(2), NONE); + break; + case '\x43': + state.tsqlFunc((bool)payloadIn.at(2), NONE); + break; + case '\44': + state.compFunc((bool)payloadIn.at(2), NONE); + break; + case '\45': + state.monFunc((bool)payloadIn.at(2), NONE); + break; + case '\46': + state.voxFunc((bool)payloadIn.at(2), NONE); + break; + case '\x47': + if (payloadIn.at(2) == '\00') { + state.fbkinFunc(false, NONE); + state.sbkinFunc(false, NONE); + } + else if (payloadIn.at(2) == '\01') { + state.fbkinFunc(false, NONE); + state.sbkinFunc(true, NONE); + + } + else if (payloadIn.at(2) == '\02') { + state.fbkinFunc(true, NONE); + state.sbkinFunc(false, NONE); + } + break; + case '\48': // Manual Notch + state.mnFunc((bool)payloadIn.at(2), NONE); break; default: break; @@ -3815,49 +3788,51 @@ void rigCommander::parseFrequency() // printHex(payloadIn, false, true); frequencyMhz = 0.0; - if(payloadIn.length() == 7) + if (payloadIn.length() == 7) { // 7300 has these digits too, as zeros. // IC-705 or IC-9700 with higher frequency data available. - frequencyMhz += 100*(payloadIn[05] & 0x0f); - frequencyMhz += (1000*((payloadIn[05] & 0xf0) >> 4)); + frequencyMhz += 100 * (payloadIn[05] & 0x0f); + frequencyMhz += (1000 * ((payloadIn[05] & 0xf0) >> 4)); - freq.Hz += (payloadIn[05] & 0x0f) * 1E6 * 100; - freq.Hz += ((payloadIn[05] & 0xf0) >> 4) * 1E6 * 1000; + freq.Hz += (payloadIn[05] & 0x0f) * 1E6 * 100; + freq.Hz += ((payloadIn[05] & 0xf0) >> 4) * 1E6 * 1000; } freq.Hz += (payloadIn[04] & 0x0f) * 1E6; - freq.Hz += ((payloadIn[04] & 0xf0) >> 4) * 1E6 * 10; + freq.Hz += ((payloadIn[04] & 0xf0) >> 4) * 1E6 * 10; frequencyMhz += payloadIn[04] & 0x0f; - frequencyMhz += 10*((payloadIn[04] & 0xf0) >> 4); + frequencyMhz += 10 * ((payloadIn[04] & 0xf0) >> 4); // KHz land: - frequencyMhz += ((payloadIn[03] & 0xf0) >>4)/10.0 ; + frequencyMhz += ((payloadIn[03] & 0xf0) >> 4) / 10.0; frequencyMhz += (payloadIn[03] & 0x0f) / 100.0; frequencyMhz += ((payloadIn[02] & 0xf0) >> 4) / 1000.0; frequencyMhz += (payloadIn[02] & 0x0f) / 10000.0; - frequencyMhz += ((payloadIn[01] & 0xf0) >> 4) / 100000.0; - frequencyMhz += (payloadIn[01] & 0x0f) / 1000000.0; + frequencyMhz += ((payloadIn[01] & 0xf0) >> 4) / 100000.0; + frequencyMhz += (payloadIn[01] & 0x0f) / 1000000.0; freq.Hz += payloadIn[01] & 0x0f; - freq.Hz += ((payloadIn[01] & 0xf0) >> 4)* 10; + freq.Hz += ((payloadIn[01] & 0xf0) >> 4) * 10; - freq.Hz += (payloadIn[02] & 0x0f) * 100; - freq.Hz += ((payloadIn[02] & 0xf0) >> 4) * 1000; + freq.Hz += (payloadIn[02] & 0x0f) * 100; + freq.Hz += ((payloadIn[02] & 0xf0) >> 4) * 1000; - freq.Hz += (payloadIn[03] & 0x0f) * 10000; - freq.Hz += ((payloadIn[03] & 0xf0) >>4) * 100000; + freq.Hz += (payloadIn[03] & 0x0f) * 10000; + freq.Hz += ((payloadIn[03] & 0xf0) >> 4) * 100000; freq.MHzDouble = frequencyMhz; - rigState.mutex->lock(); - rigState.vfoAFreq = freq; - rigState.mutex->unlock(); - + if (state.currentVfo() == 0) { + state.vfoAFreq(freq.Hz, NONE); + } + else { + state.vfoBFreq(freq.Hz, NONE); + } emit haveFrequency(freq); } @@ -3935,11 +3910,9 @@ void rigCommander::parseMode() } else { filter = 0; } - rigState.mutex->lock(); - rigState.mode = (unsigned char)payloadIn[01]; - rigState.filter = filter; - rigState.mutex->unlock(); emit haveMode((unsigned char)payloadIn[01], filter); + state.mode((unsigned char)payloadIn[01],NONE); + state.filter(filter,NONE); } @@ -4014,6 +3987,144 @@ void rigCommander::setAntenna(unsigned char ant, bool rx) prepDataAndSend(payload); } +void rigCommander::setNb(bool enabled) { + QByteArray payload("\x16\x22"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getNb() +{ + QByteArray payload; + payload.setRawData("\x16\x22", 2); + prepDataAndSend(payload); +} + +void rigCommander::setNr(bool enabled) { + QByteArray payload("\x16\x40"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getNr() +{ + QByteArray payload; + payload.setRawData("\x16\x40", 2); + prepDataAndSend(payload); +} + +void rigCommander::setAutoNotch(bool enabled) +{ + QByteArray payload("\x16\x41"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getAutoNotch() +{ + QByteArray payload; + payload.setRawData("\x16\x41", 2); + prepDataAndSend(payload); +} + +void rigCommander::setToneEnabled(bool enabled) +{ + QByteArray payload("\x16\x42"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getToneEnabled() +{ + QByteArray payload; + payload.setRawData("\x16\x42", 2); + prepDataAndSend(payload); +} + +void rigCommander::setToneSql(bool enabled) +{ + QByteArray payload("\x16\x43"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getToneSql() +{ + QByteArray payload; + payload.setRawData("\x16\x43", 2); + prepDataAndSend(payload); +} + +void rigCommander::setCompressor(bool enabled) +{ + QByteArray payload("\x16\x44"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getCompressor() +{ + QByteArray payload; + payload.setRawData("\x16\x44", 2); + prepDataAndSend(payload); +} + +void rigCommander::setMonitor(bool enabled) +{ + QByteArray payload("\x16\x45"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getMonitor() +{ + QByteArray payload; + payload.setRawData("\x16\x45", 2); + prepDataAndSend(payload); +} + +void rigCommander::setVox(bool enabled) +{ + QByteArray payload("\x16\x46"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getVox() +{ + QByteArray payload; + payload.setRawData("\x16\x46", 2); + prepDataAndSend(payload); +} + +void rigCommander::setBreakIn(unsigned char type) { + QByteArray payload("\x16\x47"); + payload.append((unsigned char)type); + prepDataAndSend(payload); +} + +void rigCommander::getBreakIn() +{ + QByteArray payload; + payload.setRawData("\x16\x47", 2); + prepDataAndSend(payload); +} + +void rigCommander::setManualNotch(bool enabled) +{ + QByteArray payload("\x16\x48"); + payload.append((unsigned char)enabled); + prepDataAndSend(payload); +} + +void rigCommander::getManualNotch() +{ + QByteArray payload; + payload.setRawData("\x16\x48", 2); + prepDataAndSend(payload); +} + + void rigCommander::getRigID() { QByteArray payload; @@ -4086,7 +4197,185 @@ QByteArray rigCommander::stripData(const QByteArray &data, unsigned char cutPosi void rigCommander::sendState() { - emit stateInfo(&rigState); + emit stateInfo(&state); +} + +void rigCommander::stateUpdated() +{ + // A remote process has updated the rigState + // First we need to find which item(s) have been updated and send the command(s) to the rig. + /* + 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, + RESUMEFUNC, TBURSTFUNC, TUNERFUNC}; + */ + + /* VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL */ + + if ((state.updated()) & (1ULL <<(VFOAFREQ))) { + // VFO A FREQUENCY IS UPDATED! + freqt freq; + freq.Hz = state.vfoAFreq(); + setFrequency(0, freq); + setFrequency(0, freq); + setFrequency(0, freq); + getFrequency(); + + } + if ((state.updated()) & (1ULL <<(VFOBFREQ))) { + // VFO B FREQUENCY IS UPDATED! + freqt freq; + freq.Hz = state.vfoBFreq(); + setFrequency(1, freq); + setFrequency(1, freq); + setFrequency(1, freq); + getFrequency(); + } + if ((state.updated()) & (1ULL <<(CURRENTVFO))) { + // Work on VFOB - how do we do this? + } + if ((state.updated()) & (1ULL <<(PTT))) { + setPTT(state.ptt()); + setPTT(state.ptt()); + setPTT(state.ptt()); + getPTT(); + } + if (((state.updated()) & (1ULL <<(MODE))) || ((state.updated()) & (1ULL <<(FILTER)))) { + setMode(state.mode(),state.filter()); + getMode(); + } + + if ((state.updated()) & (1ULL <<(DUPLEX))) { + setDuplexMode(state.duplex()); + getDuplexMode(); + } + + if ((state.updated()) & (1ULL <<(DATAMODE))) { + setDataMode(state.datamode(), state.filter()); + getDataMode(); + } + + if (((state.updated()) & (1ULL <<(ANTENNA))) || ((state.updated()) & (1ULL <<(RXANTENNA)))) { + setAntenna(state.antenna(), state.rxAntenna()); + getAntenna(); + } + + if ((state.updated()) & (1ULL <<(CTCSS))) { + setTone(state.ctcss()); + getTone(); + } + if ((state.updated()) & (1ULL <<(TSQL))) { + setTSQL(state.tsql()); + getTSQL(); + } + if ((state.updated()) & (1ULL <<(DTCS))) { + setDTCS(state.dtcs(),false,false); // Not sure about this? + getDTCS(); + } + if ((state.updated()) & (1ULL <<(CSQL))) { // Not sure about this one? + //setTone(state.ctcss()); + //getTone(); + } + + /* PREAMP, ATTENUATOR, MODINPUT, AFGAIN, RFGAIN, SQUELCH, TXPOWER, MICGAIN, COMPLEVEL, MONITORLEVEL, VOXGAIN, ANTIVOXGAIN */ + if ((state.updated()) & (1ULL <<(PREAMP))) { + setPreamp(state.preamp()); + getPreamp(); + } + if ((state.updated()) & (1ULL <<(ATTENUATOR))) { + setAttenuator(state.attenuator()); + getAttenuator(); + } + if ((state.updated()) & (1ULL <<(MODINPUT))) { + getModInputLevel(rigInput::inputLAN); // Need to fix this! + } + + if ((state.updated()) & (1ULL <<(AFGAIN))) { + setAfGain(state.afGain()); + getAfGain(); + } + + if ((state.updated()) & (1ULL <<(RFGAIN))) { + setRfGain(state.rfGain()); + getRfGain(); + } + + if ((state.updated()) & (1ULL <<(SQUELCH))) { + setSquelch(state.squelch()); + getSql(); + } + + if ((state.updated()) & (1ULL <<(TXPOWER))) { + setTxPower(state.txPower()); + getTxLevel(); + } + + if ((state.updated()) & (1ULL <<(MICGAIN))) { + setMicGain(state.micGain()); + getMicGain(); + } + + if ((state.updated()) & (1ULL <<(COMPLEVEL))) { + setCompLevel(state.compLevel()); + getCompLevel(); + } + + if ((state.updated()) & (1ULL <<(MONITORLEVEL))) { + setMonitorLevel(state.monitorLevel()); + getMonitorLevel(); + } + + if ((state.updated()) & (1ULL <<(VOXGAIN))) { + setVoxGain(state.voxGain()); + getVoxGain(); + } + + if ((state.updated()) & (1ULL <<(ANTIVOXGAIN))) { + setAntiVoxGain(state.antiVoxGain()); + getAntiVoxGain(); + } + if ((state.updated()) & (1ULL <<(NBFUNC))) { + setNb(state.nbFunc()); + getNb(); + } + if ((state.updated()) & (1ULL << (NRFUNC))) { + setNr(state.nrFunc()); + getNr(); + } + if ((state.updated()) & (1ULL << (ANFFUNC))) { + setAutoNotch(state.anfFunc()); + getAutoNotch(); + } + if ((state.updated()) & (1ULL << (TONEFUNC))) { + setToneEnabled(state.toneFunc()); + getToneEnabled(); + } + if ((state.updated()) & (1ULL << (TSQLFUNC))) { + setToneSql(state.tsqlFunc()); + getToneSql(); + } + if ((state.updated()) & (1ULL << (COMPFUNC))) { + setCompressor(state.compFunc()); + getCompressor(); + } + if ((state.updated()) & (1ULL << (MONFUNC))) { + setMonitor(state.monFunc()); + getMonitor(); + } + if ((state.updated()) & (1ULL << (VOXFUNC))) { + setVox(state.voxFunc()); + getVox(); + } + if ((state.updated()) & (1ULL <<(FBKINFUNC))) { + setBreakIn(state.sbkinFunc()<<1); + getBreakIn(); + } + if ((state.updated()) & (1ULL << (MNFUNC))) { + setManualNotch(state.mnFunc()); + getManualNotch(); + } + + state.updated(0); } void rigCommander::getDebug() diff --git a/rigcommander.h b/rigcommander.h index 90550e0..de1f4a1 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -2,10 +2,10 @@ #define RIGCOMMANDER_H #include -#include #include #include + #include "commhandler.h" #include "pttyhandler.h" #include "udphandler.h" @@ -13,6 +13,8 @@ #include "repeaterattributes.h" #include "freqmemory.h" +#include "rigstate.h" + // This file figures out what to send to the comm and also // parses returns into useful things. @@ -61,78 +63,6 @@ struct timekind { bool isMinus; }; -struct rigStateStruct { - QMutex *mutex; - freqt vfoAFreq; - freqt vfoBFreq; - unsigned char currentVfo; - bool ptt; - unsigned char mode; - unsigned char filter; - duplexMode duplex; - bool datamode; - unsigned char antenna; - bool rxAntenna; - // Tones - quint16 ctcss; - quint16 tsql; - quint16 dtcs; - quint16 csql; - // Levels - unsigned char preamp; - unsigned char attenuator; - unsigned char modInput; - unsigned char afGain; - unsigned char rfGain; - unsigned char squelch; - unsigned char txPower; - unsigned char micGain; - unsigned char compLevel; - unsigned char monitorLevel; - unsigned char voxGain; - unsigned char antiVoxGain; - // Meters - unsigned char sMeter; - unsigned char powerMeter; - unsigned char swrMeter; - unsigned char alcMeter; - unsigned char compMeter; - unsigned char voltageMeter; - unsigned char currentMeter; - // Functions - bool fagcFunc=false; - bool nbFunc=false; - bool compFunc=false; - bool voxFunc = false; - bool toneFunc = false; - bool tsqlFunc = false; - bool sbkinFunc = false; - bool fbkinFunc = false; - bool anfFunc = false; - bool nrFunc = false; - bool aipFunc = false; - bool apfFunc = false; - bool monFunc = false; - bool mnFunc = false; - bool rfFunc = false; - bool aroFunc = false; - bool muteFunc = false; - bool vscFunc = false; - bool revFunc = false; - bool sqlFunc = false; - bool abmFunc = false; - bool bcFunc = false; - bool mbcFunc = false; - bool ritFunc = false; - bool afcFunc = false; - bool satmodeFunc = false; - bool scopeFunc = false; - bool resumeFunc = false; - bool tburstFunc = false; - bool tunerFunc = false; - bool lockFunc = false; -}; - class rigCommander : public QObject { Q_OBJECT @@ -148,6 +78,7 @@ public slots: void commSetup(unsigned char rigCivAddr, QString rigSerialPort, quint32 rigBaudRate,QString vsp); void commSetup(unsigned char rigCivAddr, udpPreferences prefs, audioSetup rxSetup, audioSetup txSetup, QString vsp); void closeComm(); + void stateUpdated(); // Power: void powerOn(); @@ -199,6 +130,26 @@ public slots: void setAttenuator(unsigned char att); void setPreamp(unsigned char pre); void setAntenna(unsigned char ant, bool rx); + void setNb(bool enabled); + void getNb(); + void setNr(bool enabled); + void getNr(); + void setAutoNotch(bool enabled); + void getAutoNotch(); + void setToneEnabled(bool enabled); + void getToneEnabled(); + void setToneSql(bool enabled); + void getToneSql(); + void setCompressor(bool enabled); + void getCompressor(); + void setMonitor(bool enabled); + void getMonitor(); + void setVox(bool enabled); + void getVox(); + void setBreakIn(unsigned char type); + void getBreakIn(); + void setManualNotch(bool enabled); + void getManualNotch(); // Repeater: void setDuplexMode(duplexMode dm); @@ -406,7 +357,7 @@ signals: void haveAntenna(unsigned char ant,bool rx); // Rig State - void stateInfo(rigStateStruct* state); + void stateInfo(rigstate* state); // Housekeeping: void getMoreDebug(); @@ -480,7 +431,7 @@ private: struct rigCapabilities rigCaps; - rigStateStruct rigState; + rigstate state; bool haveRigCaps; model_kind model; diff --git a/rigctld.cpp b/rigctld.cpp index c456cbd..ebceb3b 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -61,7 +61,7 @@ rigCtlD::~rigCtlD() // emit setFrequency(0, freq); //} -void rigCtlD::receiveStateInfo(rigStateStruct* state) +void rigCtlD::receiveStateInfo(rigstate* state) { qInfo("Setting rig state"); rigState = state; @@ -100,7 +100,7 @@ void rigCtlD::receiveRigCaps(rigCapabilities caps) this->rigCaps = caps; } -rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigStateStruct* state, rigCtlD* parent) : QObject(parent) +rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigstate* state, rigCtlD* parent) : QObject(parent) { commandBuffer.clear(); @@ -132,7 +132,7 @@ void rigCtlClient::socketReadyRead() bool setCommand = false; if (commandBuffer.endsWith('\n')) { - qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer; + //qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer; commandBuffer.chop(1); // Remove \n character if (commandBuffer.endsWith('\r')) { @@ -175,7 +175,6 @@ void rigCtlClient::socketReadyRead() QStringList command = commandBuffer.mid(num).split(" "); - QMutexLocker locker(rigState->mutex); if (command[0] == 0xf0 || command[0] == "chk_vfo") { @@ -183,7 +182,7 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("ChkVFO: ")); } - resp.append(QString("%1").arg(rigState->currentVfo)); + resp.append(QString("%1").arg(rigState->currentVfo())); response.append(resp); } else if (command[0] == "dump_state") @@ -276,11 +275,11 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("Frequency: ")); } - if (rigState->currentVfo == 0) { - resp.append(QString("%1").arg(rigState->vfoAFreq.Hz)); + if (rigState->currentVfo()==0) { + resp.append(QString("%1").arg(rigState->vfoAFreq())); } else { - resp.append(QString("%1").arg(rigState->vfoBFreq.Hz)); + resp.append(QString("%1").arg(rigState->vfoBFreq())); } response.append(resp); } @@ -307,11 +306,12 @@ void rigCtlClient::socketReadyRead() if (ok) { freq.Hz = static_cast(newFreq); qDebug(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]); - emit parent->setFrequency(vfo, freq); - emit parent->setFrequency(vfo, freq); - emit parent->setFrequency(vfo, freq); - emit parent->setFrequency(vfo, freq); - emit parent->setFrequency(vfo, freq); + if (vfo == 0) { + rigState->vfoAFreq(freq.Hz, VFOAFREQ); + } + else { + rigState->vfoAFreq(freq.Hz, VFOBFREQ); + } } } else if (command[0] == "1" || command[0] == "dump_caps") @@ -341,7 +341,7 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("PTT: ")); } - resp.append(QString("%1").arg(rigState->ptt)); + resp.append(QString("%1").arg(rigState->ptt())); response.append(resp); } else @@ -353,11 +353,7 @@ void rigCtlClient::socketReadyRead() { setCommand = true; if (rigCaps.hasPTTCommand) { - emit parent->setPTT(bool(command[1].toInt())); - emit parent->setPTT(bool(command[1].toInt())); - emit parent->setPTT(bool(command[1].toInt())); - emit parent->setPTT(bool(command[1].toInt())); - emit parent->setPTT(bool(command[1].toInt())); + rigState->ptt(bool(command[1].toInt()), PTT); } else { @@ -371,7 +367,7 @@ void rigCtlClient::socketReadyRead() resp.append("VFO: "); } - if (rigState->currentVfo == 0) { + if (rigState->currentVfo() == 0) { resp.append("VFOA"); } else { @@ -400,10 +396,10 @@ void rigCtlClient::socketReadyRead() else if (command[0] == "s" || command[0] == "get_split_vfo") { if (longReply) { - response.append(QString("Split: %1").arg(rigState->duplex)); + response.append(QString("Split: %1").arg(rigState->duplex())); } else { - response.append(QString("%1").arg(rigState->duplex)); + response.append(QString("%1").arg(rigState->duplex())); } QString resp; @@ -411,7 +407,7 @@ void rigCtlClient::socketReadyRead() resp.append("TX VFO: "); } - if (rigState->currentVfo == 0) + if (rigState->currentVfo() == 0) { resp.append(QString("%1").arg("VFOB")); } @@ -425,12 +421,10 @@ void rigCtlClient::socketReadyRead() setCommand = true; if (command[1] == "1") { - emit parent->setDuplexMode(dmSplitOn); - rigState->duplex = dmSplitOn; + rigState->duplex(dmSplitOn, DUPLEX); } else { - emit parent->setDuplexMode(dmSplitOff); - rigState->duplex = dmSplitOff; + rigState->duplex(dmSplitOff, DUPLEX); } } else if (command[0] == "\xf3" || command[0] == "get_vfo_info") @@ -439,25 +433,25 @@ void rigCtlClient::socketReadyRead() //response.append(QString("set_vfo: %1").arg(command[1])); if (command[1] == "VFOB") { - response.append(QString("Freq: %1").arg(rigState->vfoBFreq.Hz)); + response.append(QString("Freq: %1").arg(rigState->vfoBFreq())); } else { - response.append(QString("Freq: %1").arg(rigState->vfoAFreq.Hz)); + response.append(QString("Freq: %1").arg(rigState->vfoAFreq())); } - response.append(QString("Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("Width: %1").arg(getFilter(rigState->mode, rigState->filter))); - response.append(QString("Split: %1").arg(rigState->duplex)); + response.append(QString("Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("Width: %1").arg(getFilter(rigState->mode(), rigState->filter()))); + response.append(QString("Split: %1").arg(rigState->duplex())); response.append(QString("SatMode: %1").arg(0)); // Need to get satmode } else { if (command[1] == "VFOB") { - response.append(QString("%1").arg(rigState->vfoBFreq.Hz)); + response.append(QString("%1").arg(rigState->vfoBFreq())); } else { - response.append(QString("%1").arg(rigState->vfoAFreq.Hz)); + response.append(QString("%1").arg(rigState->vfoAFreq())); } - response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); } } else if (command[0] == "i" || command[0] == "get_split_freq") @@ -466,56 +460,51 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append("TX VFO: "); } - if (rigState->currentVfo == 0) { - resp.append(QString("%1").arg(rigState->vfoBFreq.Hz)); + if (rigState->currentVfo() == 0) { + resp.append(QString("%1").arg(rigState->vfoBFreq())); } else { - resp.append(QString("%1").arg(rigState->vfoAFreq.Hz)); + resp.append(QString("%1").arg(rigState->vfoAFreq())); } response.append(resp); } else if (command.length() > 1 && (command[0] == "I" || command[0] == "set_split_freq")) { setCommand = true; - freqt freq; bool ok = false; double newFreq = 0.0f; newFreq = command[1].toDouble(&ok); if (ok) { - freq.Hz = static_cast(newFreq); - qDebug(logRigCtlD()) << QString("set_split_freq: %1 (%2)").arg(freq.Hz).arg(command[1]); - emit parent->setFrequency(1, freq); - emit parent->setFrequency(1, freq); - emit parent->setFrequency(1, freq); - emit parent->setFrequency(1, freq); - emit parent->setFrequency(1, freq); + qDebug(logRigCtlD()) << QString("set_split_freq: %1 (%2)").arg(newFreq).arg(command[1]); + rigState->vfoBFreq(static_cast(newFreq),VFOBFREQ); } } else if (command.length() > 2 && (command[0] == "X" || command[0] == "set_split_mode")) { setCommand = true; - } - else if (command.length() > 0 && (command[0] == "x" || command[0] == "get_split_mode")) - { + } + + else if (command.length() > 0 && (command[0] == "x" || command[0] == "get_split_mode")) + { if (longReply) { - response.append(QString("TX Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("TX Passband: %1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("TX Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("TX Passband: %1").arg(getFilter(rigState->mode(), rigState->filter()))); } else { - response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); } } else if (command[0] == "m" || command[0] == "get_mode") { if (longReply) { - response.append(QString("Mode: %1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("Passband: %1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("Passband: %1").arg(getFilter(rigState->mode(), rigState->filter()))); } else { - response.append(QString("%1").arg(getMode(rigState->mode, rigState->datamode))); - response.append(QString("%1").arg(getFilter(rigState->mode, rigState->filter))); + response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); + response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); } } else if (command[0] == "M" || command[0] == "set_mode") @@ -541,14 +530,13 @@ void rigCtlClient::socketReadyRead() else width = 1; - emit parent->setMode(getMode(mode), width); + rigState->mode(getMode(mode), MODE); + rigState->filter(width, FILTER); if (mode.mid(0, 3) == "PKT") { - emit parent->setDataMode(true, width); - emit parent->setDataMode(true, width); + rigState->datamode(true, DATAMODE); } else { - emit parent->setDataMode(false, width); - emit parent->setDataMode(false, width); + rigState->datamode(true, DATAMODE); } } else if (command[0] == "s" || command[0] == "get_split_vfo") @@ -585,34 +573,35 @@ void rigCtlClient::socketReadyRead() if (longReply) { response.append(QString("AntCurr: %1").arg(getAntName((unsigned char)command[1].toInt()))); response.append(QString("Option: %1").arg(0)); - response.append(QString("AntTx: %1").arg(getAntName(rigState->antenna))); - response.append(QString("AntRx: %1").arg(getAntName(rigState->antenna))); + response.append(QString("AntTx: %1").arg(getAntName(rigState->antenna()))); + response.append(QString("AntRx: %1").arg(getAntName(rigState->antenna()))); } else { response.append(QString("%1").arg(getAntName((unsigned char)command[1].toInt()))); response.append(QString("%1").arg(0)); - response.append(QString("%1").arg(getAntName(rigState->antenna))); - response.append(QString("%1").arg(getAntName(rigState->antenna))); + response.append(QString("%1").arg(getAntName(rigState->antenna()))); + response.append(QString("%1").arg(getAntName(rigState->antenna()))); } } } else if (command[0] == "Y" || command[0] == "set_ant") { - qInfo(logRigCtlD()) << "set_ant:"; - setCommand = true; + setCommand = true; + qInfo(logRigCtlD()) << "set_ant:" << command[1]; + rigState->antenna(antFromName(command[1]),ANTENNA); } else if (command[0] == "z" || command[0] == "get_xit") { - QString resp; - if (longReply) { - resp.append("XIT: "); - } - resp.append(QString("%1").arg(0)); - response.append(resp); + QString resp; + if (longReply) { + resp.append("XIT: "); + } + resp.append(QString("%1").arg(0)); + response.append(resp); } else if (command[0] == "Z" || command[0] == "set_xit") { - setCommand = true; + setCommand = true; } else if (command.length() > 1 && (command[0] == "l" || command[0] == "get_level")) { @@ -624,46 +613,46 @@ void rigCtlClient::socketReadyRead() if (command[1] == "STRENGTH") { if (rigCaps.model == model7610) - value = getCalibratedValue(rigState->sMeter, IC7610_STR_CAL); + value = getCalibratedValue(rigState->sMeter(), IC7610_STR_CAL); else if (rigCaps.model == model7850) - value = getCalibratedValue(rigState->sMeter, IC7850_STR_CAL); + value = getCalibratedValue(rigState->sMeter(), IC7850_STR_CAL); else - value = getCalibratedValue(rigState->sMeter, IC7300_STR_CAL); + value = getCalibratedValue(rigState->sMeter(), IC7300_STR_CAL); //qInfo(logRigCtlD()) << "Calibration IN:" << rigState->sMeter << "OUT" << value; resp.append(QString("%1").arg(value)); } else if (command[1] == "AF") { - resp.append(QString("%1").arg((float)rigState->afGain / 255.0)); + resp.append(QString("%1").arg((float)rigState->afGain() / 255.0)); } else if (command[1] == "RF") { - resp.append(QString("%1").arg((float)rigState->rfGain / 255.0)); + resp.append(QString("%1").arg((float)rigState->rfGain() / 255.0)); } else if (command[1] == "SQL") { - resp.append(QString("%1").arg((float)rigState->squelch / 255.0)); + resp.append(QString("%1").arg((float)rigState->squelch() / 255.0)); } else if (command[1] == "COMP") { - resp.append(QString("%1").arg((float)rigState->compLevel / 255.0)); + resp.append(QString("%1").arg((float)rigState->compLevel() / 255.0)); } else if (command[1] == "MICGAIN") { - resp.append(QString("%1").arg((float)rigState->micGain / 255.0)); + resp.append(QString("%1").arg((float)rigState->micGain() / 255.0)); } else if (command[1] == "MON") { - resp.append(QString("%1").arg((float)rigState->monitorLevel / 255.0)); + resp.append(QString("%1").arg((float)rigState->monitorLevel() / 255.0)); } else if (command[1] == "VOXGAIN") { - resp.append(QString("%1").arg((float)rigState->voxGain / 255.0)); + resp.append(QString("%1").arg((float)rigState->voxGain() / 255.0)); } else if (command[1] == "ANTIVOX") { - resp.append(QString("%1").arg((float)rigState->antiVoxGain / 255.0)); + resp.append(QString("%1").arg((float)rigState->antiVoxGain() / 255.0)); } else if (command[1] == "RFPOWER") { - resp.append(QString("%1").arg((float)rigState->txPower / 255.0)); + resp.append(QString("%1").arg((float)rigState->txPower() / 255.0)); } else if (command[1] == "PREAMP") { - resp.append(QString("%1").arg((float)rigState->preamp / 255.0)); + resp.append(QString("%1").arg(rigState->preamp()*10)); } else if (command[1] == "ATT") { - resp.append(QString("%1").arg((float)rigState->attenuator / 255.0)); + resp.append(QString("%1").arg(rigState->attenuator())); } else { resp.append(QString("%1").arg(value)); @@ -677,55 +666,49 @@ void rigCtlClient::socketReadyRead() setCommand = true; if (command[1] == "AF") { value = command[2].toFloat() * 255; - emit parent->setAfGain(value); - rigState->afGain = value; + rigState->afGain(value,AFGAIN); } else if (command[1] == "RF") { value = command[2].toFloat() * 255; - emit parent->setRfGain(value); - rigState->rfGain = value; + rigState->rfGain(value,RFGAIN); } else if (command[1] == "SQL") { value = command[2].toFloat() * 255; - emit parent->setSql(value); - rigState->squelch = value; + rigState->squelch(value,SQUELCH); } else if (command[1] == "COMP") { value = command[2].toFloat() * 255; - emit parent->setCompLevel(value); - rigState->compLevel = value; + rigState->compLevel(value,COMPLEVEL); } else if (command[1] == "MICGAIN") { value = command[2].toFloat() * 255; - emit parent->setMicGain(value); - rigState->micGain = value; + rigState->micGain(value,MICGAIN); } else if (command[1] == "MON") { value = command[2].toFloat() * 255; - emit parent->setMonitorLevel(value); - rigState->monitorLevel = value; + rigState->monitorLevel(value,MONITORLEVEL); } else if (command[1] == "VOXGAIN") { value = command[2].toFloat() * 255; - emit parent->setVoxGain(value); - rigState->voxGain = value; + rigState->voxGain(value,VOXGAIN); } else if (command[1] == "ANTIVOX") { value = command[2].toFloat() * 255; - emit parent->setAntiVoxGain(value); - rigState->antiVoxGain = value; + rigState->antiVoxGain(value,ANTIVOXGAIN); } else if (command[1] == "ATT") { value = command[2].toFloat(); - emit parent->setAttenuator(value); - rigState->attenuator = value; + rigState->attenuator(value,ATTENUATOR); } else if (command[1] == "PREAMP") { - value = command[2].toFloat()/10; - emit parent->setPreamp(value); - rigState->preamp = value; + value = command[2].toFloat() / 10; + rigState->preamp(value, PREAMP); } - + else if (command[1] == "AGC") { + value = command[2].toInt();; + rigState->agc(value, AGC); + } + qInfo(logRigCtlD()) << "Setting:" << command[1] << command[2] << value; } @@ -739,265 +722,266 @@ void rigCtlClient::socketReadyRead() if (command[1] == "FAGC") { - result=rigState->fagcFunc; + result=rigState->fagcFunc(); } else if (command[1] == "NB") { - result=rigState->nbFunc; + result = rigState->nbFunc(); } else if (command[1] == "COMP") { - result=rigState->compFunc; + result=rigState->compFunc(); } else if (command[1] == "VOX") { - result = rigState->voxFunc; + result = rigState->voxFunc(); } else if (command[1] == "TONE") { - result = rigState->toneFunc; + result = rigState->toneFunc(); } else if (command[1] == "TSQL") { - result = rigState->tsqlFunc; + result = rigState->tsqlFunc(); } else if (command[1] == "SBKIN") { - result = rigState->sbkinFunc; + result = rigState->sbkinFunc(); } else if (command[1] == "FBKIN") { - result = rigState->fbkinFunc; + result = rigState->fbkinFunc(); } else if (command[1] == "ANF") { - result = rigState->anfFunc; + result = rigState->anfFunc(); } else if (command[1] == "NR") { - result = rigState->nrFunc; + result = rigState->nrFunc(); } else if (command[1] == "AIP") { - result = rigState->aipFunc; + result = rigState->aipFunc(); } else if (command[1] == "APF") { - result = rigState->apfFunc; + result = rigState->apfFunc(); } else if (command[1] == "MON") { - result = rigState->monFunc; + result = rigState->monFunc(); } else if (command[1] == "MN") { - result = rigState->mnFunc; + result = rigState->mnFunc(); } else if (command[1] == "RF") { - result = rigState->rfFunc; + result = rigState->rfFunc(); } else if (command[1] == "ARO") { - result = rigState->aroFunc; + result = rigState->aroFunc(); } else if (command[1] == "MUTE") { - result = rigState->muteFunc; + result = rigState->muteFunc(); } else if (command[1] == "VSC") { - result = rigState->vscFunc; + result = rigState->vscFunc(); } else if (command[1] == "REV") { - result = rigState->revFunc; + result = rigState->revFunc(); } else if (command[1] == "SQL") { - result = rigState->sqlFunc; + result = rigState->sqlFunc(); } else if (command[1] == "ABM") { - result = rigState->abmFunc; + result = rigState->abmFunc(); } else if (command[1] == "BC") { - result = rigState->bcFunc; + result = rigState->bcFunc(); } else if (command[1] == "MBC") { - result = rigState->mbcFunc; + result = rigState->mbcFunc(); } else if (command[1] == "RIT") { - result = rigState->ritFunc; + result = rigState->ritFunc(); } else if (command[1] == "AFC") { - result = rigState->afcFunc; + result = rigState->afcFunc(); } else if (command[1] == "SATMODE") { - result = rigState->satmodeFunc; + result = rigState->satmodeFunc(); } else if (command[1] == "SCOPE") { - result = rigState->scopeFunc; + result = rigState->scopeFunc(); } else if (command[1] == "RESUME") { - result = rigState->resumeFunc; + result = rigState->resumeFunc(); } else if (command[1] == "TBURST") { - result = rigState->tburstFunc; + result = rigState->tburstFunc(); } else if (command[1] == "TUNER") { - result = rigState->tunerFunc; + result = rigState->tunerFunc(); } else if (command[1] == "LOCK") { - result = rigState->lockFunc; + result = rigState->lockFunc(); } else { qInfo(logRigCtlD()) << "Unimplemented func:" << command[0] << command[1]; } - resp.append(QString("%1").arg(result)); response.append(resp); } else if (command.length() >2 && (command[0] == "U" || command[0] == "set_func")) { setCommand = true; + if (command[1] == "FAGC") { - rigState->fagcFunc = (bool)command[2].toInt(); + rigState->fagcFunc((bool)command[2].toInt(),FAGCFUNC); } else if (command[1] == "NB") { - rigState->nbFunc = (bool)command[2].toInt(); + rigState->nbFunc((bool)command[2].toInt(),NBFUNC); } else if (command[1] == "COMP") { - rigState->compFunc = (bool)command[2].toInt(); + rigState->compFunc((bool)command[2].toInt(),COMPFUNC); } else if (command[1] == "VOX") { - rigState->voxFunc = (bool)command[2].toInt(); + rigState->voxFunc((bool)command[2].toInt(),VOXFUNC); } else if (command[1] == "TONE") { - rigState->toneFunc = (bool)command[2].toInt(); + rigState->toneFunc((bool)command[2].toInt(),TONEFUNC); } else if (command[1] == "TSQL") { - rigState->tsqlFunc = (bool)command[2].toInt(); + rigState->tsqlFunc((bool)command[2].toInt(),TSQLFUNC); } else if (command[1] == "SBKIN") { - rigState->sbkinFunc = (bool)command[2].toInt(); + rigState->sbkinFunc((bool)command[2].toInt(),SBKINFUNC); } else if (command[1] == "FBKIN") { - rigState->fbkinFunc = (bool)command[2].toInt(); + rigState->fbkinFunc((bool)command[2].toInt(),FBKINFUNC); } else if (command[1] == "ANF") { - rigState->anfFunc = (bool)command[2].toInt(); + rigState->anfFunc((bool)command[2].toInt(),ANFFUNC); } else if (command[1] == "NR") { - rigState->nrFunc = (bool)command[2].toInt(); + rigState->nrFunc((bool)command[2].toInt(),NRFUNC); } else if (command[1] == "AIP") { - rigState->aipFunc = (bool)command[2].toInt(); + rigState->aipFunc((bool)command[2].toInt(),AIPFUNC); } else if (command[1] == "APF") { - rigState->apfFunc = (bool)command[2].toInt(); + rigState->apfFunc((bool)command[2].toInt(),APFFUNC); } else if (command[1] == "MON") { - rigState->monFunc = (bool)command[2].toInt(); + rigState->monFunc((bool)command[2].toInt(),MONFUNC); } else if (command[1] == "MN") { - rigState->mnFunc = (bool)command[2].toInt(); + rigState->mnFunc((bool)command[2].toInt(),MNFUNC); } else if (command[1] == "RF") { - rigState->rfFunc = (bool)command[2].toInt(); + rigState->rfFunc((bool)command[2].toInt(),MONFUNC); } else if (command[1] == "ARO") { - rigState->aroFunc = (bool)command[2].toInt(); + rigState->aroFunc((bool)command[2].toInt(),AROFUNC); } else if (command[1] == "MUTE") { - rigState->muteFunc = (bool)command[2].toInt(); + rigState->muteFunc((bool)command[2].toInt(),MUTEFUNC); } else if (command[1] == "VSC") { - rigState->vscFunc = (bool)command[2].toInt(); + rigState->vscFunc((bool)command[2].toInt(),VSCFUNC); } else if (command[1] == "REV") { - rigState->revFunc = (bool)command[2].toInt(); + rigState->revFunc((bool)command[2].toInt(),REVFUNC); } else if (command[1] == "SQL") { - rigState->sqlFunc = (bool)command[2].toInt(); + rigState->sqlFunc((bool)command[2].toInt(),SQLFUNC); } else if (command[1] == "ABM") { - rigState->abmFunc = (bool)command[2].toInt(); + rigState->abmFunc((bool)command[2].toInt(),ABMFUNC); } else if (command[1] == "BC") { - rigState->bcFunc = (bool)command[2].toInt(); + rigState->bcFunc((bool)command[2].toInt(),BCFUNC); } else if (command[1] == "MBC") { - rigState->mbcFunc = (bool)command[2].toInt(); + rigState->mbcFunc((bool)command[2].toInt(),MBCFUNC); } else if (command[1] == "RIT") { - rigState->ritFunc = (bool)command[2].toInt(); + rigState->ritFunc((bool)command[2].toInt(),RITFUNC); } else if (command[1] == "AFC") { - rigState->afcFunc = (bool)command[2].toInt(); + rigState->afcFunc((bool)command[2].toInt(),AFCFUNC); } else if (command[1] == "SATMODE") { - rigState->satmodeFunc = (bool)command[2].toInt(); + rigState->satmodeFunc((bool)command[2].toInt(),SATMODEFUNC); } else if (command[1] == "SCOPE") { - rigState->scopeFunc = (bool)command[2].toInt(); + rigState->scopeFunc((bool)command[2].toInt(),SCOPEFUNC); } else if (command[1] == "RESUME") { - rigState->resumeFunc = (bool)command[2].toInt(); + rigState->resumeFunc((bool)command[2].toInt(),RESUMEFUNC); } else if (command[1] == "TBURST") { - rigState->tburstFunc = (bool)command[2].toInt(); + rigState->tburstFunc((bool)command[2].toInt(),TBURSTFUNC); } else if (command[1] == "TUNER") { - rigState->tunerFunc = (bool)command[2].toInt(); + rigState->tunerFunc((bool)command[2].toInt(),TUNERFUNC); } else if (command[1] == "LOCK") { - rigState->lockFunc = (bool)command[2].toInt(); + rigState->lockFunc((bool)command[2].toInt(),LOCKFUNC); } else { qInfo(logRigCtlD()) << "Unimplemented func:" << command[0] << command[1] << command[2]; } + qInfo(logRigCtlD()) << "Setting:" << command[1] << command[2]; } else if (command.length() > 1 && (command[0] == 0x88 || command[0] == "get_powerstat")) @@ -1034,6 +1018,11 @@ void rigCtlClient::socketReadyRead() sendData(QString("%1: %2 %3 %4%5").arg(command[0]).arg(command[1]).arg(command[2]).arg(command[3]).arg(sep)); } + if (setCommand) + { + emit parent->stateUpdated(); + } + if (setCommand || responseCode != 0 || longReply) { if (responseCode == 0) { response.append(QString("RPRT 0")); @@ -1056,6 +1045,7 @@ void rigCtlClient::socketReadyRead() commandBuffer.clear(); sep = " "; num = 0; + } } @@ -1073,7 +1063,7 @@ void rigCtlClient::closeSocket() void rigCtlClient::sendData(QString data) { - qDebug(logRigCtlD()) << "Sending:" << data; + //qDebug(logRigCtlD()) << "Sending:" << data; if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen()) { socket->write(data.toLatin1()); @@ -1380,6 +1370,28 @@ QString rigCtlClient::getAntName(unsigned char ant) return ret; } +unsigned char rigCtlClient::antFromName(QString name) { + unsigned char ret; + + if (name == "ANT1") + ret = 0; + else if (name == "ANT2") + ret = 1; + else if (name == "ANT3") + ret = 2; + else if (name == "ANT4") + ret = 3; + else if (name == "ANT5") + ret = 4; + else if (name == "ANT_UNKNOWN") + ret = 30; + else if (name == "ANT_CURR") + ret = 31; + else + ret = 99; + return ret; +} + int rigCtlClient::getCalibratedValue(unsigned char meter,cal_table_t cal) { int interp; diff --git a/rigctld.h b/rigctld.h index 130ae5e..1132abf 100644 --- a/rigctld.h +++ b/rigctld.h @@ -19,6 +19,7 @@ #include #include "rigcommander.h" +#include "rigstate.h" #define CONSTANT_64BIT_FLAG(BIT) (1ull << (BIT)) @@ -343,7 +344,7 @@ signals: void setVFO(unsigned char vfo); void setSplit(unsigned char split); void setDuplexMode(duplexMode dm); - + void stateUpdated(); // Power void sendPowerOn(); void sendPowerOff(); @@ -368,11 +369,11 @@ signals: public slots: virtual void incomingConnection(qintptr socketDescriptor); void receiveRigCaps(rigCapabilities caps); - void receiveStateInfo(rigStateStruct* state); + void receiveStateInfo(rigstate* state); // void receiveFrequency(freqt freq); private: - rigStateStruct* rigState = Q_NULLPTR; + rigstate* rigState = Q_NULLPTR; }; @@ -382,7 +383,7 @@ class rigCtlClient : public QObject public: - explicit rigCtlClient(int socket, rigCapabilities caps, rigStateStruct *state, rigCtlD* parent = Q_NULLPTR); + explicit rigCtlClient(int socket, rigCapabilities caps, rigstate *state, rigCtlD* parent = Q_NULLPTR); int getSocketId(); @@ -399,7 +400,7 @@ protected: private: rigCapabilities rigCaps; - rigStateStruct* rigState = Q_NULLPTR; + rigstate* rigState = Q_NULLPTR; rigCtlD* parent; QString getMode(unsigned char mode, bool datamode); unsigned char getMode(QString modeString); @@ -408,6 +409,7 @@ private: unsigned char getAntennas(); quint64 getRadioModes(); QString getAntName(unsigned char ant); + unsigned char antFromName(QString name); int getCalibratedValue(unsigned char meter,cal_table_t cal); }; diff --git a/rigstate.h b/rigstate.h new file mode 100644 index 0000000..7aef7d6 --- /dev/null +++ b/rigstate.h @@ -0,0 +1,264 @@ +#ifndef RIGSTATE_H +#define RIGSTATE_H + +#include +#include + +#include "rigcommander.h" + +// Meters at the end as they are ALWAYS updated from the rig! +enum stateTypes { NONE, VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL, + 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, + RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER }; + + +class rigstate +{ + +public: + + void lock() { _mutex.lock(); return; } + void unlock() { _mutex.unlock(); return; } + + quint64 updated() { return _updated; } + void updated(int update) { _mutex.lock(); _updated |= 1ULL << update; _mutex.unlock(); } + + quint64 vfoAFreq() { return _vfoAFreq; } + void vfoAFreq(quint64 vfoAFreq, int update) { _mutex.lock(); _vfoAFreq = vfoAFreq; _updated |= 1ULL << update; _mutex.unlock(); } + + quint64 vfoBFreq() { return _vfoBFreq; } + void vfoBFreq(quint64 vfoBFreq, int update) { _mutex.lock(); _vfoBFreq = vfoBFreq; _updated |= 1ULL << update; _mutex.unlock(); } + + unsigned char currentVfo() { return _currentVfo; } + void currentVfo(unsigned char currentVfo, int update) { _mutex.lock(); _currentVfo = currentVfo; _updated |= 1ULL << update; _mutex.unlock(); } + + bool ptt() { return _ptt; } + void ptt(bool ptt, int update) { _mutex.lock(); _ptt = ptt; _updated |= 1ULL << update; _mutex.unlock(); } + + unsigned char mode() { return _mode; } + void mode(unsigned char mode, int update) { _mutex.lock(); _mode = mode; _updated |= 1ULL << update; _mutex.unlock(); } + + unsigned char filter() { return _filter; } + void filter(unsigned char filter, int update) { _mutex.lock(); _filter = filter; _updated |= 1ULL << update; _mutex.unlock();} + + duplexMode duplex() { return _duplex; } + void duplex(duplexMode duplex, int update) { _mutex.lock(); _duplex = duplex; _updated |= 1ULL << update; _mutex.unlock();} + + bool datamode() { return _datamode; } + void datamode(bool datamode, int update) { _mutex.lock(); _datamode = datamode; _updated |= 1ULL << update; _mutex.unlock();} + + unsigned char antenna() { return _antenna; } + void antenna(unsigned char antenna, int update) { _mutex.lock(); _antenna = antenna; _updated |= 1ULL << update; _mutex.unlock();} + + bool rxAntenna() { return _rxAntenna; } + void rxAntenna(bool rxAntenna, int update) { _mutex.lock(); _rxAntenna = rxAntenna; _updated |= 1ULL << update; _mutex.unlock(); } + quint16 ctcss() { return _ctcss; } + void ctcss(quint16 ctcss, int update) { _mutex.lock(); _ctcss = ctcss; _updated |= 1ULL << update; _mutex.unlock(); } + quint16 tsql() { return _tsql; } + void tsql(quint16 tsql, int update) { _mutex.lock(); _tsql = tsql; _updated |= 1ULL << update; _mutex.unlock(); } + quint16 dtcs() { return _dtcs; } + void dtcs(quint16 dtcs, int update) { _mutex.lock(); _dtcs = dtcs; _updated |= 1ULL << update; _mutex.unlock(); } + quint16 csql() { return _csql; } + void csql(quint16 csql, int update) { _mutex.lock(); _csql = csql; _updated |= 1ULL << update; _mutex.unlock(); } + + unsigned char preamp() { return _preamp; } + void preamp(unsigned char preamp, int update) { _mutex.lock(); _preamp = preamp; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char agc() { return _agc; } + void agc(unsigned char agc, int update) { _mutex.lock(); _agc = agc; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char attenuator() { return _attenuator; } + void attenuator(unsigned char attenuator, int update) { _mutex.lock(); _attenuator = attenuator; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char modInput() { return _modInput; } + void modInput(unsigned char modInput, int update) { _mutex.lock(); _modInput = modInput; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char afGain() { return _afGain; } + void afGain(unsigned char afGain, int update) { _mutex.lock(); _afGain = afGain; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char rfGain() { return _rfGain; } + void rfGain(unsigned char rfGain, int update) { _mutex.lock(); _rfGain = rfGain; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char squelch() { return _squelch; } + void squelch(unsigned char squelch, int update) { _mutex.lock(); _squelch = squelch; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char txPower() { return _txPower; } + void txPower(unsigned char txPower, int update) { _mutex.lock(); _txPower = txPower; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char micGain() { return _micGain; } + void micGain(unsigned char micGain, int update) { _mutex.lock(); _micGain = micGain; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char compLevel() { return _compLevel; } + void compLevel(unsigned char compLevel, int update) { _mutex.lock(); _compLevel = compLevel; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char monitorLevel() { return _monitorLevel; } + void monitorLevel(unsigned char monitorLevel, int update) { _mutex.lock(); _monitorLevel = monitorLevel; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char voxGain() { return _voxGain; } + void voxGain(unsigned char voxGain, int update) { _mutex.lock(); _voxGain = voxGain; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char antiVoxGain() { return _antiVoxGain; } + void antiVoxGain(unsigned char antiVoxGain, int update) { _mutex.lock(); _antiVoxGain = antiVoxGain; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char nbLevel() { return _nbLevel; } + void nbLevel(unsigned char nbLevel, int update) { _mutex.lock(); _nbLevel = nbLevel; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char nbDepth() { return _nbDepth; } + void nbDepth(unsigned char nbDepth, int update) { _mutex.lock(); _nbDepth = nbDepth; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char nbWidth() { return _nbWidth; } + void nbWidth(unsigned char nbWidth, int update) { _mutex.lock(); _nbWidth = nbWidth; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char nrLevel() { return _nrLevel; } + void nrLevel(unsigned char nrLevel, int update) { _mutex.lock(); _nrLevel = nrLevel; _updated |= 1ULL << update; _mutex.unlock(); } + + unsigned char sMeter() { return _sMeter; } + void sMeter(unsigned char sMeter, int update) { _mutex.lock(); _sMeter = sMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char powerMeter() { return _powerMeter; } + void powerMeter(unsigned char powerMeter, int update) { _mutex.lock(); _powerMeter = powerMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char swrMeter() { return _swrMeter; } + void swrMeter(unsigned char swrMeter, int update) { _mutex.lock(); _swrMeter = swrMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char alcMeter() { return _alcMeter; } + void alcMeter(unsigned char alcMeter, int update) { _mutex.lock(); _alcMeter = alcMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char compMeter() { return _compMeter; } + void compMeter(unsigned char compMeter, int update) { _mutex.lock(); _compMeter = compMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char voltageMeter() { return _voltageMeter; } + void voltageMeter(unsigned char voltageMeter, int update) { _mutex.lock(); _voltageMeter = voltageMeter; _updated |= 1ULL << update; _mutex.unlock(); } + unsigned char currentMeter() { return _currentMeter; } + void currentMeter(unsigned char currentMeter, int update) { _mutex.lock(); _currentMeter = currentMeter; _updated |= 1ULL << update; _mutex.unlock(); } + + /*FAGCFUNC, NBFUNC, COMPFUNC, VOXFUNC, TONEFUNC, TSQLFUNC, SBKINFUNC, FBKINFUNC, ANFFUNC, NRFUNC, AIPFUNC, APFFUNC, MONFUNC, MNFUNC,RFFUNC, + */ + bool fagcFunc() { return _fagcFunc; } + void fagcFunc(bool fagcFunc, int update) { _mutex.lock(); _fagcFunc = fagcFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool nbFunc() { return _nbFunc; } + void nbFunc(bool nbFunc, int update) { _mutex.lock(); _nbFunc = nbFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool compFunc() { return _compFunc; } + void compFunc(bool compFunc, int update) { _mutex.lock(); _compFunc = compFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool voxFunc() { return _voxFunc; } + void voxFunc(bool voxFunc, int update) { _mutex.lock(); _voxFunc = voxFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool toneFunc() { return _toneFunc; } + void toneFunc(bool toneFunc, int update) { _mutex.lock(); _toneFunc = toneFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool tsqlFunc() { return _tsqlFunc; } + void tsqlFunc(bool tsqlFunc, int update) { _mutex.lock(); _tsqlFunc = tsqlFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool sbkinFunc() { return _sbkinFunc; } + void sbkinFunc(bool sbkinFunc, int update) { _mutex.lock(); _sbkinFunc = sbkinFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool fbkinFunc() { return _fbkinFunc; } + void fbkinFunc(bool fbkinFunc, int update) { _mutex.lock(); _fbkinFunc = fbkinFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool anfFunc() { return _anfFunc; } + void anfFunc(bool anfFunc, int update) { _mutex.lock(); _anfFunc = anfFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool nrFunc() { return _nrFunc; } + void nrFunc(bool nrFunc, int update) { _mutex.lock(); _nrFunc = nrFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool aipFunc() { return _aipFunc; } + void aipFunc(bool aipFunc, int update) { _mutex.lock(); _aipFunc = aipFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool apfFunc() { return _apfFunc; } + void apfFunc(bool apfFunc, int update) { _mutex.lock(); _apfFunc = apfFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool monFunc() { return _monFunc; } + void monFunc(bool monFunc, int update) { _mutex.lock(); _monFunc = monFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool mnFunc() { return _mnFunc; } + void mnFunc(bool mnFunc, int update) { _mutex.lock(); _mnFunc = mnFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool rfFunc() { return _rfFunc; } + void rfFunc(bool rfFunc, int update) { _mutex.lock(); _rfFunc = rfFunc; _updated |= 1ULL << update; _mutex.unlock(); } + + /* AROFUNC, MUTEFUNC, VSCFUNC, REVFUNC, SQLFUNC, ABMFUNC, BCFUNC, MBCFUNC, RITFUNC, AFCFUNC, SATMODEFUNC, SCOPEFUNC, + RESUMEFUNC, TBURSTFUNC, TUNERFUNC}; */ + bool aroFunc() { return _aroFunc; } + void aroFunc(bool aroFunc, int update) { _mutex.lock(); _aroFunc = aroFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool muteFunc() { return _muteFunc; } + void muteFunc(bool muteFunc, int update) { _mutex.lock(); _muteFunc = muteFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool vscFunc() { return _vscFunc; } + void vscFunc(bool vscFunc, int update) { _mutex.lock(); _vscFunc = vscFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool revFunc() { return _revFunc; } + void revFunc(bool revFunc, int update) { _mutex.lock(); _revFunc = revFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool sqlFunc() { return _sqlFunc; } + void sqlFunc(bool sqlFunc, int update) { _mutex.lock(); _sqlFunc = sqlFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool abmFunc() { return _abmFunc; } + void abmFunc(bool abmFunc, int update) { _mutex.lock(); _abmFunc = abmFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool bcFunc() { return _bcFunc; } + void bcFunc(bool bcFunc, int update) { _mutex.lock(); _bcFunc = bcFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool mbcFunc() { return _mbcFunc; } + void mbcFunc(bool mbcFunc, int update) { _mutex.lock(); _mbcFunc = mbcFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool ritFunc() { return _ritFunc; } + void ritFunc(bool ritFunc, int update) { _mutex.lock(); _ritFunc = ritFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool afcFunc() { return _afcFunc; } + void afcFunc(bool afcFunc, int update) { _mutex.lock(); _afcFunc = afcFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool satmodeFunc() { return _satmodeFunc; } + void satmodeFunc(bool satmodeFunc, int update) { _mutex.lock(); _satmodeFunc = satmodeFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool scopeFunc() { return _scopeFunc; } + void scopeFunc(bool scopeFunc, int update) { _mutex.lock(); _scopeFunc = scopeFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool resumeFunc() { return _resumeFunc; } + void resumeFunc(bool resumeFunc, int update) { _mutex.lock(); _resumeFunc = resumeFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool tburstFunc() { return _tburstFunc; } + void tburstFunc(bool tburstFunc, int update) { _mutex.lock(); _tburstFunc = tburstFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool tunerFunc() { return _tunerFunc; } + void tunerFunc(bool tunerFunc, int update) { _mutex.lock(); _tunerFunc = tunerFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool lockFunc() { return _lockFunc; } + void lockFunc(bool lockFunc, int update) { _mutex.lock(); _lockFunc = lockFunc; _updated |= 1ULL << update; _mutex.unlock(); } + + +private: + QMutex _mutex; + quint64 _updated=0; + quint64 _vfoAFreq=0; + quint64 _vfoBFreq=0; + unsigned char _currentVfo=0; + bool _ptt=0; + unsigned char _mode=0; + unsigned char _filter=0; + duplexMode _duplex; + bool _datamode=0; + unsigned char _antenna=0; + bool _rxAntenna=0; + // Tones + quint16 _ctcss; + quint16 _tsql; + quint16 _dtcs; + quint16 _csql; + // Levels + unsigned char _preamp; + unsigned char _agc; + unsigned char _attenuator; + unsigned char _modInput; + unsigned char _afGain; + unsigned char _rfGain; + unsigned char _squelch; + unsigned char _txPower; + unsigned char _micGain; + unsigned char _compLevel; + unsigned char _monitorLevel; + unsigned char _voxGain; + unsigned char _antiVoxGain; + unsigned char _nrLevel; + unsigned char _nbLevel; + unsigned char _nbDepth; + unsigned char _nbWidth; + // Meters + unsigned char _sMeter; + unsigned char _powerMeter; + unsigned char _swrMeter; + unsigned char _alcMeter; + unsigned char _compMeter; + unsigned char _voltageMeter; + unsigned char _currentMeter; + // Functions + bool _fagcFunc = false; + bool _nbFunc = false; + bool _compFunc = false; + bool _voxFunc = false; + bool _toneFunc = false; + bool _tsqlFunc = false; + bool _sbkinFunc = false; + bool _fbkinFunc = false; + bool _anfFunc = false; + bool _nrFunc = false; + bool _aipFunc = false; + bool _apfFunc = false; + bool _monFunc = false; + bool _mnFunc = false; + bool _rfFunc = false; + bool _aroFunc = false; + bool _muteFunc = false; + bool _vscFunc = false; + bool _revFunc = false; + bool _sqlFunc = false; + bool _abmFunc = false; + bool _bcFunc = false; + bool _mbcFunc = false; + bool _ritFunc = false; + bool _afcFunc = false; + bool _satmodeFunc = false; + bool _scopeFunc = false; + bool _resumeFunc = false; + bool _tburstFunc = false; + bool _tunerFunc = false; + bool _lockFunc = false; + +}; + +#endif \ No newline at end of file diff --git a/wfmain.cpp b/wfmain.cpp index ff1011f..82983dd 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -46,6 +46,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s qRegisterMetaType (); qRegisterMetaType (); qRegisterMetaType (); + qRegisterMetaType(); haveRigCaps = false; @@ -413,7 +414,7 @@ void wfmain::makeRig() connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady())); if (rigCtl != Q_NULLPTR) { - connect(rig, SIGNAL(stateInfo(rigStateStruct*)), rigCtl, SLOT(receiveStateInfo(rigStateStruct*))); + connect(rig, SIGNAL(stateInfo(rigstate*)), rigCtl, SLOT(receiveStateInfo(rigstate*))); connect(this, SIGNAL(requestRigState()), rig, SLOT(sendState())); connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); @@ -421,6 +422,7 @@ void wfmain::makeRig() connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); connect(rigCtl, SIGNAL(sendPowerOn()), rig, SLOT(powerOn())); connect(rigCtl, SIGNAL(sendPowerOff()), rig, SLOT(powerOff())); + connect(rigCtl, SIGNAL(stateUpdated()), rig, SLOT(stateUpdated())); connect(rigCtl, SIGNAL(setAttenuator(unsigned char)), rig, SLOT(setAttenuator(unsigned char))); connect(rigCtl, SIGNAL(setPreamp(unsigned char)), rig, SLOT(setPreamp(unsigned char))); @@ -5444,13 +5446,14 @@ void wfmain::on_enableRigctldChk_clicked(bool checked) connect(this, SIGNAL(sendRigCaps(rigCapabilities)), rigCtl, SLOT(receiveRigCaps(rigCapabilities))); if (rig != Q_NULLPTR) { // We are already connected to a rig. - connect(rig, SIGNAL(stateInfo(rigStateStruct*)), rigCtl, SLOT(receiveStateInfo(rigStateStruct*))); + connect(rig, SIGNAL(stateInfo(rigstate*)), rigCtl, SLOT(receiveStateInfo(rigstate*))); connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); connect(rigCtl, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char))); connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); connect(rigCtl, SIGNAL(sendPowerOn()), rig, SLOT(powerOn())); connect(rigCtl, SIGNAL(sendPowerOff()), rig, SLOT(powerOff())); + connect(rigCtl, SIGNAL(stateUpdated()), rig, SLOT(stateUpdated())); connect(rigCtl, SIGNAL(setAttenuator(unsigned char)), rig, SLOT(setAttenuator(unsigned char))); connect(rigCtl, SIGNAL(setPreamp(unsigned char)), rig, SLOT(setPreamp(unsigned char))); diff --git a/wfmain.h b/wfmain.h index b854a48..1b19d7b 100644 --- a/wfmain.h +++ b/wfmain.h @@ -14,6 +14,7 @@ #include "logcategories.h" #include "commhandler.h" #include "rigcommander.h" +#include "rigstate.h" #include "freqmemory.h" #include "rigidentities.h" #include "repeaterattributes.h" @@ -850,7 +851,6 @@ Q_DECLARE_METATYPE(struct rigCapabilities) Q_DECLARE_METATYPE(struct freqt) Q_DECLARE_METATYPE(struct mode_info) Q_DECLARE_METATYPE(struct udpPreferences) -Q_DECLARE_METATYPE(struct rigStateStruct) Q_DECLARE_METATYPE(struct audioPacket) Q_DECLARE_METATYPE(struct audioSetup) Q_DECLARE_METATYPE(struct timekind) @@ -858,6 +858,7 @@ Q_DECLARE_METATYPE(struct datekind) Q_DECLARE_METATYPE(enum rigInput) Q_DECLARE_METATYPE(enum meterKind) Q_DECLARE_METATYPE(enum spectrumMode) +Q_DECLARE_METATYPE(rigstate*) #endif // WFMAIN_H From 8ddf6880ee6915b9ae473be86c54b6ff400ca66c Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 23 Nov 2021 00:39:36 +0000 Subject: [PATCH 02/32] Windows support files --- wfview.sln | 27 +-- wfview.vcxproj | 377 +++++++++++------------------------------ wfview.vcxproj.filters | 54 +----- wfview.vcxproj.user | 8 +- 4 files changed, 115 insertions(+), 351 deletions(-) diff --git a/wfview.sln b/wfview.sln index 397c02c..ff4a8cd 100644 --- a/wfview.sln +++ b/wfview.sln @@ -7,33 +7,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wfview", "wfview.vcxproj", EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 Release|x86 = Release|x86 - Template|Win32 = Template|Win32 - Template|x64 = Template|x64 - Template|x86 = Template|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|Win32.ActiveCfg = Debug|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|Win32.Build.0 = Debug|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x64.ActiveCfg = Debug|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x64.Build.0 = Debug|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x86.ActiveCfg = Debug|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|Win32.ActiveCfg = Release|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|Win32.Build.0 = Release|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.ActiveCfg = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x64.Build.0 = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x86.ActiveCfg = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|Win32.ActiveCfg = Debug|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|Win32.Build.0 = Debug|Win32 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|x64.ActiveCfg = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|x64.Build.0 = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|x86.ActiveCfg = Release|x64 - {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Template|x86.Build.0 = Release|x64 + {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x86.ActiveCfg = Debug|Win32 + {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Debug|x86.Build.0 = Debug|Win32 + {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x86.ActiveCfg = Release|Win32 + {326108AD-FA9D-3AAF-8D3E-062C4DDC34E2}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/wfview.vcxproj b/wfview.vcxproj index 030b9d6..21e1461 100644 --- a/wfview.vcxproj +++ b/wfview.vcxproj @@ -16,7 +16,8 @@ QtVS_v304 10.0.19041.0 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild + $(MSBuildProjectDirectory)\QtMsBuild + v142 @@ -36,7 +37,10 @@ debug\ wfview - + + + + @@ -44,11 +48,37 @@ - debug\debug\wfviewtruerelease\release\wfviewtruefalsemsvc2019core;network;gui;multimedia;widgets;serialport;printsupportmsvc2019core;network;gui;multimedia;widgets;serialport;printsupport - + + + + + + debug\ + debug\ + wfview + true + + + release\ + release\ + wfview + true + false + + + msvc2019 + core;network;gui;multimedia;widgets;serialport;printsupport + + + msvc2019 + core;network;gui;multimedia;widgets;serialport;printsupport + + + + - .;..\qcustomplot;..\opus\include;resampler;rtaudio;release;/include;%(AdditionalIncludeDirectories) + .;..\qcustomplot;..\opus\include;resampler;release;/include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) release\ false @@ -57,14 +87,16 @@ Sync release\ MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="66912e1";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="62771f6";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) false - + + MultiThreadedDLL true true Level3 - true + true + ..\opus\win32\VS2015\Win32\Release\opus.lib;shell32.lib;%(AdditionalDependencies) ..\opus\win32\VS2015\Win32\Release;C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories) @@ -85,12 +117,31 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"66912e1\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"62771f6\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h + + msvc + ./$(Configuration)/moc_predefs.h + Moc'ing %(Identity)... + output + $(Configuration) + moc_%(Filename).cpp + + + default + Rcc'ing %(Identity)... + $(Configuration) + qrc_%(Filename).cpp + + + Uic'ing %(Identity)... + $(ProjectDir) + ui_%(Filename).h + + - .;..\qcustomplot;..\opus\include;resampler;rtaudio;debug;/include;%(AdditionalIncludeDirectories) + .;..\qcustomplot;..\opus\include;resampler;debug;/include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) debug\ false @@ -99,13 +150,14 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="66912e1";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";GITSHORT="62771f6";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) false MultiThreadedDebugDLL true true Level3 - true + true + ..\opus\win32\VS2015\Win32\Debug\opus.lib;shell32.lib;%(AdditionalDependencies) ..\opus\win32\VS2015\Win32\Debug;C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories) @@ -124,9 +176,28 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"66912e1\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WFVIEW_VERSION="1.2d";QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;USE_SSE2;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";GITSHORT=\"62771f6\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h + + msvc + ./$(Configuration)/moc_predefs.h + Moc'ing %(Identity)... + output + $(Configuration) + moc_%(Filename).cpp + + + default + Rcc'ing %(Identity)... + $(Configuration) + qrc_%(Filename).cpp + + + Uic'ing %(Identity)... + $(ProjectDir) + ui_%(Filename).h + + @@ -154,198 +225,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document true @@ -362,119 +288,21 @@ release\moc_predefs.h;%(Outputs) true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -508,30 +336,16 @@ - - - - - - - - - - resourcesresources + resources + resources + - - - - - - - - - - stylestyle + style + style + @@ -550,6 +364,9 @@ - + + + + \ No newline at end of file diff --git a/wfview.vcxproj.filters b/wfview.vcxproj.filters index d78480d..051ed7d 100644 --- a/wfview.vcxproj.filters +++ b/wfview.vcxproj.filters @@ -214,57 +214,12 @@ - - - - - - - - - - Generated Files Generated Files - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -419,6 +374,8 @@ Resource Files + + @@ -432,6 +389,11 @@ - + + + + + Generated Files + \ No newline at end of file diff --git a/wfview.vcxproj.user b/wfview.vcxproj.user index dd9de9b..a638198 100644 --- a/wfview.vcxproj.user +++ b/wfview.vcxproj.user @@ -1,11 +1,15 @@  - PATH=$(QTDIR)\bin%3bC:\QT\5.15.2\MSVC2019\bin%3b$(QTDIR)\bin%3bC:\QT\5.15.2\MSVC2019\bin%3b$(PATH) - PATH=$(QTDIR)\bin%3bC:\QT\5.15.2\MSVC2019\bin%3b$(QTDIR)\bin%3bC:\QT\5.15.2\MSVC2019\bin%3b$(PATH) + + 2021-11-22T18:24:33.3752914Z + + + 2021-11-22T18:24:41.6960953Z + \ No newline at end of file From 47b439b74166a1167482a80fd3a9d362e57b91c8 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 1 Dec 2021 10:01:05 +0000 Subject: [PATCH 03/32] Rewrite rigstate (again!) --- rigcommander.cpp | 533 +++++++++++++++++++++++++++-------------------- rigcommander.h | 1 + rigctld.cpp | 335 +++++++++++++++-------------- rigstate.h | 324 ++++++++-------------------- 4 files changed, 579 insertions(+), 614 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index c161171..f635688 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -22,11 +22,6 @@ rigCommander::rigCommander() { - state.filter(0,NONE); - state.mode(0,NONE); - state.ptt(0,NONE); - state.currentVfo(0,NONE); - state.duplex(dmSplitOff,NONE); } rigCommander::~rigCommander() @@ -143,6 +138,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud connect(this, SIGNAL(discoveredRigID(rigCapabilities)), ptty, SLOT(receiveFoundRigID(rigCapabilities))); emit haveAfGain(rxSetup.localAFgain); + localVolume = rxSetup.localAFgain; } // data from the comm port to the program: @@ -262,7 +258,26 @@ void rigCommander::powerOn() { QByteArray payload; - for(int i=0; i < 150; i++) + int numFE=150; + switch (this->rigBaudRate) { + case 57600: + numFE = 75; + break; + case 38400: + numFE = 50; + break; + case 19200: + numFE = 25; + break; + case 9600: + numFE = 13; + break; + case 4800: + numFE = 7; + break; + } + + for(int i=0; i < numFE; i++) { payload.append("\xFE"); } @@ -568,12 +583,10 @@ void rigCommander::setFrequency(unsigned char vfo, freqt freq) cmdPayload.append(freqPayload); if (vfo == 0) { - state.vfoAFreq(freq.Hz,NONE); cmdPayload.prepend('\x00'); } else { - state.vfoBFreq(freq.Hz,NONE); cmdPayload.prepend(vfo); cmdPayload.prepend('\x25'); } @@ -1233,16 +1246,16 @@ void rigCommander::parseCommand() break; case '\x0F': emit haveDuplexMode((duplexMode)(unsigned char)payloadIn[1]); - state.duplex((duplexMode)(unsigned char)payloadIn[1],NONE); + state.set(DUPLEX, (duplexMode)(unsigned char)payloadIn[1], false); break; case '\x11': emit haveAttenuator((unsigned char)payloadIn.at(1)); - state.attenuator((unsigned char)payloadIn.at(1),NONE); + state.set(ATTENUATOR, (quint8)payloadIn[1], false); break; case '\x12': emit haveAntenna((unsigned char)payloadIn.at(1), (bool)payloadIn.at(2)); - state.antenna((unsigned char)payloadIn.at(1),NONE); - state.rxAntenna((bool)payloadIn.at(2),NONE); + state.set(ANTENNA, (quint8)payloadIn[1], false); + state.set(RXANTENNA, (bool)payloadIn[2], false); break; case '\x14': // read levels @@ -1346,18 +1359,21 @@ void rigCommander::parseLevels() // AF level - ignore if LAN connection. if (udp == Q_NULLPTR) { emit haveAfGain(level); - state.afGain(level,NONE); + state.set(AFGAIN, level, false); + } + else { + state.set(AFGAIN, localVolume, false); } break; case '\x02': // RX RF Gain emit haveRfGain(level); - state.rfGain(level,NONE); + state.set(RFGAIN, level, false); break; case '\x03': // Squelch level emit haveSql(level); - state.squelch(level,NONE); + state.set(SQUELCH, level, false); break; case '\x07': // Twin BPF Inner, or, IF-Shift level @@ -1376,12 +1392,12 @@ void rigCommander::parseLevels() case '\x0A': // TX RF level emit haveTxPower(level); - state.txPower(level,NONE); + state.set(TXPOWER, level, false); break; case '\x0B': // Mic Gain emit haveMicGain(level); - state.micGain(level,NONE); + state.set(MICGAIN, level, false); break; case '\x0C': // CW Keying Speed - ignore for now @@ -1392,7 +1408,7 @@ void rigCommander::parseLevels() case '\x0E': // compressor level emit haveCompLevel(level); - state.compLevel(level,NONE); + state.set(COMPLEVEL, level, false); break; case '\x12': // NB level - ignore for now @@ -1400,17 +1416,17 @@ void rigCommander::parseLevels() case '\x15': // monitor level emit haveMonitorLevel(level); - state.monitorLevel(level,NONE); + state.set(MONITORLEVEL, level, false); break; case '\x16': // VOX gain emit haveVoxGain(level); - state.voxGain(level,NONE); + state.set(VOXGAIN, level, false); break; case '\x17': // anti-VOX gain emit haveAntiVoxGain(level); - state.antiVoxGain(level,NONE); + state.set(ANTIVOXGAIN, level, false); break; default: @@ -1428,42 +1444,42 @@ void rigCommander::parseLevels() case '\x02': // S-Meter emit haveMeter(meterS, level); - state.sMeter(level,NONE); + state.set(SMETER, level, false); break; case '\x04': // Center (IC-R8600) emit haveMeter(meterCenter, level); - state.sMeter(level,NONE); + state.set(SMETER, level, false); break; case '\x11': // RF-Power meter emit haveMeter(meterPower, level); - state.powerMeter(level,NONE); + state.set(POWERMETER, level, false); break; case '\x12': // SWR emit haveMeter(meterSWR, level); - state.swrMeter(level,NONE); + state.set(SWRMETER, level, false); break; case '\x13': // ALC emit haveMeter(meterALC, level); - state.alcMeter(level,NONE); + state.set(ALCMETER, level, false); break; case '\x14': // COMP dB reduction emit haveMeter(meterComp, level); - state.compMeter(level,NONE); + state.set(COMPMETER, level, false); break; case '\x15': // VD (12V) emit haveMeter(meterVoltage, level); - state.voltageMeter(level,NONE); + state.set(VOLTAGEMETER, level, false); break; case '\x16': // ID emit haveMeter(meterCurrent, level); - state.currentMeter(level,NONE); + state.set(CURRENTMETER, level, false); break; default: @@ -2094,6 +2110,7 @@ void rigCommander::setAfGain(unsigned char level) } else { emit haveSetVolume(level); + localVolume = level; } } @@ -2370,8 +2387,7 @@ void rigCommander::parsePTT() // PTT on emit havePTTStatus(true); } - state.ptt((bool)payloadIn[2],NONE); - + state.set(PTT,(bool)payloadIn[2],false); } void rigCommander::parseRegisters1A() @@ -2400,7 +2416,7 @@ void rigCommander::parseRegisters1A() parseBandStackReg(); break; case '\x04': - state.agc(payloadIn[02],AGC); + state.set(AGC, (quint8)payloadIn[2], false); break; case '\x06': // data mode @@ -2412,7 +2428,7 @@ void rigCommander::parseRegisters1A() // YY: filter selected, 01 through 03.; // if YY is 00 then XX was also set to 00 emit haveDataMode((bool)payloadIn[03]); - state.datamode((bool)payloadIn[03],NONE); + state.set(DATAMODE, (quint8)payloadIn[3], false); break; case '\x07': // IP+ status @@ -2434,24 +2450,24 @@ void rigCommander::parseRegister1B() // "Repeater tone" tone = decodeTone(payloadIn); emit haveTone(tone); - state.ctcss(tone,NONE); + state.set(CTCSS, tone, false); break; case '\x01': // "TSQL tone" tone = decodeTone(payloadIn); emit haveTSQL(tone); - state.tsql(tone,NONE); + state.set(TSQL, tone, false); break; case '\x02': // DTCS (DCS) tone = decodeTone(payloadIn, tinv, rinv); emit haveDTCS(tone, tinv, rinv); - state.dtcs(tone,NONE); + state.set(DTCS, tone, false); break; case '\x07': // "CSQL code (DV mode)" tone = decodeTone(payloadIn); - state.csql(tone,NONE); + state.set(CSQL, tone, false); break; default: break; @@ -2472,49 +2488,49 @@ void rigCommander::parseRegister16() case '\x02': // Preamp emit havePreamp((unsigned char)payloadIn.at(2)); - state.preamp((unsigned char)payloadIn.at(2),NONE); + state.set(PREAMP, (quint8)payloadIn.at(2), false); break; case '\x22': - state.nbFunc((bool)payloadIn.at(2), NONE); + state.set(NBFUNC, payloadIn.at(2) != 0, false); break; case '\x40': - state.nrFunc((bool)payloadIn.at(2), NONE); + state.set(NRFUNC, payloadIn.at(2) != 0, false); break; case '\x41': // Auto notch - state.anfFunc((bool)payloadIn.at(2), NONE); + state.set(ANFFUNC, payloadIn.at(2) != 0, false); break; case '\x42': - state.toneFunc((bool)payloadIn.at(2), NONE); + state.set(TONEFUNC, payloadIn.at(2) != 0, false); break; case '\x43': - state.tsqlFunc((bool)payloadIn.at(2), NONE); + state.set(TSQLFUNC, payloadIn.at(2) != 0, false); break; case '\44': - state.compFunc((bool)payloadIn.at(2), NONE); + state.set(COMPFUNC, payloadIn.at(2) != 0, false); break; case '\45': - state.monFunc((bool)payloadIn.at(2), NONE); + state.set(MONFUNC, payloadIn.at(2) != 0, false); break; case '\46': - state.voxFunc((bool)payloadIn.at(2), NONE); + state.set(VOXFUNC, payloadIn.at(2) != 0, false); break; case '\x47': if (payloadIn.at(2) == '\00') { - state.fbkinFunc(false, NONE); - state.sbkinFunc(false, NONE); + state.set(FBKINFUNC, false, false); + state.set(SBKINFUNC, false, false); } else if (payloadIn.at(2) == '\01') { - state.fbkinFunc(false, NONE); - state.sbkinFunc(true, NONE); + state.set(FBKINFUNC, false, false); + state.set(SBKINFUNC, true, false); } else if (payloadIn.at(2) == '\02') { - state.fbkinFunc(true, NONE); - state.sbkinFunc(false, NONE); + state.set(FBKINFUNC, true, false); + state.set(SBKINFUNC, false, false); } break; case '\48': // Manual Notch - state.mnFunc((bool)payloadIn.at(2), NONE); + state.set(MNFUNC, payloadIn.at(2) != 0, false); break; default: break; @@ -2820,6 +2836,7 @@ void rigCommander::parseWFData() break; case 0x10: // confirming scope is on + state.set(SCOPEFUNC, (bool)payloadIn[2], true); break; case 0x11: // confirming output enabled/disabled of wf data. @@ -3826,13 +3843,14 @@ void rigCommander::parseFrequency() freq.Hz += ((payloadIn[03] & 0xf0) >> 4) * 100000; freq.MHzDouble = frequencyMhz; - - if (state.currentVfo() == 0) { - state.vfoAFreq(freq.Hz, NONE); + + if (state.getChar(CURRENTVFO) == 0) { + state.set(VFOAFREQ, freq.Hz, false); } else { - state.vfoBFreq(freq.Hz, NONE); + state.set(VFOBFREQ, freq.Hz, false); } + emit haveFrequency(freq); } @@ -3911,8 +3929,8 @@ void rigCommander::parseMode() filter = 0; } emit haveMode((unsigned char)payloadIn[01], filter); - state.mode((unsigned char)payloadIn[01],NONE); - state.filter(filter,NONE); + state.set(MODE,(unsigned char)payloadIn[01],false); + state.set(FILTER,filter,false); } @@ -4210,172 +4228,243 @@ void rigCommander::stateUpdated() RESUMEFUNC, TBURSTFUNC, TUNERFUNC}; */ - /* VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL */ + /* VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL */ - if ((state.updated()) & (1ULL <<(VFOAFREQ))) { - // VFO A FREQUENCY IS UPDATED! - freqt freq; - freq.Hz = state.vfoAFreq(); - setFrequency(0, freq); - setFrequency(0, freq); - setFrequency(0, freq); - getFrequency(); + QMap::iterator i = state.map.begin(); + while (i != state.map.end()) { + if (!i.value()._valid || i.value()._updated) + { + i.value()._updated = false; + i.value()._valid = true; // Set value to valid as we have requested it (even if we haven't had a response) + qDebug(logRigCtlD()) << "Got new value:" << i.key() << "=" << i.value()._value; + switch (i.key()) { + case VFOAFREQ: + if (i.value()._valid) { + freqt freq; + freq.Hz = state.getInt64(VFOAFREQ); + setFrequency(0, freq); + setFrequency(0, freq); + setFrequency(0, freq); + } + getFrequency(); + break; + case VFOBFREQ: + if (i.value()._valid) { + freqt freq; + freq.Hz = state.getInt64(VFOBFREQ); + setFrequency(1, freq); + setFrequency(1, freq); + setFrequency(1, freq); + } + getFrequency(); + break; + case CURRENTVFO: + // Work on VFOB - how do we do this? + break; + case PTT: + if (i.value()._valid) { + setPTT(state.getBool(PTT)); + setPTT(state.getBool(PTT)); + setPTT(state.getBool(PTT)); + } + getPTT(); + break; + case MODE: + case FILTER: + if (i.value()._valid) { + setMode(state.getChar(MODE), state.getChar(FILTER)); + } + getMode(); + break; + case DUPLEX: + if (i.value()._valid) { + setDuplexMode(state.getDuplex(DUPLEX)); + } + getDuplexMode(); + break; + case DATAMODE: + if (i.value()._valid) { + setDataMode(state.getBool(DATAMODE), state.getChar(FILTER)); + } + getDuplexMode(); + break; + case ANTENNA: + case RXANTENNA: + if (i.value()._valid) { + setAntenna(state.getChar(ANTENNA), state.getBool(RXANTENNA)); + } + getAntenna(); + break; + case CTCSS: + if (i.value()._valid) { + setTone(state.getChar(CTCSS)); + } + getTone(); + break; + case TSQL: + if (i.value()._valid) { + setTSQL(state.getChar(TSQL)); + } + getTSQL(); + break; + case DTCS: + if (i.value()._valid) { + setDTCS(state.getChar(DTCS), false, false); // Not sure about this? + } + getDTCS(); + break; + case CSQL: + if (i.value()._valid) { + setTone(state.getChar(CSQL)); + } + getTone(); + break; + case PREAMP: + if (i.value()._valid) { + setPreamp(state.getChar(PREAMP)); + } + getPreamp(); + break; + case ATTENUATOR: + if (i.value()._valid) { + setAttenuator(state.getChar(ATTENUATOR)); + } + getAttenuator(); + break; + case AFGAIN: + if (i.value()._valid) { + setAfGain(state.getChar(AFGAIN)); + } + getAfGain(); + break; + case RFGAIN: + if (i.value()._valid) { + setRfGain(state.getChar(RFGAIN)); + } + getRfGain(); + break; + case SQUELCH: + if (i.value()._valid) { + setSquelch(state.getChar(SQUELCH)); + } + getSql(); + break; + case TXPOWER: + if (i.value()._valid) { + setTxPower(state.getChar(TXPOWER)); + } + getTxLevel(); + break; + case MICGAIN: + if (i.value()._valid) { + setMicGain(state.getChar(MICGAIN)); + } + getMicGain(); + break; + case COMPLEVEL: + if (i.value()._valid) { + setCompLevel(state.getChar(COMPLEVEL)); + } + getCompLevel(); + break; + case MONITORLEVEL: + if (i.value()._valid) { + setMonitorLevel(state.getChar(MONITORLEVEL)); + } + getMonitorLevel(); + break; + case VOXGAIN: + if (i.value()._valid) { + setVoxGain(state.getChar(VOXGAIN)); + } + getVoxGain(); + break; + case ANTIVOXGAIN: + if (i.value()._valid) { + setAntiVoxGain(state.getChar(ANTIVOXGAIN)); + } + getAntiVoxGain(); + break; + case NBFUNC: + if (i.value()._valid) { + setNb(state.getBool(NBFUNC)); + } + getNb(); + break; + case NRFUNC: + if (i.value()._valid) { + setNr(state.getBool(NRFUNC)); + } + getNr(); + break; + case ANFFUNC: + if (i.value()._valid) { + setAutoNotch(state.getBool(ANFFUNC)); + } + getAutoNotch(); + break; + case TONEFUNC: + if (i.value()._valid) { + setToneEnabled(state.getBool(TONEFUNC)); + } + getToneEnabled(); + break; + case TSQLFUNC: + if (i.value()._valid) { + setToneSql(state.getBool(TSQLFUNC)); + } + getToneSql(); + break; + case COMPFUNC: + if (i.value()._valid) { + setCompressor(state.getBool(COMPFUNC)); + } + getCompressor(); + break; + case MONFUNC: + if (i.value()._valid) { + setMonitor(state.getBool(MONFUNC)); + } + getMonitor(); + break; + case VOXFUNC: + if (i.value()._valid) { + setVox(state.getBool(VOXFUNC)); + } + getVox(); + break; + case SBKINFUNC: + if (i.value()._valid) { + setBreakIn(state.getBool(VOXFUNC)); + } + getVox(); + break; + case FBKINFUNC: + if (i.value()._valid) { + setBreakIn(state.getBool(VOXFUNC) << 1); + } + getBreakIn(); + break; + case MNFUNC: + if (i.value()._valid) { + setManualNotch(state.getBool(MNFUNC)); + } + getManualNotch(); + break; + case SCOPEFUNC: + if (i.value()._valid) { + if (state.getBool(SCOPEFUNC)) { + enableSpectOutput(); + } + else { + disableSpectOutput(); + } + } + } + } + ++i; } - if ((state.updated()) & (1ULL <<(VFOBFREQ))) { - // VFO B FREQUENCY IS UPDATED! - freqt freq; - freq.Hz = state.vfoBFreq(); - setFrequency(1, freq); - setFrequency(1, freq); - setFrequency(1, freq); - getFrequency(); - } - if ((state.updated()) & (1ULL <<(CURRENTVFO))) { - // Work on VFOB - how do we do this? - } - if ((state.updated()) & (1ULL <<(PTT))) { - setPTT(state.ptt()); - setPTT(state.ptt()); - setPTT(state.ptt()); - getPTT(); - } - if (((state.updated()) & (1ULL <<(MODE))) || ((state.updated()) & (1ULL <<(FILTER)))) { - setMode(state.mode(),state.filter()); - getMode(); - } - - if ((state.updated()) & (1ULL <<(DUPLEX))) { - setDuplexMode(state.duplex()); - getDuplexMode(); - } - - if ((state.updated()) & (1ULL <<(DATAMODE))) { - setDataMode(state.datamode(), state.filter()); - getDataMode(); - } - - if (((state.updated()) & (1ULL <<(ANTENNA))) || ((state.updated()) & (1ULL <<(RXANTENNA)))) { - setAntenna(state.antenna(), state.rxAntenna()); - getAntenna(); - } - - if ((state.updated()) & (1ULL <<(CTCSS))) { - setTone(state.ctcss()); - getTone(); - } - if ((state.updated()) & (1ULL <<(TSQL))) { - setTSQL(state.tsql()); - getTSQL(); - } - if ((state.updated()) & (1ULL <<(DTCS))) { - setDTCS(state.dtcs(),false,false); // Not sure about this? - getDTCS(); - } - if ((state.updated()) & (1ULL <<(CSQL))) { // Not sure about this one? - //setTone(state.ctcss()); - //getTone(); - } - - /* PREAMP, ATTENUATOR, MODINPUT, AFGAIN, RFGAIN, SQUELCH, TXPOWER, MICGAIN, COMPLEVEL, MONITORLEVEL, VOXGAIN, ANTIVOXGAIN */ - if ((state.updated()) & (1ULL <<(PREAMP))) { - setPreamp(state.preamp()); - getPreamp(); - } - if ((state.updated()) & (1ULL <<(ATTENUATOR))) { - setAttenuator(state.attenuator()); - getAttenuator(); - } - if ((state.updated()) & (1ULL <<(MODINPUT))) { - getModInputLevel(rigInput::inputLAN); // Need to fix this! - } - - if ((state.updated()) & (1ULL <<(AFGAIN))) { - setAfGain(state.afGain()); - getAfGain(); - } - - if ((state.updated()) & (1ULL <<(RFGAIN))) { - setRfGain(state.rfGain()); - getRfGain(); - } - - if ((state.updated()) & (1ULL <<(SQUELCH))) { - setSquelch(state.squelch()); - getSql(); - } - - if ((state.updated()) & (1ULL <<(TXPOWER))) { - setTxPower(state.txPower()); - getTxLevel(); - } - - if ((state.updated()) & (1ULL <<(MICGAIN))) { - setMicGain(state.micGain()); - getMicGain(); - } - - if ((state.updated()) & (1ULL <<(COMPLEVEL))) { - setCompLevel(state.compLevel()); - getCompLevel(); - } - - if ((state.updated()) & (1ULL <<(MONITORLEVEL))) { - setMonitorLevel(state.monitorLevel()); - getMonitorLevel(); - } - - if ((state.updated()) & (1ULL <<(VOXGAIN))) { - setVoxGain(state.voxGain()); - getVoxGain(); - } - - if ((state.updated()) & (1ULL <<(ANTIVOXGAIN))) { - setAntiVoxGain(state.antiVoxGain()); - getAntiVoxGain(); - } - if ((state.updated()) & (1ULL <<(NBFUNC))) { - setNb(state.nbFunc()); - getNb(); - } - if ((state.updated()) & (1ULL << (NRFUNC))) { - setNr(state.nrFunc()); - getNr(); - } - if ((state.updated()) & (1ULL << (ANFFUNC))) { - setAutoNotch(state.anfFunc()); - getAutoNotch(); - } - if ((state.updated()) & (1ULL << (TONEFUNC))) { - setToneEnabled(state.toneFunc()); - getToneEnabled(); - } - if ((state.updated()) & (1ULL << (TSQLFUNC))) { - setToneSql(state.tsqlFunc()); - getToneSql(); - } - if ((state.updated()) & (1ULL << (COMPFUNC))) { - setCompressor(state.compFunc()); - getCompressor(); - } - if ((state.updated()) & (1ULL << (MONFUNC))) { - setMonitor(state.monFunc()); - getMonitor(); - } - if ((state.updated()) & (1ULL << (VOXFUNC))) { - setVox(state.voxFunc()); - getVox(); - } - if ((state.updated()) & (1ULL <<(FBKINFUNC))) { - setBreakIn(state.sbkinFunc()<<1); - getBreakIn(); - } - if ((state.updated()) & (1ULL << (MNFUNC))) { - setManualNotch(state.mnFunc()); - getManualNotch(); - } - - state.updated(0); } void rigCommander::getDebug() diff --git a/rigcommander.h b/rigcommander.h index de1f4a1..afef8b9 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -460,6 +460,7 @@ private: QString password; QString serialPortError; + unsigned char localVolume=0; }; diff --git a/rigctld.cpp b/rigctld.cpp index ebceb3b..1ef76ac 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -79,6 +79,7 @@ int rigCtlD::startServer(qint16 port) { qInfo(logRigCtlD()) << "started on port " << port; } + return 0; } @@ -118,6 +119,8 @@ rigCtlClient::rigCtlClient(int socketId, rigCapabilities caps, rigstate* state, connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()), Qt::DirectConnection); connect(parent, SIGNAL(sendData(QString)), this, SLOT(sendData(QString)), Qt::DirectConnection); qInfo(logRigCtlD()) << " session connected: " << sessionId; + emit parent->stateUpdated(); // Get the current state. + } void rigCtlClient::socketReadyRead() @@ -182,15 +185,15 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("ChkVFO: ")); } - resp.append(QString("%1").arg(rigState->currentVfo())); + resp.append(QString("%1").arg(rigState->getChar(CURRENTVFO))); response.append(resp); } else if (command[0] == "dump_state") { // Currently send "fake" state information until I can work out what is required! - response.append("1"); - response.append(QString("%1").arg(rigCaps.rigctlModel)); - response.append("0"); + response.append("1"); // rigctld protocol version + response.append(QString("%1").arg(rigCaps.rigctlModel)); + response.append("0"); // Print something for (bandType band : rigCaps.bands) { response.append(generateFreqRange(band)); @@ -203,6 +206,7 @@ void rigCtlClient::socketReadyRead() } } response.append("0 0 0 0 0 0 0"); + response.append("0x1ff 1"); response.append("0x1ff 0"); response.append("0 0"); @@ -251,12 +255,21 @@ void rigCtlClient::socketReadyRead() response.append(attens); + response.append("0xffffffffffffffff"); + response.append("0xffffffffffffffff"); + response.append("0xffffffffffffffff"); + response.append("0xffffffffffffffff"); + response.append("0xffffffffffffffff"); + response.append("0xffffffffffffffff"); + + /* response.append("0xffffffffffffffff"); response.append("0xffffffffffffffff"); response.append("0xfffffffff7ffffff"); response.append("0xfffffff083ffffff"); response.append("0xffffffffffffffff"); response.append("0xffffffffffffffbf"); + */ /* response.append("0x3effffff"); @@ -275,12 +288,14 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("Frequency: ")); } - if (rigState->currentVfo()==0) { - resp.append(QString("%1").arg(rigState->vfoAFreq())); + + if (rigState->getChar(CURRENTVFO)==0) { + resp.append(QString("%1").arg(rigState->getInt64(VFOAFREQ))); } else { - resp.append(QString("%1").arg(rigState->vfoBFreq())); + resp.append(QString("%1").arg(rigState->getInt64(VFOBFREQ))); } + response.append(resp); } else if (command[0] == "F" || command[0] == "set_freq") @@ -307,10 +322,10 @@ void rigCtlClient::socketReadyRead() freq.Hz = static_cast(newFreq); qDebug(logRigCtlD()) << QString("Set frequency: %1 (%2)").arg(freq.Hz).arg(command[1]); if (vfo == 0) { - rigState->vfoAFreq(freq.Hz, VFOAFREQ); + rigState->set(VFOAFREQ, freq.Hz,true); } else { - rigState->vfoAFreq(freq.Hz, VFOBFREQ); + rigState->set(VFOBFREQ, freq.Hz,true); } } } @@ -341,7 +356,7 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("PTT: ")); } - resp.append(QString("%1").arg(rigState->ptt())); + resp.append(QString("%1").arg(rigState->getBool(PTT))); response.append(resp); } else @@ -353,26 +368,27 @@ void rigCtlClient::socketReadyRead() { setCommand = true; if (rigCaps.hasPTTCommand) { - rigState->ptt(bool(command[1].toInt()), PTT); + rigState->set(PTT, (bool)command[1].toInt(), true); } else { responseCode = -1; } } - else if (command[0] == "v" || command[0] == "get_vfo") + else if (command[0] == "v" || command[0] == "v\nv" || command[0] == "get_vfo") { QString resp; if (longReply) { resp.append("VFO: "); } - - if (rigState->currentVfo() == 0) { + + if (rigState->getChar(CURRENTVFO) == 0) { resp.append("VFOA"); } else { resp.append("VFOB"); } + response.append(resp); } else if (command.length() > 1 && (command[0] == "V" || command[0] == "set_vfo")) @@ -387,71 +403,75 @@ void rigCtlClient::socketReadyRead() response.append("MEM"); } else if (command[1] == "VFOB" || command[1] == "Sub") { - emit parent->setVFO(1); + //emit parent->setVFO(1); } else { - emit parent->setVFO(0); + //emit parent->setVFO(0); } } else if (command[0] == "s" || command[0] == "get_split_vfo") { + if (longReply) { - response.append(QString("Split: %1").arg(rigState->duplex())); + response.append(QString("Split: %1").arg(rigState->getChar(DUPLEX))); } else { - response.append(QString("%1").arg(rigState->duplex())); + response.append(QString("%1").arg(rigState->getChar(DUPLEX))); } - + QString resp; if (longReply) { resp.append("TX VFO: "); } - if (rigState->currentVfo() == 0) + + if (rigState->getChar(CURRENTVFO) == 0) { resp.append(QString("%1").arg("VFOB")); } else { resp.append(QString("%1").arg("VFOA")); } + response.append(resp); } else if (command.length() > 1 && (command[0] == "S" || command[0] == "set_split_vfo")) { setCommand = true; + if (command[1] == "1") { - rigState->duplex(dmSplitOn, DUPLEX); + rigState->set(DUPLEX, dmSplitOn, true); } else { - rigState->duplex(dmSplitOff, DUPLEX); + rigState->set(DUPLEX, dmSplitOff, true); } } else if (command[0] == "\xf3" || command[0] == "get_vfo_info") { if (longReply) { - //response.append(QString("set_vfo: %1").arg(command[1])); + response.append(QString("set_vfo: %1").arg(command[1])); if (command[1] == "VFOB") { - response.append(QString("Freq: %1").arg(rigState->vfoBFreq())); + response.append(QString("Freq: %1").arg(rigState->getInt64(VFOBFREQ))); } else { - response.append(QString("Freq: %1").arg(rigState->vfoAFreq())); + response.append(QString("Freq: %1").arg(rigState->getInt64(VFOAFREQ))); } - response.append(QString("Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("Width: %1").arg(getFilter(rigState->mode(), rigState->filter()))); - response.append(QString("Split: %1").arg(rigState->duplex())); + response.append(QString("Mode: %1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("Width: %1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); + response.append(QString("Split: %1").arg(rigState->getDuplex(DUPLEX))); response.append(QString("SatMode: %1").arg(0)); // Need to get satmode } else { if (command[1] == "VFOB") { - response.append(QString("%1").arg(rigState->vfoBFreq())); + response.append(QString("%1").arg(rigState->getInt64(VFOBFREQ))); } else { - response.append(QString("%1").arg(rigState->vfoAFreq())); + response.append(QString("%1").arg(rigState->getInt64(VFOAFREQ))); } - response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); + response.append(QString("%1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("%1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); } } else if (command[0] == "i" || command[0] == "get_split_freq") @@ -460,12 +480,14 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append("TX VFO: "); } - if (rigState->currentVfo() == 0) { - resp.append(QString("%1").arg(rigState->vfoBFreq())); + + if (rigState->getInt64(CURRENTVFO) == 0) { + resp.append(QString("%1").arg(rigState->getInt64(VFOBFREQ))); } else { - resp.append(QString("%1").arg(rigState->vfoAFreq())); + resp.append(QString("%1").arg(rigState->getInt64(VFOAFREQ))); } + response.append(resp); } else if (command.length() > 1 && (command[0] == "I" || command[0] == "set_split_freq")) @@ -476,7 +498,7 @@ void rigCtlClient::socketReadyRead() newFreq = command[1].toDouble(&ok); if (ok) { qDebug(logRigCtlD()) << QString("set_split_freq: %1 (%2)").arg(newFreq).arg(command[1]); - rigState->vfoBFreq(static_cast(newFreq),VFOBFREQ); + rigState->set(VFOBFREQ, static_cast(newFreq),false); } } else if (command.length() > 2 && (command[0] == "X" || command[0] == "set_split_mode")) @@ -486,26 +508,26 @@ void rigCtlClient::socketReadyRead() else if (command.length() > 0 && (command[0] == "x" || command[0] == "get_split_mode")) { - if (longReply) { - response.append(QString("TX Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("TX Passband: %1").arg(getFilter(rigState->mode(), rigState->filter()))); - } - else { - response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); - } + if (longReply) { + response.append(QString("TX Mode: %1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("TX Passband: %1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); + } + else { + response.append(QString("%1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("%1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); + } } else if (command[0] == "m" || command[0] == "get_mode") { - if (longReply) { - response.append(QString("Mode: %1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("Passband: %1").arg(getFilter(rigState->mode(), rigState->filter()))); - } - else { - response.append(QString("%1").arg(getMode(rigState->mode(), rigState->datamode()))); - response.append(QString("%1").arg(getFilter(rigState->mode(), rigState->filter()))); - } + if (longReply) { + response.append(QString("TX Mode: %1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("TX Passband: %1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); + } + else { + response.append(QString("%1").arg(getMode(rigState->getChar(MODE), rigState->getBool(DATAMODE)))); + response.append(QString("%1").arg(getFilter(rigState->getChar(MODE), rigState->getChar(FILTER)))); + } } else if (command[0] == "M" || command[0] == "set_mode") { @@ -529,15 +551,16 @@ void rigCtlClient::socketReadyRead() width = 2; else width = 1; - - rigState->mode(getMode(mode), MODE); - rigState->filter(width, FILTER); + + rigState->set(MODE,getMode(mode),true); + rigState->set(FILTER,(quint8)width, true); if (mode.mid(0, 3) == "PKT") { - rigState->datamode(true, DATAMODE); + rigState->set(DATAMODE, true, true); } else { - rigState->datamode(true, DATAMODE); + rigState->set(DATAMODE, false, true); } + } else if (command[0] == "s" || command[0] == "get_split_vfo") { @@ -573,22 +596,22 @@ void rigCtlClient::socketReadyRead() if (longReply) { response.append(QString("AntCurr: %1").arg(getAntName((unsigned char)command[1].toInt()))); response.append(QString("Option: %1").arg(0)); - response.append(QString("AntTx: %1").arg(getAntName(rigState->antenna()))); - response.append(QString("AntRx: %1").arg(getAntName(rigState->antenna()))); + response.append(QString("AntTx: %1").arg(getAntName(rigState->getChar(ANTENNA)))); + response.append(QString("AntRx: %1").arg(getAntName(rigState->getChar(ANTENNA)))); } else { response.append(QString("%1").arg(getAntName((unsigned char)command[1].toInt()))); response.append(QString("%1").arg(0)); - response.append(QString("%1").arg(getAntName(rigState->antenna()))); - response.append(QString("%1").arg(getAntName(rigState->antenna()))); + response.append(QString("%1").arg(getAntName(rigState->getChar(ANTENNA)))); + response.append(QString("%1").arg(getAntName(rigState->getChar(ANTENNA)))); } } } - else if (command[0] == "Y" || command[0] == "set_ant") + else if (command.length() > 1 && (command[0] == "Y" || command[0] == "set_ant")) { setCommand = true; qInfo(logRigCtlD()) << "set_ant:" << command[1]; - rigState->antenna(antFromName(command[1]),ANTENNA); + rigState->set(ANTENNA,antFromName(command[1]),true); } else if (command[0] == "z" || command[0] == "get_xit") { @@ -612,52 +635,54 @@ void rigCtlClient::socketReadyRead() } if (command[1] == "STRENGTH") { + if (rigCaps.model == model7610) - value = getCalibratedValue(rigState->sMeter(), IC7610_STR_CAL); + value = getCalibratedValue(rigState->getChar(SMETER), IC7610_STR_CAL); else if (rigCaps.model == model7850) - value = getCalibratedValue(rigState->sMeter(), IC7850_STR_CAL); + value = getCalibratedValue(rigState->getChar(SMETER), IC7850_STR_CAL); else - value = getCalibratedValue(rigState->sMeter(), IC7300_STR_CAL); + value = getCalibratedValue(rigState->getChar(SMETER), IC7300_STR_CAL); //qInfo(logRigCtlD()) << "Calibration IN:" << rigState->sMeter << "OUT" << value; resp.append(QString("%1").arg(value)); } + else if (command[1] == "AF") { - resp.append(QString("%1").arg((float)rigState->afGain() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(AFGAIN) / 255.0)); } else if (command[1] == "RF") { - resp.append(QString("%1").arg((float)rigState->rfGain() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(RFGAIN) / 255.0)); } else if (command[1] == "SQL") { - resp.append(QString("%1").arg((float)rigState->squelch() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(SQUELCH) / 255.0)); } else if (command[1] == "COMP") { - resp.append(QString("%1").arg((float)rigState->compLevel() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(COMPLEVEL) / 255.0)); } else if (command[1] == "MICGAIN") { - resp.append(QString("%1").arg((float)rigState->micGain() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(MICGAIN) / 255.0)); } else if (command[1] == "MON") { - resp.append(QString("%1").arg((float)rigState->monitorLevel() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(MONITORLEVEL) / 255.0)); } else if (command[1] == "VOXGAIN") { - resp.append(QString("%1").arg((float)rigState->voxGain() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(VOXGAIN) / 255.0)); } else if (command[1] == "ANTIVOX") { - resp.append(QString("%1").arg((float)rigState->antiVoxGain() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(ANTIVOXGAIN) / 255.0)); } else if (command[1] == "RFPOWER") { - resp.append(QString("%1").arg((float)rigState->txPower() / 255.0)); + resp.append(QString("%1").arg((float)rigState->getChar(TXPOWER) / 255.0)); } else if (command[1] == "PREAMP") { - resp.append(QString("%1").arg(rigState->preamp()*10)); + resp.append(QString("%1").arg(rigState->getChar(PREAMP)*10)); } else if (command[1] == "ATT") { - resp.append(QString("%1").arg(rigState->attenuator())); + resp.append(QString("%1").arg(rigState->getChar(ATTENUATOR))); } else { resp.append(QString("%1").arg(value)); } - + response.append(resp); } else if (command.length() > 2 && (command[0] == "L" || command[0] == "set_level")) @@ -666,47 +691,47 @@ void rigCtlClient::socketReadyRead() setCommand = true; if (command[1] == "AF") { value = command[2].toFloat() * 255; - rigState->afGain(value,AFGAIN); + rigState->set(AFGAIN, value, true); } else if (command[1] == "RF") { value = command[2].toFloat() * 255; - rigState->rfGain(value,RFGAIN); + rigState->set(RFGAIN, value, true); } else if (command[1] == "SQL") { value = command[2].toFloat() * 255; - rigState->squelch(value,SQUELCH); + rigState->set(SQUELCH, value, true); } else if (command[1] == "COMP") { value = command[2].toFloat() * 255; - rigState->compLevel(value,COMPLEVEL); + rigState->set(COMPLEVEL, value, true); } else if (command[1] == "MICGAIN") { value = command[2].toFloat() * 255; - rigState->micGain(value,MICGAIN); + rigState->set(MICGAIN, value, true); } else if (command[1] == "MON") { value = command[2].toFloat() * 255; - rigState->monitorLevel(value,MONITORLEVEL); + rigState->set(MONITORLEVEL, value, true); } else if (command[1] == "VOXGAIN") { value = command[2].toFloat() * 255; - rigState->voxGain(value,VOXGAIN); + rigState->set(VOXGAIN, value, true); } else if (command[1] == "ANTIVOX") { value = command[2].toFloat() * 255; - rigState->antiVoxGain(value,ANTIVOXGAIN); + rigState->set(ANTIVOXGAIN, value, true); } else if (command[1] == "ATT") { - value = command[2].toFloat(); - rigState->attenuator(value,ATTENUATOR); + value = command[2].toInt(); + rigState->set(ATTENUATOR, value, true); } else if (command[1] == "PREAMP") { value = command[2].toFloat() / 10; - rigState->preamp(value, PREAMP); + rigState->set(PREAMP, value, true); } else if (command[1] == "AGC") { value = command[2].toInt();; - rigState->agc(value, AGC); + rigState->set(AGC, value, true); } qInfo(logRigCtlD()) << "Setting:" << command[1] << command[2] << value; @@ -719,134 +744,134 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append(QString("Func Status: ")); } - if (command[1] == "FAGC") { - result=rigState->fagcFunc(); + result=rigState->getBool(FAGCFUNC); } else if (command[1] == "NB") { - result = rigState->nbFunc(); + result = rigState->getBool(NBFUNC); } else if (command[1] == "COMP") { - result=rigState->compFunc(); + result=rigState->getBool(COMPFUNC); } else if (command[1] == "VOX") { - result = rigState->voxFunc(); + result = rigState->getBool(VOXFUNC); } else if (command[1] == "TONE") { - result = rigState->toneFunc(); + result = rigState->getBool(TONEFUNC); } else if (command[1] == "TSQL") { - result = rigState->tsqlFunc(); + result = rigState->getBool(TSQLFUNC); } else if (command[1] == "SBKIN") { - result = rigState->sbkinFunc(); + result = rigState->getBool(SBKINFUNC); } else if (command[1] == "FBKIN") { - result = rigState->fbkinFunc(); + result = rigState->getBool(FBKINFUNC); } else if (command[1] == "ANF") { - result = rigState->anfFunc(); + result = rigState->getBool (ANFFUNC); } else if (command[1] == "NR") { - result = rigState->nrFunc(); + result = rigState->getBool(NRFUNC); } else if (command[1] == "AIP") { - result = rigState->aipFunc(); + result = rigState->getBool(AIPFUNC); } else if (command[1] == "APF") { - result = rigState->apfFunc(); + result = rigState->getBool(APFFUNC); } else if (command[1] == "MON") { - result = rigState->monFunc(); + result = rigState->getBool(MONFUNC); } else if (command[1] == "MN") { - result = rigState->mnFunc(); + result = rigState->getBool(MNFUNC); } else if (command[1] == "RF") { - result = rigState->rfFunc(); + result = rigState->getBool(RFFUNC); } else if (command[1] == "ARO") { - result = rigState->aroFunc(); + result = rigState->getBool(AROFUNC); } else if (command[1] == "MUTE") { - result = rigState->muteFunc(); + result = rigState->getBool(MUTEFUNC); } else if (command[1] == "VSC") { - result = rigState->vscFunc(); + result = rigState->getBool(VSCFUNC); } else if (command[1] == "REV") { - result = rigState->revFunc(); + result = rigState->getBool(REVFUNC); } else if (command[1] == "SQL") { - result = rigState->sqlFunc(); + result = rigState->getBool(SQLFUNC); } else if (command[1] == "ABM") { - result = rigState->abmFunc(); + result = rigState->getBool(ABMFUNC); } else if (command[1] == "BC") { - result = rigState->bcFunc(); + result = rigState->getBool(BCFUNC); } else if (command[1] == "MBC") { - result = rigState->mbcFunc(); + result = rigState->getBool(MBCFUNC); } else if (command[1] == "RIT") { - result = rigState->ritFunc(); + result = rigState->getBool(RITFUNC); } else if (command[1] == "AFC") { - result = rigState->afcFunc(); + result = rigState->getBool(AFCFUNC); } else if (command[1] == "SATMODE") { - result = rigState->satmodeFunc(); + result = rigState->getBool(SATMODEFUNC); } else if (command[1] == "SCOPE") { - result = rigState->scopeFunc(); + result = rigState->getBool(SCOPEFUNC); } else if (command[1] == "RESUME") { - result = rigState->resumeFunc(); + result = rigState->getBool(RESUMEFUNC); } else if (command[1] == "TBURST") { - result = rigState->tburstFunc(); + result = rigState->getBool(TBURSTFUNC); } else if (command[1] == "TUNER") { - result = rigState->tunerFunc(); + result = rigState->getBool(TUNERFUNC); } else if (command[1] == "LOCK") { - result = rigState->lockFunc(); + result = rigState->getBool(LOCKFUNC); } else { qInfo(logRigCtlD()) << "Unimplemented func:" << command[0] << command[1]; } + resp.append(QString("%1").arg(result)); response.append(resp); } @@ -856,127 +881,127 @@ void rigCtlClient::socketReadyRead() if (command[1] == "FAGC") { - rigState->fagcFunc((bool)command[2].toInt(),FAGCFUNC); + rigState->set(FAGCFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "NB") { - rigState->nbFunc((bool)command[2].toInt(),NBFUNC); + rigState->set(NBFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "COMP") { - rigState->compFunc((bool)command[2].toInt(),COMPFUNC); + rigState->set(COMPFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "VOX") { - rigState->voxFunc((bool)command[2].toInt(),VOXFUNC); + rigState->set(VOXFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "TONE") { - rigState->toneFunc((bool)command[2].toInt(),TONEFUNC); + rigState->set(TONEFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "TSQL") { - rigState->tsqlFunc((bool)command[2].toInt(),TSQLFUNC); + rigState->set(TSQLFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "SBKIN") { - rigState->sbkinFunc((bool)command[2].toInt(),SBKINFUNC); + rigState->set(SBKINFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "FBKIN") { - rigState->fbkinFunc((bool)command[2].toInt(),FBKINFUNC); + rigState->set(FBKINFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "ANF") { - rigState->anfFunc((bool)command[2].toInt(),ANFFUNC); + rigState->set(ANFFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "NR") { - rigState->nrFunc((bool)command[2].toInt(),NRFUNC); + rigState->set(NRFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "AIP") { - rigState->aipFunc((bool)command[2].toInt(),AIPFUNC); + rigState->set(AIPFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "APF") { - rigState->apfFunc((bool)command[2].toInt(),APFFUNC); + rigState->set(APFFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "MON") { - rigState->monFunc((bool)command[2].toInt(),MONFUNC); + rigState->set(MONFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "MN") { - rigState->mnFunc((bool)command[2].toInt(),MNFUNC); + rigState->set(MNFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "RF") { - rigState->rfFunc((bool)command[2].toInt(),MONFUNC); + rigState->set(RFFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "ARO") { - rigState->aroFunc((bool)command[2].toInt(),AROFUNC); + rigState->set(AROFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "MUTE") { - rigState->muteFunc((bool)command[2].toInt(),MUTEFUNC); + rigState->set(MUTEFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "VSC") { - rigState->vscFunc((bool)command[2].toInt(),VSCFUNC); + rigState->set(VSCFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "REV") { - rigState->revFunc((bool)command[2].toInt(),REVFUNC); + rigState->set(REVFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "SQL") { - rigState->sqlFunc((bool)command[2].toInt(),SQLFUNC); + rigState->set(SQLFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "ABM") { - rigState->abmFunc((bool)command[2].toInt(),ABMFUNC); + rigState->set(ABMFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "BC") { - rigState->bcFunc((bool)command[2].toInt(),BCFUNC); + rigState->set(BCFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "MBC") { - rigState->mbcFunc((bool)command[2].toInt(),MBCFUNC); + rigState->set(MBCFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "RIT") { - rigState->ritFunc((bool)command[2].toInt(),RITFUNC); + rigState->set(RITFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "AFC") { - rigState->afcFunc((bool)command[2].toInt(),AFCFUNC); + rigState->set(AFCFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "SATMODE") { - rigState->satmodeFunc((bool)command[2].toInt(),SATMODEFUNC); + rigState->set(SATMODEFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "SCOPE") { - rigState->scopeFunc((bool)command[2].toInt(),SCOPEFUNC); + rigState->set(SCOPEFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "RESUME") { - rigState->resumeFunc((bool)command[2].toInt(),RESUMEFUNC); + rigState->set(RESUMEFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "TBURST") { - rigState->tburstFunc((bool)command[2].toInt(),TBURSTFUNC); + rigState->set(TBURSTFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "TUNER") - { - rigState->tunerFunc((bool)command[2].toInt(),TUNERFUNC); + { + rigState->set(TUNERFUNC, (quint8)command[2].toInt(), true); } else if (command[1] == "LOCK") { - rigState->lockFunc((bool)command[2].toInt(),LOCKFUNC); + rigState->set(LOCKFUNC, (quint8)command[2].toInt(), true); } else { qInfo(logRigCtlD()) << "Unimplemented func:" << command[0] << command[1] << command[2]; @@ -984,7 +1009,7 @@ void rigCtlClient::socketReadyRead() qInfo(logRigCtlD()) << "Setting:" << command[1] << command[2]; } - else if (command.length() > 1 && (command[0] == 0x88 || command[0] == "get_powerstat")) + else if (command.length() > 0 && (command[0] == 0x88 || command[0] == "get_powerstat")) { QString resp; diff --git a/rigstate.h b/rigstate.h index 7aef7d6..54267fd 100644 --- a/rigstate.h +++ b/rigstate.h @@ -1,8 +1,12 @@ -#ifndef RIGSTATE_H -#define RIGSTATE_H +#ifndef RIGSTATEH +#define RIGSTATEH #include #include +#include +#include +#include +#include #include "rigcommander.h" @@ -11,254 +15,100 @@ enum stateTypes { NONE, VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLE 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, - RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER }; + NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, + RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER +}; +struct value { + quint64 _value=0; + bool _valid = false; + bool _updated = false; + QDateTime _dateUpdated; +}; class rigstate { public: - void lock() { _mutex.lock(); return; } - void unlock() { _mutex.unlock(); return; } + 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; } - quint64 updated() { return _updated; } - void updated(int update) { _mutex.lock(); _updated |= 1ULL << update; _mutex.unlock(); } + 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(); + } + } + void set(stateTypes s, quint32 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, 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(); + } + } - quint64 vfoAFreq() { return _vfoAFreq; } - void vfoAFreq(quint64 vfoAFreq, int update) { _mutex.lock(); _vfoAFreq = vfoAFreq; _updated |= 1ULL << update; _mutex.unlock(); } - - quint64 vfoBFreq() { return _vfoBFreq; } - void vfoBFreq(quint64 vfoBFreq, int update) { _mutex.lock(); _vfoBFreq = vfoBFreq; _updated |= 1ULL << update; _mutex.unlock(); } - - unsigned char currentVfo() { return _currentVfo; } - void currentVfo(unsigned char currentVfo, int update) { _mutex.lock(); _currentVfo = currentVfo; _updated |= 1ULL << update; _mutex.unlock(); } - - bool ptt() { return _ptt; } - void ptt(bool ptt, int update) { _mutex.lock(); _ptt = ptt; _updated |= 1ULL << update; _mutex.unlock(); } - - unsigned char mode() { return _mode; } - void mode(unsigned char mode, int update) { _mutex.lock(); _mode = mode; _updated |= 1ULL << update; _mutex.unlock(); } - - unsigned char filter() { return _filter; } - void filter(unsigned char filter, int update) { _mutex.lock(); _filter = filter; _updated |= 1ULL << update; _mutex.unlock();} - - duplexMode duplex() { return _duplex; } - void duplex(duplexMode duplex, int update) { _mutex.lock(); _duplex = duplex; _updated |= 1ULL << update; _mutex.unlock();} - - bool datamode() { return _datamode; } - void datamode(bool datamode, int update) { _mutex.lock(); _datamode = datamode; _updated |= 1ULL << update; _mutex.unlock();} - - unsigned char antenna() { return _antenna; } - void antenna(unsigned char antenna, int update) { _mutex.lock(); _antenna = antenna; _updated |= 1ULL << update; _mutex.unlock();} - - bool rxAntenna() { return _rxAntenna; } - void rxAntenna(bool rxAntenna, int update) { _mutex.lock(); _rxAntenna = rxAntenna; _updated |= 1ULL << update; _mutex.unlock(); } - quint16 ctcss() { return _ctcss; } - void ctcss(quint16 ctcss, int update) { _mutex.lock(); _ctcss = ctcss; _updated |= 1ULL << update; _mutex.unlock(); } - quint16 tsql() { return _tsql; } - void tsql(quint16 tsql, int update) { _mutex.lock(); _tsql = tsql; _updated |= 1ULL << update; _mutex.unlock(); } - quint16 dtcs() { return _dtcs; } - void dtcs(quint16 dtcs, int update) { _mutex.lock(); _dtcs = dtcs; _updated |= 1ULL << update; _mutex.unlock(); } - quint16 csql() { return _csql; } - void csql(quint16 csql, int update) { _mutex.lock(); _csql = csql; _updated |= 1ULL << update; _mutex.unlock(); } - - unsigned char preamp() { return _preamp; } - void preamp(unsigned char preamp, int update) { _mutex.lock(); _preamp = preamp; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char agc() { return _agc; } - void agc(unsigned char agc, int update) { _mutex.lock(); _agc = agc; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char attenuator() { return _attenuator; } - void attenuator(unsigned char attenuator, int update) { _mutex.lock(); _attenuator = attenuator; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char modInput() { return _modInput; } - void modInput(unsigned char modInput, int update) { _mutex.lock(); _modInput = modInput; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char afGain() { return _afGain; } - void afGain(unsigned char afGain, int update) { _mutex.lock(); _afGain = afGain; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char rfGain() { return _rfGain; } - void rfGain(unsigned char rfGain, int update) { _mutex.lock(); _rfGain = rfGain; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char squelch() { return _squelch; } - void squelch(unsigned char squelch, int update) { _mutex.lock(); _squelch = squelch; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char txPower() { return _txPower; } - void txPower(unsigned char txPower, int update) { _mutex.lock(); _txPower = txPower; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char micGain() { return _micGain; } - void micGain(unsigned char micGain, int update) { _mutex.lock(); _micGain = micGain; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char compLevel() { return _compLevel; } - void compLevel(unsigned char compLevel, int update) { _mutex.lock(); _compLevel = compLevel; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char monitorLevel() { return _monitorLevel; } - void monitorLevel(unsigned char monitorLevel, int update) { _mutex.lock(); _monitorLevel = monitorLevel; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char voxGain() { return _voxGain; } - void voxGain(unsigned char voxGain, int update) { _mutex.lock(); _voxGain = voxGain; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char antiVoxGain() { return _antiVoxGain; } - void antiVoxGain(unsigned char antiVoxGain, int update) { _mutex.lock(); _antiVoxGain = antiVoxGain; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char nbLevel() { return _nbLevel; } - void nbLevel(unsigned char nbLevel, int update) { _mutex.lock(); _nbLevel = nbLevel; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char nbDepth() { return _nbDepth; } - void nbDepth(unsigned char nbDepth, int update) { _mutex.lock(); _nbDepth = nbDepth; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char nbWidth() { return _nbWidth; } - void nbWidth(unsigned char nbWidth, int update) { _mutex.lock(); _nbWidth = nbWidth; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char nrLevel() { return _nrLevel; } - void nrLevel(unsigned char nrLevel, int update) { _mutex.lock(); _nrLevel = nrLevel; _updated |= 1ULL << update; _mutex.unlock(); } - - unsigned char sMeter() { return _sMeter; } - void sMeter(unsigned char sMeter, int update) { _mutex.lock(); _sMeter = sMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char powerMeter() { return _powerMeter; } - void powerMeter(unsigned char powerMeter, int update) { _mutex.lock(); _powerMeter = powerMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char swrMeter() { return _swrMeter; } - void swrMeter(unsigned char swrMeter, int update) { _mutex.lock(); _swrMeter = swrMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char alcMeter() { return _alcMeter; } - void alcMeter(unsigned char alcMeter, int update) { _mutex.lock(); _alcMeter = alcMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char compMeter() { return _compMeter; } - void compMeter(unsigned char compMeter, int update) { _mutex.lock(); _compMeter = compMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char voltageMeter() { return _voltageMeter; } - void voltageMeter(unsigned char voltageMeter, int update) { _mutex.lock(); _voltageMeter = voltageMeter; _updated |= 1ULL << update; _mutex.unlock(); } - unsigned char currentMeter() { return _currentMeter; } - void currentMeter(unsigned char currentMeter, int update) { _mutex.lock(); _currentMeter = currentMeter; _updated |= 1ULL << update; _mutex.unlock(); } - - /*FAGCFUNC, NBFUNC, COMPFUNC, VOXFUNC, TONEFUNC, TSQLFUNC, SBKINFUNC, FBKINFUNC, ANFFUNC, NRFUNC, AIPFUNC, APFFUNC, MONFUNC, MNFUNC,RFFUNC, - */ - bool fagcFunc() { return _fagcFunc; } - void fagcFunc(bool fagcFunc, int update) { _mutex.lock(); _fagcFunc = fagcFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool nbFunc() { return _nbFunc; } - void nbFunc(bool nbFunc, int update) { _mutex.lock(); _nbFunc = nbFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool compFunc() { return _compFunc; } - void compFunc(bool compFunc, int update) { _mutex.lock(); _compFunc = compFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool voxFunc() { return _voxFunc; } - void voxFunc(bool voxFunc, int update) { _mutex.lock(); _voxFunc = voxFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool toneFunc() { return _toneFunc; } - void toneFunc(bool toneFunc, int update) { _mutex.lock(); _toneFunc = toneFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool tsqlFunc() { return _tsqlFunc; } - void tsqlFunc(bool tsqlFunc, int update) { _mutex.lock(); _tsqlFunc = tsqlFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool sbkinFunc() { return _sbkinFunc; } - void sbkinFunc(bool sbkinFunc, int update) { _mutex.lock(); _sbkinFunc = sbkinFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool fbkinFunc() { return _fbkinFunc; } - void fbkinFunc(bool fbkinFunc, int update) { _mutex.lock(); _fbkinFunc = fbkinFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool anfFunc() { return _anfFunc; } - void anfFunc(bool anfFunc, int update) { _mutex.lock(); _anfFunc = anfFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool nrFunc() { return _nrFunc; } - void nrFunc(bool nrFunc, int update) { _mutex.lock(); _nrFunc = nrFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool aipFunc() { return _aipFunc; } - void aipFunc(bool aipFunc, int update) { _mutex.lock(); _aipFunc = aipFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool apfFunc() { return _apfFunc; } - void apfFunc(bool apfFunc, int update) { _mutex.lock(); _apfFunc = apfFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool monFunc() { return _monFunc; } - void monFunc(bool monFunc, int update) { _mutex.lock(); _monFunc = monFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool mnFunc() { return _mnFunc; } - void mnFunc(bool mnFunc, int update) { _mutex.lock(); _mnFunc = mnFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool rfFunc() { return _rfFunc; } - void rfFunc(bool rfFunc, int update) { _mutex.lock(); _rfFunc = rfFunc; _updated |= 1ULL << update; _mutex.unlock(); } - - /* AROFUNC, MUTEFUNC, VSCFUNC, REVFUNC, SQLFUNC, ABMFUNC, BCFUNC, MBCFUNC, RITFUNC, AFCFUNC, SATMODEFUNC, SCOPEFUNC, - RESUMEFUNC, TBURSTFUNC, TUNERFUNC}; */ - bool aroFunc() { return _aroFunc; } - void aroFunc(bool aroFunc, int update) { _mutex.lock(); _aroFunc = aroFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool muteFunc() { return _muteFunc; } - void muteFunc(bool muteFunc, int update) { _mutex.lock(); _muteFunc = muteFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool vscFunc() { return _vscFunc; } - void vscFunc(bool vscFunc, int update) { _mutex.lock(); _vscFunc = vscFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool revFunc() { return _revFunc; } - void revFunc(bool revFunc, int update) { _mutex.lock(); _revFunc = revFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool sqlFunc() { return _sqlFunc; } - void sqlFunc(bool sqlFunc, int update) { _mutex.lock(); _sqlFunc = sqlFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool abmFunc() { return _abmFunc; } - void abmFunc(bool abmFunc, int update) { _mutex.lock(); _abmFunc = abmFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool bcFunc() { return _bcFunc; } - void bcFunc(bool bcFunc, int update) { _mutex.lock(); _bcFunc = bcFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool mbcFunc() { return _mbcFunc; } - void mbcFunc(bool mbcFunc, int update) { _mutex.lock(); _mbcFunc = mbcFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool ritFunc() { return _ritFunc; } - void ritFunc(bool ritFunc, int update) { _mutex.lock(); _ritFunc = ritFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool afcFunc() { return _afcFunc; } - void afcFunc(bool afcFunc, int update) { _mutex.lock(); _afcFunc = afcFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool satmodeFunc() { return _satmodeFunc; } - void satmodeFunc(bool satmodeFunc, int update) { _mutex.lock(); _satmodeFunc = satmodeFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool scopeFunc() { return _scopeFunc; } - void scopeFunc(bool scopeFunc, int update) { _mutex.lock(); _scopeFunc = scopeFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool resumeFunc() { return _resumeFunc; } - void resumeFunc(bool resumeFunc, int update) { _mutex.lock(); _resumeFunc = resumeFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool tburstFunc() { return _tburstFunc; } - void tburstFunc(bool tburstFunc, int update) { _mutex.lock(); _tburstFunc = tburstFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool tunerFunc() { return _tunerFunc; } - void tunerFunc(bool tunerFunc, int update) { _mutex.lock(); _tunerFunc = tunerFunc; _updated |= 1ULL << update; _mutex.unlock(); } - bool lockFunc() { return _lockFunc; } - void lockFunc(bool lockFunc, int update) { _mutex.lock(); _lockFunc = lockFunc; _updated |= 1ULL << update; _mutex.unlock(); } + bool getBool(stateTypes s) { return map[s]._value != 0; } + quint8 getChar(stateTypes s) { return map[s]._value & 0xff; } + quint16 getInt16(stateTypes s) { return map[s]._value != 0xffff; } + quint32 getInt32(stateTypes s) { return map[s]._value != 0xffffffff; } + quint64 getInt64(stateTypes s) { return map[s]._value; } + duplexMode getDuplex(stateTypes s) { return(duplexMode)map[s]._value; } + QMap map; private: + //std::map > values; QMutex _mutex; - quint64 _updated=0; - quint64 _vfoAFreq=0; - quint64 _vfoBFreq=0; - unsigned char _currentVfo=0; - bool _ptt=0; - unsigned char _mode=0; - unsigned char _filter=0; - duplexMode _duplex; - bool _datamode=0; - unsigned char _antenna=0; - bool _rxAntenna=0; - // Tones - quint16 _ctcss; - quint16 _tsql; - quint16 _dtcs; - quint16 _csql; - // Levels - unsigned char _preamp; - unsigned char _agc; - unsigned char _attenuator; - unsigned char _modInput; - unsigned char _afGain; - unsigned char _rfGain; - unsigned char _squelch; - unsigned char _txPower; - unsigned char _micGain; - unsigned char _compLevel; - unsigned char _monitorLevel; - unsigned char _voxGain; - unsigned char _antiVoxGain; - unsigned char _nrLevel; - unsigned char _nbLevel; - unsigned char _nbDepth; - unsigned char _nbWidth; - // Meters - unsigned char _sMeter; - unsigned char _powerMeter; - unsigned char _swrMeter; - unsigned char _alcMeter; - unsigned char _compMeter; - unsigned char _voltageMeter; - unsigned char _currentMeter; - // Functions - bool _fagcFunc = false; - bool _nbFunc = false; - bool _compFunc = false; - bool _voxFunc = false; - bool _toneFunc = false; - bool _tsqlFunc = false; - bool _sbkinFunc = false; - bool _fbkinFunc = false; - bool _anfFunc = false; - bool _nrFunc = false; - bool _aipFunc = false; - bool _apfFunc = false; - bool _monFunc = false; - bool _mnFunc = false; - bool _rfFunc = false; - bool _aroFunc = false; - bool _muteFunc = false; - bool _vscFunc = false; - bool _revFunc = false; - bool _sqlFunc = false; - bool _abmFunc = false; - bool _bcFunc = false; - bool _mbcFunc = false; - bool _ritFunc = false; - bool _afcFunc = false; - bool _satmodeFunc = false; - bool _scopeFunc = false; - bool _resumeFunc = false; - bool _tburstFunc = false; - bool _tunerFunc = false; - bool _lockFunc = false; - }; #endif \ No newline at end of file From 0d9dfed85eb5ef1d66bca92dceb4873247b21db5 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sat, 4 Dec 2021 18:09:32 +0100 Subject: [PATCH 04/32] WHATSNEW and CHANGELOG updated --- .CHANGELOG.swp | Bin 0 -> 16384 bytes CHANGELOG | 119 +++++++++++++++++++++++++++++++++++++++++++++++++ WHATSNEW | 9 ++++ 3 files changed, 128 insertions(+) create mode 100644 .CHANGELOG.swp diff --git a/.CHANGELOG.swp b/.CHANGELOG.swp new file mode 100644 index 0000000000000000000000000000000000000000..8f40da8932a9852ff3da135fab632a3955073987 GIT binary patch literal 16384 zcmeI3TZ|k>6^1*Igp89w#6>|Qi1HfAYqUFi@%k1Cr1jcsR*5fo);1u8sHeMTrg2Yq z)0dsya2Jsv4+se<0TLd#BmsnifJ7pIfPmlu9=JRZt^x@pkPvwxT#|78PE}X$*cN%o z3rI7{pY={vpE~u|Ij7D!ZFlF-t{qng+w&fu>pbuMAN#D|UbxFUv(xkPRL6c2%E&W* ziXF=lo&J}quH|lLfdNjB4+T|0+j^1+e*fXv$8JsXMVc^*_aILp@ zalyFyuBn~sMK3(_>_tu_OckoBzkg#bz{&Y%J^r?O{8tx^|Dzs%z&&3p zOc_bv-^Zwt}|9^gg=RE=b1bz>G z2Oa@m0(XG-fK4z0N5K(r2pj}Af*ZhN&-c6^gYSXwf=_^tgBY9#N5BerDYzb71Fi;- zUCVReUT_bnKnWr+0Ivdjz;Cbdyx)MIfXBcWz~{mJ;6CtHa65PtxE1UH)8O%|J@1d; zN8pFxQ{VycKJZ@90jI%Bz>7f(Tm`q@ZUbOYH^-d)raN}FhlWa zwN57SmMU}-s?)Dmep2cr@l|)L)T&HX9`)5|pc569YTy@)kIzc8GD;asWZsIO6;9@A zw5j+@EB$1slTxKU8BhG7mZ_y*obUQM=iFKjLv>#3jHw%1_0n9$QBrNr4gEl6<<_{g zaw|*S@2B-JWqw#?aTNF{TIljr9;JCyZcXp;yk?V&i!9QuhM5j!GYjp-Pz};d_o|pZ z$9_?&QWxch&I{Q`SEGWKX}rs~=K3uv82CwF7iw6=Wt7Db6b<=x6qN(n zU{J=PTYO=De!r8ko^M4-Uliy?NDKU`(85Wa2Is5H(i_B)Fcn6HpJm$58z$GIaBG%X zh0ak^6@#h_(^0a$&bF?HIU~fDJi&Ty^&@GryHs6SOjSu4#mcY3C{^96*F&HjYLWSY z9+SA}p6!%Ox^R9N<(iFdsoXCIJYT|zD&%zIxgt)>Z83WnoS5bC%@tJFD;Cl1oSn{K zR%n6um@`ZQF~YJO)BFrH*=IODtF)NNEn*^SdW7Oe>~V}G#fCX}duGS|^Oyvu5)5R4 zt}aI!3$_ycEGm@tiwNDP`CC|qF4fL*Ih|NHLc}z)G%xK_MU}}fZiU<$V3j0VhmCTU z1sF}jSYzK-8`;I{*445leT$vehClMB;p>aL-8fdk)GJ9a}{@NASjyS2P z$JBao^|%`HP;K`M3-e2EnjZwZDEuzADio=W$mhg_{%!>`RavGv4h+zI)0qirK^R>uMC2xJ_HFRC$i+#*MdHIaq~zd^V0akRVOUJdKUu+{XfI z$FXt`ueP1eRx2}4Z(F+xRE0>8wd#POR@P?EDnAT!h@6r8xEQ1rH;&@dY7q^M z`c~q!#DjQ`Pzs&=$CbmSXQ)ZzkV7BmueNQ&O)bt^4YzEbM}#AoPcclZ5VG>wBGWE{x+bZTmW0*uD#mJZ&mI_6Lnr%Dv+HI9e-EG@McZg!6fwN^WOz61kV z%`QSZQ-zs1Z=14>so2EMI)OC?%pI2#L(_g=gqXl-B)QeZtO_F87S}blNUF_^!fiMt z0*o_gJ=P>wc@-1VL^-Qdkyf%<^z7o9>89qIs>xa=dY2^;n~FN%`fQbE{|9j-I>i?9tPmH4J(efs8rhQsm}UPEeHe z@TKNF8w=Z}TjGNd5cNCU7$!*~Z!6_Gu!&Cd_#&Bqy~88!KIhKo{7L3b^hQBT5k-%& zI;1vt(=yknB)3x>Y?@DDX~xrp(F>>7+Ac~C=j~G4f9qcA{|{X5d4Homl=`2GzK3{_=1B(V%gP2|>-o)szA%Gz13G+SNs zGznhO$l0D~QeZUId>�d1vLt7j8_dM0c;*8X|Lm(h@`djlcD0htmBKg*F2 znxWX_y^Pix%u$usf0PX{$PWr$65U-#Xrcbp^HL`6Rsd-!+=sE@LCTs~O)q|Uh z8(24@O7yo(wIl!RQkb{R3?&`zR?C_aokUv&nL3Jd$12xOHH&OS1+5JpG>nl;9-_33 zE92hNwjIRz8vEW35aOR=L3UFZF3h?eEH2b1>n0VmcEa|IMQcC3S<@G`0g8WaYLn)1 z+gdi^s0e&&1Uasd8c9>4_vd_Z8&k9h|Md!u3QP3@#`ncV>UQ^~D;N(}MnQHHOE<~( z13VFdXPd5k(>1BPFQN<08@dLRXVmRgP*#Mdw(8L5ms*jpOcLbW0~l+y)~(m!Dl#lZigYLZ zL>h9mHE7mIg=kva(zr9)NhyJ#wmL!mV*JdgB|CPX^@=MYr1r2XWHgo9>LejmZKW07 zLYIwAS#4QEt`NOj)KmRbIP79`m&S^YJt#(Dx**&YH@QklS~?Ip+zt_o`&;$tNF8Jf zP+kU6v-OPGgi*+HL|KW;V4Q0t!OI*t!QA&k_1Z zJ{7$b)y6@netSK_G-qS`5|mm*CEKBgFcZ1fR!sEc$KLsQHElv0H_eRDLphv;duHgK z+u+Dg>{Enb><~-;RI1DE5}&o_?28B~oLj;P?@TONSPic)Xj4P^Zrj1a8dLbUuLB&p z7d*oo9ufi!YNX>Bk#gkRdt6EBrtB+_ri!$1Yj@f^ztmcn#u!pdofSJ(hZi}qX>&;f z<95yK3o$xOk6s47I&3|R`jPaL2hxx&0($S_TB5(PbG3BS!agP63OVB!tg%{2UEE9? z|Hj$}woTE`O;1qf*#g;IzZ+3rns8?Cba`!}TwOlDS1uiMigg=Gwq&o(Inyt?)LweL zd8_30(51G_9d5j|Nl2i=nuH?7N^^ Date: Sat, 4 Dec 2021 18:19:01 +0100 Subject: [PATCH 05/32] removed another swapfile (some day I'll learn..) and normalized WHATSNEW --- .CHANGELOG.swp | Bin 16384 -> 0 bytes WHATSNEW | 7 ------- 2 files changed, 7 deletions(-) delete mode 100644 .CHANGELOG.swp diff --git a/.CHANGELOG.swp b/.CHANGELOG.swp deleted file mode 100644 index 8f40da8932a9852ff3da135fab632a3955073987..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3TZ|k>6^1*Igp89w#6>|Qi1HfAYqUFi@%k1Cr1jcsR*5fo);1u8sHeMTrg2Yq z)0dsya2Jsv4+se<0TLd#BmsnifJ7pIfPmlu9=JRZt^x@pkPvwxT#|78PE}X$*cN%o z3rI7{pY={vpE~u|Ij7D!ZFlF-t{qng+w&fu>pbuMAN#D|UbxFUv(xkPRL6c2%E&W* ziXF=lo&J}quH|lLfdNjB4+T|0+j^1+e*fXv$8JsXMVc^*_aILp@ zalyFyuBn~sMK3(_>_tu_OckoBzkg#bz{&Y%J^r?O{8tx^|Dzs%z&&3p zOc_bv-^Zwt}|9^gg=RE=b1bz>G z2Oa@m0(XG-fK4z0N5K(r2pj}Af*ZhN&-c6^gYSXwf=_^tgBY9#N5BerDYzb71Fi;- zUCVReUT_bnKnWr+0Ivdjz;Cbdyx)MIfXBcWz~{mJ;6CtHa65PtxE1UH)8O%|J@1d; zN8pFxQ{VycKJZ@90jI%Bz>7f(Tm`q@ZUbOYH^-d)raN}FhlWa zwN57SmMU}-s?)Dmep2cr@l|)L)T&HX9`)5|pc569YTy@)kIzc8GD;asWZsIO6;9@A zw5j+@EB$1slTxKU8BhG7mZ_y*obUQM=iFKjLv>#3jHw%1_0n9$QBrNr4gEl6<<_{g zaw|*S@2B-JWqw#?aTNF{TIljr9;JCyZcXp;yk?V&i!9QuhM5j!GYjp-Pz};d_o|pZ z$9_?&QWxch&I{Q`SEGWKX}rs~=K3uv82CwF7iw6=Wt7Db6b<=x6qN(n zU{J=PTYO=De!r8ko^M4-Uliy?NDKU`(85Wa2Is5H(i_B)Fcn6HpJm$58z$GIaBG%X zh0ak^6@#h_(^0a$&bF?HIU~fDJi&Ty^&@GryHs6SOjSu4#mcY3C{^96*F&HjYLWSY z9+SA}p6!%Ox^R9N<(iFdsoXCIJYT|zD&%zIxgt)>Z83WnoS5bC%@tJFD;Cl1oSn{K zR%n6um@`ZQF~YJO)BFrH*=IODtF)NNEn*^SdW7Oe>~V}G#fCX}duGS|^Oyvu5)5R4 zt}aI!3$_ycEGm@tiwNDP`CC|qF4fL*Ih|NHLc}z)G%xK_MU}}fZiU<$V3j0VhmCTU z1sF}jSYzK-8`;I{*445leT$vehClMB;p>aL-8fdk)GJ9a}{@NASjyS2P z$JBao^|%`HP;K`M3-e2EnjZwZDEuzADio=W$mhg_{%!>`RavGv4h+zI)0qirK^R>uMC2xJ_HFRC$i+#*MdHIaq~zd^V0akRVOUJdKUu+{XfI z$FXt`ueP1eRx2}4Z(F+xRE0>8wd#POR@P?EDnAT!h@6r8xEQ1rH;&@dY7q^M z`c~q!#DjQ`Pzs&=$CbmSXQ)ZzkV7BmueNQ&O)bt^4YzEbM}#AoPcclZ5VG>wBGWE{x+bZTmW0*uD#mJZ&mI_6Lnr%Dv+HI9e-EG@McZg!6fwN^WOz61kV z%`QSZQ-zs1Z=14>so2EMI)OC?%pI2#L(_g=gqXl-B)QeZtO_F87S}blNUF_^!fiMt z0*o_gJ=P>wc@-1VL^-Qdkyf%<^z7o9>89qIs>xa=dY2^;n~FN%`fQbE{|9j-I>i?9tPmH4J(efs8rhQsm}UPEeHe z@TKNF8w=Z}TjGNd5cNCU7$!*~Z!6_Gu!&Cd_#&Bqy~88!KIhKo{7L3b^hQBT5k-%& zI;1vt(=yknB)3x>Y?@DDX~xrp(F>>7+Ac~C=j~G4f9qcA{|{X5d4Homl=`2GzK3{_=1B(V%gP2|>-o)szA%Gz13G+SNs zGznhO$l0D~QeZUId>�d1vLt7j8_dM0c;*8X|Lm(h@`djlcD0htmBKg*F2 znxWX_y^Pix%u$usf0PX{$PWr$65U-#Xrcbp^HL`6Rsd-!+=sE@LCTs~O)q|Uh z8(24@O7yo(wIl!RQkb{R3?&`zR?C_aokUv&nL3Jd$12xOHH&OS1+5JpG>nl;9-_33 zE92hNwjIRz8vEW35aOR=L3UFZF3h?eEH2b1>n0VmcEa|IMQcC3S<@G`0g8WaYLn)1 z+gdi^s0e&&1Uasd8c9>4_vd_Z8&k9h|Md!u3QP3@#`ncV>UQ^~D;N(}MnQHHOE<~( z13VFdXPd5k(>1BPFQN<08@dLRXVmRgP*#Mdw(8L5ms*jpOcLbW0~l+y)~(m!Dl#lZigYLZ zL>h9mHE7mIg=kva(zr9)NhyJ#wmL!mV*JdgB|CPX^@=MYr1r2XWHgo9>LejmZKW07 zLYIwAS#4QEt`NOj)KmRbIP79`m&S^YJt#(Dx**&YH@QklS~?Ip+zt_o`&;$tNF8Jf zP+kU6v-OPGgi*+HL|KW;V4Q0t!OI*t!QA&k_1Z zJ{7$b)y6@netSK_G-qS`5|mm*CEKBgFcZ1fR!sEc$KLsQHElv0H_eRDLphv;duHgK z+u+Dg>{Enb><~-;RI1DE5}&o_?28B~oLj;P?@TONSPic)Xj4P^Zrj1a8dLbUuLB&p z7d*oo9ufi!YNX>Bk#gkRdt6EBrtB+_ri!$1Yj@f^ztmcn#u!pdofSJ(hZi}qX>&;f z<95yK3o$xOk6s47I&3|R`jPaL2hxx&0($S_TB5(PbG3BS!agP63OVB!tg%{2UEE9? z|Hj$}woTE`O;1qf*#g;IzZ+3rns8?Cba`!}TwOlDS1uiMigg=Gwq&o(Inyt?)LweL zd8_30(51G_9d5j|Nl2i=nuH?7N^^ Date: Sat, 4 Dec 2021 19:21:23 +0000 Subject: [PATCH 06/32] Various changes and fixes to rigctld/rigstate --- rigcommander.cpp | 24 +++++++++----- rigctld.cpp | 82 +++++++++++++++++++++++++++--------------------- rigstate.h | 15 ++++++++- wfmain.cpp | 53 ++++++------------------------- wfmain.h | 4 +++ 5 files changed, 90 insertions(+), 88 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index f635688..c2b4e78 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -4222,13 +4222,6 @@ void rigCommander::stateUpdated() { // A remote process has updated the rigState // First we need to find which item(s) have been updated and send the command(s) to the rig. - /* - 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, - RESUMEFUNC, TBURSTFUNC, TUNERFUNC}; - */ - - /* VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL */ QMap::iterator i = state.map.begin(); while (i != state.map.end()) { @@ -4460,7 +4453,22 @@ void rigCommander::stateUpdated() disableSpectOutput(); } } - + break; + case RIGINPUT: + if (i.value()._valid) { + setModInput(state.getInput(RIGINPUT), state.getBool(DATAMODE)); + } + getModInput(state.getBool(DATAMODE)); + break; + case POWERONOFF: + if (i.value()._valid) { + if (state.getBool(POWERONOFF)) { + powerOn(); + } + else { + powerOff(); + } + } } } ++i; diff --git a/rigctld.cpp b/rigctld.cpp index 1ef76ac..0ab4e09 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -55,11 +55,7 @@ rigCtlD::~rigCtlD() qInfo(logRigCtlD()) << "closing rigctld"; } -//void rigCtlD::receiveFrequency(freqt freq) -//{ -// emit setFrequency(0, freq); -// emit setFrequency(0, freq); -//} + void rigCtlD::receiveStateInfo(rigstate* state) { @@ -127,21 +123,29 @@ void rigCtlClient::socketReadyRead() { QByteArray data = socket->readAll(); commandBuffer.append(data); + QStringList commandList(commandBuffer.split('\n')); QString sep = "\n"; static int num = 0; - bool longReply = false; - char responseCode = 0; - QStringList response; - bool setCommand = false; - if (commandBuffer.endsWith('\n')) + + for (QString &commands : commandList) { - //qDebug(logRigCtlD()) << sessionId << "command received" << commandBuffer; - commandBuffer.chop(1); // Remove \n character - if (commandBuffer.endsWith('\r')) + bool longReply = false; + char responseCode = 0; + QStringList response; + bool setCommand = false; + //commands.chop(1); // Remove \n character + if (commands.endsWith('\r')) { - commandBuffer.chop(1); // Remove \n character + commands.chop(1); // Remove \n character } + if (commands.isEmpty()) + { + continue; + } + + qDebug(logRigCtlD()) << sessionId << "command received" << commands; + // We have a full line so process command. if (rigState == Q_NULLPTR) @@ -150,33 +154,33 @@ void rigCtlClient::socketReadyRead() return; } - if (commandBuffer[num] == ";" || commandBuffer[num] == "|" || commandBuffer[num] == ",") + if (commands[num] == ";" || commands[num] == "|" || commands[num] == ",") { - sep = commandBuffer[num].toLatin1(); + sep = commands[num].toLatin1(); num++; } - else if (commandBuffer[num] == "+") + else if (commands[num] == "+") { longReply = true; sep = "\n"; num++; } - else if (commandBuffer[num] == "#") + else if (commands[num] == "#") { - return; + continue; } - else if (commandBuffer[num].toLower() == "q") + else if (commands[num].toLower() == "q") { closeSocket(); return; } - if (commandBuffer[num] == "\\") + if (commands[num] == "\\") { num++; } - QStringList command = commandBuffer.mid(num).split(" "); + QStringList command = commands.mid(num).split(" "); if (command[0] == 0xf0 || command[0] == "chk_vfo") @@ -403,10 +407,10 @@ void rigCtlClient::socketReadyRead() response.append("MEM"); } else if (command[1] == "VFOB" || command[1] == "Sub") { - //emit parent->setVFO(1); + rigState->set(CURRENTVFO, (quint8)1, true); } else { - //emit parent->setVFO(0); + rigState->set(CURRENTVFO, (quint8)0, true); } } else if (command[0] == "s" || command[0] == "get_split_vfo") @@ -450,8 +454,15 @@ void rigCtlClient::socketReadyRead() else if (command[0] == "\xf3" || command[0] == "get_vfo_info") { if (longReply) { - response.append(QString("set_vfo: %1").arg(command[1])); - + if (command[1] == "?") { + if (rigState->getChar(CURRENTVFO) == 0) { + response.append(QString("set_vfo: VFOA")); + } + else + { + response.append(QString("set_vfo: VFOB")); + } + } if (command[1] == "VFOB") { response.append(QString("Freq: %1").arg(rigState->getInt64(VFOBFREQ))); } @@ -1022,17 +1033,17 @@ void rigCtlClient::socketReadyRead() } else if (command.length() > 1 && (command[0] == 0x87 || command[0] == "set_powerstat")) { - setCommand = true; - if (command[1] == "0") - { - emit parent->sendPowerOff(); + setCommand = true; + if (command[1] == "0") + { + rigState->set(POWERONOFF, false, true); } - else { - emit parent->sendPowerOn(); + else { + rigState->set(POWERONOFF, true, true); } } else { - qInfo(logRigCtlD()) << "Unimplemented command" << commandBuffer; + qInfo(logRigCtlD()) << "Unimplemented command" << commands; } if (longReply) { if (command.length() == 2) @@ -1045,6 +1056,7 @@ void rigCtlClient::socketReadyRead() if (setCommand) { + // This was a set command so state has likely been updated. emit parent->stateUpdated(); } @@ -1067,11 +1079,11 @@ void rigCtlClient::socketReadyRead() sendData(QString("\n")); } - commandBuffer.clear(); sep = " "; num = 0; } + commandBuffer.clear(); } void rigCtlClient::socketDisconnected() @@ -1088,7 +1100,7 @@ void rigCtlClient::closeSocket() void rigCtlClient::sendData(QString data) { - //qDebug(logRigCtlD()) << "Sending:" << data; + qDebug(logRigCtlD()) << "Sending:" << data; if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen()) { socket->write(data.toLatin1()); diff --git a/rigstate.h b/rigstate.h index 54267fd..d0ff1e0 100644 --- a/rigstate.h +++ b/rigstate.h @@ -9,13 +9,14 @@ #include #include "rigcommander.h" +#include "rigidentities.h" // Meters at the end as they are ALWAYS updated from the rig! enum stateTypes { NONE, VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL, 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, - NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, + NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, RIGINPUT, POWERONOFF, RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER }; @@ -97,12 +98,24 @@ public: } } + 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(); + } + } + bool getBool(stateTypes s) { return map[s]._value != 0; } quint8 getChar(stateTypes s) { return map[s]._value & 0xff; } quint16 getInt16(stateTypes s) { return map[s]._value != 0xffff; } quint32 getInt32(stateTypes s) { return map[s]._value != 0xffffffff; } quint64 getInt64(stateTypes s) { return map[s]._value; } duplexMode getDuplex(stateTypes s) { return(duplexMode)map[s]._value; } + rigInput getInput(stateTypes s) { return(rigInput)map[s]._value; } QMap map; diff --git a/wfmain.cpp b/wfmain.cpp index 3c0403b..de6ceed 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -413,32 +413,12 @@ void wfmain::makeRig() connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities))); connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady())); + connect(this, SIGNAL(requestRigState()), rig, SLOT(sendState())); + connect(this, SIGNAL(stateUpdated()), rig, SLOT(stateUpdated())); + connect(rig, SIGNAL(stateInfo(rigstate*)), this, SLOT(receiveStateInfo(rigstate*))); if (rigCtl != Q_NULLPTR) { connect(rig, SIGNAL(stateInfo(rigstate*)), rigCtl, SLOT(receiveStateInfo(rigstate*))); - connect(this, SIGNAL(requestRigState()), rig, SLOT(sendState())); - connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); - connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); - connect(rigCtl, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char))); - connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); - connect(rigCtl, SIGNAL(sendPowerOn()), rig, SLOT(powerOn())); - connect(rigCtl, SIGNAL(sendPowerOff()), rig, SLOT(powerOff())); connect(rigCtl, SIGNAL(stateUpdated()), rig, SLOT(stateUpdated())); - - connect(rigCtl, SIGNAL(setAttenuator(unsigned char)), rig, SLOT(setAttenuator(unsigned char))); - connect(rigCtl, SIGNAL(setPreamp(unsigned char)), rig, SLOT(setPreamp(unsigned char))); - connect(rigCtl, SIGNAL(setDuplexMode(duplexMode)), rig, SLOT(setDuplexMode(duplexMode))); - - // Levels: Set: - connect(rigCtl, SIGNAL(setRfGain(unsigned char)), rig, SLOT(setRfGain(unsigned char))); - connect(rigCtl, SIGNAL(setAfGain(unsigned char)), rig, SLOT(setAfGain(unsigned char))); - connect(rigCtl, SIGNAL(setSql(unsigned char)), rig, SLOT(setSquelch(unsigned char))); - connect(rigCtl, SIGNAL(setTxPower(unsigned char)), rig, SLOT(setTxPower(unsigned char))); - connect(rigCtl, SIGNAL(setMicGain(unsigned char)), rig, SLOT(setMicGain(unsigned char))); - connect(rigCtl, SIGNAL(setMonitorLevel(unsigned char)), rig, SLOT(setMonitorLevel(unsigned char))); - connect(rigCtl, SIGNAL(setVoxGain(unsigned char)), rig, SLOT(setVoxGain(unsigned char))); - connect(rigCtl, SIGNAL(setAntiVoxGain(unsigned char)), rig, SLOT(setAntiVoxGain(unsigned char))); - connect(rigCtl, SIGNAL(setSpectrumRefLevel(int)), rig, SLOT(setSpectrumRefLevel(int))); - } } } @@ -5461,29 +5441,8 @@ void wfmain::on_enableRigctldChk_clicked(bool checked) if (rig != Q_NULLPTR) { // We are already connected to a rig. connect(rig, SIGNAL(stateInfo(rigstate*)), rigCtl, SLOT(receiveStateInfo(rigstate*))); - connect(rigCtl, SIGNAL(setFrequency(unsigned char, freqt)), rig, SLOT(setFrequency(unsigned char, freqt))); - connect(rigCtl, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); - connect(rigCtl, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char))); - connect(rigCtl, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool))); - connect(rigCtl, SIGNAL(sendPowerOn()), rig, SLOT(powerOn())); - connect(rigCtl, SIGNAL(sendPowerOff()), rig, SLOT(powerOff())); connect(rigCtl, SIGNAL(stateUpdated()), rig, SLOT(stateUpdated())); - connect(rigCtl, SIGNAL(setAttenuator(unsigned char)), rig, SLOT(setAttenuator(unsigned char))); - connect(rigCtl, SIGNAL(setPreamp(unsigned char)), rig, SLOT(setPreamp(unsigned char))); - connect(rigCtl, SIGNAL(setDuplexMode(duplexMode)), rig, SLOT(setDuplexMode(duplexMode))); - - // Levels: Set: - connect(rigCtl, SIGNAL(setRfGain(unsigned char)), rig, SLOT(setRfGain(unsigned char))); - connect(rigCtl, SIGNAL(setAfGain(unsigned char)), rig, SLOT(setAfGain(unsigned char))); - connect(rigCtl, SIGNAL(setSql(unsigned char)), rig, SLOT(setSquelch(unsigned char))); - connect(rigCtl, SIGNAL(setTxPower(unsigned char)), rig, SLOT(setTxPower(unsigned char))); - connect(rigCtl, SIGNAL(setMicGain(unsigned char)), rig, SLOT(setMicGain(unsigned char))); - connect(rigCtl, SIGNAL(setMonitorLevel(unsigned char)), rig, SLOT(setMonitorLevel(unsigned char))); - connect(rigCtl, SIGNAL(setVoxGain(unsigned char)), rig, SLOT(setVoxGain(unsigned char))); - connect(rigCtl, SIGNAL(setAntiVoxGain(unsigned char)), rig, SLOT(setAntiVoxGain(unsigned char))); - connect(rigCtl, SIGNAL(setSpectrumRefLevel(int)), rig, SLOT(setSpectrumRefLevel(int))); - emit sendRigCaps(rigCaps); emit requestRigState(); } @@ -5512,6 +5471,12 @@ void wfmain::on_useCIVasRigIDChk_clicked(bool checked) prefs.CIVisRadioModel = checked; } +void wfmain::receiveStateInfo(rigstate* state) +{ + qInfo("Setting rig state for wfmain"); + rigState = state; +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index 1b19d7b..3a889a4 100644 --- a/wfmain.h +++ b/wfmain.h @@ -166,6 +166,7 @@ signals: void sendServerConfig(SERVERCONFIG conf); void sendRigCaps(rigCapabilities caps); void requestRigState(); + void stateUpdated(); private slots: void updateSizes(int tabIndex); @@ -501,6 +502,8 @@ private slots: void on_useCIVasRigIDChk_clicked(bool checked); + void receiveStateInfo(rigstate* state); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -843,6 +846,7 @@ private: unsigned int tsWfScrollHz; unsigned int tsKnobHz; + rigstate* rigState = Q_NULLPTR; SERVERCONFIG serverConfig; }; From 55cda83ec242e2ad614fc72188161d47b51e33d2 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Mon, 6 Dec 2021 17:41:11 +0100 Subject: [PATCH 07/32] WHATSNEW updated --- WHATSNEW | 1 + 1 file changed, 1 insertion(+) diff --git a/WHATSNEW b/WHATSNEW index 155770e..30289b7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -19,3 +19,4 @@ The following highlights are in this 1.x-release: and that lowers the latency to maybe less than 50 ms added PBT and IF-shift several bugs fixed + RTS as PTT for several radios like the 706/718/736… From 247817077c69bfb9c80eac8e505802c0307c0c7d Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 7 Dec 2021 12:32:51 +0000 Subject: [PATCH 08/32] Add RIT function and other rigctl fixes --- rigcommander.cpp | 34 ++++++++++++++++++++--- rigctld.cpp | 71 ++++++++++++++++++++++++++++++++---------------- rigstate.h | 10 +++---- 3 files changed, 82 insertions(+), 33 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index c2b4e78..99e63db 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -675,6 +675,8 @@ void rigCommander::setRitValue(int ritValue) bool isNegative = false; payload.setRawData("\x21\x00", 2); + qDebug() << "Sending RIT" << ritValue; + if(ritValue < 0) { isNegative = true; @@ -694,6 +696,7 @@ void rigCommander::setRitValue(int ritValue) payload.append(QByteArray(1,(char)isNegative)); prepDataAndSend(payload); + qDebug() << "Sending RIT" << ritValue; } void rigCommander::setMode(mode_info m) @@ -2347,6 +2350,7 @@ void rigCommander::parseRegister21() break; ritHz = f.Hz*((payloadIn.at(4)=='\x01')?-1:1); emit haveRitFrequency(ritHz); + state.set(RITVALUE, ritHz, false); break; case '\x01': // RIT on/off @@ -2356,6 +2360,7 @@ void rigCommander::parseRegister21() } else { emit haveRitEnabled(false); } + state.set(RITFUNC, (bool)payloadIn.at(02), false); break; case '\x02': // Delta TX setting on/off @@ -2505,13 +2510,13 @@ void rigCommander::parseRegister16() case '\x43': state.set(TSQLFUNC, payloadIn.at(2) != 0, false); break; - case '\44': + case '\x44': state.set(COMPFUNC, payloadIn.at(2) != 0, false); break; - case '\45': + case '\x45': state.set(MONFUNC, payloadIn.at(2) != 0, false); break; - case '\46': + case '\x46': state.set(VOXFUNC, payloadIn.at(2) != 0, false); break; case '\x47': @@ -2529,7 +2534,7 @@ void rigCommander::parseRegister16() state.set(SBKINFUNC, false, false); } break; - case '\48': // Manual Notch + case '\x48': // Manual Notch state.set(MNFUNC, payloadIn.at(2) != 0, false); break; default: @@ -4469,6 +4474,27 @@ void rigCommander::stateUpdated() powerOff(); } } + break; + case RITVALUE: + if (i.value()._valid) { + setRitValue(state.getInt32(RITVALUE)); + } + getRitValue(); + break; + case RITFUNC: + if (i.value()._valid) { + setRitEnable(state.getBool(RITFUNC)); + } + getRitEnabled(); + break; + + case SMETER: + case POWERMETER: + case ALCMETER: + case COMPMETER: + case VOLTAGEMETER: + case CURRENTMETER: + break; } } ++i; diff --git a/rigctld.cpp b/rigctld.cpp index 0ab4e09..b2222cf 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -144,7 +144,7 @@ void rigCtlClient::socketReadyRead() continue; } - qDebug(logRigCtlD()) << sessionId << "command received" << commands; + //qDebug(logRigCtlD()) << sessionId << "command received" << commands; // We have a full line so process command. @@ -198,29 +198,42 @@ void rigCtlClient::socketReadyRead() response.append("1"); // rigctld protocol version response.append(QString("%1").arg(rigCaps.rigctlModel)); response.append("0"); // Print something + bandType lastBand; for (bandType band : rigCaps.bands) { - response.append(generateFreqRange(band)); + if (band != lastBand) + response.append(generateFreqRange(band)); + lastBand = band; } response.append("0 0 0 0 0 0 0"); if (rigCaps.hasTransmit) { for (bandType band : rigCaps.bands) - { - response.append(generateFreqRange(band)); + { + if (band != lastBand) + response.append(generateFreqRange(band)); + lastBand = band; } } response.append("0 0 0 0 0 0 0"); - response.append("0x1ff 1"); - response.append("0x1ff 0"); + response.append(QString("0x%1 1").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 10").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 100").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 1000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 2500").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 5000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 6125").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 8333").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 10000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 12500").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 25000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 100000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 250000").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 1000000").arg(getRadioModes(), 0, 16)); response.append("0 0"); - response.append("0x1e 2400"); - response.append("0x2 500"); - response.append("0x1 8000"); - response.append("0x1 2400"); - response.append("0x20 15000"); - response.append("0x20 8000"); - response.append("0x40 230000"); + response.append(QString("0x%1 1200").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 2400").arg(getRadioModes(), 0, 16)); + response.append(QString("0x%1 3000").arg(getRadioModes(), 0, 16)); response.append("0 0"); response.append("9900"); response.append("9900"); @@ -283,7 +296,7 @@ void rigCtlClient::socketReadyRead() response.append("0x7fffffff"); response.append("0x7fffffff"); */ - response.append("done"); + //response.append("done"); } else if (command[0] == "f" || command[0] == "get_freq") @@ -592,11 +605,13 @@ void rigCtlClient::socketReadyRead() if (longReply) { resp.append("RIT: "); } - resp.append(QString("%1").arg(0)); + resp.append(QString("%1").arg(rigState->getInt32(RITVALUE))); response.append(resp); - } + } else if (command[0] == "J" || command[0] == "set_rit") { + qDebug(logRigCtlD()) << "set_rit:" << command[1]; + rigState->set(RITVALUE, command[1].toInt(),true); setCommand = true; } else if (command[0] == "y" || command[0] == "get_ant") @@ -1074,12 +1089,11 @@ void rigCtlClient::socketReadyRead() if (str != "") sendData(QString("%1%2").arg(str).arg(sep)); } - if (sep != "\n") { sendData(QString("\n")); } - sep = " "; + sep = "\n"; num = 0; } @@ -1100,7 +1114,7 @@ void rigCtlClient::closeSocket() void rigCtlClient::sendData(QString data) { - qDebug(logRigCtlD()) << "Sending:" << data; + //qDebug(logRigCtlD()) << "Sending:" << data; if (socket != Q_NULLPTR && socket->isValid() && socket->isOpen()) { socket->write(data.toLatin1()); @@ -1173,18 +1187,18 @@ QString rigCtlClient::getFilter(unsigned char mode, unsigned char filter) { QString rigCtlClient::getMode(unsigned char mode, bool datamode) { QString ret; - if (datamode) { - ret="PKT"; - } switch (mode) { case 0: + if (datamode) { ret = "PKT"; } ret.append("LSB"); break; case 1: + if (datamode) { ret = "PKT"; } ret.append("USB"); break; case 2: + if (datamode) { ret = "PKT"; } ret.append("AM"); break; case 3: @@ -1194,6 +1208,7 @@ QString rigCtlClient::getMode(unsigned char mode, bool datamode) { ret.append("RTTY"); break; case 5: + if (datamode) { ret = "PKT"; } ret.append("FM"); break; case 6: @@ -1206,12 +1221,15 @@ QString rigCtlClient::getMode(unsigned char mode, bool datamode) { ret.append("RTTYR"); break; case 12: + if (datamode) { ret = "PKT"; } ret.append("USB"); break; case 17: + if (datamode) { ret = "PKT"; } ret.append("LSB"); break; case 22: + if (datamode) { ret = "PKT"; } ret.append("FM"); break; } @@ -1351,7 +1369,7 @@ QString rigCtlClient::generateFreqRange(bandType band) QString ret = ""; if (lowFreq > 0 && highFreq > 0) { - ret = QString("%1 %2 0x%3 %4 %5 0x%6 0x%7").arg(lowFreq).arg(highFreq).arg(getRadioModes(),0,16).arg(-1).arg(-1).arg(0x16000003,0,16).arg(getAntennas(),0,16); + ret = QString("%1.000000 %2.000000 0x%3 %4 %5 0x%6 0x%7").arg(lowFreq).arg(highFreq).arg(getRadioModes(),0,16).arg(-1).arg(-1).arg(0x16000003,0,16).arg(getAntennas(),0,16); } return ret; } @@ -1376,13 +1394,18 @@ quint64 rigCtlClient::getRadioModes() QString curMode = mode.name; if (!strcmp(curMode.toLocal8Bit(), mode_str[i].str)) { + //qDebug(logRigCtlD()) << "Found mode:" << mode.name << mode_str[i].mode; modes |= mode_str[i].mode; } if (rigCaps.hasDataModes) { curMode = "PKT" + mode.name; if (!strcmp(curMode.toLocal8Bit(), mode_str[i].str)) { - modes |= mode_str[i].mode; + if (mode.name == "LSB" || mode.name == "USB" || mode.name == "FM" || mode.name == "AM") + { + // qDebug(logRigCtlD()) << "Found data mode:" << mode.name << mode_str[i].mode; + modes |= mode_str[i].mode; + } } } } diff --git a/rigstate.h b/rigstate.h index d0ff1e0..154088f 100644 --- a/rigstate.h +++ b/rigstate.h @@ -16,7 +16,7 @@ enum stateTypes { NONE, VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLE 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, - NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, RIGINPUT, POWERONOFF, + NBLEVEL, NBDEPTH, NBWIDTH, NRLEVEL, RIGINPUT, POWERONOFF, RITVALUE, RESUMEFUNC, TBURSTFUNC, TUNERFUNC, LOCKFUNC, SMETER, POWERMETER, SWRMETER, ALCMETER, COMPMETER, VOLTAGEMETER, CURRENTMETER }; @@ -47,7 +47,7 @@ public: _mutex.unlock(); } } - void set(stateTypes s, quint32 x, bool u) { + void set(stateTypes s, qint32 x, bool u) { if ((quint64)x != map[s]._value) { _mutex.lock(); map[s]._value = (quint64)x; @@ -110,9 +110,9 @@ public: } bool getBool(stateTypes s) { return map[s]._value != 0; } - quint8 getChar(stateTypes s) { return map[s]._value & 0xff; } - quint16 getInt16(stateTypes s) { return map[s]._value != 0xffff; } - quint32 getInt32(stateTypes s) { return map[s]._value != 0xffffffff; } + 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; } quint64 getInt64(stateTypes s) { return map[s]._value; } duplexMode getDuplex(stateTypes s) { return(duplexMode)map[s]._value; } rigInput getInput(stateTypes s) { return(rigInput)map[s]._value; } From 60118169e1026456abd0633003dbd7d1bde37344 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 7 Dec 2021 14:52:47 +0000 Subject: [PATCH 09/32] Properly handle different rigctld client versions --- rigcommander.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++---- rigcommander.h | 4 ++ rigctld.cpp | 17 +++++++- rigctld.h | 1 + rigstate.h | 2 +- 5 files changed, 121 insertions(+), 12 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 99e63db..da5e894 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -22,6 +22,7 @@ rigCommander::rigCommander() { + state.set(SCOPEFUNC,true,false); } rigCommander::~rigCommander() @@ -675,8 +676,6 @@ void rigCommander::setRitValue(int ritValue) bool isNegative = false; payload.setRawData("\x21\x00", 2); - qDebug() << "Sending RIT" << ritValue; - if(ritValue < 0) { isNegative = true; @@ -696,7 +695,6 @@ void rigCommander::setRitValue(int ritValue) payload.append(QByteArray(1,(char)isNegative)); prepDataAndSend(payload); - qDebug() << "Sending RIT" << ritValue; } void rigCommander::setMode(mode_info m) @@ -1706,6 +1704,20 @@ void rigCommander::setModInputLevel(rigInput input, unsigned char level) } } +void rigCommander::setAfMute(bool gainOn) +{ + QByteArray payload("\x1a\x09"); + payload.append((quint8)gainOn); + prepDataAndSend(payload); +} + +void rigCommander::setDialLock(bool lockOn) +{ + QByteArray payload("\x16\x50"); + payload.append((quint8)lockOn); + prepDataAndSend(payload); +} + void rigCommander::getModInputLevel(rigInput input) { switch(input) @@ -1739,6 +1751,18 @@ void rigCommander::getModInputLevel(rigInput input) } } +void rigCommander::getAfMute() +{ + QByteArray payload("\x1a\x09"); + prepDataAndSend(payload); +} + +void rigCommander::getDialLock() +{ + QByteArray payload("\x16\x50"); + prepDataAndSend(payload); +} + QByteArray rigCommander::getUSBAddr() { QByteArray payload; @@ -2378,6 +2402,8 @@ void rigCommander::parseATU() // [1]: 0x01 // [2]: 0 = off, 0x01 = on, 0x02 = tuning in-progress emit haveATUStatus((unsigned char) payloadIn[2]); + // This is a bool so any non-zero will mean enabled. + state.set(TUNERFUNC, (bool)payloadIn[2], false); } void rigCommander::parsePTT() @@ -2438,6 +2464,8 @@ void rigCommander::parseRegisters1A() case '\x07': // IP+ status break; + case '\x09': + state.set(MUTEFUNC, (quint8)payloadIn[2], false); default: break; } @@ -2537,6 +2565,9 @@ void rigCommander::parseRegister16() case '\x48': // Manual Notch state.set(MNFUNC, payloadIn.at(2) != 0, false); break; + case '\x50': // Dial lock + state.set(LOCKFUNC, payloadIn.at(2) != 0, false); + break; default: break; } @@ -4482,12 +4513,12 @@ void rigCommander::stateUpdated() getRitValue(); break; case RITFUNC: - if (i.value()._valid) { - setRitEnable(state.getBool(RITFUNC)); - } - getRitEnabled(); - break; - + if (i.value()._valid) { + setRitEnable(state.getBool(RITFUNC)); + } + getRitEnabled(); + break; + // All meters can only be updated from the rig end. case SMETER: case POWERMETER: case ALCMETER: @@ -4495,6 +4526,66 @@ void rigCommander::stateUpdated() case VOLTAGEMETER: case CURRENTMETER: break; + case AGC: + break; + case MODINPUT: + break; + case FAGCFUNC: + break; + case AIPFUNC: + break; + case APFFUNC: + break; + case RFFUNC: // Should this set RF output power to 0? + break; + case AROFUNC: + break; + case MUTEFUNC: + if (i.value()._valid) { + setAfMute(state.getBool(MUTEFUNC)); + } + getAfMute(); + break; + case VSCFUNC: + break; + case REVFUNC: + break; + case SQLFUNC: + break; + case ABMFUNC: + break; + case BCFUNC: + break; + case MBCFUNC: + break; + case AFCFUNC: + break; + case SATMODEFUNC: + break; + case NBLEVEL: + break; + case NBDEPTH: + break; + case NBWIDTH: + break; + case NRLEVEL: + break; + case RESUMEFUNC: + break; + case TBURSTFUNC: + break; + case TUNERFUNC: + if (i.value()._valid) { + setATU(state.getBool(TUNERFUNC)); + } + getATUStatus(); + break; + case LOCKFUNC: + if (i.value()._valid) { + setDialLock(state.getBool(LOCKFUNC)); + } + getDialLock(); + break; } } ++i; diff --git a/rigcommander.h b/rigcommander.h index afef8b9..b1248a9 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -184,6 +184,8 @@ public slots: void getACCGain(unsigned char ab); void getModInput(bool dataOn); void getModInputLevel(rigInput input); + void getAfMute(); + void getDialLock(); // Set Levels: void setSquelch(unsigned char level); @@ -204,6 +206,8 @@ public slots: void setAntiVoxGain(unsigned char gain); void setModInput(rigInput input, bool dataOn); void setModInputLevel(rigInput input, unsigned char level); + void setAfMute(bool muteOn); + void setDialLock(bool lockOn); // NB, NR, IP+: void setIPP(bool enabled); diff --git a/rigctld.cpp b/rigctld.cpp index b2222cf..daf779d 100644 --- a/rigctld.cpp +++ b/rigctld.cpp @@ -185,6 +185,7 @@ void rigCtlClient::socketReadyRead() if (command[0] == 0xf0 || command[0] == "chk_vfo") { + chkVfoEecuted = true; QString resp; if (longReply) { resp.append(QString("ChkVFO: ")); @@ -296,7 +297,20 @@ void rigCtlClient::socketReadyRead() response.append("0x7fffffff"); response.append("0x7fffffff"); */ - //response.append("done"); + if (chkVfoEecuted) { + response.append(QString("vfo_ops=0x%1").arg(255, 0, 16)); + response.append(QString("ptt_type=0x%1").arg(rigCaps.hasTransmit, 0, 16)); + response.append(QString("has_set_vfo=0x%1").arg(1, 0, 16)); + response.append(QString("has_get_vfo=0x%1").arg(1, 0, 16)); + response.append(QString("has_set_freq=0x%1").arg(1, 0, 16)); + response.append(QString("has_get_freq=0x%1").arg(1, 0, 16)); + response.append(QString("has_set_conf=0x%1").arg(1, 0, 16)); + response.append(QString("has_get_conf=0x%1").arg(1, 0, 16)); + response.append(QString("has_power2mW=0x%1").arg(1, 0, 16)); + response.append(QString("has_mW2power=0x%1").arg(1, 0, 16)); + response.append(QString("timeout=0x%1").arg(1000, 0, 16)); + response.append("done"); + } } else if (command[0] == "f" || command[0] == "get_freq") @@ -610,7 +624,6 @@ void rigCtlClient::socketReadyRead() } else if (command[0] == "J" || command[0] == "set_rit") { - qDebug(logRigCtlD()) << "set_rit:" << command[1]; rigState->set(RITVALUE, command[1].toInt(),true); setCommand = true; } diff --git a/rigctld.h b/rigctld.h index 1132abf..d86818d 100644 --- a/rigctld.h +++ b/rigctld.h @@ -402,6 +402,7 @@ private: rigCapabilities rigCaps; rigstate* rigState = Q_NULLPTR; rigCtlD* parent; + bool chkVfoEecuted=false; QString getMode(unsigned char mode, bool datamode); unsigned char getMode(QString modeString); QString getFilter(unsigned char mode, unsigned char filter); diff --git a/rigstate.h b/rigstate.h index 154088f..8722f9e 100644 --- a/rigstate.h +++ b/rigstate.h @@ -12,7 +12,7 @@ #include "rigidentities.h" // Meters at the end as they are ALWAYS updated from the rig! -enum stateTypes { NONE, VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL, +enum stateTypes { VFOAFREQ, VFOBFREQ, CURRENTVFO, PTT, MODE, FILTER, DUPLEX, DATAMODE, ANTENNA, RXANTENNA, CTCSS, TSQL, DTCS, CSQL, 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, From 1dc5cc042816b281b733d327ed1f4b692f37d38a Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sat, 11 Dec 2021 10:49:06 +0100 Subject: [PATCH 10/32] added 500 Hz step for VFO --- wfmain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wfmain.cpp b/wfmain.cpp index de6ceed..09cd9c5 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -649,6 +649,7 @@ void wfmain::setupMainUI() ui->tuningStepCombo->addItem("1 Hz", (unsigned int) 1); ui->tuningStepCombo->addItem("10 Hz", (unsigned int) 10); ui->tuningStepCombo->addItem("100 Hz", (unsigned int) 100); + ui->tuningStepCombo->addItem("500 Hz", (unsigned int) 500); ui->tuningStepCombo->addItem("1 kHz", (unsigned int) 1000); ui->tuningStepCombo->addItem("2.5 kHz", (unsigned int) 2500); ui->tuningStepCombo->addItem("5 kHz", (unsigned int) 5000); From 4be3398dfa9abc573f84a8ec793d66dd679fdc8c Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 20 Dec 2021 14:40:41 -0800 Subject: [PATCH 11/32] About box updated to include Patreon site and to indicate path for stylesheet only as applicable. --- aboutbox.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aboutbox.cpp b/aboutbox.cpp index dadd943..ba8de0f 100644 --- a/aboutbox.cpp +++ b/aboutbox.cpp @@ -19,10 +19,16 @@ aboutbox::aboutbox(QWidget *parent) : QString nacode = QString("

Networking, audio, rigctl server, and much more written by Phil Taylor, M0VSE"); QString doctest = QString("

Testing, documentation, bug fixes, and development mentorship from
Roeland Jansen, PA3MET, and Jim Nijkamp, PA8E."); - +#if defined(Q_OS_LINUX) QString ssCredit = QString("

Stylesheet qdarkstyle used under MIT license, stored in /usr/share/wfview/stylesheets/."); +#else + QString ssCredit = QString("

Stylesheet qdarkstyle used under MIT license."); +#endif QString website = QString("

Please visit https://wfview.org/ for the latest information."); + + QString donate = QString("

Join us on Patreon for a behind-the-scenes look at wfview development, nightly builds, and to support the software you love."); + QString docs = QString("

Be sure to check the User Manual and the Forum if you have any questions."); QString support = QString("

For support, please visit the official wfview support forum."); QString gitcodelink = QString("").arg(GITSHORT); @@ -78,7 +84,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); // String it all together: QString aboutText = head + copyright + "\n" + nacode + "\n" + doctest + wfviewcommunityack; - aboutText.append(website + "\n"+ docs + support + contact +"\n"); + aboutText.append(website + "\n" + donate + "\n"+ docs + support + contact +"\n"); aboutText.append("\n" + ssCredit + "\n" + rsCredit + "\n"); #if defined(RTAUDIO) From 0c807f54c2a752f760da65e431c09f06d04a7674 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 14:30:58 -0800 Subject: [PATCH 12/32] Beginning of the new Settings tab. Does not compile as-is yet. --- wfmain.cpp | 19 + wfmain.h | 4 + wfmain.ui | 1588 ++++++++++++++++++++++++++-------------------------- 3 files changed, 819 insertions(+), 792 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 09cd9c5..e7238db 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -213,6 +213,25 @@ void wfmain::openRig() } +void wfmain::createSettingsListItems() +{ + // Add items to the settings tab list widget + ui->settingsList->addItem("Radio Access"); // 0 + ui->settingsList->addItem("User Interface"); // 1 + ui->settingsList->addItem("Radio Settings"); // 2 + ui->settingsList->addItem("Radio Server"); // 3 + ui->settingsList->addItem("External Control"); // 4 + ui->settingsList->addItem("Audio Processing"); // 5 + ui->settingsList->addItem("Experimental"); // 6 + ui->settingsList->addItem("About"); // 7 +} + +void wfmain::connectSettingsList() +{ + +} + + void wfmain::rigConnections() { connect(this, SIGNAL(setCIVAddr(unsigned char)), rig, SLOT(setCIVAddr(unsigned char))); diff --git a/wfmain.h b/wfmain.h index 3a889a4..efef3cf 100644 --- a/wfmain.h +++ b/wfmain.h @@ -510,6 +510,10 @@ private: QSettings *settings=Q_NULLPTR; void loadSettings(); void saveSettings(); + + void createSettingsListItems(); + void connectSettingsList(); + QCustomPlot *plot; // line plot QCustomPlot *wf; // waterfall image QCPItemLine * freqIndicatorLine; diff --git a/wfmain.ui b/wfmain.ui index f5b6cbd..f97f01a 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2038,324 +2038,108 @@ Settings - + - - - - - Draw Peaks - - - - - - - When tuning, set lower digits to zero - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - + + + 10 + - 0 + 10 - - - Use System Theme - - - - - - - Waterfall Dark Theme - - - - - - - Anti-Alias Waterfall - - - - - - - Interpolate Waterfall - - - true - - - - - - - Show full screen - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - <html><head/><body><p>Click here to adjust the frequency reference on the IC-9700.</p></body></html> - - - Adjust Reference - - - - - - - Satellite Ops - - - - - - - Modulation Input: - - - - - - - Modulation Input - - - Transmit modulation source - - - QComboBox::AdjustToContents - - - - - - - Data Mod Input: - - - - - - - Data Modulation Input - - - Transmit Data-mode modulation input source - - - QComboBox::AdjustToContents - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - PTT On - - - Ctrl+S - - - - - - - PTT Off - - - - - - - Enable PTT Controls - - - - - - - Secondary Meter Selection: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - <html><head/><body><p>Select this option if the rig is pluged into the computer using a USB cable or a serial connection. </p></body></html> - - - Connect over USB (serial) - - - radioConnectionSerialNetworkGrp - - - - - - - Serial Device: - - - - - - - <html><head/><body><p>Select a serial port here. </p><p>Once selected, check &quot;Enable USB(serial), press &quot;Save Settings&quot;, exit, and re-start wfview. </p></body></html> - - - Serial Device Selector - - - - - - - Baud: - - - - - - - <html><head/><body><p>Baud rate selection menu. </p><p>For the IC-7300 select 115200. </p><p>Older rigs may require other settings. </p><p>Be sure to match what baud rate the rig is set to. Using the highese supported baud rate for the radio is recommended. </p><p>Please press &quot;Save Settings&quot; and re-launc wfview for this to take effect.</p></body></html> - - - baud rate - - - baud rate selection menu - - - - - - - <html><head/><body><p>Press here to set up the built-in rig server. The built-in server is intended to allow access over the network to a serial or USB-connected radio. </p></body></html> - - - Server Setup - - - - - - - <html><head/><body><p>If you are using an older (year 2010) radio, you may need to enable this option to manually specify the CI-V address. This option is also useful for radios that do not have CI-V Transceive enabled and thus will not answer our broadcast query for connected rigs on the CI-V bus.</p><p>If you have a modern radio with CI-V Transceive enabled, you should not need to check this box. </p><p>You will need to Save Settings and re-launch wfview for this to take effect. </p></body></html> - - - Manual Radio CI-V Address: - - - - - - - false - - - - 50 - 0 - - + - 50 + 180 16777215 - - <html><head/><body><p>Enter the address in as hexidecimal, without any prefix, just as the radio presents the address in the menu. </p><p>Here are some common examples:</p> + + + + + + 0 + + + + + + + + + Radio Connection + + + + + + Serial (USB) + + + buttonGroup + + + + + + + Network + + + buttonGroup + + + + + + + + + + CI-V and Model + + + + + + <html><head/><body><p>If you are using an older (year 2010) radio, you may need to enable this option to manually specify the CI-V address. This option is also useful for radios that do not have CI-V Transceive enabled and thus will not answer our broadcast query for connected rigs on the CI-V bus.</p><p>If you have a modern radio with CI-V Transceive enabled, you should not need to check this box. </p><p>You will need to Save Settings and re-launch wfview for this to take effect. </p></body></html> + + + Manual Radio CI-V Address: + + + + + + + <html><head/><body><p>Only check for older radios!</p><p>This checkbox forces wfview to trust that the CI-V address is also the model number of the radio. This is only useful for older radios that do not reply to our Rig ID requests (0x19 0x00). Do not check this box unless you have an older radio. </p></body></html> + + + Use CI-V address as Model ID too + + + + + + + false + + + + 50 + 0 + + + + + 50 + 16777215 + + + + <html><head/><body><p>Enter the address in as hexidecimal, without any prefix, just as the radio presents the address in the menu. </p><p>Here are some common examples:</p> <p>IC-706: 58 <br/>IC-756: 50 <br/>IC-756 Pro: 5C @@ -2367,496 +2151,716 @@ <br/>IC-7300: 94 </p><p>This setting is typically needed for older radios and for radios that do not have CI-V Transceive enabled. </p> <p>After changing, press Save Settings and re-launch wfview.</p></body></html> - - - auto - - - - - - - <html><head/><body><p>Only check for older radios!</p><p>This checkbox forces wfview to trust that the CI-V address is also the model number of the radio. This is only useful for older radios that do not reply to our Rig ID requests (0x19 0x00). Do not check this box unless you have an older radio. </p></body></html> - - - Use as Model too - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - <html><head/><body><p>Connection to the radio is via network. </p><p>This means you are connecting to a radio with native ethernet or wifi, such as the IC-705, IC-7610, IC-7850, IC-R8600, or IC-9700</p><p>You should also select this option if you are connecting to another instance of wfview over a network. </p></body></html> - - - Connect over LAN - - - radioConnectionSerialNetworkGrp - - - - - - - Press here to initiate the network connection to the rig. - - - Connect - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::RightToLeft - - - Enable RigCtld - - - - - - - Port - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Virtual Serial Port - - - - - - - <html><head/><body><p>Use this to define a virtual serial port. </p><p><br/></p><p>On Windows, the virtual serial port can be used to connect to a serial port loopback device, through which other programs can connect to the radio. </p><p><br/></p><p>On Linux and macOS, the port defined here is a pseudo-terminal device, which may be connected to directly by any program designed for a serial connection. </p></body></html> - - - Virtual Serial Port Selector - + + + auto + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + Serial Connected Radios + + + + + + Serial Device: + + + + + + + + 180 + 0 + + + + + 180 + 16777215 + + + + + + + + Baud Rate + + + + + + + + 120 + 16777215 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Network Connected Radios + + + + + + 0 + + + 0 + + + 0 + + + + + Hostname + + + + + + + + 256 + 0 + + + + + 256 + 16777215 + + + + + + + + Control Port + + + + + + + + 75 + 16777215 + + + + 50001 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Username + + + + + + + + 256 + 0 + + + + + 256 + 16777215 + + + + + + + + Password + + + + + + + + 180 + 0 + + + + + 180 + 16777215 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + RX Latency (ms) + + + + + + + + 0 + 0 + + + + 30 + + + 500 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + TX Latency (ms) + + + + + + + 30 + + + 500 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + RX Codec + + + + + + + Receive Audio Codec Selector + + + + + + + TX Codec + + + + + + + Transmit Audio Codec Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Sample Rate + + + + + + + Audio Sample Rate Selector + + + + 48000 + + + + + 24000 + + + + + 16000 + + + + + 8000 + + + + + + + + Audio Output + + + + + + + + 300 + 16777215 + + + + Audio Output Selector + + + + + + + Audio Input + + + + + + + + 300 + 16777215 + + + + Audio Input Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 0 + + + + + Connect + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Draw Peaks + + + + + + + When tuning, set lower digits to zero + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Waterfall Dark Theme + + + + + + + Interpolate Waterfall + + + true + + + + + + + Use System Theme + + + + + + + Anti-Alias Waterfall + + + + + + + Show full screen + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Secondary Meter Selection: + + + + + + + + + + Set up radio polling. The radio's meter is polled every-other interval. + + + Polling + + + + + + Polling + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + - - - - - - Radio IP Address - - - - - - - - - - Radio Control Port - - - - - - - 50001 - - - - - - - - - - - Username - - - - - - - - - - Password - - - - - - - Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhSensitiveData - - - QLineEdit::PasswordEchoOnEdit - - - - - - - - - - - RX Latency (ms) - - - - - - - - 0 - 0 - - - - 30 - - - 500 - - - Qt::Horizontal - - - - - - - 0 - - - - - - - TX Latency (ms) - - - - - - - 30 - - - 500 - - - Qt::Horizontal - - - - - - - 0 - - - - - - - RX Codec - - - - - - - Receive Audio Codec Selector - - - - - - - TX Codec - - - - - - - Transmit Audio Codec Selector - - - - - - - - - - - Sample Rate - - - - - - - Audio Sample Rate Selector - - - - 48000 - - - - - 24000 - - - - - 16000 - - - - - 8000 - - - - - - - - Audio Output - - - - - - - - 300 - 16777215 - - - - Audio Output Selector - - - - - - - Audio Input - - - - - - - - 300 - 16777215 - - - - Audio Input Selector - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - - - <html><head/><body><p>This button runs debug functions, and is provided as a convenience for programmers. The functions executed are under:</p><p><span style=" color:#ffff55;">void</span><span style=" color:#55ff55;">wfmain</span><span style=" color:#aaaaaa;">::</span><span style=" font-weight:600;">on_debugBtn_clicked</span><span style=" color:#aaaaaa;">()</span></p><p>in wfmain.cpp.</p></body></html> - - - Debug - - - Ctrl+Alt+D - - - - - - - Set up radio polling. The radio's meter is polled every-other interval. - - - Polling - - - - - - Polling - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - About - - - - - - - Save Settings - - - - - - - - 75 - true - - - - Exit Program - - - - - - - - - 0 - - - - - Please note: Changing the built-in network server requires pressing "Save Settings", closing wfview, and re-opening. - - - - - - - - - 0 - - - - - <html><head></head><body><p>Please see the <a href="https://wfview.org/wfview-user-manual/settings-tab/">User Manual</a> for more information. </p></body></html> - - - Qt::RichText - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - + + + + 0 + + + 0 + + + 0 + + + + + About + + + + + + + Save Settings + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 50 + false + + + + Exit Program + + + + + @@ -2887,6 +2891,6 @@ - + From 888824f9a4d0991786899dca86fddf1f5d3fc50a Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 16:52:29 -0800 Subject: [PATCH 13/32] Brought back the Save Settings button --- wfmain.ui | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 3 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index f97f01a..1682cf3 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2060,7 +2060,7 @@ - 0 + 3 @@ -2779,6 +2779,53 @@ + + + + 0 + + + 0 + + + + + PTT Off + + + + + + + PTT On + + + Ctrl+S + + + + + + + Enable PTT Controls + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -2794,8 +2841,146 @@ - - + + + + + + + + Satellite Ops + + + + + + + <html><head/><body><p>Click here to adjust the frequency reference on the IC-9700.</p></body></html> + + + Adjust Reference + + + + + + + Data Mod Input: + + + + + + + Data Modulation Input + + + Transmit Data-mode modulation input source + + + QComboBox::AdjustToContents + + + + + + + Modulation Input: + + + + + + + Modulation Input + + + Transmit modulation source + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Set Clock + + + + + + + Use UTC + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 312 + + + + + + + + + + + 350 + 130 + 80 + 25 + + + + <html><head/><body><p>Press here to set up the built-in rig server. The built-in server is intended to allow access over the network to a serial or USB-connected radio. </p></body></html> + + + Server Setup + + + From 700ac53b288fc987f009c9d421192f08ea63d1be Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 19:34:45 -0800 Subject: [PATCH 14/32] Added more pages. --- wfmain.cpp | 5 +- wfmain.ui | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 229 insertions(+), 13 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index e7238db..9deffe5 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -221,9 +221,8 @@ void wfmain::createSettingsListItems() ui->settingsList->addItem("Radio Settings"); // 2 ui->settingsList->addItem("Radio Server"); // 3 ui->settingsList->addItem("External Control"); // 4 - ui->settingsList->addItem("Audio Processing"); // 5 - ui->settingsList->addItem("Experimental"); // 6 - ui->settingsList->addItem("About"); // 7 + ui->settingsList->addItem("Experimental"); // 5 + //ui->settingsList->addItem("Audio Processing"); // 6 } void wfmain::connectSettingsList() diff --git a/wfmain.ui b/wfmain.ui index 1682cf3..702f54f 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2060,7 +2060,7 @@ - 3 + 2 @@ -2920,14 +2920,20 @@ - + + + Press here to set the clock of the radio. The command will be sent to the radio when the seconds go to zero. + Set Clock - + + + Check this box to set the radio's clock to UTC. Otherwise, the clock will be set to the local timezone of this computer. + Use UTC @@ -2964,27 +2970,238 @@ - + + + + + + + <html><head/><body><p>Press here to set up the built-in rig server. The built-in server is intended to allow access over the network to a serial or USB-connected radio. </p></body></html> + + + Server Setup + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 0 + + + + + Audio Sources here + + + + + + + + + Qt::Vertical + + + + 20 + 320 + + + + + + + + + + + + + + Rigctld Server + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::LeftToRight + + + Enable RigCtld + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Port + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Virtual Serial Port + + + + + + + + 180 + 0 + + + + + 180 + 16777215 + + + + <html><head/><body><p>Use this to define a virtual serial port. </p><p><br/></p><p>On Windows, the virtual serial port can be used to connect to a serial port loopback device, through which other programs can connect to the radio. </p><p><br/></p><p>On Linux and macOS, the port defined here is a pseudo-terminal device, which may be connected to directly by any program designed for a serial connection. </p></body></html> + + + Virtual Serial Port Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + - 350 + 70 130 80 25 - <html><head/><body><p>Press here to set up the built-in rig server. The built-in server is intended to allow access over the network to a serial or USB-connected radio. </p></body></html> + <html><head/><body><p>This button runs debug functions, and is provided as a convenience for programmers. The functions executed are under:</p><p><span style=" color:#ffff55;">void</span><span style=" color:#55ff55;">wfmain</span><span style=" color:#aaaaaa;">::</span><span style=" font-weight:600;">on_debugBtn_clicked</span><span style=" color:#aaaaaa;">()</span></p><p>in wfmain.cpp.</p></body></html> - Server Setup + Debug + + + Ctrl+Alt+D - - - From 26f15cc9dbe35b58fca01108b52c355d4a8f0ab4 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 19:45:58 -0800 Subject: [PATCH 15/32] Working preferences with a list. --- wfmain.cpp | 8 +++ wfmain.h | 2 + wfmain.ui | 144 ++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 114 insertions(+), 40 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 9deffe5..77e90f4 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -225,6 +225,12 @@ void wfmain::createSettingsListItems() //ui->settingsList->addItem("Audio Processing"); // 6 } +void wfmain::on_settingsList_currentRowChanged(int currentRow) +{ + ui->settingsStack->setCurrentIndex(currentRow); +} + + void wfmain::connectSettingsList() { @@ -626,6 +632,8 @@ void wfmain::setupPlots() void wfmain::setupMainUI() { + createSettingsListItems(); + ui->bandStkLastUsedBtn->setVisible(false); ui->bandStkVoiceBtn->setVisible(false); ui->bandStkDataBtn->setVisible(false); diff --git a/wfmain.h b/wfmain.h index efef3cf..a22b7dc 100644 --- a/wfmain.h +++ b/wfmain.h @@ -504,6 +504,8 @@ private slots: void receiveStateInfo(rigstate* state); + void on_settingsList_currentRowChanged(int currentRow); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index 702f54f..cea22b3 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2060,7 +2060,7 @@ - 2 + 0 @@ -2349,7 +2349,7 @@ - + 256 @@ -2372,7 +2372,7 @@ - + 180 @@ -2787,23 +2787,6 @@ 0 - - - - PTT Off - - - - - - - PTT On - - - Ctrl+S - - - @@ -2954,6 +2937,50 @@ + + + + 0 + + + + + Manual PTT Toggle + + + + + + + PTT On + + + Ctrl+S + + + + + + + PTT Off + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -2962,7 +2989,7 @@ 20 - 312 + 279 @@ -3181,25 +3208,62 @@ - - - - 70 - 130 - 80 - 25 - - - - <html><head/><body><p>This button runs debug functions, and is provided as a convenience for programmers. The functions executed are under:</p><p><span style=" color:#ffff55;">void</span><span style=" color:#55ff55;">wfmain</span><span style=" color:#aaaaaa;">::</span><span style=" font-weight:600;">on_debugBtn_clicked</span><span style=" color:#aaaaaa;">()</span></p><p>in wfmain.cpp.</p></body></html> - - - Debug - - - Ctrl+Alt+D - - + + + + + + + This page contains experimental features. Use at your own risk. + + + + + + + + + + + <html><head/><body><p>This button runs debug functions, and is provided as a convenience for programmers. The functions executed are under:</p><p><span style=" color:#ffff55;">void</span><span style=" color:#55ff55;">wfmain</span><span style=" color:#aaaaaa;">::</span><span style=" font-weight:600;">on_debugBtn_clicked</span><span style=" color:#aaaaaa;">()</span></p><p>in wfmain.cpp.</p></body></html> + + + Debug + + + Ctrl+Alt+D + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 320 + + + + + From 6b30cb53bc0cac03cb599b9f5fbb9d30a5ca7de8 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 19:52:56 -0800 Subject: [PATCH 16/32] Changed width of list, other minor tweaks. --- wfmain.cpp | 1 + wfmain.ui | 153 +++++++++++++++++++++++++---------------------------- 2 files changed, 73 insertions(+), 81 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 77e90f4..f8e38ed 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -223,6 +223,7 @@ void wfmain::createSettingsListItems() ui->settingsList->addItem("External Control"); // 4 ui->settingsList->addItem("Experimental"); // 5 //ui->settingsList->addItem("Audio Processing"); // 6 + ui->settingsStack->setCurrentIndex(0); } void wfmain::on_settingsList_currentRowChanged(int currentRow) diff --git a/wfmain.ui b/wfmain.ui index cea22b3..3750d72 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2049,9 +2049,15 @@ + + + 150 + 0 + + - 180 + 150 16777215 @@ -2060,7 +2066,7 @@ - 0 + 4 @@ -3061,89 +3067,74 @@ + + 0 + + + 0 + - - - Rigctld Server + + + Qt::LeftToRight + + + Enable RigCtld - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::LeftToRight - - - Enable RigCtld - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - Port - - - - - - - - 75 - 0 - - - - - 75 - 16777215 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Port + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + + + + + Qt::Horizontal + + + + 422 + 20 + + + + From 314d78ad051081c0ced4c843a4574ccf743fab7b Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 20:05:34 -0800 Subject: [PATCH 17/32] Added clock and UTC toggle. --- wfmain.cpp | 16 ++++++++++++++-- wfmain.h | 2 ++ wfmain.ui | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index f8e38ed..744df09 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4566,8 +4566,15 @@ void wfmain::setRadioTimeDatePrep() if(!waitingToSetTimeDate) { // 1: Find the current time and date - QDateTime now = QDateTime::currentDateTime(); - now.setTime(QTime::currentTime()); + QDateTime now; + if(ui->useUTCChk->isChecked()) + { + now = QDateTime::currentDateTimeUtc(); + now.setTime(QTime::currentTime()); + } else { + now = QDateTime::currentDateTime(); + now.setTime(QTime::currentTime()); + } int second = now.time().second(); @@ -5505,6 +5512,11 @@ void wfmain::receiveStateInfo(rigstate* state) rigState = state; } +void wfmain::on_setClockBtn_clicked() +{ + setRadioTimeDatePrep(); +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index a22b7dc..7c1a9f4 100644 --- a/wfmain.h +++ b/wfmain.h @@ -506,6 +506,8 @@ private slots: void on_settingsList_currentRowChanged(int currentRow); + void on_setClockBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index 3750d72..69277c6 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 4 + 2 From 7564239a68c90fc7863758b29c1cc3718dea7d61 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 20:15:39 -0800 Subject: [PATCH 18/32] Slightly wider radio connection box --- wfmain.ui | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wfmain.ui b/wfmain.ui index 69277c6..7cf3ce3 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 2 + 0 @@ -2074,6 +2074,12 @@ + + + 140 + 0 + + Radio Connection From 9a781c671ec8cb9aa8c7b818c3c2367cdd0d38e6 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 20:26:53 -0800 Subject: [PATCH 19/32] Changed the order of the mod source combos --- wfmain.ui | 56 +++++++++++++++++++++++++++--------------------------- wfview.pro | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index 7cf3ce3..e685ed2 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 0 + 2 @@ -2841,19 +2841,22 @@ - + - Satellite Ops + Modulation Input: - - - <html><head/><body><p>Click here to adjust the frequency reference on the IC-9700.</p></body></html> + + + Modulation Input - - Adjust Reference + + Transmit modulation source + + + QComboBox::AdjustToContents @@ -2877,26 +2880,6 @@ - - - - Modulation Input: - - - - - - - Modulation Input - - - Transmit modulation source - - - QComboBox::AdjustToContents - - - @@ -2934,6 +2917,23 @@ + + + + Satellite Ops + + + + + + + <html><head/><body><p>Click here to adjust the frequency reference on the IC-9700.</p></body></html> + + + Adjust Reference + + + diff --git a/wfview.pro b/wfview.pro index 95862aa..199fe33 100644 --- a/wfview.pro +++ b/wfview.pro @@ -49,7 +49,7 @@ DEFINES += PREFIX=\\\"$$PREFIX\\\" # Choose audio system, uses QTMultimedia if both are commented out. # DEFINES += RTAUDIO -# DEFINES += PORTAUDIO +DEFINES += PORTAUDIO contains(DEFINES, RTAUDIO) { # RTAudio defines From 37a2c1caf398d2919e97ea209f8d61a73059cc3c Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 20:45:58 -0800 Subject: [PATCH 20/32] Larger vsp combo box... seems like it resizes though? --- wfmain.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index e685ed2..e35b81d 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 2 + 4 @@ -3156,13 +3156,13 @@ - 180 + 250 0 - 180 + 250 16777215 From c860fa77a161e52fcb04ab0693fd218cfa99a244 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 20:55:48 -0800 Subject: [PATCH 21/32] Change to width of group box --- wfmain.ui | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wfmain.ui b/wfmain.ui index e35b81d..2b598a5 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 4 + 0 @@ -2109,6 +2109,18 @@ + + + 300 + 0 + + + + + 300 + 16777215 + + CI-V and Model From 7977de42d9e4c7c4bb25a770e1bce949701e1f45 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 21:02:35 -0800 Subject: [PATCH 22/32] Changed the enable/disable for some network UI elements. --- wfmain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wfmain.cpp b/wfmain.cpp index 744df09..0a8f270 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4343,6 +4343,13 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) ui->controlPortTxt->setEnabled(checked); ui->usernameTxt->setEnabled(checked); ui->passwordTxt->setEnabled(checked); + ui->audioRXCodecCombo->setEnabled(checked); + ui->audioTXCodecCombo->setEnabled(checked); + ui->audioSampleRateCombo->setEnabled(checked); + ui->rxLatencySlider->setEnabled(checked); + ui->txLatencySlider->setEnabled(checked); + ui->rxLatencyValue->setEnabled(checked); + ui->txLatencyValue->setEnabled(checked); ui->baudRateCombo->setEnabled(!checked); ui->serialDeviceListCombo->setEnabled(!checked); //ui->udpServerSetupBtn->setEnabled(false); From 8e95919aa92b4d66b65ff848969bb096e50d47f5 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 23 Dec 2021 21:04:53 -0800 Subject: [PATCH 23/32] A little more on the enable/disable UI elements. Should be good. --- wfmain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wfmain.cpp b/wfmain.cpp index 0a8f270..ce769d2 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4330,6 +4330,8 @@ void wfmain::on_serialEnableBtn_clicked(bool checked) ui->txLatencySlider->setEnabled(!checked); ui->rxLatencyValue->setEnabled(!checked); ui->txLatencyValue->setEnabled(!checked); + ui->audioOutputCombo->setEnabled(!checked); + ui->audioInputCombo->setEnabled(!checked); ui->baudRateCombo->setEnabled(checked); ui->serialDeviceListCombo->setEnabled(checked); //ui->udpServerSetupBtn->setEnabled(true); @@ -4350,6 +4352,8 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) ui->txLatencySlider->setEnabled(checked); ui->rxLatencyValue->setEnabled(checked); ui->txLatencyValue->setEnabled(checked); + ui->audioOutputCombo->setEnabled(checked); + ui->audioInputCombo->setEnabled(checked); ui->baudRateCombo->setEnabled(!checked); ui->serialDeviceListCombo->setEnabled(!checked); //ui->udpServerSetupBtn->setEnabled(false); From 605a87dec9087b78c5c1420444b0c76ca0cb4d96 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 24 Dec 2021 08:21:50 -0800 Subject: [PATCH 24/32] Masked password input after focus change. --- wfmain.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wfmain.ui b/wfmain.ui index 2b598a5..77ac1c2 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2409,6 +2409,9 @@ 16777215 + + QLineEdit::PasswordEchoOnEdit + From e1cdcad65baaef93b5d80a1492b86d302f21a0ea Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 30 Dec 2021 00:48:39 +0000 Subject: [PATCH 25/32] Integrate server setup into new settings pages --- udpserver.h | 23 ++- udpserversetup.cpp | 127 ---------------- udpserversetup.h | 60 -------- wfmain.cpp | 241 +++++++++++++++++++++++------ wfmain.h | 20 ++- wfmain.ui | 366 +++++++++++++++++++++++++++++++++++++++++---- wfview.pro | 4 +- 7 files changed, 565 insertions(+), 276 deletions(-) delete mode 100644 udpserversetup.cpp delete mode 100644 udpserversetup.h diff --git a/udpserver.h b/udpserver.h index 1bfbacd..4da37de 100644 --- a/udpserver.h +++ b/udpserver.h @@ -19,7 +19,6 @@ #include -#include #include "packettypes.h" #include "rigidentities.h" #include "audiohandler.h" @@ -34,6 +33,28 @@ struct SEQBUFENTRY { quint8 retransmitCount; }; + +struct SERVERUSER { + QString username; + QString password; + quint8 userType; +}; + +struct SERVERCONFIG { + bool enabled; + bool lan; + quint16 controlPort; + quint16 civPort; + quint16 audioPort; + int audioOutput; + int audioInput; + quint8 resampleQuality; + quint32 baudRate; + + QList users; +}; + + class udpServer : public QObject { Q_OBJECT diff --git a/udpserversetup.cpp b/udpserversetup.cpp deleted file mode 100644 index 72b5996..0000000 --- a/udpserversetup.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "udpserversetup.h" -#include "ui_udpserversetup.h" -#include "logcategories.h" - -extern void passcode(QString in,QByteArray& out); - -udpServerSetup::udpServerSetup(QWidget* parent) : - QDialog(parent), - ui(new Ui::udpServerSetup) -{ - ui->setupUi(this); - addUserLine("", "", 0); // Create a blank row if we never receive config. - - // Get any stored config information from the main form. - SERVERCONFIG config; - emit serverConfig(config,false); // Just send blank server config. -} - -udpServerSetup::~udpServerSetup() -{ - delete ui; -} - -// Slot to receive config. -void udpServerSetup::receiveServerConfig(SERVERCONFIG conf) -{ - qInfo() << "Getting server config"; - - ui->enableCheckbox->setChecked(conf.enabled); - ui->controlPortText->setText(QString::number(conf.controlPort)); - ui->civPortText->setText(QString::number(conf.civPort)); - ui->audioPortText->setText(QString::number(conf.audioPort)); - - int row = 0; - - for (int i = 0; i < ui->usersTable->rowCount(); i++) - { - ui->usersTable->removeRow(i); - } - - foreach (SERVERUSER user, conf.users) - { - if (user.username != "" && user.password != "") - { - addUserLine(user.username, user.password, user.userType); - row++; - } - } - - if (row == 0) { - addUserLine("", "", 0); - } - -} - -void udpServerSetup::accept() -{ - qInfo() << "Server config stored"; - SERVERCONFIG config; - config.enabled = ui->enableCheckbox->isChecked(); - config.controlPort = ui->controlPortText->text().toInt(); - config.civPort = ui->civPortText->text().toInt(); - config.audioPort = ui->audioPortText->text().toInt(); - - config.users.clear(); - - for (int row = 0; row < ui->usersTable->model()->rowCount(); row++) - { - if (ui->usersTable->item(row, 0) != NULL) - { - SERVERUSER user; - user.username = ui->usersTable->item(row, 0)->text(); - QLineEdit* password = (QLineEdit*)ui->usersTable->cellWidget(row, 1); - user.password = password->text(); - QComboBox* comboBox = (QComboBox*)ui->usersTable->cellWidget(row, 2); - user.userType = comboBox->currentIndex(); - config.users.append(user); - - } - else { - ui->usersTable->removeRow(row); - } - } - - emit serverConfig(config,true); - this->hide(); -} - - -void udpServerSetup::on_usersTable_cellClicked(int row, int col) -{ - qInfo() << "Clicked on " << row << "," << col; - if (row == ui->usersTable->model()->rowCount() - 1 && ui->usersTable->item(row, 0) != NULL) { - addUserLine("", "", 0); - } -} - -void udpServerSetup::onPasswordChanged() -{ - int row = sender()->property("row").toInt(); - QLineEdit* password = (QLineEdit*)ui->usersTable->cellWidget(row, 1); - QByteArray pass; - passcode(password->text(), pass); - password->setText(pass); - qInfo() << "password row" << row << "changed"; -} - -void udpServerSetup::addUserLine(const QString& user, const QString& pass, const int& type) -{ - ui->usersTable->insertRow(ui->usersTable->rowCount()); - ui->usersTable->setItem(ui->usersTable->rowCount() - 1, 0, new QTableWidgetItem(user)); - ui->usersTable->setItem(ui->usersTable->rowCount() - 1, 1, new QTableWidgetItem()); - ui->usersTable->setItem(ui->usersTable->rowCount() - 1, 2, new QTableWidgetItem()); - - QLineEdit* password = new QLineEdit(); - password->setProperty("row", (int)ui->usersTable->rowCount() - 1); - password->setEchoMode(QLineEdit::PasswordEchoOnEdit); - password->setText(pass); - connect(password, SIGNAL(editingFinished()), this, SLOT(onPasswordChanged())); - ui->usersTable->setCellWidget(ui->usersTable->rowCount() - 1, 1, password); - - QComboBox* comboBox = new QComboBox(); - comboBox->insertItems(0, { "Full User","Full with no TX","Monitor only" }); - comboBox->setCurrentIndex(type); - ui->usersTable->setCellWidget(ui->usersTable->rowCount() - 1, 2, comboBox); - -} diff --git a/udpserversetup.h b/udpserversetup.h deleted file mode 100644 index 54d47c4..0000000 --- a/udpserversetup.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef UDPSERVERSETUP_H -#define UDPSERVERSETUP_H - -#include -#include -#include - -#include - - -struct SERVERUSER { - QString username; - QString password; - quint8 userType; -}; - -struct SERVERCONFIG { - bool enabled; - bool lan; - quint16 controlPort; - quint16 civPort; - quint16 audioPort; - int audioOutput; - int audioInput; - quint8 resampleQuality; - quint32 baudRate; - - QList users; -}; - -namespace Ui { - class udpServerSetup; -} - -class udpServerSetup : public QDialog -{ - Q_OBJECT - -public: - explicit udpServerSetup(QWidget* parent = 0); - ~udpServerSetup(); - -private slots: - void on_usersTable_cellClicked(int row, int col); - void onPasswordChanged(); - -public slots: - void receiveServerConfig(SERVERCONFIG conf); - -signals: - void serverConfig(SERVERCONFIG conf, bool store); - -private: - Ui::udpServerSetup* ui; - void accept(); - QList userTypes; - void addUserLine(const QString &user, const QString &pass, const int &type); -}; - -#endif // UDPSERVER_H diff --git a/wfmain.cpp b/wfmain.cpp index ce769d2..285f1d8 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -27,12 +27,8 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s rpt = new repeaterSetup(); sat = new satelliteSetup(); trxadj = new transceiverAdjustments(); - srv = new udpServerSetup(); abtBox = new aboutbox(); - connect(this, SIGNAL(sendServerConfig(SERVERCONFIG)), srv, SLOT(receiveServerConfig(SERVERCONFIG))); - connect(srv, SIGNAL(serverConfig(SERVERCONFIG, bool)), this, SLOT(serverConfigRequested(SERVERCONFIG, bool))); - qRegisterMetaType(); // Needs to be registered early. qRegisterMetaType(); qRegisterMetaType(); @@ -956,10 +952,11 @@ void wfmain::setServerToPrefs() { // Start server if enabled in config + ui->serverSetupGroup->setEnabled(serverConfig.enabled); if (serverConfig.enabled) { serverConfig.lan = prefs.enableLAN; - udp = new udpServer(serverConfig,rxSetup,txSetup); + udp = new udpServer(serverConfig,serverTxSetup,serverRxSetup); serverThread = new QThread(this); @@ -1061,10 +1058,12 @@ void wfmain::setAudioDevicesUI() if (info.outputChannels > 0) { qInfo(logAudio()) << (info.isDefaultOutput ? "*" : " ") << "(" << i << ") Output Device : " << QString::fromStdString(info.name); ui->audioOutputCombo->addItem(QString::fromStdString(info.name), i); + ui->serverTXAudioOutputCombo->addItem(QString::fromStdString(info.name), i); } if (info.inputChannels > 0) { qInfo(logAudio()) << (info.isDefaultInput ? "*" : " ") << "(" << i << ") Input Device : " << QString::fromStdString(info.name); ui->audioInputCombo->addItem(QString::fromStdString(info.name), i); + ui->serverRXAudioInputCombo->addItem(QString::fromStdString(info.name), i); } } @@ -1095,11 +1094,13 @@ void wfmain::setAudioDevicesUI() if (info->maxInputChannels > 0) { qInfo(logAudio()) << (i == Pa_GetDefaultInputDevice() ? "*" : " ") << "(" << i << ") Output Device : " << info->name; ui->audioInputCombo->addItem(info->name, i); + ui->serverRXAudioInputCombo->addItem(info->name, i); } if (info->maxOutputChannels > 0) { qInfo(logAudio()) << (i == Pa_GetDefaultOutputDevice() ? "*" : " ") << "(" << i << ") Input Device : " << info->name; ui->audioOutputCombo->addItem(info->name, i); - } + ui->serverTXAudioOutputCombo->addItem(info->name, i); +} } #else @@ -1108,15 +1109,19 @@ void wfmain::setAudioDevicesUI() const auto audioOutputs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); for (const QAudioDeviceInfo& deviceInfo : audioOutputs) { ui->audioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); + ui->serverTXAudioOutputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); } const auto audioInputs = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for (const QAudioDeviceInfo& deviceInfo : audioInputs) { ui->audioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); + ui->serverRXAudioInputCombo->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); } // Set these to default audio devices initially. rxSetup.port = QAudioDeviceInfo::defaultOutputDevice(); txSetup.port = QAudioDeviceInfo::defaultInputDevice(); + serverRxSetup.port = QAudioDeviceInfo::defaultOutputDevice(); + serverTxSetup.port = QAudioDeviceInfo::defaultInputDevice(); #endif } @@ -1344,7 +1349,7 @@ void wfmain::loadSettings() prefs.drawPeaks = settings->value("DrawPeaks", defPrefs.drawPeaks).toBool(); prefs.wfAntiAlias = settings->value("WFAntiAlias", defPrefs.wfAntiAlias).toBool(); prefs.wfInterpolate = settings->value("WFInterpolate", defPrefs.wfInterpolate).toBool(); - prefs.wflength = (unsigned int) settings->value("WFLength", defPrefs.wflength).toInt(); + prefs.wflength = (unsigned int)settings->value("WFLength", defPrefs.wflength).toInt(); prefs.stylesheetPath = settings->value("StylesheetPath", defPrefs.stylesheetPath).toString(); ui->splitter->restoreState(settings->value("splitter").toByteArray()); @@ -1392,15 +1397,16 @@ void wfmain::loadSettings() // Radio and Comms: C-IV addr, port to use settings->beginGroup("Radio"); - prefs.radioCIVAddr = (unsigned char) settings->value("RigCIVuInt", defPrefs.radioCIVAddr).toInt(); - if(prefs.radioCIVAddr!=0) + prefs.radioCIVAddr = (unsigned char)settings->value("RigCIVuInt", defPrefs.radioCIVAddr).toInt(); + if (prefs.radioCIVAddr != 0) { ui->rigCIVManualAddrChk->setChecked(true); ui->rigCIVaddrHexLine->blockSignals(true); ui->rigCIVaddrHexLine->setText(QString("%1").arg(prefs.radioCIVAddr, 2, 16)); ui->rigCIVaddrHexLine->setEnabled(true); ui->rigCIVaddrHexLine->blockSignals(false); - } else { + } + else { ui->rigCIVManualAddrChk->setChecked(false); ui->rigCIVaddrHexLine->setEnabled(false); } @@ -1413,9 +1419,9 @@ void wfmain::loadSettings() ui->serialDeviceListCombo->setCurrentIndex(serialIndex); } - prefs.serialPortBaud = (quint32) settings->value("SerialPortBaud", defPrefs.serialPortBaud).toInt(); + prefs.serialPortBaud = (quint32)settings->value("SerialPortBaud", defPrefs.serialPortBaud).toInt(); ui->baudRateCombo->blockSignals(true); - ui->baudRateCombo->setCurrentIndex( ui->baudRateCombo->findData(prefs.serialPortBaud) ); + ui->baudRateCombo->setCurrentIndex(ui->baudRateCombo->findData(prefs.serialPortBaud)); ui->baudRateCombo->blockSignals(false); if (prefs.serialPortBaud > 0) @@ -1431,10 +1437,10 @@ void wfmain::loadSettings() else { ui->vspCombo->addItem(prefs.virtualSerialPort); - ui->vspCombo->setCurrentIndex(ui->vspCombo->count()-1); + ui->vspCombo->setCurrentIndex(ui->vspCombo->count() - 1); } - prefs.localAFgain = (unsigned char) settings->value("localAFgain", defPrefs.localAFgain).toUInt(); + prefs.localAFgain = (unsigned char)settings->value("localAFgain", defPrefs.localAFgain).toUInt(); rxSetup.localAFgain = prefs.localAFgain; settings->endGroup(); @@ -1448,15 +1454,14 @@ void wfmain::loadSettings() settings->beginGroup("LAN"); prefs.enableLAN = settings->value("EnableLAN", defPrefs.enableLAN).toBool(); - if(prefs.enableLAN) + if (prefs.enableLAN) { ui->baudRateCombo->setEnabled(false); ui->serialDeviceListCombo->setEnabled(false); - //ui->udpServerSetupBtn->setEnabled(false); - } else { + } + else { ui->baudRateCombo->setEnabled(true); ui->serialDeviceListCombo->setEnabled(true); - //ui->udpServerSetupBtn->setEnabled(true); } ui->lanEnableBtn->setChecked(prefs.enableLAN); @@ -1472,15 +1477,15 @@ void wfmain::loadSettings() udpPrefs.ipAddress = settings->value("IPAddress", udpDefPrefs.ipAddress).toString(); ui->ipAddressTxt->setEnabled(ui->lanEnableBtn->isChecked()); ui->ipAddressTxt->setText(udpPrefs.ipAddress); - + udpPrefs.controlLANPort = settings->value("ControlLANPort", udpDefPrefs.controlLANPort).toInt(); ui->controlPortTxt->setEnabled(ui->lanEnableBtn->isChecked()); ui->controlPortTxt->setText(QString("%1").arg(udpPrefs.controlLANPort)); - + udpPrefs.username = settings->value("Username", udpDefPrefs.username).toString(); ui->usernameTxt->setEnabled(ui->lanEnableBtn->isChecked()); ui->usernameTxt->setText(QString("%1").arg(udpPrefs.username)); - + udpPrefs.password = settings->value("Password", udpDefPrefs.password).toString(); ui->passwordTxt->setEnabled(ui->lanEnableBtn->isChecked()); ui->passwordTxt->setText(QString("%1").arg(udpPrefs.password)); @@ -1596,6 +1601,72 @@ void wfmain::loadSettings() serverConfig.users.append(user); } + ui->serverEnableCheckbox->setChecked(serverConfig.enabled); + ui->serverControlPortText->setText(QString::number(serverConfig.controlPort)); + ui->serverCivPortText->setText(QString::number(serverConfig.civPort)); + ui->serverAudioPortText->setText(QString::number(serverConfig.audioPort)); + + serverRxSetup.isinput = true; + serverTxSetup.isinput = false; + + ui->serverRXAudioInputCombo->blockSignals(true); + serverRxSetup.name = settings->value("ServerAudioInput", "").toString(); + qInfo(logGui()) << "Got Server Audio Input: " << serverRxSetup.name; + int serverAudioInputIndex = ui->serverRXAudioInputCombo->findText(serverRxSetup.name); + if (serverAudioInputIndex != -1) { + ui->serverRXAudioInputCombo->setCurrentIndex(serverAudioInputIndex); +#if defined(RTAUDIO) + serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(serverAudioInputIndex).toInt(); +#elif defined(PORTAUDIO) + serverRxSetup.port = ui->audioOutputCombo->itemData(serverAudioInputIndex).toInt(); +#else + QVariant v = ui->serverRXAudioInputCombo->currentData(); + serverRxSetup.port = v.value(); +#endif + } + ui->serverRXAudioInputCombo->blockSignals(false); + + serverRxSetup.resampleQuality = settings->value("ResampleQuality", "4").toInt(); + serverRxSetup.resampleQuality = rxSetup.resampleQuality; + + ui->serverTXAudioOutputCombo->blockSignals(true); + serverTxSetup.name = settings->value("ServerAudioOutput", "").toString(); + qInfo(logGui()) << "Got Server Audio Output: " << serverTxSetup.name; + int serverAudioOutputIndex = ui->serverTXAudioOutputCombo->findText(serverTxSetup.name); + if (serverAudioOutputIndex != -1) { + ui->serverTXAudioOutputCombo->setCurrentIndex(serverAudioOutputIndex); +#if defined(RTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(serverAudioOutputIndex).toInt(); +#elif defined(PORTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(serverAudioOutputIndex).toInt(); +#else + QVariant v = ui->serverTXAudioOutputCombo->currentData(); + serverRxSetup.port = v.value(); +#endif + } + ui->serverTXAudioOutputCombo->blockSignals(false); + + serverTxSetup.resampleQuality = settings->value("ResampleQuality", "4").toInt(); + serverTxSetup.resampleQuality = rxSetup.resampleQuality; + + int row = 0; + + ui->serverUsersTable->setRowCount(0); + + foreach(SERVERUSER user, serverConfig.users) + { + if (user.username != "" && user.password != "") + { + serverAddUserLine(user.username, user.password, user.userType); + row++; + } + } + + if (row == 0) { + serverAddUserLine("", "", 0); + } + + settings->endGroup(); // Memory channels @@ -1615,7 +1686,7 @@ void wfmain::loadSettings() // Also annoying that the preference groups are not written in // the order they are specified here. - for(int i=0; i < size; i++) + for (int i = 0; i < size; i++) { settings->setArrayIndex(i); chan = settings->value("chan", 0).toInt(); @@ -1623,7 +1694,7 @@ void wfmain::loadSettings() mode = settings->value("mode", 0).toInt(); isSet = settings->value("isSet", false).toBool(); - if(isSet) + if (isSet) { mem.setPreset(chan, freq, (mode_kind)mode); } @@ -1632,10 +1703,45 @@ void wfmain::loadSettings() settings->endArray(); settings->endGroup(); - emit sendServerConfig(serverConfig); - } +void wfmain::serverAddUserLine(const QString& user, const QString& pass, const int& type) +{ + ui->serverUsersTable->insertRow(ui->serverUsersTable->rowCount()); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 0, new QTableWidgetItem(user)); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 1, new QTableWidgetItem()); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 2, new QTableWidgetItem()); + + QLineEdit* password = new QLineEdit(); + password->setProperty("row", (int)ui->serverUsersTable->rowCount() - 1); + password->setEchoMode(QLineEdit::PasswordEchoOnEdit); + password->setText(pass); + connect(password, SIGNAL(editingFinished()), this, SLOT(onServerPasswordChanged())); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 1, password); + + QComboBox* comboBox = new QComboBox(); + comboBox->insertItems(0, { "Full User","Full with no TX","Monitor only" }); + comboBox->setCurrentIndex(type); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 2, comboBox); +} + +void wfmain::onServerPasswordChanged() +{ + int row = sender()->property("row").toInt(); + QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(row, 1); + QByteArray pass; + passcode(password->text(), pass); + password->setText(pass); + qInfo() << "password row" << row << "changed"; +} + +void wfmain::on_serverUsersTable_cellClicked(int row, int col) +{ + qInfo() << "Clicked on " << row << "," << col; + if (row == ui->serverUsersTable->model()->rowCount() - 1 && ui->serverUsersTable->item(row, 0) != NULL) { + serverAddUserLine("", "", 0); + } +} void wfmain::saveSettings() @@ -1766,11 +1872,37 @@ void wfmain::saveSettings() settings->beginGroup("Server"); + serverConfig.controlPort = ui->serverControlPortText->text().toInt(); + serverConfig.civPort = ui->serverCivPortText->text().toInt(); + serverConfig.audioPort = ui->serverAudioPortText->text().toInt(); + settings->setValue("ServerEnabled", serverConfig.enabled); settings->setValue("ServerControlPort", serverConfig.controlPort); settings->setValue("ServerCivPort", serverConfig.civPort); settings->setValue("ServerAudioPort", serverConfig.audioPort); settings->setValue("ServerNumUsers", serverConfig.users.count()); + settings->setValue("ServerAudioOutput", serverTxSetup.name); + settings->setValue("ServerAudioInput", serverRxSetup.name); + + serverConfig.users.clear(); + + for (int row = 0; row < ui->serverUsersTable->model()->rowCount(); row++) + { + if (ui->serverUsersTable->item(row, 0) != NULL) + { + SERVERUSER user; + user.username = ui->serverUsersTable->item(row, 0)->text(); + QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(row, 1); + user.password = password->text(); + QComboBox* comboBox = (QComboBox*)ui->serverUsersTable->cellWidget(row, 2); + user.userType = comboBox->currentIndex(); + serverConfig.users.append(user); + } + else { + ui->serverUsersTable->removeRow(row); + } + } + for (int f = 0; f < serverConfig.users.count(); f++) { settings->setValue("ServerUsername_" + QString::number(f), serverConfig.users[f].username); @@ -1778,6 +1910,8 @@ void wfmain::saveSettings() settings->setValue("ServerUserType_" + QString::number(f), serverConfig.users[f].userType); } + qInfo() << "Server config stored"; + settings->endGroup(); @@ -4334,7 +4468,6 @@ void wfmain::on_serialEnableBtn_clicked(bool checked) ui->audioInputCombo->setEnabled(!checked); ui->baudRateCombo->setEnabled(checked); ui->serialDeviceListCombo->setEnabled(checked); - //ui->udpServerSetupBtn->setEnabled(true); } void wfmain::on_lanEnableBtn_clicked(bool checked) @@ -4356,7 +4489,6 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) ui->audioInputCombo->setEnabled(checked); ui->baudRateCombo->setEnabled(!checked); ui->serialDeviceListCombo->setEnabled(!checked); - //ui->udpServerSetupBtn->setEnabled(false); if(checked) { showStatusBarText("After filling in values, press Save Settings."); @@ -4411,6 +4543,35 @@ void wfmain::on_audioInputCombo_currentIndexChanged(int value) qDebug(logGui()) << "Changed default audio input to:" << txSetup.name; } + +void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverRXAudioInputCombo->itemData(value); + serverRxSetup.port = v.value(); +#endif + serverRxSetup.name = ui->serverRXAudioInputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; +} + +void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverTXAudioOutputCombo->itemData(value); + serverTxSetup.port = v.value(); +#endif + serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; +} + void wfmain::on_audioSampleRateCombo_currentIndexChanged(QString text) { //udpPrefs.audioRXSampleRate = text.toInt(); @@ -4473,10 +4634,6 @@ void wfmain::on_connectBtn_clicked() } } -void wfmain::on_udpServerSetupBtn_clicked() -{ - srv->show(); -} void wfmain::on_sqlSlider_valueChanged(int value) { issueCmd(cmdSetSql, (unsigned char)value); @@ -4832,22 +4989,6 @@ void wfmain::receiveSpectrumRefLevel(int level) changeSliderQuietly(ui->scopeRefLevelSlider, level); } -// Slot to send/receive server config. -// If store is true then write to config otherwise send current config by signal -void wfmain::serverConfigRequested(SERVERCONFIG conf, bool store) -{ - - if (!store) { - emit sendServerConfig(serverConfig); - } - else { - // Store config in file! - qInfo(logSystem()) << "Storing server config"; - serverConfig = conf; - } - -} - void wfmain::on_modInputCombo_activated(int index) { emit setModInput( (rigInput)ui->modInputCombo->currentData().toInt(), false ); @@ -5528,6 +5669,12 @@ void wfmain::on_setClockBtn_clicked() setRadioTimeDatePrep(); } +void wfmain::on_serverEnableCheckbox_clicked(bool checked) +{ + ui->serverSetupGroup->setEnabled(checked); + serverConfig.enabled = checked; +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index 7c1a9f4..a2bb8d4 100644 --- a/wfmain.h +++ b/wfmain.h @@ -23,7 +23,6 @@ #include "repeatersetup.h" #include "satellitesetup.h" #include "transceiveradjustments.h" -#include "udpserversetup.h" #include "udpserver.h" #include "qledlabel.h" #include "rigctld.h" @@ -163,7 +162,6 @@ signals: void sendCloseComm(); void sendChangeLatency(quint16 latency); void initServer(); - void sendServerConfig(SERVERCONFIG conf); void sendRigCaps(rigCapabilities caps); void requestRigState(); void stateUpdated(); @@ -268,7 +266,6 @@ private slots: void handlePlotScroll(QWheelEvent *); void sendRadioCommandLoop(); void showStatusBarText(QString text); - void serverConfigRequested(SERVERCONFIG conf, bool store); void receiveBaudRate(quint32 baudrate); void setRadioTimeDateSend(); @@ -387,6 +384,10 @@ private slots: void on_audioInputCombo_currentIndexChanged(int value); + void on_serverTXAudioOutputCombo_currentIndexChanged(int value); + + void on_serverRXAudioInputCombo_currentIndexChanged(int value); + void on_toFixedBtn_clicked(); void on_connectBtn_clicked(); @@ -411,7 +412,6 @@ private slots: void on_dataModeBtn_toggled(bool checked); - void on_udpServerSetupBtn_clicked(); void on_transmitBtn_clicked(); @@ -508,6 +508,12 @@ private slots: void on_setClockBtn_clicked(); + void on_serverEnableCheckbox_clicked(bool checked); + + void on_serverUsersTable_cellClicked(int row, int col); + + void onServerPasswordChanged(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -756,6 +762,9 @@ private: audioSetup rxSetup; audioSetup txSetup; + audioSetup serverRxSetup; + audioSetup serverTxSetup; + colors defaultColors; void setDefaultColors(); // populate with default values @@ -824,7 +833,6 @@ private: repeaterSetup *rpt; satelliteSetup *sat; transceiverAdjustments *trxadj; - udpServerSetup *srv; aboutbox *abtBox; @@ -857,6 +865,8 @@ private: rigstate* rigState = Q_NULLPTR; SERVERCONFIG serverConfig; + void serverAddUserLine(const QString& user, const QString& pass, const int& type); + }; Q_DECLARE_METATYPE(struct rigCapabilities) diff --git a/wfmain.ui b/wfmain.ui index 77ac1c2..49b9e2d 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -6,7 +6,7 @@ 0 0 - 948 + 940 554 @@ -2066,7 +2066,7 @@ - 0 + 3 @@ -3025,20 +3025,32 @@ + + QLayout::SetDefaultConstraint + - + - - - <html><head/><body><p>Press here to set up the built-in rig server. The built-in server is intended to allow access over the network to a serial or USB-connected radio. </p></body></html> + + + + 0 + 20 + + + + + 16777215 + 20 + - Server Setup + Enable - + Qt::Horizontal @@ -3053,35 +3065,323 @@ - - - 0 - - - 0 - + - - - Audio Sources here + + + Server Setup + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Contol Port + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 99999 + + + 50001 + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Civ Port + + + + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 99999 + + + 50002 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Audio Port + + + + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 99999 + + + 50003 + + + + + + + + + + + RX Audio Input + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + TX Audio Output + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + 400 + 160 + + + + + 750 + 330 + + + + QFrame::StyledPanel + + + 1 + + + 0 + + + 3 + + + false + + + 100 + + + false + + + true + + + false + + + true + + + false + + + + Username + + + + + Password + + + + + Admin + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - - - - Qt::Vertical - - - - 20 - 320 - - - - @@ -3347,8 +3647,8 @@ 0 0 - 948 - 22 + 940 + 21 diff --git a/wfview.pro b/wfview.pro index 199fe33..f105bb3 100644 --- a/wfview.pro +++ b/wfview.pro @@ -49,7 +49,7 @@ DEFINES += PREFIX=\\\"$$PREFIX\\\" # Choose audio system, uses QTMultimedia if both are commented out. # DEFINES += RTAUDIO -DEFINES += PORTAUDIO +# DEFINES += PORTAUDIO contains(DEFINES, RTAUDIO) { # RTAudio defines @@ -152,7 +152,6 @@ SOURCES += main.cpp\ audiohandler.cpp \ calibrationwindow.cpp \ satellitesetup.cpp \ - udpserversetup.cpp \ udpserver.cpp \ meter.cpp \ qledlabel.cpp \ @@ -174,7 +173,6 @@ HEADERS += wfmain.h \ audiohandler.h \ calibrationwindow.h \ satellitesetup.h \ - udpserversetup.h \ udpserver.h \ packettypes.h \ meter.h \ From c8b4992bab0a676852e1ca485cd5413a46415a9e Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Wed, 29 Dec 2021 17:52:35 -0800 Subject: [PATCH 26/32] Edited some size constraints for better resizing and full-screen mode. --- wfmain.ui | 133 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 60 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index 49b9e2d..1849c09 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -6,8 +6,8 @@ 0 0 - 940 - 554 + 946 + 569 @@ -3103,13 +3103,13 @@ - 0 + 130 25 - 16777215 + 130 25 @@ -3124,19 +3124,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -3166,13 +3153,13 @@ - 0 + 130 25 - 16777215 + 130 25 @@ -3184,19 +3171,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -3220,13 +3194,13 @@ - 0 + 130 25 - 16777215 + 130 25 @@ -3238,6 +3212,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -3250,7 +3237,43 @@ - + + + + 100 + 0 + + + + + 300 + 16777215 + + + + + + + + TX Audio Output + + + + + + + + 100 + 0 + + + + + 300 + 16777215 + + + @@ -3265,31 +3288,8 @@ - - - - TX Audio Output - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -3377,6 +3377,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -3647,8 +3660,8 @@ 0 0 - 940 - 21 + 946 + 22 From d1165980a93ecd1839fc443e7f5bc9389cc0995d Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Wed, 29 Dec 2021 19:49:16 -0800 Subject: [PATCH 27/32] Minor typo with the new audio selection combo box, only on PORTAUDIO builds. --- wfmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 285f1d8..34db21d 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4547,9 +4547,9 @@ void wfmain::on_audioInputCombo_currentIndexChanged(int value) void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) { #if defined(RTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); + serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); #elif defined(PORTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); + serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); #else QVariant v = ui->serverRXAudioInputCombo->itemData(value); serverRxSetup.port = v.value(); From 8dd42ba39224623f2881e760176637ebc1a2fa66 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 30 Dec 2021 01:52:23 -0800 Subject: [PATCH 28/32] Added forced manual RTS setting --- rigcommander.cpp | 21 ++++++++++++++++++++- rigcommander.h | 4 ++++ wfmain.cpp | 17 ++++++++++++++++- wfmain.h | 4 ++++ wfmain.ui | 12 +++++++++++- 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index da5e894..d497c0d 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -217,6 +217,20 @@ void rigCommander::receiveBaudRate(quint32 baudrate) { emit haveBaudRate(baudrate); } +void rigCommander::setRTSforPTT(bool enabled) +{ + if(!usingNativeLAN) + { + useRTSforPTT_isSet = true; + useRTSforPTT_manual = enabled; + if(comm != NULL) + { + rigCaps.useRTSforPTT=enabled; + comm->setUseRTSforPTT(enabled); + } + } +} + void rigCommander::findRigs() { // This function sends data to 0x00 ("broadcast") to look for any connected rig. @@ -3596,8 +3610,13 @@ void rigCommander::determineRigCaps() haveRigCaps = true; if(!usingNativeLAN) + { + if(useRTSforPTT_isSet) + { + rigCaps.useRTSforPTT = useRTSforPTT_manual; + } comm->setUseRTSforPTT(rigCaps.useRTSforPTT); - + } if(lookingForRig) { diff --git a/rigcommander.h b/rigcommander.h index b1248a9..6da1744 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -79,6 +79,7 @@ public slots: void commSetup(unsigned char rigCivAddr, udpPreferences prefs, audioSetup rxSetup, audioSetup txSetup, QString vsp); void closeComm(); void stateUpdated(); + void setRTSforPTT(bool enabled); // Power: void powerOn(); @@ -452,6 +453,9 @@ private: unsigned char civAddr; unsigned char incomingCIVAddr; // place to store the incoming CIV. bool pttAllowed; + bool useRTSforPTT_isSet = false; + bool useRTSforPTT_manual = false; + QString rigSerialPort; quint32 rigBaudRate; diff --git a/wfmain.cpp b/wfmain.cpp index 34db21d..ebb4634 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -423,7 +423,7 @@ void wfmain::makeRig() // Rig comm setup: connect(this, SIGNAL(sendCommSetup(unsigned char, udpPreferences, audioSetup, audioSetup, QString)), rig, SLOT(commSetup(unsigned char, udpPreferences, audioSetup, audioSetup, QString))); connect(this, SIGNAL(sendCommSetup(unsigned char, QString, quint32,QString)), rig, SLOT(commSetup(unsigned char, QString, quint32,QString))); - + connect(this, SIGNAL(setRTSforPTT(bool)), rig, SLOT(setRTSforPTT(bool))); connect(rig, SIGNAL(haveBaudRate(quint32)), this, SLOT(receiveBaudRate(quint32))); @@ -1312,6 +1312,7 @@ void wfmain::setDefPrefs() defPrefs.stylesheetPath = QString("qdarkstyle/style.qss"); defPrefs.radioCIVAddr = 0x00; // previously was 0x94 for 7300. defPrefs.CIVisRadioModel = false; + defPrefs.forceRTSasPTT = false; defPrefs.serialPortRadio = QString("auto"); defPrefs.serialPortBaud = 115200; defPrefs.enablePTT = false; @@ -1411,7 +1412,9 @@ void wfmain::loadSettings() ui->rigCIVaddrHexLine->setEnabled(false); } prefs.CIVisRadioModel = (bool)settings->value("CIVisRadioModel", defPrefs.CIVisRadioModel).toBool(); + prefs.forceRTSasPTT = (bool)settings->value("ForceRTSasPTT", defPrefs.forceRTSasPTT).toBool(); + ui->useRTSforPTTchk->setChecked(prefs.forceRTSasPTT); prefs.serialPortRadio = settings->value("SerialPortRadio", defPrefs.serialPortRadio).toString(); int serialIndex = ui->serialDeviceListCombo->findText(prefs.serialPortRadio); @@ -1772,6 +1775,7 @@ void wfmain::saveSettings() settings->beginGroup("Radio"); settings->setValue("RigCIVuInt", prefs.radioCIVAddr); settings->setValue("CIVisRadioModel", prefs.CIVisRadioModel); + settings->setValue("ForceRTSasPTT", prefs.forceRTSasPTT); settings->setValue("SerialPortRadio", prefs.serialPortRadio); settings->setValue("SerialPortBaud", prefs.serialPortBaud); settings->setValue("VirtualSerialPort", prefs.virtualSerialPort); @@ -3262,6 +3266,10 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) ui->tuneEnableChk->setEnabled(rigCaps.hasATU); ui->tuneNowBtn->setEnabled(rigCaps.hasATU); + ui->useRTSforPTTchk->blockSignals(true); + ui->useRTSforPTTchk->setChecked(rigCaps.useRTSforPTT); + ui->useRTSforPTTchk->blockSignals(false); + ui->connectBtn->setText("Disconnect"); // We must be connected now. prepareWf(ui->wfLengthSlider->value()); if(usingLAN) @@ -5497,6 +5505,7 @@ void wfmain::on_rigCIVaddrHexLine_editingFinished() } } + void wfmain::on_baudRateCombo_activated(int index) { bool ok = false; @@ -5510,6 +5519,12 @@ void wfmain::on_baudRateCombo_activated(int index) (void)index; } +void wfmain::on_useRTSforPTTchk_clicked(bool checked) +{ + emit setRTSforPTT(checked); + prefs.forceRTSasPTT = checked; +} + void wfmain::on_wfLengthSlider_valueChanged(int value) { prefs.wflength = (unsigned int)(value); diff --git a/wfmain.h b/wfmain.h index a2bb8d4..09a8b86 100644 --- a/wfmain.h +++ b/wfmain.h @@ -52,6 +52,7 @@ signals: // Basic to rig: void setCIVAddr(unsigned char newRigCIVAddr); void setRigID(unsigned char rigID); + void setRTSforPTT(bool enabled); // Power void sendPowerOn(); @@ -514,6 +515,8 @@ private slots: void onServerPasswordChanged(); + void on_useRTSforPTTchk_clicked(bool checked); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -736,6 +739,7 @@ private: QString stylesheetPath; unsigned char radioCIVAddr; bool CIVisRadioModel; + bool forceRTSasPTT; QString serialPortRadio; quint32 serialPortBaud; bool enablePTT; diff --git a/wfmain.ui b/wfmain.ui index 1849c09..a938ee3 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2066,7 +2066,7 @@ - 3 + 0 @@ -2250,6 +2250,16 @@ + + + + <html><head/><body><p>This feature is for older radios that respond best to an RTS serial port signal than a PTT command.</p><p><br/>For radios lacking PTT commands, this is automatic and transparent, but for radios which have a PTT command, you can check this box to override and force the PTT to be done using RTS. Do not check this box unless you really need this and have an appropriate adapter with RTS connected to the PTT line of the transceiver. </p></body></html> + + + Send RTS for PTT + + + From 3f06ab60612edc3d98988de7964b81046830fd54 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 30 Dec 2021 11:17:54 +0000 Subject: [PATCH 29/32] Allow dynamic restarting of server --- wfmain.cpp | 86 ++++++++++++++++++++++++++---------------- wfmain.h | 11 +++--- wfview.vcxproj.filters | 12 ------ 3 files changed, 58 insertions(+), 51 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index ebb4634..fd2ebce 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -953,6 +953,14 @@ void wfmain::setServerToPrefs() // Start server if enabled in config ui->serverSetupGroup->setEnabled(serverConfig.enabled); + if (serverThread != Q_NULLPTR) { + serverThread->quit(); + serverThread->wait(); + serverThread = Q_NULLPTR; + udp = Q_NULLPTR; + ui->statusBar->showMessage(QString("Server disabled"), 1000); + } + if (serverConfig.enabled) { serverConfig.lan = prefs.enableLAN; @@ -974,6 +982,7 @@ void wfmain::setServerToPrefs() emit initServer(); connect(this, SIGNAL(sendRigCaps(rigCapabilities)), udp, SLOT(receiveRigCaps(rigCapabilities))); + ui->statusBar->showMessage(QString("Server enabled"), 1000); } } @@ -1876,10 +1885,6 @@ void wfmain::saveSettings() settings->beginGroup("Server"); - serverConfig.controlPort = ui->serverControlPortText->text().toInt(); - serverConfig.civPort = ui->serverCivPortText->text().toInt(); - serverConfig.audioPort = ui->serverAudioPortText->text().toInt(); - settings->setValue("ServerEnabled", serverConfig.enabled); settings->setValue("ServerControlPort", serverConfig.controlPort); settings->setValue("ServerCivPort", serverConfig.civPort); @@ -4551,35 +4556,6 @@ void wfmain::on_audioInputCombo_currentIndexChanged(int value) qDebug(logGui()) << "Changed default audio input to:" << txSetup.name; } - -void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) -{ -#if defined(RTAUDIO) - serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); -#elif defined(PORTAUDIO) - serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); -#else - QVariant v = ui->serverRXAudioInputCombo->itemData(value); - serverRxSetup.port = v.value(); -#endif - serverRxSetup.name = ui->serverRXAudioInputCombo->itemText(value); - qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; -} - -void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) -{ -#if defined(RTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#elif defined(PORTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#else - QVariant v = ui->serverTXAudioOutputCombo->itemData(value); - serverTxSetup.port = v.value(); -#endif - serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); - qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; -} - void wfmain::on_audioSampleRateCombo_currentIndexChanged(QString text) { //udpPrefs.audioRXSampleRate = text.toInt(); @@ -5688,6 +5664,50 @@ void wfmain::on_serverEnableCheckbox_clicked(bool checked) { ui->serverSetupGroup->setEnabled(checked); serverConfig.enabled = checked; + setServerToPrefs(); +} + +void wfmain::on_serverControlPortText_textChanged(QString text) +{ + serverConfig.controlPort = ui->serverControlPortText->text().toInt(); +} + +void wfmain::on_serverCivPortText_textChanged(QString text) +{ + serverConfig.civPort = ui->serverCivPortText->text().toInt(); +} + +void wfmain::on_serverAudioPortText_textChanged(QString text) +{ + serverConfig.audioPort = ui->serverAudioPortText->text().toInt(); +} + +void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverRXAudioInputCombo->itemData(value); + serverRxSetup.port = v.value(); +#endif + serverRxSetup.name = ui->serverRXAudioInputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; +} + +void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverTXAudioOutputCombo->itemData(value); + serverTxSetup.port = v.value(); +#endif + serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; } // --- DEBUG FUNCTION --- diff --git a/wfmain.h b/wfmain.h index 09a8b86..b9bd713 100644 --- a/wfmain.h +++ b/wfmain.h @@ -385,10 +385,6 @@ private slots: void on_audioInputCombo_currentIndexChanged(int value); - void on_serverTXAudioOutputCombo_currentIndexChanged(int value); - - void on_serverRXAudioInputCombo_currentIndexChanged(int value); - void on_toFixedBtn_clicked(); void on_connectBtn_clicked(); @@ -510,9 +506,12 @@ private slots: void on_setClockBtn_clicked(); void on_serverEnableCheckbox_clicked(bool checked); - void on_serverUsersTable_cellClicked(int row, int col); - + void on_serverControlPortText_textChanged(QString text); + void on_serverCivPortText_textChanged(QString text); + void on_serverAudioPortText_textChanged(QString text); + void on_serverTXAudioOutputCombo_currentIndexChanged(int value); + void on_serverRXAudioInputCombo_currentIndexChanged(int value); void onServerPasswordChanged(); void on_useRTSforPTTchk_clicked(bool checked); diff --git a/wfview.vcxproj.filters b/wfview.vcxproj.filters index 051ed7d..bfaabf2 100644 --- a/wfview.vcxproj.filters +++ b/wfview.vcxproj.filters @@ -120,9 +120,6 @@ Source Files - - Source Files - Source Files @@ -203,9 +200,6 @@ Header Files - - Header Files - Header Files @@ -375,7 +369,6 @@ Resource Files - @@ -391,9 +384,4 @@ - - - Generated Files - - \ No newline at end of file From 2c82561ff57f444f21ffb02e5ec7afd58684e853 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 30 Dec 2021 11:24:44 +0000 Subject: [PATCH 30/32] Clear server status when disabled --- udpserver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/udpserver.cpp b/udpserver.cpp index 9f6527c..d7dd5c8 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -96,6 +96,8 @@ udpServer::~udpServer() udpAudio->close(); delete udpAudio; } + emit haveNetworkStatus(QString("")); + } From cf1caf0a0f1caca88468ab3961f6c809844b6a3d Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 30 Dec 2021 18:22:34 +0000 Subject: [PATCH 31/32] Update server users table dynamically --- wfmain.cpp | 164 ++++++++++++++++++++++++++++++----------------------- wfmain.h | 1 + 2 files changed, 95 insertions(+), 70 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index fd2ebce..33779db 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1662,7 +1662,6 @@ void wfmain::loadSettings() serverTxSetup.resampleQuality = rxSetup.resampleQuality; int row = 0; - ui->serverUsersTable->setRowCount(0); foreach(SERVERUSER user, serverConfig.users) @@ -1678,7 +1677,6 @@ void wfmain::loadSettings() serverAddUserLine("", "", 0); } - settings->endGroup(); // Memory channels @@ -1719,6 +1717,8 @@ void wfmain::loadSettings() void wfmain::serverAddUserLine(const QString& user, const QString& pass, const int& type) { + ui->serverUsersTable->blockSignals(true); + ui->serverUsersTable->insertRow(ui->serverUsersTable->rowCount()); ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 0, new QTableWidgetItem(user)); ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 1, new QTableWidgetItem()); @@ -1735,6 +1735,8 @@ void wfmain::serverAddUserLine(const QString& user, const QString& pass, const i comboBox->insertItems(0, { "Full User","Full with no TX","Monitor only" }); comboBox->setCurrentIndex(type); ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 2, comboBox); + ui->serverUsersTable->blockSignals(false); + } void wfmain::onServerPasswordChanged() @@ -1745,6 +1747,23 @@ void wfmain::onServerPasswordChanged() passcode(password->text(), pass); password->setText(pass); qInfo() << "password row" << row << "changed"; + serverConfig.users.clear(); + for (int rows = 0; rows < ui->serverUsersTable->model()->rowCount(); rows++) + { + if (ui->serverUsersTable->item(rows, 0) != NULL) + { + SERVERUSER user; + user.username = ui->serverUsersTable->item(rows, 0)->text(); + QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(rows, 1); + user.password = password->text(); + QComboBox* comboBox = (QComboBox*)ui->serverUsersTable->cellWidget(rows, 2); + user.userType = comboBox->currentIndex(); + serverConfig.users.append(user); + } + else { + ui->serverUsersTable->removeRow(rows); + } + } } void wfmain::on_serverUsersTable_cellClicked(int row, int col) @@ -1756,6 +1775,79 @@ void wfmain::on_serverUsersTable_cellClicked(int row, int col) } +void wfmain::on_serverEnableCheckbox_clicked(bool checked) +{ + ui->serverSetupGroup->setEnabled(checked); + serverConfig.enabled = checked; + setServerToPrefs(); +} + +void wfmain::on_serverControlPortText_textChanged(QString text) +{ + serverConfig.controlPort = ui->serverControlPortText->text().toInt(); +} + +void wfmain::on_serverCivPortText_textChanged(QString text) +{ + serverConfig.civPort = ui->serverCivPortText->text().toInt(); +} + +void wfmain::on_serverAudioPortText_textChanged(QString text) +{ + serverConfig.audioPort = ui->serverAudioPortText->text().toInt(); +} + +void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverRXAudioInputCombo->itemData(value); + serverRxSetup.port = v.value(); +#endif + serverRxSetup.name = ui->serverRXAudioInputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; +} + +void wfmain::on_serverUsersTable_cellChanged(int row, int column) +{ + qInfo() << "Cell Changed:" << row << "," << column; + + serverConfig.users.clear(); + for (int rows = 0; rows < ui->serverUsersTable->model()->rowCount(); rows++) + { + if (ui->serverUsersTable->item(rows, 0) != NULL) + { + SERVERUSER user; + user.username = ui->serverUsersTable->item(rows, 0)->text(); + QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(rows, 1); + user.password = password->text(); + QComboBox* comboBox = (QComboBox*)ui->serverUsersTable->cellWidget(rows, 2); + user.userType = comboBox->currentIndex(); + serverConfig.users.append(user); + } + else { + ui->serverUsersTable->removeRow(rows); + } + } +} + +void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverTXAudioOutputCombo->itemData(value); + serverTxSetup.port = v.value(); +#endif + serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; +} + void wfmain::saveSettings() { qInfo(logSystem()) << "Saving settings to " << settings->fileName(); @@ -1893,24 +1985,6 @@ void wfmain::saveSettings() settings->setValue("ServerAudioOutput", serverTxSetup.name); settings->setValue("ServerAudioInput", serverRxSetup.name); - serverConfig.users.clear(); - - for (int row = 0; row < ui->serverUsersTable->model()->rowCount(); row++) - { - if (ui->serverUsersTable->item(row, 0) != NULL) - { - SERVERUSER user; - user.username = ui->serverUsersTable->item(row, 0)->text(); - QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(row, 1); - user.password = password->text(); - QComboBox* comboBox = (QComboBox*)ui->serverUsersTable->cellWidget(row, 2); - user.userType = comboBox->currentIndex(); - serverConfig.users.append(user); - } - else { - ui->serverUsersTable->removeRow(row); - } - } for (int f = 0; f < serverConfig.users.count(); f++) { @@ -5660,56 +5734,6 @@ void wfmain::on_setClockBtn_clicked() setRadioTimeDatePrep(); } -void wfmain::on_serverEnableCheckbox_clicked(bool checked) -{ - ui->serverSetupGroup->setEnabled(checked); - serverConfig.enabled = checked; - setServerToPrefs(); -} - -void wfmain::on_serverControlPortText_textChanged(QString text) -{ - serverConfig.controlPort = ui->serverControlPortText->text().toInt(); -} - -void wfmain::on_serverCivPortText_textChanged(QString text) -{ - serverConfig.civPort = ui->serverCivPortText->text().toInt(); -} - -void wfmain::on_serverAudioPortText_textChanged(QString text) -{ - serverConfig.audioPort = ui->serverAudioPortText->text().toInt(); -} - -void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) -{ -#if defined(RTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); -#elif defined(PORTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); -#else - QVariant v = ui->serverRXAudioInputCombo->itemData(value); - serverRxSetup.port = v.value(); -#endif - serverRxSetup.name = ui->serverRXAudioInputCombo->itemText(value); - qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; -} - -void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) -{ -#if defined(RTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#elif defined(PORTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#else - QVariant v = ui->serverTXAudioOutputCombo->itemData(value); - serverTxSetup.port = v.value(); -#endif - serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); - qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; -} - // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index b9bd713..498b6fe 100644 --- a/wfmain.h +++ b/wfmain.h @@ -513,6 +513,7 @@ private slots: void on_serverTXAudioOutputCombo_currentIndexChanged(int value); void on_serverRXAudioInputCombo_currentIndexChanged(int value); void onServerPasswordChanged(); + void on_serverUsersTable_cellChanged(int row, int column); void on_useRTSforPTTchk_clicked(bool checked); From daf94543acd337e25d57282b29736ee5c61fbfc0 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 30 Dec 2021 18:27:22 +0000 Subject: [PATCH 32/32] Fix typo for portaudio/rtaudio builds --- wfmain.cpp | 31 ++++++++++++++-------------- wfview.vcxproj.filters | 46 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 33779db..efdec3e 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1800,9 +1800,9 @@ void wfmain::on_serverAudioPortText_textChanged(QString text) void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) { #if defined(RTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); + serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); #elif defined(PORTAUDIO) - serverRxSetup.port = ui->serverRXaudioInputCombo->itemData(value).toInt(); + serverRxSetup.port = ui->serverRXAudioInputCombo->itemData(value).toInt(); #else QVariant v = ui->serverRXAudioInputCombo->itemData(value); serverRxSetup.port = v.value(); @@ -1811,6 +1811,20 @@ void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) qDebug(logGui()) << "Changed default server audio input to:" << serverRxSetup.name; } +void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) +{ +#if defined(RTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#elif defined(PORTAUDIO) + serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); +#else + QVariant v = ui->serverTXAudioOutputCombo->itemData(value); + serverTxSetup.port = v.value(); +#endif + serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); + qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; +} + void wfmain::on_serverUsersTable_cellChanged(int row, int column) { qInfo() << "Cell Changed:" << row << "," << column; @@ -1834,19 +1848,6 @@ void wfmain::on_serverUsersTable_cellChanged(int row, int column) } } -void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) -{ -#if defined(RTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#elif defined(PORTAUDIO) - serverTxSetup.port = ui->serverTXAudioOutputCombo->itemData(value).toInt(); -#else - QVariant v = ui->serverTXAudioOutputCombo->itemData(value); - serverTxSetup.port = v.value(); -#endif - serverTxSetup.name = ui->serverTXAudioOutputCombo->itemText(value); - qDebug(logGui()) << "Changed default server audio output to:" << serverTxSetup.name; -} void wfmain::saveSettings() { diff --git a/wfview.vcxproj.filters b/wfview.vcxproj.filters index bfaabf2..46000f0 100644 --- a/wfview.vcxproj.filters +++ b/wfview.vcxproj.filters @@ -208,12 +208,55 @@ + + + + + + + + + + Generated Files Generated Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -368,7 +411,6 @@ Resource Files - @@ -382,6 +424,6 @@ - + \ No newline at end of file