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)
}
}
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:
/** 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:
......
......@@ -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();
......
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