Skip to content
Snippets Groups Projects
Commit eb92e31a authored by Aaron Cuevas Lopez's avatar Aaron Cuevas Lopez
Browse files

Set sefault descriptions and descriptors to channels

parent f16c923d
No related branches found
No related tags found
No related merge requests found
......@@ -145,7 +145,7 @@ DataChannel::DataChannel(DataChannelTypes type, float sampleRate, GenericProcess
InfoObjectCommon(source->dataChannelCount++, source->dataChannelTypeCount[type]++, sampleRate, source, subproc),
m_type(type)
{
setName(getDefaultName());
setDefaultNameAndDescription();
}
DataChannel::DataChannel(const DataChannel& ch)
......@@ -222,21 +222,42 @@ void DataChannel::reset()
m_isRecording = false;
}
String DataChannel::getDefaultName() const
void DataChannel::setDefaultNameAndDescription()
{
String name;
String description;
String descriptor = "continuous.";
switch (m_type)
{
case HEADSTAGE_CHANNEL: name = "CH "; break;
case AUX_CHANNEL: name = "AUX "; break;
case ADC_CHANNEL: name = "ADC "; break;
default: name = "INVALID "; break;
case HEADSTAGE_CHANNEL:
name = "CH";
description = "Headstage";
descriptor += "headstage";
break;
case AUX_CHANNEL:
name = "AUX ";
description = "Auxiliar";
descriptor += "aux";
break;
case ADC_CHANNEL:
name = "ADC ";
description = "ADC";
descriptor = "adc";
break;
default:
setName("INVALID");
setDescription("Invalid Channel");
setDescriptor("invalid");
return;
break;
}
name += "p";
name += " p";
name += String(getSourceNodeID()) + String(".") + String(getSubProcessorIdx());
name += " n";
name += String(getSourceTypeIndex());
return name;
setName(name);
setDescription(description + " data channel");
setDescriptor(descriptor);
}
//EventChannel
......@@ -257,7 +278,7 @@ EventChannel::EventChannel(EventChannelTypes type, unsigned int nChannels, unsig
//for messages, add 1 byte to account for the null terminator
if (m_type == TEXT) m_dataSize += 1;
}
setName(getDefaultName());
setDefaultNameAndDescription();
}
EventChannel::~EventChannel()
......@@ -315,28 +336,51 @@ size_t EventChannel::getTypeByteSize(EventChannel::EventChannelTypes type)
}
}
String EventChannel::getDefaultName() const
void EventChannel::setDefaultNameAndDescription()
{
String name;
switch (m_type)
{
case TTL: name = "TTL "; break;
case TEXT: name = "TEXT "; break;
case INT8_ARRAY: name = "INT8 "; break;
case UINT8_ARRAY: name = "UINT8 "; break;
case INT16_ARRAY: name = "INT16 "; break;
case UINT16_ARRAY: name = "UINT16 "; break;
case INT32_ARRAY: name = "INT32 "; break;
case UINT32_ARRAY: name = "UINT32 "; break;
case INT64_ARRAY: name = "INT64 "; break;
case UINT64_ARRAY: name = "UINT64 "; break;
default: name = "INVALID "; break;
case TTL: name = "TTL"; break;
case TEXT: name = "TEXT"; break;
case INT8_ARRAY: name = "INT8"; break;
case UINT8_ARRAY: name = "UINT8"; break;
case INT16_ARRAY: name = "INT16"; break;
case UINT16_ARRAY: name = "UINT16"; break;
case INT32_ARRAY: name = "INT32"; break;
case UINT32_ARRAY: name = "UINT32"; break;
case INT64_ARRAY: name = "INT64"; break;
case UINT64_ARRAY: name = "UINT64"; break;
default:
setName("INVALID");
setDescription("Invalid channel");
setDescriptor("invalid");
return;
break;
}
name += "p";
name += String(getSourceNodeID()) + String(".") + String(getSubProcessorIdx());
name += " n";
name += String(getSourceTypeIndex());
return name;
setName(name);
if (m_type == TTL)
{
setDescription("TTL data input");
setDescriptor("genericevent.ttl");
}
else if (m_type == TEXT)
{
setDescription("Text event");
setDescriptor("genericevent.text");
}
else
{
if (m_length > 1)
setDescription(name + " data array");
else
setDescription(name + " single value");
setDescriptor("genericevent." + name.toLowerCase());
}
}
//SpikeChannel
......@@ -357,7 +401,7 @@ SpikeChannel::SpikeChannel(ElectrodeTypes type, GenericProcessor* source, const
m_sourceInfo.add(info);
m_channelBitVolts.add(chan->getBitVolts());
}
setName(getDefaultName());
setDefaultNameAndDescription();
}
SpikeChannel::~SpikeChannel()
......@@ -454,26 +498,42 @@ float SpikeChannel::getChannelBitVolts(int index) const
return m_channelBitVolts[index];
}
String SpikeChannel::getDefaultName() const
void SpikeChannel::setDefaultNameAndDescription()
{
String name;
String description;
String descriptor = "spikesource.";
switch (m_type)
{
case SINGLE: name = "SE "; break;
case STEREOTRODE: name = "ST "; break;
case TETRODE: name = "TT "; break;
case SINGLE:
name = "SE ";
description = "Single electrode";
descriptor += "single";
break;
case STEREOTRODE:
name = "ST ";
description = "Stereotrode";
descriptor += "stereotrode";
break;
case TETRODE:
name = "TT ";
description = "Tetrode";
descriptor += "tetrode";
break;
default: name = "INVALID "; break;
}
name += String(" p") + String(getSourceNodeID()) + String(".") + String(getSubProcessorIdx()) + String(" n") + String(getSourceTypeIndex());
return name;
setName(name);
setDescription(description + " spike data source");
setDescriptor(descriptor);
}
//ConfigurationObject
ConfigurationObject::ConfigurationObject(String descriptor, GenericProcessor* source, uint16 subproc)
: SourceProcessorInfo(source, subproc)
{
setDefaultNameAndDescription();
setDescriptor(descriptor);
setName(getDefaultName());
}
void ConfigurationObject::setShouldBeRecorded(bool status)
......@@ -486,7 +546,8 @@ bool ConfigurationObject::getShouldBeRecorded() const
return m_shouldBeRecorded;
}
String ConfigurationObject::getDefaultName() const
void ConfigurationObject::setDefaultNameAndDescription()
{
return "Config";
setName("Configuration Object");
setDescription("Generic configuration object");
}
\ No newline at end of file
......@@ -119,7 +119,7 @@ public:
String getDescriptor() const;
protected:
NamedInfoObject();
virtual String getDefaultName() const = 0;
virtual void setDefaultNameAndDescription() = 0;
private:
String m_name;
String m_descriptor;
......@@ -228,7 +228,7 @@ public:
void reset();
InfoObjectType getInfoObjectType() const override;
String getDefaultName() const override;
void setDefaultNameAndDescription() override;
private:
const DataChannelTypes m_type;
float m_bitVolts{ 1.0f };
......@@ -320,7 +320,7 @@ public:
static size_t getTypeByteSize(EventChannelTypes type);
InfoObjectType getInfoObjectType() const override;
String getDefaultName() const override;
void setDefaultNameAndDescription() override;
private:
const EventChannelTypes m_type;
unsigned int m_numChannels{ 1 };
......@@ -395,7 +395,7 @@ public:
static ElectrodeTypes typeFromNumChannels(unsigned int nChannels);
InfoObjectType getInfoObjectType() const override;
String getDefaultName() const override;
void setDefaultNameAndDescription() override;
private:
const ElectrodeTypes m_type;
Array<sourceChannelInfo> m_sourceInfo;
......@@ -431,7 +431,7 @@ public:
/** Gets the config preference about being recorded */
bool getShouldBeRecorded() const;
String getDefaultName() const override;
void setDefaultNameAndDescription() override;
private:
bool m_shouldBeRecorded{ true };
JUCE_LEAK_DETECTOR(ConfigurationObject);
......
......@@ -306,13 +306,14 @@ const int MetaDataInfoObject::getMetaDataCount() const
return m_metaDataDescriptorArray.size();
}
int MetaDataInfoObject::findMetaData(MetaDataDescriptor::MetaDataTypes type, unsigned int length, String descriptor) const
int MetaDataInfoObject::findMetaData(MetaDataDescriptor::MetaDataTypes type, unsigned int length, String descriptor, bool fullDescriptor) const
{
int nMetaData = m_metaDataDescriptorArray.size();
for (int i = 0; i < nMetaData; i++)
{
MetaDataDescriptorPtr md = m_metaDataDescriptorArray[i];
if (md->getType() == type && md->getLength() == length && (descriptor.isEmpty() || descriptor.equalsIgnoreCase(md->getDescriptor())))
if (md->getType() == type && md->getLength() == length && (descriptor.isEmpty() ||
(fullDescriptor ? descriptor.equalsIgnoreCase(md->getDescriptor()) : StringArray::fromTokens(md->getDescriptor(),".","").contains(descriptor,true))))
return i;
}
return -1;
......
......@@ -176,7 +176,7 @@ public:
void addMetaData(const MetaDataDescriptor& desc, const MetaDataValue& val);
const MetaDataDescriptor* getMetaDataDescriptor(int index) const;
const MetaDataValue* getMetaDataValue(int index) const;
int findMetaData(MetaDataDescriptor::MetaDataTypes type, unsigned int length, String descriptor = String::empty) const;
int findMetaData(MetaDataDescriptor::MetaDataTypes type, unsigned int length, String descriptor = String::empty, bool fullDescriptor = true) const;
const int getMetaDataCount() const;
protected:
MetaDataDescriptorArray m_metaDataDescriptorArray;
......
......@@ -183,6 +183,9 @@ void SourceNode::createEventChannels()
if (nChans > 0)
{
EventChannel* chan = new EventChannel(EventChannel::TTL, nChans, 0, dataThread->getSampleRate(i), this, i);
chan->setName(getName() + " source TTL events input");
chan->setDescription("TTL Events coming from the hardware source processor \"" + getName() + "\"");
chan->setDescriptor("sourceevent.ttl");
eventChannelArray.add(chan);
ttlChannels.add(chan);
}
......
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