void CRemoteControl::decode(char *buffer) { QString decodedString(buffer); if (decodedString.startsWith("INIT")) { emit sigInitialize(true); } else if (isRadioCommand(decodedString)) { emit sigRadio(radio); } else if (isBandscopeCommand(decodedString)) { emit sigBandScope(bandscope); } else if (isDecoderCommand(decodedString)) { emit sigDecoder(decoder); } else if (decodedString.startsWith("WT")) { QString params = decodedString.replace("WT",""); if (params == "OFF") { datastream.enabled = false; } else { bool ok = false; datastream.enabled = true; datastream.refreshRate = params.toDouble(&ok) * 1000; //qDebug() << "receive WT on with refresh " << datastream.refreshRate << " ms"; if (!ok) { datastream.enabled = false; } else time.start(); } } else { client->write("UNK"); return; } client->write("ACK"); }
void CMainWindow::slotLoadFile() { // File dialog chooser QString fileName = QFileDialog::getOpenFileName(this, tr("Open Sound"), QDir::homePath(), tr("Sound Files (*.wav *.flac *.au *.voc *.ogg)")); #ifdef WITH_SNDFILE1 if (!fileName.isEmpty()) { // Close sound card reader if (sound) { sound->terminate(); delete sound; } // Create new sound reader from file sound = new CSoundFile(this); sound->Load(fileName); sound->SetDecoder(decoder); sound->setRunning(true); connect(remote,SIGNAL(sigRadio(uint)), sound, SLOT(setChannel(uint))); } #endif slotSwitchSound(true); }
bool CRemoteControl::isRadioCommand(QString decodedString) { bool found = true; if (decodedString.startsWith("PWRON")) { radio.power = true; } else if (decodedString.startsWith("PWROFF")) { radio.power = false; } else if (decodedString.startsWith("RADIO")) { QString antenna= decodedString.replace("RADIO",""); radio.antenna = antenna.toInt(); emit sigRadio(radio); } else if (decodedString.startsWith("AGCON")) { radio.agc = true; } else if (decodedString.startsWith("AGCOFF")) { radio.agc = false; } else if (decodedString.startsWith("VSCON")) { radio.vsc = true; } else if (decodedString.startsWith("VSCOFF")) { radio.vsc = false; } else if (decodedString.startsWith("FILTER")) { QString filter = decodedString.replace("FILTER",""); if (filter == "230000") radio.filter = CCommand::e230k; if (filter == "50000") radio.filter = CCommand::e50k; if (filter == "15000") radio.filter = CCommand::e15k; if (filter == "6000") radio.filter = CCommand::e6k; if (filter == "2800") radio.filter = CCommand::e28k; } else if (decodedString.startsWith("FREQ")) { QString frequency = decodedString.replace("FREQ",""); radio.frequency = frequency.toUInt(); } else if (decodedString.startsWith("IF")) { QString shift = decodedString.replace("IF",""); radio.ifshift = shift.toUInt(); } else if (decodedString.startsWith("SQUELCH")) { QString sq = decodedString.replace("SQUELCH",""); radio.squelch = sq.toUInt(); } else if (decodedString.startsWith("MOD")) { QString modulation = decodedString.replace("MOD",""); if (modulation == "WFM") radio.modulation = CCommand::eWFM; if (modulation == "FM") radio.modulation = CCommand::eFM; if (modulation == "AM") radio.modulation = CCommand::eAM; if (modulation == "LSB") radio.modulation = CCommand::eLSB; if (modulation == "USB") radio.modulation = CCommand::eUSB; if (modulation == "CW") radio.modulation = CCommand::eCW; } else if (decodedString.startsWith("NBON")) { radio.nb = true; } else if (decodedString.startsWith("NBOFF")) { radio.nb = false; } else found = false; return found; }