Skip to content
Snippets Groups Projects
Commit 13e05e9b authored by jsiegle's avatar jsiegle
Browse files

Add updated editor for RHD2000Thread

parent 13650eea
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -27,6 +27,7 @@
#include "../../../JuceLibraryCode/JuceHeader.h"
#include <stdio.h>
#include "DataBuffer.h"
#include "../GenericProcessor.h"
class SourceNode;
......@@ -92,6 +93,30 @@ public:
{
return 0;
}
virtual int modifyChannelName(channelType t, int stream, int ch, String newName)
{
return -1;
}
virtual int modifyChannelGain(channelType t, int stream, int ch, float gain)
{
return -1;
}
virtual void setDefaultNamingScheme(int scheme)
{
}
virtual void getChannelsInfo(StringArray &Names, Array<channelType> &type, Array<int> &stream, Array<int> &originalChannelNumber, Array<float> &gains)
{
};
virtual void getEventChannelNames(StringArray &names)
{
}
/** Returns the number of ADC channels of the data source.*/
virtual int getNumADCchannels()
{
return 0;
}
/** Changes the names of channels, if the thread needs custom names. */
virtual void updateChannelNames() { }
......
This diff is collapsed.
......@@ -26,6 +26,7 @@
#include "../../../JuceLibraryCode/JuceHeader.h"
#include "GenericEditor.h"
#include "VisualizerEditor.h"
#include "ElectrodeButtons.h" // for ElectrodeButton
......@@ -44,9 +45,116 @@ class UtilityButton;
@see SourceNode
*/
class SourceNode;
class FPGAchannelComponent;
class RHD2000Editor;
class FPGAcanvas;
class RHD2000Editor : public GenericEditor
class FPGAchannelList : public Component,
public AccessClass, Button::Listener, ComboBox::Listener
{
public:
FPGAchannelList(GenericProcessor* proc, Viewport *p, FPGAcanvas*c);
~FPGAchannelList();
void setNewName(int stream, int channelIndex, channelType t, String newName);
void setNewGain(int stream, int channel,channelType t, float gain);
void disableAll();
void enableAll();
void paint(Graphics& g);
void buttonClicked(Button *btn);
void update();
void updateButtons();
int getNumChannels();
void comboBoxChanged(ComboBox *b);
void updateImpedance(Array<int> streams, Array<int> channels, Array<float> magnitude, Array<float> phase);
GenericProcessor* proc;
private:
Array<float> gains;
Array<channelType> types;
Array<int> stream;
Array<int> orig_number;
Viewport *viewport;
FPGAcanvas *canvas;
ScopedPointer<UtilityButton> impedanceButton;
ScopedPointer<ComboBox> numberingScheme;
ScopedPointer<Label> numberingSchemeLabel;
OwnedArray<Label> staticLabels;
OwnedArray<FPGAchannelComponent> channelComponents;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FPGAchannelList);
};
class FPGAchannelComponent : public Component, public AccessClass, Button::Listener, public ComboBox::Listener, public Label::Listener
{
public:
FPGAchannelComponent(FPGAchannelList* cl,int stream, int ch, channelType t, int gainIndex_, String name_, Array<float> gains_);
~FPGAchannelComponent();
Colour getDefaultColor(int ID);
void setImpedanceValues(float mag, float phase);
void disableEdit();
void enableEdit();
void setEnabledState(bool);
bool getEnabledState()
{
return isEnabled;
}
void buttonClicked(Button *btn);
void setUserDefinedData(int d);
int getUserDefinedData();
void comboBoxChanged(ComboBox* comboBox);
void labelTextChanged(Label* lbl);
void resized();
private:
Array<float> gains;
FPGAchannelList* channelList;
ScopedPointer<Label> staticLabel, editName, impedance;
ScopedPointer<ComboBox> gainComboBox;
int channel;
String name;
int stream;
channelType type;
int gainIndex;
int userDefinedData;
Font font;
bool isEnabled;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FPGAchannelComponent);
};
class FPGAcanvas : public Visualizer, public Button::Listener
{
public:
FPGAcanvas(GenericProcessor* n);
~FPGAcanvas();
void paint(Graphics& g);
void refresh();
void beginAnimation();
void endAnimation();
void refreshState();
void update();
void setParameter(int, float) ;
void setParameter(int, int, int, float) ;
void updateImpedance(Array<int> streams, Array<int> channels, Array<float> magnitude, Array<float> phase);
void resized();
void buttonClicked(Button* button);
Viewport* channelsViewport;
GenericProcessor* processor;
ScopedPointer<FPGAchannelList> channelList;
};
class RHD2000Editor : public VisualizerEditor, public ComboBox::Listener
{
public:
......@@ -56,7 +164,8 @@ public:
void buttonEvent(Button* button);
void scanPorts();
void comboBoxChanged(ComboBox* comboBox);
void startAcquisition();
void stopAcquisition();
......@@ -64,7 +173,8 @@ public:
void saveCustomParameters(XmlElement* xml);
void loadCustomParameters(XmlElement* xml);
Visualizer* createNewCanvas(void);
void measureImpedance();
private:
OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces;
......@@ -75,13 +185,15 @@ private:
ScopedPointer<AudioInterface> audioInterface;
ScopedPointer<UtilityButton> rescanButton;
ScopedPointer<UtilityButton> rescanButton,dacTTLButton;
ScopedPointer<UtilityButton> adcButton;
ScopedPointer<ComboBox> ttlSettleCombo,dacHPFcombo;
ScopedPointer<Label> audioLabel;
RHD2000Thread* board;
ScopedPointer<Label> audioLabel,ttlSettleLabel,dacHPFlabel ;
RHD2000Thread* board;
FPGAcanvas *canvas;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHD2000Editor);
};
......@@ -177,36 +289,36 @@ private:
};
class AudioInterface : public Component,
public Label::Listener
public Label::Listener
{
public:
AudioInterface(RHD2000Thread*, RHD2000Editor*);
~AudioInterface();
void paint(Graphics& g);
void labelTextChanged(Label* te);
void setNoiseSlicerLevel(int value);
int getNoiseSlicerLevel();
//void setGain(double value);
//double getGain();
private:
String name;
String lastNoiseSlicerString;
String lastGainString;
RHD2000Thread* board;
RHD2000Editor* editor;
ScopedPointer<Label> noiseSlicerLevelSelection;
//ScopedPointer<Label> gainSelection;
int actualNoiseSlicerLevel;
//double actualGain;
};
......
......@@ -45,7 +45,7 @@ SourceNode::SourceNode(const String& name_)
if (getName().equalsIgnoreCase("RHA2000-EVAL"))
{
// dataThread = new IntanThread(this);
// dataThread = new IntanThread(this);o
}
else if (getName().equalsIgnoreCase("Custom FPGA"))
{
......@@ -116,6 +116,85 @@ DataThread* SourceNode::getThread()
return dataThread;
}
int SourceNode::modifyChannelName(channelType t, int str, int ch, String newName, bool updateSignalChain)
{
if (dataThread != 0) {
int channel_index = dataThread->modifyChannelName(t, str, ch, newName);
if (channel_index >= 0 && channel_index < channels.size())
{
if (channels[channel_index]->getChannelName() != newName)
{
channels[channel_index]->setName(newName);
// propagate this information...
if (updateSignalChain)
getEditorViewport()->makeEditorVisible(getEditor(), false, true);
}
}
return channel_index;
}
return -1;
}
int SourceNode::modifyChannelGain(int stream, int channel,channelType type, float gain, bool updateSignalChain)
{
if (dataThread != 0)
{
int channel_index = dataThread->modifyChannelGain(type, stream, channel, gain);
if (channel_index >= 0 && channel_index < channels.size())
{
// we now need to update the signal chain to propagate this change.....
if (channels[channel_index]->getChannelGain() != gain)
{
channels[channel_index]->setGain(gain);
if (updateSignalChain)
getEditorViewport()->makeEditorVisible(getEditor(), false, true);
return channel_index;
}
}
}
return -1;
}
void SourceNode::getChannelsInfo(StringArray &names, Array<channelType> &types, Array<int> &stream, Array<int> &originalChannelNumber, Array<float> &gains)
{
if (dataThread != 0)
dataThread->getChannelsInfo(names, types,stream,originalChannelNumber,gains);
}
void SourceNode::setDefaultNamingScheme(int scheme)
{
if (dataThread != 0)
{
dataThread->setDefaultNamingScheme(scheme);
StringArray names;
Array<channelType> types;
Array<int> stream;
Array<int> originalChannelNumber;
Array<float> gains;
getChannelsInfo(names, types, stream, originalChannelNumber, gains);
for (int k=0;k<names.size();k++)
{
modifyChannelName(types[k],stream[k],originalChannelNumber[k], names[k],false);
}
}
}
void SourceNode::getEventChannelNames(StringArray &names)
{
if (dataThread != 0)
dataThread->getEventChannelNames(names);
}
void SourceNode::updateSettings()
{
if (inputBuffer == 0 && dataThread != 0)
......
......@@ -60,6 +60,13 @@ public:
int getDefaultNumOutputs();
float getDefaultBitVolts();
int modifyChannelGain(int stream, int channel,channelType type, float gain, bool updateSignalChain);
int modifyChannelName(channelType t, int str, int ch, String newName, bool updateSignalChain);
void getChannelsInfo(StringArray &Names, Array<channelType> &type, Array<int> &stream, Array<int> &originalChannelNumber, Array<float> &gains);
void setDefaultNamingScheme(int scheme);
void getEventChannelNames(StringArray &names);
AudioProcessorEditor* createEditor();
bool hasEditor() const
{
......
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