AnimatLab  2
Test
ExternalStimulus.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 <sys/types.h>
13 #include <sys/stat.h>
14 #include "Gain.h"
15 #include "Node.h"
16 #include "Link.h"
17 #include "IPhysicsMovableItem.h"
18 #include "IPhysicsBody.h"
19 #include "BoundingBox.h"
20 #include "MovableItem.h"
21 #include "BodyPart.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 "Adapter.h"
29 #include "NervousSystem.h"
30 #include "Organism.h"
31 #include "ActivatedItem.h"
32 #include "ActivatedItemMgr.h"
33 #include "DataChartMgr.h"
34 #include "ExternalStimulus.h"
35 #include "ExternalStimuliMgr.h"
36 #include "KeyFrame.h"
37 #include "SimulationRecorder.h"
38 #include "OdorType.h"
39 #include "Odor.h"
40 #include "Light.h"
41 #include "LightManager.h"
42 #include "Simulator.h"
43 
44 namespace AnimatSim
45 {
46  namespace ExternalStimuli
47  {
55 {
56 }
57 
65 {
66 }
67 
68 bool ExternalStimulus::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
69 {
70  std::string strType = Std_CheckString(strDataType);
71 
72  if(ActivatedItem::SetData(strDataType, strValue, bThrowError))
73  {
75  return true;
76  }
77 
78  //Value type tells whether this is using an equation or constant. This is determined in the
79  //derived class. Lets set this to true here just so we do not generate an exception.
80  if(strType == "VALUETYPE")
81  return true;
82 
83  //If it was not one of those above then we have a problem.
84  if(bThrowError)
85  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
86 
87  return false;
88 }
89 
90 void ExternalStimulus::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
91 {
92  ActivatedItem::QueryProperties(aryProperties);
93 
94  aryProperties.Add(new TypeProperty("ValueType", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
95 }
96 
98 {
99  ExternalStimulus *lpStimulus = dynamic_cast<ExternalStimulus *>(lpItem);
100 
101  if(!lpStimulus)
102  THROW_ERROR(Al_Err_lItemNotStimulusType, Al_Err_strItemNotStimulusType);
103 
104  if(m_lStartSlice < lpStimulus->m_lStartSlice)
105  return true;
106 
107  if( (m_lStartSlice == lpStimulus->m_lStartSlice) && (m_lEndSlice < lpStimulus->m_lEndSlice))
108  return true;
109 
110  return false;
111 }
112 
113  } //ExternalStimuli
114 } //AnimatSim
virtual void ReInitialize()
Re-initialize this object.
Declares the external stimulus base class.
Base class file for all Animat simulation objects.
Declares the nervous system class.
Declares the simulation recorder class.
long m_lEndSlice
The time slice where this item is deactived.
Definition: ActivatedItem.h:39
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
virtual ExternalStimuliMgr * GetExternalStimuliMgr()
Gets the external stimuli manager.
Definition: Simulator.cpp:410
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual bool operator<(ActivatedItem *lpItem)
Less-than comparison operator.
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Declares the key frame class.
Base class for all activated items.
Definition: ActivatedItem.h:27
Declares the joint class.
Declares the organism class.
Declares a light object.
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
Declares the gain base 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.
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
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.
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.
long m_lStartSlice
The time slice where this item becomes active.
Definition: ActivatedItem.h:36
Declares the receptive field 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.