Session save handler

This commit is contained in:
Charles J. Cliffe 2015-01-09 17:17:56 -05:00
parent 95fcb30733
commit 8ec6b75e54
3 changed files with 39 additions and 1 deletions

View File

@ -17,6 +17,7 @@
#include "DemodulatorMgr.h"
#include "AudioThread.h"
#include "CubicSDR.h"
#include "DataTree.h"
#include <thread>
@ -32,7 +33,7 @@ EVT_IDLE(AppFrame::OnIdle)
wxEND_EVENT_TABLE()
AppFrame::AppFrame() :
wxFrame(NULL, wxID_ANY, wxT("CubicSDR v0.1a by Charles J. Cliffe (@ccliffe)")), activeDemodulator(NULL) {
wxFrame(NULL, wxID_ANY, wxT("CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe)")), activeDemodulator(NULL) {
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodOpts = new wxBoxSizer(wxVERTICAL);
@ -282,3 +283,33 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
event.Skip();
}
}
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();
header.newChild("offset") = wxGetApp().getOffset();
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") = (long)(*instance_i)->getBandwidth();
demod.newChild("frequency") = (long long)(*instance_i)->getFrequency();
demod.newChild("type") = (int)(*instance_i)->getDemodulatorType();
if ((*instance_i)->isSquelchEnabled()) {
demod.newChild("squelch") = (*instance_i)->getSquelchLevel();
demod.newChild("squelch_enabled") = (char)1;
}
demod.newChild("stereo") = (char)(*instance_i)->isStereo();
demod.newChild("output_device") = outputDevices[(*instance_i)->getOutputDevice()].name;
}
s.SaveToFileXML(fileName);
}
bool AppFrame::loadSession(std::string fileName) {
}

View File

@ -23,6 +23,9 @@ public:
void OnThread(wxCommandEvent& event);
void OnEventInput(wxThreadEvent& event);
void saveSession(std::string fileName);
bool loadSession(std::string fileName);
private:
void OnMenu(wxCommandEvent& event);
void OnClose(wxCommandEvent& event);
@ -46,5 +49,7 @@ private:
std::map<int,RtAudio::DeviceInfo> outputDevices;
std::map<int,wxMenuItem *> outputDeviceMenuItems;
std::string currentSessionFile;
wxDECLARE_EVENT_TABLE();
};

View File

@ -1,5 +1,7 @@
#pragma once
#define CUBICSDR_VERSION "v0.01a"
#ifdef __APPLE__
#define BUF_SIZE (16384*2)
#define SRATE 2000000