From 90dff66cd5d21865c19ab66e7d95a78b0a476529 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Tue, 18 Jun 2013 22:50:54 -0400 Subject: [PATCH] RHD2000 source node now saves and loads its parameters --- Source/Processors/Editors/RHD2000Editor.cpp | 86 +++++++++++++++++---- Source/Processors/Editors/RHD2000Editor.h | 18 ++++- Source/Processors/SourceNode.cpp | 4 +- 3 files changed, 88 insertions(+), 20 deletions(-) diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp index f8426a6f1..fa6ce9ac0 100644 --- a/Source/Processors/Editors/RHD2000Editor.cpp +++ b/Source/Processors/Editors/RHD2000Editor.cpp @@ -169,6 +169,29 @@ void RHD2000Editor::stopAcquisition() } +void RHD2000Editor::saveEditorParameters(XmlElement* xml) +{ + xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId()); + xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth()); + xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth()); + xml->setAttribute("ADCsOn", adcButton->getToggleState()); + + // XmlElement* selectedChannel = xml->createNewChildElement("SELECTEDID"); + + // selectedChannel->setAttribute("ID",referenceSelector->getSelectedId()); +} + +void RHD2000Editor::loadEditorParameters(XmlElement* xml) +{ + + sampleRateInterface->setSelectedId(xml->getIntAttribute("SampleRate")); + bandwidthInterface->setLowerBandwidth(xml->getDoubleAttribute("LowCut")); + bandwidthInterface->setUpperBandwidth(xml->getDoubleAttribute("HighCut")); + adcButton->setToggleState(xml->getBoolAttribute("ADCsOn"), true); + +} + + // Bandwidth Options -------------------------------------------------------------------- BandwidthInterface::BandwidthInterface(RHD2000Thread* board_, @@ -181,21 +204,24 @@ BandwidthInterface::BandwidthInterface(RHD2000Thread* board_, lastHighCutString = "7500"; lastLowCutString = "1"; - UpperBandwidthSelection = new Label("UpperBandwidth",lastHighCutString); // this is currently set in RHD2000Thread, the cleaner would be to set it here again - UpperBandwidthSelection->setEditable(true,false,false); - UpperBandwidthSelection->addListener(this); - UpperBandwidthSelection->setBounds(30,30,60,20); - UpperBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); - addAndMakeVisible(UpperBandwidthSelection); + actualUpperBandwidth = 7500.0f; + actualLowerBandwidth = 1.0f; + upperBandwidthSelection = new Label("UpperBandwidth",lastHighCutString); // this is currently set in RHD2000Thread, the cleaner would be to set it here again + upperBandwidthSelection->setEditable(true,false,false); + upperBandwidthSelection->addListener(this); + upperBandwidthSelection->setBounds(30,30,60,20); + upperBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); + addAndMakeVisible(upperBandwidthSelection); - LowerBandwidthSelection = new Label("LowerBandwidth",lastLowCutString); - LowerBandwidthSelection->setEditable(true,false,false); - LowerBandwidthSelection->addListener(this); - LowerBandwidthSelection->setBounds(25,10,60,20); - LowerBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); - addAndMakeVisible(LowerBandwidthSelection); + lowerBandwidthSelection = new Label("LowerBandwidth",lastLowCutString); + lowerBandwidthSelection->setEditable(true,false,false); + lowerBandwidthSelection->addListener(this); + lowerBandwidthSelection->setBounds(25,10,60,20); + lowerBandwidthSelection->setColour(Label::textColourId, Colours::darkgrey); + + addAndMakeVisible(lowerBandwidthSelection); @@ -212,7 +238,7 @@ void BandwidthInterface::labelTextChanged(Label* label) if (!(editor->acquisitionIsActive) && board->foundInputSource()) { - if (label == UpperBandwidthSelection) + if (label == upperBandwidthSelection) { Value val = label->getTextValue(); @@ -227,7 +253,7 @@ void BandwidthInterface::labelTextChanged(Label* label) return; } - double actualUpperBandwidth = board->setUpperBandwidth(requestedValue); + actualUpperBandwidth = board->setUpperBandwidth(requestedValue); std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl; std::cout << "Actual Upper Bandwidth: " << actualUpperBandwidth << std::endl; @@ -249,7 +275,7 @@ void BandwidthInterface::labelTextChanged(Label* label) return; } - double actualLowerBandwidth = board->setLowerBandwidth(requestedValue); + actualLowerBandwidth = board->setLowerBandwidth(requestedValue); std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl; std::cout << "Actual Upper Bandwidth: " << actualLowerBandwidth << std::endl; @@ -258,7 +284,27 @@ void BandwidthInterface::labelTextChanged(Label* label) } } +void BandwidthInterface::setLowerBandwidth(double value) +{ + actualLowerBandwidth = board->setLowerBandwidth(value); + lowerBandwidthSelection->setText(String(roundFloatToInt(actualLowerBandwidth)), false); +} +void BandwidthInterface::setUpperBandwidth(double value) +{ + actualUpperBandwidth = board->setUpperBandwidth(value); + upperBandwidthSelection->setText(String(roundFloatToInt(actualUpperBandwidth)), false); +} + +double BandwidthInterface::getLowerBandwidth() +{ + return actualLowerBandwidth; +} + +double BandwidthInterface::getUpperBandwidth() +{ + return actualUpperBandwidth; +} void BandwidthInterface::paint(Graphics& g) @@ -283,7 +329,7 @@ SampleRateInterface::SampleRateInterface(RHD2000Thread* board_, board(board_), editor(editor_) { - name="Sample Rate"; + name = "Sample Rate"; sampleRateOptions.add("1.00 kS/s"); sampleRateOptions.add("1.25 kS/s"); @@ -335,7 +381,15 @@ void SampleRateInterface::comboBoxChanged(ComboBox* cb) } } +int SampleRateInterface::getSelectedId() +{ + return rateSelection->getSelectedId(); +} +void SampleRateInterface::setSelectedId(int id) +{ + rateSelection->setSelectedId(id); +} void SampleRateInterface::paint(Graphics& g) diff --git a/Source/Processors/Editors/RHD2000Editor.h b/Source/Processors/Editors/RHD2000Editor.h index 5ae7c7f38..45e032fe7 100644 --- a/Source/Processors/Editors/RHD2000Editor.h +++ b/Source/Processors/Editors/RHD2000Editor.h @@ -61,6 +61,9 @@ public: void channelChanged(int chan); + void saveEditorParameters(XmlElement* xml); + void loadEditorParameters(XmlElement* xml); + private: OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces; @@ -121,6 +124,11 @@ public: void paint(Graphics& g); void labelTextChanged(Label* te); + void setLowerBandwidth(double value); + void setUpperBandwidth(double value); + double getLowerBandwidth(); + double getUpperBandwidth(); + private: String name; @@ -130,8 +138,11 @@ private: RHD2000Thread* board; RHD2000Editor* editor; - ScopedPointer<Label> UpperBandwidthSelection; - ScopedPointer<Label> LowerBandwidthSelection; + ScopedPointer<Label> upperBandwidthSelection; + ScopedPointer<Label> lowerBandwidthSelection; + + double actualUpperBandwidth; + double actualLowerBandwidth; }; @@ -143,6 +154,9 @@ public: SampleRateInterface(RHD2000Thread*, RHD2000Editor*); ~SampleRateInterface(); + int getSelectedId(); + void setSelectedId(int); + void paint(Graphics& g); void comboBoxChanged(ComboBox* cb); diff --git a/Source/Processors/SourceNode.cpp b/Source/Processors/SourceNode.cpp index 51327d9a5..43fc015df 100755 --- a/Source/Processors/SourceNode.cpp +++ b/Source/Processors/SourceNode.cpp @@ -417,7 +417,7 @@ void SourceNode::saveCustomParametersToXml(XmlElement* parentElement) FileReaderThread* thread = (FileReaderThread*) dataThread.get(); childNode->setAttribute("path", thread->getFile()); - } + } } @@ -436,7 +436,7 @@ void SourceNode::loadCustomParametersFromXml() FileReaderEditor* fre = (FileReaderEditor*) getEditor(); fre->setFile(filepath); - } + } } } -- GitLab