diff --git a/Source/Processors/Editors/SerialInputEditor.cpp b/Source/Processors/Editors/SerialInputEditor.cpp index 836e388720bab051d516378acbfaf88e4c56e99b..5eeae52cf42e1faf7f973e5478725732b7e043ff 100644 --- a/Source/Processors/Editors/SerialInputEditor.cpp +++ b/Source/Processors/Editors/SerialInputEditor.cpp @@ -106,3 +106,23 @@ void SerialInputEditor::comboBoxChanged(ComboBox* comboBox) } } +void SerialInputEditor::saveEditorParameters(XmlElement* xmlNode) +{ + XmlElement* parameters = xmlNode->createNewChildElement("PARAMETERS"); + + parameters->setAttribute("device", deviceList->getText().toStdString()); + parameters->setAttribute("baudrate", baudrateList->getSelectedId()); +} + +void SerialInputEditor::loadEditorParameters(XmlElement* xmlNode) +{ + forEachXmlChildElement(*xmlNode, subNode) + { + if (subNode->hasTagName("PARAMETERS")) + { + deviceList->setText(subNode->getStringAttribute("device", "")); + baudrateList->setSelectedId(subNode->getIntAttribute("baudrate")); + } + } +} + diff --git a/Source/Processors/Editors/SerialInputEditor.h b/Source/Processors/Editors/SerialInputEditor.h index 2b561e6dd14c4fa91bcd3de03b74e92843cb74cb..e0928e1d77784c18af57c18d49ac6e5c1c558b61 100644 --- a/Source/Processors/Editors/SerialInputEditor.h +++ b/Source/Processors/Editors/SerialInputEditor.h @@ -51,10 +51,12 @@ public: /** Called by processor graph at the end of the acqusition, reenables editor completly. */ void stopAcquisition(); + + /** Called when configuration is saved. Adds editors config to xml. */ + void saveEditorParameters(XmlElement* xml); - //void saveEditorParameters(XmlElement*); - - //void loadEditorParameters(XmlElement*); + /** Called when configuration is loaded. Reads editors config from xml. */ + void loadEditorParameters(XmlElement* xml); private: diff --git a/Source/Processors/SerialInput.cpp b/Source/Processors/SerialInput.cpp index 904e8e0991de95f702d3b30f3e5cb07985ed3f8f..c266c4ae690881727bf14fe7825a58875f9ba744 100644 --- a/Source/Processors/SerialInput.cpp +++ b/Source/Processors/SerialInput.cpp @@ -28,12 +28,8 @@ const int SerialInput::BAUDRATES[12] = {300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400}; SerialInput::SerialInput() -: GenericProcessor("Serial Port") + : GenericProcessor("Serial Port"), baudrate(0) { - baudrate = 0; - // ToDo: One day, this should use the Parameter class, and it will look roughly like this: - //parameters.add(Parameter("device", varArray(getDevices()), 0, 0, true)); - //parameters.add(Parameter("baudrate", varArray(getBaudrates()), 6, 1, true)); } SerialInput::~SerialInput() @@ -75,12 +71,11 @@ bool SerialInput::isReady() { if(device == "" || baudrate == 0) { - // ToDo: Properly warn about problem here! AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Please set device and baudrate to use first!"); return false; } - if(!serial.setup(device, baudrate)) { - // ToDo: Properly warn about problem here! + if(!serial.setup(device, baudrate)) + { AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Could not connect to specified serial device. Check log files for details."); return false; } @@ -94,9 +89,7 @@ bool SerialInput::disable() } -void SerialInput::process(AudioSampleBuffer& buffer, - MidiBuffer& events, - int& nSamples) +void SerialInput::process(AudioSampleBuffer&, MidiBuffer& events, int&) { int bytesAvailable = serial.available();