AnimatLab  2
Test
Adapter.h
1 #pragma once
2 
3 namespace AnimatSim
4 {
5 
15  namespace Adapters
16  {
17 
21  {
22  NoDelayBuffer,
23  DelayBufferInSimOnly,
24  DelayBufferAlwaysOn
25  };
26 
39  class ANIMAT_PORT Adapter : public Node
40  {
41  protected:
43  std::string m_strSourceModule;
44 
46  std::string m_strSourceID;
47 
49  std::string m_strSourceDataType;
50 
53 
56 
58  std::string m_strTargetModule;
59 
61  std::string m_strTargetID;
62 
66  std::string m_strTargetDataType;
67 
70 
73 
75  Gain *m_lpGain;
76 
80 
83 
85  float m_fltNextVal;
86 
87  //Determines whether this adapter uses a delay buffer.
88  eDelayBufferMode m_eDelayBufferMode;
89 
90  //The duration of the delay buffer.
91  float m_fltDelayBufferInterval;
92 
95  CStdCircularArray<float> m_aryDelayBuffer;
96 
101 
104 
107 
112 
115 
118 
121 
128 
132 
135 
136  virtual void AddGain(std::string strXml);
137  virtual void SetOriginID(std::string strXml);
138  virtual void SetDestinationID(std::string strXml);
139 
140  virtual void SetDelayBufferSize();
141 
142  virtual bool NeedsRobotSynch();
143 
144  virtual void ApplyExternalNodeInput(int iTargetDataType, float fltNextVal);
145 
146  public:
147  Adapter();
148  virtual ~Adapter();
149 
150  static Adapter *CastToDerived(AnimatBase *lpBase) {return static_cast<Adapter*>(lpBase);}
151 
152  virtual std::string SourceModule();
153  virtual void SourceModule(std::string strName);
154 
155  virtual std::string SourceID();
156  virtual void SourceID(std::string strID);
157 
158  virtual std::string SourceDataType();
159  virtual void SourceDataType(std::string strType);
160 
161  virtual Node *SourceNode();
162 
163  virtual std::string TargetModule();
164  virtual void TargetModule(std::string strName);
165 
166  virtual std::string TargetID();
167  virtual void TargetID(std::string strID);
168 
169  virtual std::string TargetDataType();
170  virtual void TargetDataType(std::string strType);
171 
172  virtual Node *TargetNode();
173 
174  virtual Gain *GetGain();
175  virtual void SetGain(Gain *lpGain);
176 
177  virtual bool ConnectedToPhysics();
178 
179  virtual eDelayBufferMode DelayBufferMode();
180  virtual void DelayBufferMode(eDelayBufferMode eMode);
181 
182  virtual float DelayBufferInterval();
183  virtual void DelayBufferInterval(float fltVal);
184 
185  virtual void DetachAdaptersFromSimulation();
186 
187  virtual float RobotIOScale();
188  virtual void RobotIOScale(float fltVal);
189 
190  virtual bool SynchWithRobot();
191  virtual void SynchWithRobot(bool bVal);
192 
193  virtual float SynchUpdateInterval();
194  virtual void SynchUpdateInterval(float fltVal);
195 
196  virtual float SynchUpdateStartInterval();
197  virtual void SynchUpdateStartInterval(float fltVal);
198 
199  virtual float InitIODisableDuration();
200  virtual void InitIODisableDuration(float fltVal);
201 
202  virtual void Initialize();
203  virtual void TimeStepModified();
204  virtual void ResetSimulation();
205  virtual void AddExternalNodeInput(int iTargetDataType, float fltInput);
206  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
207  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
208  virtual float *GetDataPointer(const std::string &strDataType);
209  virtual void StepSimulation();
210  virtual void Load(CStdXml &oXml);
211  };
212 
213  } //Adapters
214 } //AnimatSim
Gain * m_lpGain
Pointer to the Gain that will be used to convert the source value into the target value...
Definition: Adapter.h:75
Root namespace for the base simulation library for AnimatLab.
std::string m_strSourceModule
Name of the source NeuralModule.
Definition: Adapter.h:43
float m_fltUpdatedValue
Set to 1 each time the adapter was updated and 0 otherwise. Use to chart when the adpater was updated...
Definition: Adapter.h:134
float m_fltCalculatedVal
This is the value that will was calculated for this adpater. If you are using a delay buffer this may...
Definition: Adapter.h:82
CStdCircularArray< float > m_aryDelayBuffer
Definition: Adapter.h:95
std::string m_strSourceDataType
DateType of the source variable that will be converted. This is retrieved using the GetDataPointer me...
Definition: Adapter.h:49
std::string m_strTargetDataType
Definition: Adapter.h:66
Node * m_lpSourceNode
Pointer to the source node.
Definition: Adapter.h:52
std::string m_strTargetModule
Name of the target NeuralModule.
Definition: Adapter.h:58
std::string m_strSourceID
GUID ID of the source node.
Definition: Adapter.h:46
std::string m_strTargetID
GUID ID of the target node.
Definition: Adapter.h:61
Node * m_lpTargetNode
Pointer to the target node.
Definition: Adapter.h:72
int m_iSynchTarget
The target count for synching.
Definition: Adapter.h:117
int m_iSynchUpdateStartInterval
The number of ticks between the first call to update for this adapter till the next update time...
Definition: Adapter.h:114
Animat base class.
Definition: AnimatBase.h:36
float * m_lpSourceData
Pointer to the source data varaible.
Definition: Adapter.h:55
int m_iSynchCount
Keeps track of the last time we did a synch for the robot.
Definition: Adapter.h:120
Base class for body parts and neural network nodes.
Definition: Node.h:25
float m_fltSynchUpdateInterval
This is how often we need to update this particular adapter.
Definition: Adapter.h:103
float m_fltNextVal
This is the value that will be passed into the adpters target.
Definition: Adapter.h:85
int m_iTargetDataType
The m_strTargetDataType string is converted to an integer for use within the simulation loop to maxim...
Definition: Adapter.h:69
int m_iSynchUpdateInterval
The number of ticks between each call to update for this adapter till the next update time...
Definition: Adapter.h:106