Пример #1
0
void AppFrame::saveSession(std::string fileName) {
    DataTree s("cubicsdr_session");
    DataNode *header = s.rootNode()->newChild("header");
    *header->newChild("version") = std::string(CUBICSDR_VERSION);
    *header->newChild("center_freq") = wxGetApp().getFrequency();

    DataNode *demods = s.rootNode()->newChild("demodulators");

    std::vector<DemodulatorInstance *> &instances = wxGetApp().getDemodMgr().getDemodulators();
    std::vector<DemodulatorInstance *>::iterator instance_i;
    for (instance_i = instances.begin(); instance_i != instances.end(); instance_i++) {
        DataNode *demod = demods->newChild("demodulator");
        *demod->newChild("bandwidth") = (*instance_i)->getBandwidth();
        *demod->newChild("frequency") = (*instance_i)->getFrequency();
        *demod->newChild("type") = (*instance_i)->getDemodulatorType();
        *demod->newChild("squelch_level") = (*instance_i)->getSquelchLevel();
        *demod->newChild("squelch_enabled") = (*instance_i)->isSquelchEnabled() ? 1 : 0;
        *demod->newChild("stereo") = (*instance_i)->isStereo() ? 1 : 0;
        *demod->newChild("output_device") = outputDevices[(*instance_i)->getOutputDevice()].name;
        *demod->newChild("gain") = (*instance_i)->getGain();
    }

    s.SaveToFileXML(fileName);

    currentSessionFile = fileName;
    std::string filePart = fileName.substr(fileName.find_last_of(filePathSeparator) + 1);
    GetStatusBar()->SetStatusText(wxString::Format(wxT("Saved session: %s"), currentSessionFile.c_str()));
    SetTitle(wxString::Format(wxT("%s: %s"), CUBICSDR_TITLE, filePart.c_str()));
}
Пример #2
0
void DeviceConfig::save(DataNode *node) {
    busy_lock.lock();
    *node->newChild("id") = deviceId;
    *node->newChild("name") = deviceName;
    *node->newChild("ppm") = (int)ppm;
    *node->newChild("offset") = offset;
    DataNode *streamOptsNode = node->newChild("streamOpts");
    for (ConfigSettings::const_iterator opt_i = streamOpts.begin(); opt_i != streamOpts.end(); opt_i++) {
        *streamOptsNode->newChild(opt_i->first.c_str()) = opt_i->second;
    }
    DataNode *settingsNode = node->newChild("settings");
    for (ConfigSettings::const_iterator set_i = settings.begin(); set_i != settings.end(); set_i++) {
        *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();
}
Пример #3
0
void DeviceConfig::save(DataNode *node) {

    std::lock_guard < std::mutex > lock(busy_lock);
    
    *node->newChild("id") = deviceId;
    *node->newChild("name") = deviceName;
    *node->newChild("ppm") = ppm.load();
    *node->newChild("offset") = offset.load();
    *node->newChild("sample_rate") = sampleRate.load();
    *node->newChild("agc_mode") = agcMode.load()?1:0;

    if (!antennaName.empty()) {
        *node->newChild("antenna") = antennaName;
    }

    if (streamOpts.size()) {
        DataNode *streamOptsNode = node->newChild("streamOpts");
        for (ConfigSettings::const_iterator opt_i = streamOpts.begin(); opt_i != streamOpts.end(); opt_i++) {
            *streamOptsNode->newChild(opt_i->first.c_str()) = opt_i->second;
        }
    }
    if (settings.size()) {
        DataNode *settingsNode = node->newChild("settings");
        for (ConfigSettings::const_iterator set_i = settings.begin(); set_i != settings.end(); set_i++) {
            *settingsNode->newChild(set_i->first.c_str()) = set_i->second;
        }
    }
    if (rigIF.size()) {
        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;
        }
    }
    if (gains.size()) {
        DataNode *gainsNode = node->newChild("gains");
        for (ConfigGains::const_iterator gain_i = gains.begin(); gain_i != gains.end(); gain_i++) {
            DataNode *gainNode = gainsNode->newChild("gain");
            *gainNode->newChild("id") = gain_i->first;
            *gainNode->newChild("value") = gain_i->second;
        }
    }
   
}