12 #include "ClassFactory.h"
42 {
Std_TraceMsg(0,
"Caught Error in desctructor of FiringRateModule\r\n",
"", -1,
false,
true);}
111 for(
int iIndex=0; iIndex<iCount; iIndex++)
132 for(
int iIndex=0; iIndex<iCount; iIndex++)
137 THROW_TEXT_ERROR(Nl_Err_lNeuronNotFound, Nl_Err_strNeuronNotFound,
"ID");
144 NeuralModule::ResetSimulation();
147 for(
int iIndex=0; iIndex<iCount; iIndex++)
154 NeuralModule::Initialize();
156 Organism *lpOrganism =
dynamic_cast<Organism *
>(
m_lpStructure);
158 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
161 for(
int iIndex=0; iIndex<iCount; iIndex++)
168 NeuralModule::StepSimulation();
171 for(
int iIndex=0; iIndex<iCount; iIndex++)
179 #pragma region DataAccesMethods
185 if(NeuralModule::SetData(strDataType, strValue,
false))
188 if(strType ==
"TIMESTEP")
196 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
201 void FiringRateModule::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
203 NeuralModule::QueryProperties(aryProperties);
205 aryProperties.Add(
new TypeProperty(
"TimeStep", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
219 oXml.Deserialize(strXml);
220 oXml.FindElement(
"Root");
221 oXml.FindChildElement(
"Neuron");
247 if(strType ==
"NEURON")
257 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
266 if(strType ==
"NEURON")
276 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
287 for(
int iIndex=0; iIndex<iCount; iIndex++)
289 lByteSize +=
m_aryNeurons[iIndex]->CalculateSnapshotByteSize();
297 for(
int iIndex=0; iIndex<iCount; iIndex++)
299 m_aryNeurons[iIndex]->SaveKeyFrameSnapshot(aryBytes, lIndex);
305 for(
int iIndex=0; iIndex<iCount; iIndex++)
307 m_aryNeurons[iIndex]->LoadKeyFrameSnapshot(aryBytes, lIndex);
311 void FiringRateModule::Load(CStdXml &oXml)
329 TRACE_DEBUG(
"Finished loading nervous system config file.");
342 short iNeuron, iTotalNeurons;
351 m_fltTimeStep = oXml.GetChildFloat(
"TimeStep", m_fltTimeStep);
357 oXml.IntoChildElement(
"Neurons");
359 iTotalNeurons = oXml.NumberOfChildren();
360 for(iNeuron=0; iNeuron<iTotalNeurons; iNeuron++)
362 oXml.FindChildByIndex(iNeuron);
391 strType = oXml.GetChildString(
"Type");
396 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Neuron");
399 lpNeuron->Load(oXml);
404 catch(CStdErrorInfo oError)
406 if(lpNeuron)
delete lpNeuron;
412 if(lpNeuron)
delete lpNeuron;
413 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
CStdArray< Adapter * > m_arySourceAdapters
An array of source adapters for this module.
bool InactiveArray()
Gets the inactive array.
virtual void Initialize()
Initializes this object.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
virtual float TimeStep()
Gets the time step for this moudle in time units.
IStdClassFactory * m_lpClassFactory
The pointer to the class factory for this module.
virtual std::string Type()
returns the string type name of this object.
Simulator * m_lpSim
The pointer to a Simulation.
virtual std::string ID()
Gets the unique GUID ID of this object.
void LoadNetworkXml(CStdXml &oXml)
Loads the network configuration.
virtual void StepSimulation()
Step the simulation for this object.
virtual ~FiringRateModule()
Destructor.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
std::string m_strID
The unique Id for this object.
std::string Std_Trim(std::string strVal)
Trims a string.
virtual void RemoveNeuron(std::string strID, bool bThrowError=true)
Removes the neuron with the specified ID.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
CStdArray< Adapter * > m_aryTargetAdapters
An array of target adapters for this module.
virtual std::string Name()
Gets the name of this object.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Firing Rate Neuron model.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
virtual void LoadExternalSynapses(CStdXml &oXml)
Loads external synapses.
CStdPtrArray< Neuron > m_aryNeurons
The array of neurons in this module.
Firing rate neural module class factory.
virtual void AddNeuron(std::string strXml, bool bDoNotInit=false)
Adds a neuron to the module.
Declares the synapse class.
FiringRateModule()
Default constructor.
Neuron * LoadNeuron(CStdXml &oXml)
Loads a neuron.
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.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
virtual void Kill(bool bState=true)
Kills.
Declares the firing rate module class.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual void Initialize()
Initializes this object.
bool ActiveArray()
Gets the active array.
Contains the classes for a firing rate neural model.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
float m_fltTimeStep
The DT time step for this neural module in seconds.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
virtual std::string ModuleName()
Gets the module name.
std::string m_strType
The type for this object. Examples are Box, Plane, Neuron, etc..
virtual void AddToObjectList(AnimatBase *lpItem)
Adds an object to the list of all simulation objects.
std::string m_strName
The name for this object.
virtual int FindNeuronListPos(std::string strID, bool bThrowError=true)
Searches for the neuron with the specified ID and returns its position in the list.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.