Skip to content
Snippets Groups Projects
Commit f883c616 authored by Florian Franzen's avatar Florian Franzen
Browse files

Adds save and load of config capabilities to serial input.

parent fde7a1f0
No related branches found
No related tags found
No related merge requests found
...@@ -106,3 +106,23 @@ void SerialInputEditor::comboBoxChanged(ComboBox* comboBox) ...@@ -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"));
}
}
}
...@@ -51,10 +51,12 @@ public: ...@@ -51,10 +51,12 @@ public:
/** Called by processor graph at the end of the acqusition, reenables editor completly. */ /** Called by processor graph at the end of the acqusition, reenables editor completly. */
void stopAcquisition(); void stopAcquisition();
/** Called when configuration is saved. Adds editors config to xml. */
void saveEditorParameters(XmlElement* xml);
//void saveEditorParameters(XmlElement*); /** Called when configuration is loaded. Reads editors config from xml. */
void loadEditorParameters(XmlElement* xml);
//void loadEditorParameters(XmlElement*);
private: private:
......
...@@ -28,12 +28,8 @@ ...@@ -28,12 +28,8 @@
const int SerialInput::BAUDRATES[12] = {300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400}; const int SerialInput::BAUDRATES[12] = {300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400};
SerialInput::SerialInput() 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() SerialInput::~SerialInput()
...@@ -75,12 +71,11 @@ bool SerialInput::isReady() ...@@ -75,12 +71,11 @@ bool SerialInput::isReady()
{ {
if(device == "" || baudrate == 0) 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!"); AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Please set device and baudrate to use first!");
return false; return false;
} }
if(!serial.setup(device, baudrate)) { if(!serial.setup(device, baudrate))
// ToDo: Properly warn about problem here! {
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Could not connect to specified serial device. Check log files for details."); AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Could not connect to specified serial device. Check log files for details.");
return false; return false;
} }
...@@ -94,9 +89,7 @@ bool SerialInput::disable() ...@@ -94,9 +89,7 @@ bool SerialInput::disable()
} }
void SerialInput::process(AudioSampleBuffer& buffer, void SerialInput::process(AudioSampleBuffer&, MidiBuffer& events, int&)
MidiBuffer& events,
int& nSamples)
{ {
int bytesAvailable = serial.available(); int bytesAvailable = serial.available();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment