mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-05 06:37:52 -04:00
Per-Rig-Per-SDR IF frequency lock control and save/load
This commit is contained in:
parent
1699c50676
commit
936a640328
@ -55,6 +55,12 @@ void DeviceConfig::save(DataNode *node) {
|
|||||||
for (ConfigSettings::const_iterator set_i = settings.begin(); set_i != settings.end(); set_i++) {
|
for (ConfigSettings::const_iterator set_i = settings.begin(); set_i != settings.end(); set_i++) {
|
||||||
*settingsNode->newChild(set_i->first.c_str()) = set_i->second;
|
*settingsNode->newChild(set_i->first.c_str()) = set_i->second;
|
||||||
}
|
}
|
||||||
|
DataNode *rigIFs = node->newChild("rig_ifs");
|
||||||
|
for (std::map<int, long long>::const_iterator rigIF_i = rigIF.begin(); rigIF_i != rigIF.end(); rigIF_i++) {
|
||||||
|
DataNode *ifNode = rigIFs->newChild("rig_if");
|
||||||
|
*ifNode->newChild("model") = rigIF_i->first;
|
||||||
|
*ifNode->newChild("sdr_if") = rigIF_i->second;
|
||||||
|
}
|
||||||
busy_lock.unlock();
|
busy_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +104,21 @@ void DeviceConfig::load(DataNode *node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (node->hasAnother("rig_ifs")) {
|
||||||
|
DataNode *rigIFNodes = node->getNext("rig_ifs");
|
||||||
|
while (rigIFNodes->hasAnother("rig_if")) {
|
||||||
|
DataNode *rigIFNode = rigIFNodes->getNext("rig_if");
|
||||||
|
if (rigIFNode->hasAnother("model") && rigIFNode->hasAnother("sdr_if")) {
|
||||||
|
int load_model;
|
||||||
|
long long load_freq;
|
||||||
|
|
||||||
|
rigIFNode->getNext("model")->element()->get(load_model);
|
||||||
|
rigIFNode->getNext("sdr_if")->element()->get(load_freq);
|
||||||
|
|
||||||
|
rigIF[load_model] = load_freq;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
busy_lock.unlock();
|
busy_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +161,16 @@ ConfigSettings DeviceConfig::getSettings() {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceConfig::setRigIF(int rigType, long long freq) {
|
||||||
|
rigIF[rigType] = freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long DeviceConfig::getRigIF(int rigType) {
|
||||||
|
if (rigIF.find(rigType) != rigIF.end()) {
|
||||||
|
return rigIF[rigType];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AppConfig::AppConfig() : configName("") {
|
AppConfig::AppConfig() : configName("") {
|
||||||
winX.store(0);
|
winX.store(0);
|
||||||
|
@ -35,6 +35,9 @@ public:
|
|||||||
void setSetting(std::string key, std::string value);
|
void setSetting(std::string key, std::string value);
|
||||||
std::string getSetting(std::string key, std::string defaultValue);
|
std::string getSetting(std::string key, std::string defaultValue);
|
||||||
|
|
||||||
|
void setRigIF(int rigType, long long freq);
|
||||||
|
long long getRigIF(int rigType);
|
||||||
|
|
||||||
void save(DataNode *node);
|
void save(DataNode *node);
|
||||||
void load(DataNode *node);
|
void load(DataNode *node);
|
||||||
|
|
||||||
@ -46,6 +49,7 @@ private:
|
|||||||
std::atomic_llong offset;
|
std::atomic_llong offset;
|
||||||
ConfigSettings streamOpts;
|
ConfigSettings streamOpts;
|
||||||
std::map<std::string, std::string> settings;
|
std::map<std::string, std::string> settings;
|
||||||
|
std::map<int, long long> rigIF;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppConfig {
|
class AppConfig {
|
||||||
|
@ -417,11 +417,13 @@ AppFrame::AppFrame() :
|
|||||||
rigModel = wxGetApp().getConfig()->getRigModel();
|
rigModel = wxGetApp().getConfig()->getRigModel();
|
||||||
rigSerialRate = wxGetApp().getConfig()->getRigRate();
|
rigSerialRate = wxGetApp().getConfig()->getRigRate();
|
||||||
rigPort = wxGetApp().getConfig()->getRigPort();
|
rigPort = wxGetApp().getConfig()->getRigPort();
|
||||||
|
|
||||||
rigMenu = new wxMenu;
|
rigMenu = new wxMenu;
|
||||||
|
|
||||||
rigEnableMenuItem = rigMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig"));
|
rigEnableMenuItem = rigMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig"));
|
||||||
|
|
||||||
|
rigMenu->Append(wxID_RIG_SDR_IF, wxT("SDR-IF"));
|
||||||
|
|
||||||
wxMenu *rigModelMenu = new wxMenu;
|
wxMenu *rigModelMenu = new wxMenu;
|
||||||
RigList &rl = RigThread::enumerate();
|
RigList &rl = RigThread::enumerate();
|
||||||
numRigs = rl.size();
|
numRigs = rl.size();
|
||||||
@ -435,7 +437,7 @@ AppFrame::AppFrame() :
|
|||||||
rigModelMenuItems[(*ri)->rig_model] = rigModelMenu->AppendRadioItem(modelMenuId, modelString, wxT("Description?"));
|
rigModelMenuItems[(*ri)->rig_model] = rigModelMenu->AppendRadioItem(modelMenuId, modelString, wxT("Description?"));
|
||||||
|
|
||||||
if (rigModel == (*ri)->rig_model) {
|
if (rigModel == (*ri)->rig_model) {
|
||||||
rigModelMenuItems[(*ri)->rig_model]->Check();
|
rigModelMenuItems[(*ri)->rig_model]->Check(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelMenuId++;
|
modelMenuId++;
|
||||||
@ -465,7 +467,7 @@ AppFrame::AppFrame() :
|
|||||||
rigSerialMenuItems[(*rate_i)] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?"));
|
rigSerialMenuItems[(*rate_i)] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?"));
|
||||||
|
|
||||||
if (rigSerialRate == (*rate_i)) {
|
if (rigSerialRate == (*rate_i)) {
|
||||||
rigSerialMenuItems[(*rate_i)]->Check();
|
rigSerialMenuItems[(*rate_i)]->Check(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
rateMenuId++;
|
rateMenuId++;
|
||||||
@ -590,7 +592,7 @@ void AppFrame::updateDeviceParams() {
|
|||||||
}
|
}
|
||||||
wxMenuItem *item = subMenu->AppendRadioItem(wxID_SETTINGS_BASE+i, displayName);
|
wxMenuItem *item = subMenu->AppendRadioItem(wxID_SETTINGS_BASE+i, displayName);
|
||||||
if (currentVal == (*str_i)) {
|
if (currentVal == (*str_i)) {
|
||||||
item->Check();
|
item->Check(true);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
i++;
|
i++;
|
||||||
@ -648,6 +650,21 @@ void AppFrame::updateDeviceParams() {
|
|||||||
|
|
||||||
agcMenuItem->Check(wxGetApp().getAGCMode());
|
agcMenuItem->Check(wxGetApp().getAGCMode());
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_HAMLIB
|
||||||
|
std::string deviceId = devInfo->getDeviceId();
|
||||||
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||||
|
|
||||||
|
if (wxGetApp().rigIsActive()) {
|
||||||
|
rigSDRIF = devConfig->getRigIF(rigModel);
|
||||||
|
if (rigSDRIF) {
|
||||||
|
wxGetApp().lockFrequency(rigSDRIF);
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
deviceChanged.store(false);
|
deviceChanged.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,7 +698,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
// iqSwapMenuItem->Check(swap_state);
|
// iqSwapMenuItem->Check(swap_state);
|
||||||
} else if (event.GetId() == wxID_AGC_CONTROL) {
|
} else if (event.GetId() == wxID_AGC_CONTROL) {
|
||||||
if (wxGetApp().getDevice() == NULL) {
|
if (wxGetApp().getDevice() == NULL) {
|
||||||
agcMenuItem->Check();
|
agcMenuItem->Check(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!wxGetApp().getAGCMode()) {
|
if (!wxGetApp().getAGCMode()) {
|
||||||
@ -891,11 +908,24 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_HAMLIB
|
#ifdef USE_HAMLIB
|
||||||
|
|
||||||
bool resetRig = false;
|
bool resetRig = false;
|
||||||
if (event.GetId() >= wxID_RIG_MODEL_BASE && event.GetId() < wxID_RIG_MODEL_BASE+numRigs) {
|
if (event.GetId() >= wxID_RIG_MODEL_BASE && event.GetId() < wxID_RIG_MODEL_BASE+numRigs) {
|
||||||
int rigIdx = event.GetId()-wxID_RIG_MODEL_BASE;
|
int rigIdx = event.GetId()-wxID_RIG_MODEL_BASE;
|
||||||
RigList &rl = RigThread::enumerate();
|
RigList &rl = RigThread::enumerate();
|
||||||
rigModel = rl[rigIdx]->rig_model;
|
rigModel = rl[rigIdx]->rig_model;
|
||||||
|
if (devInfo != nullptr) {
|
||||||
|
std::string deviceId = devInfo->getDeviceId();
|
||||||
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||||
|
rigSDRIF = devConfig->getRigIF(rigModel);
|
||||||
|
if (rigSDRIF) {
|
||||||
|
wxGetApp().lockFrequency(rigSDRIF);
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
resetRig = true;
|
resetRig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,8 +949,39 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
if (!wxGetApp().rigIsActive()) {
|
if (!wxGetApp().rigIsActive()) {
|
||||||
wxGetApp().stopRig();
|
wxGetApp().stopRig();
|
||||||
wxGetApp().initRig(rigModel, rigPort, rigSerialRate);
|
wxGetApp().initRig(rigModel, rigPort, rigSerialRate);
|
||||||
|
|
||||||
|
if (devInfo != nullptr) {
|
||||||
|
std::string deviceId = devInfo->getDeviceId();
|
||||||
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||||
|
rigSDRIF = devConfig->getRigIF(rigModel);
|
||||||
|
if (rigSDRIF) {
|
||||||
|
wxGetApp().lockFrequency(rigSDRIF);
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
wxGetApp().stopRig();
|
wxGetApp().stopRig();
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.GetId() == wxID_RIG_SDR_IF) {
|
||||||
|
if (devInfo != nullptr) {
|
||||||
|
std::string deviceId = devInfo->getDeviceId();
|
||||||
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||||
|
long long freqRigIF = wxGetNumberFromUser("Rig SDR-IF Frequency", "Frequency (Hz)", "Frequency", devConfig->getRigIF(rigModel), 0, 2000000000);
|
||||||
|
if (freqRigIF != -1) {
|
||||||
|
rigSDRIF = freqRigIF;
|
||||||
|
devConfig->setRigIF(rigModel, rigSDRIF);
|
||||||
|
}
|
||||||
|
if (rigSDRIF && wxGetApp().rigIsActive()) {
|
||||||
|
wxGetApp().lockFrequency(rigSDRIF);
|
||||||
|
} else {
|
||||||
|
wxGetApp().unlockFrequency();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#ifdef USE_HAMLIB
|
#ifdef USE_HAMLIB
|
||||||
#define wxID_RIG_TOGGLE 11900
|
#define wxID_RIG_TOGGLE 11900
|
||||||
#define wxID_RIG_PORT 11901
|
#define wxID_RIG_PORT 11901
|
||||||
|
#define wxID_RIG_SDR_IF 11902
|
||||||
#define wxID_RIG_SERIAL_BASE 11950
|
#define wxID_RIG_SERIAL_BASE 11950
|
||||||
#define wxID_RIG_MODEL_BASE 12000
|
#define wxID_RIG_MODEL_BASE 12000
|
||||||
#endif
|
#endif
|
||||||
@ -140,10 +141,12 @@ private:
|
|||||||
wxMenu *rigMenu;
|
wxMenu *rigMenu;
|
||||||
wxMenuItem *rigEnableMenuItem;
|
wxMenuItem *rigEnableMenuItem;
|
||||||
wxMenuItem *rigPortMenuItem;
|
wxMenuItem *rigPortMenuItem;
|
||||||
|
wxMenuItem *sdrIFMenuItem;
|
||||||
std::map<int, wxMenuItem *> rigSerialMenuItems;
|
std::map<int, wxMenuItem *> rigSerialMenuItems;
|
||||||
std::map<int, wxMenuItem *> rigModelMenuItems;
|
std::map<int, wxMenuItem *> rigModelMenuItems;
|
||||||
int rigModel;
|
int rigModel;
|
||||||
int rigSerialRate;
|
int rigSerialRate;
|
||||||
|
long long rigSDRIF;
|
||||||
std::vector<int> rigSerialRates;
|
std::vector<int> rigSerialRates;
|
||||||
std::string rigPort;
|
std::string rigPort;
|
||||||
int numRigs;
|
int numRigs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user