AnimatLab  2
Test
Link.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 
12 #include "Node.h"
13 #include "Link.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
16 #include "BoundingBox.h"
17 #include "MovableItem.h"
18 #include "BodyPart.h"
19 #include "Link.h"
20 #include "Gain.h"
21 #include "Adapter.h"
22 #include "Joint.h"
23 #include "ReceptiveField.h"
24 #include "ContactSensor.h"
25 #include "RigidBody.h"
26 #include "Structure.h"
27 #include "NeuralModule.h"
28 #include "NervousSystem.h"
29 #include "Organism.h"
30 #include "ActivatedItem.h"
31 #include "ActivatedItemMgr.h"
32 #include "DataChartMgr.h"
33 #include "ExternalStimuliMgr.h"
34 #include "KeyFrame.h"
35 #include "SimulationRecorder.h"
36 #include "OdorType.h"
37 #include "Odor.h"
38 #include "Light.h"
39 #include "LightManager.h"
40 #include "Simulator.h"
41 
42 
43 namespace AnimatSim
44 {
52 {
53  m_lpOrganism = NULL;
54 
55  m_bEnabled = true;
56  m_fltEnabled = 0;
57 }
58 
66 {
67 
68 try
69 {
70 }
71 catch(...)
72 {Std_TraceMsg(0, "Caught Error in desctructor of Link\r\n", "", -1, false, true);}
73 }
74 
83 bool Link::Enabled() {return m_bEnabled;};
84 
93 void Link::Enabled(bool bValue)
94 {
95  m_bEnabled = bValue;
96  m_fltEnabled = (float) m_bEnabled;
97 }
98 
106 {}
107 
108 void Link::SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
109 {
110  AnimatBase::SetSystemPointers(lpSim, lpStructure, lpModule, lpNode, false);
111 
112  m_lpOrganism = dynamic_cast<Organism *>(lpStructure);
113 
114  if(bVerify) VerifySystemPointers();
115 }
116 
118 {
120 
121  if(!m_lpStructure)
122  THROW_PARAM_ERROR(Al_Err_lStructureNotDefined, Al_Err_strStructureNotDefined, "Link: ", m_strID);
123 
124  if(!m_lpOrganism)
125  THROW_PARAM_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "Link: ", m_strID);
126 
127  if(!m_lpModule)
128  THROW_PARAM_ERROR(Al_Err_lNeuralModuleNotDefined, Al_Err_strNeuralModuleNotDefined, "Link: ", m_strID);
129 
130  if(!m_lpNode)
131  THROW_PARAM_ERROR(Al_Err_lNodeNotDefined, Al_Err_strNodeNotDefined, "Link: ", m_strID);
132 }
133 
134 bool Link::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
135 {
136  std::string strType = Std_CheckString(strDataType);
137 
138  if(AnimatBase::SetData(strType, strValue, false))
139  return true;
140 
141  if(strType == "ENABLED")
142  {
143  Enabled(Std_ToBool(strValue));
144  return true;
145  }
146 
147  //If it was not one of those above then we have a problem.
148  if(bThrowError)
149  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
150 
151  return false;
152 }
153 
154 void Link::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
155 {
156  AnimatBase::QueryProperties(aryProperties);
157 
158  aryProperties.Add(new TypeProperty("Enabled", AnimatPropertyType::Boolean, AnimatPropertyDirection::Both));
159 }
160 
161 } //AnimatSim
Base class file for all Animat simulation objects.
Declares the nervous system class.
Declares the simulation recorder class.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
Simulates the entire environment.
Definition: Simulator.h:31
Root namespace for the base simulation library for AnimatLab.
AnimatSim::Behavior::NeuralModule * m_lpModule
The pointer to this items parentNeuralModule. If this is not relevant for this object then this is NU...
Definition: AnimatBase.h:49
Declares the body part class.
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
Declares the key frame class.
Declares the joint class.
Declares the organism class.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:46
std::string m_strID
The unique Id for this object.
Definition: AnimatBase.h:55
Declares a light object.
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
Declares the gain base class.
Node * m_lpNode
The pointer to this items parent Node. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:52
A "static" structure in the simulation.
Definition: Structure.h:84
Declares the node class.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Definition: AnimatBase.cpp:447
bool Std_ToBool(int iVal)
Converts a value toa bool.
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.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
Definition: AnimatBase.h:40
A dynamic organism that is controlled by a neural network.
Definition: Organism.h:31
Base class for body parts and neural network nodes.
Definition: Node.h:25
Declares the data chart manager class.
Declares the rigid body class.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
Declares the structure class.
Declares the odor type class.
virtual void VerifySystemPointers()
Verify that system pointers have been set correctly.
Definition: AnimatBase.cpp:315
Declares the odor class.
Declares the simulator class.
Declares the neural module class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Definition: AnimatBase.cpp:371
Declares the receptive field class.