AnimatLab  2
Test
ModulateNeuronPropSynapse.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 
9 #include "Synapse.h"
10 #include "ModulateNeuronPropSynapse.h"
11 #include "Neuron.h"
12 #include "FiringRateModule.h"
13 
14 namespace FiringRateSim
15 {
16  namespace Synapses
17  {
18 
26 {
27  m_lpGain = NULL;
28  m_lpPropertyData = NULL;
29 }
30 
38 {
39 
40 try
41 {
42  if(m_lpGain) delete m_lpGain;
43 }
44 catch(...)
45 {Std_TraceMsg(0, "Caught Error in desctructor of ModulateNeuronPropSynapse\r\n", "", -1, false, true);}
46 }
47 
56 void ModulateNeuronPropSynapse::ModulationGain(AnimatSim::Gains::Gain *lpGain)
57 {
58  if(lpGain)
59  {
60  if(m_lpGain)
61  {delete m_lpGain; m_lpGain = NULL;}
62  m_lpGain = lpGain;
63  }
64 }
65 
74 void ModulateNeuronPropSynapse::ModulationGain(std::string strXml)
75 {
76  CStdXml oXml;
77  oXml.Deserialize(strXml);
78  oXml.FindElement("Root");
79  oXml.FindChildElement("Gain");
80  ModulationGain(AnimatSim::Gains::LoadGain(m_lpSim, "Gain", oXml));
81 }
82 
91 void ModulateNeuronPropSynapse::PropertyName(std::string strPropName)
92 {
93  m_strPropertyName = strPropName;
94 
95  //Reset the property name so we can get the property type setup correctly.
96  //If it is not set then we need to assume that they will set it later.
97  //Make sure the property type is set to invalid so the step sim method knows this.
98  if(m_lpToNeuron && !Std_IsBlank(strPropName))
100 }
101 
111 {return m_strPropertyName;}
112 
114 {
116 
119 }
120 
121 #pragma region DataAccesMethods
122 
123 bool ModulateNeuronPropSynapse::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
124 {
125  std::string strType = Std_CheckString(strDataType);
126 
127  if(Link::SetData(strDataType, strValue, false))
128  return true;
129 
130  if(strType == "GAIN")
131  {
132  ModulationGain(strValue);
133  return true;
134  }
135 
136  if(strType == "PROPERTYNAME")
137  {
138  PropertyName(strValue);
139  return true;
140  }
141 
142  //If it was not one of those above then we have a problem.
143  if(bThrowError)
144  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
145 
146  return false;
147 }
148 
157 void ModulateNeuronPropSynapse::Process(float &fltCurrent)
158 {
159  if(m_lpPropertyData)
160  {
161  float fltFF = this->FromNeuron()->FiringFreq(m_lpFRModule);
162  float fltScaled = m_lpGain->CalculateGain(fltFF);
163  *m_lpPropertyData = fltScaled;
164  }
165 }
166 
167 void ModulateNeuronPropSynapse::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
168 {
169  Synapse::QueryProperties(aryProperties);
170 
171  aryProperties.Add(new TypeProperty("Gain", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
172  aryProperties.Add(new TypeProperty("PropertyName", AnimatPropertyType::String, AnimatPropertyDirection::Set));
173 }
174 
175 #pragma endregion
176 
178 {
179 }
180 
181 void ModulateNeuronPropSynapse::Load(CStdXml &oXml)
182 {
183  Synapse::Load(oXml);
184 
185  oXml.IntoElem();
186 
187  ModulationGain(AnimatSim::Gains::LoadGain(m_lpSim, "Gain", oXml));
188  PropertyName(oXml.GetChildString("PropertyName", ""));
189 
190  oXml.OutOfElem(); //OutOf Synapse Element
191 }
192 
193 
194  } //Synapses
195 } //FiringRateSim
196 
197 
198 
199 
200 
201 
Neuron * m_lpToNeuron
The pointer to post-synaptic neuron.
Definition: Synapse.h:51
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual void Initialize()
Initializes this object.
Definition: Synapse.cpp:348
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual void ResetSimulation()
Resets the simulation back to time 0.
std::string m_strPropertyName
The name of the property we are modulating.
The Gain base class.
Definition: Gain.h:35
AnimatSim::Gains::Gain * m_lpGain
Pointer to the graph used to calculate the hi current.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual float FiringFreq(FiringRateModule *lpModule)
Calculates the current firing frequency.
Declares the synapse class.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
Declares the firing rate module class.
virtual void Process(float &fltCurrent)
Processes this synapse.
Neuron * FromNeuron()
Gets the pre-synaptic neuron.
Definition: Synapse.h:77
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
FiringRateModule * m_lpFRModule
Pointer to parent FiringRateModule.
Definition: Synapse.h:33
Contains the classes for a firing rate neural model.
float * m_lpPropertyData
Pointer to the property we are modulating.
virtual float CalculateGain(float fltInput)=0
Calculates the gain.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual std::string PropertyName()
Gets the name of the property that this adapter will be setting.
Gain * LoadGain(Simulator *lpSim, std::string strName, CStdXml &oXml)
Loads a gain object.
Definition: Gain.cpp:287