AnimatLab  2
Test
RemoteControlLinkage.h
1 #pragma once
2 
3 namespace AnimatSim
4 {
5  namespace Robotics
6  {
7  class RemoteControl;
8 
9  class ANIMAT_PORT RemoteControlData
10  {
11  public:
13  std::string m_strProperty;
14  int m_iButtonID;
15  float m_fltStart;
16  float m_fltValue; // vertical stick movement = forward speed
17  float m_fltStop;
18  float m_fltPrev;
19  int m_iCount;
20  bool m_bStarted;
21  int m_iStartDir;
22 
27 
30 
32  {
33  m_iButtonID = -1;
34  m_iChangeSimStepCount = 5;
35  ClearData();
36  }
37 
38  RemoteControlData(std::string strName, int iButtonID, int iChangeSimStepCount)
39  {
40  m_strProperty = strName;
41  m_iButtonID = iButtonID;
42  m_iChangeSimStepCount = iChangeSimStepCount;
43  ClearData();
44  }
45 
46  void ClearData()
47  {
48  m_fltStart = 0;
49  m_fltValue = 0;
50  m_fltStop = 0;
51  m_fltPrev = 0;
52  m_iCount = 0;
53  m_bStarted = 0;
54  m_iSimStepped = 0;
55  m_iStartDir = 1;
56  }
57 
58  void CheckStartedStopped();
59  void ClearStartStops();
60  };
61 
62  class ANIMAT_PORT RemoteControlLinkage : public AnimatBase
63  {
64  protected:
67 
70 
73 
75  std::string m_strSourceID;
76 
78  std::string m_strTargetID;
79 
81  std::string m_strSourceDataTypeID;
82 
84  std::string m_strTargetDataTypeID;
85 
89 
91  std::string m_strPropertyName;
92 
95 
98 
101 
104 
107  bool m_bInLink;
108 
109  virtual float CalculateAppliedValue(float fltData) = 0;
110  virtual void ApplyValue(float fltData);
111 
112  public:
113  RemoteControlLinkage(void);
114  virtual ~RemoteControlLinkage(void);
115 
116  static RemoteControlLinkage *CastToDerived(AnimatBase *lpBase) {return static_cast<RemoteControlLinkage*>(lpBase);}
117 
120 
121  virtual void ParentRemoteControl(RemoteControl *lpParent);
122  virtual RemoteControl *ParentRemoteControl();
123 
124  virtual std::string SourceID();
125  virtual void SourceID(std::string strID);
126 
127  virtual std::string TargetID();
128  virtual void TargetID(std::string strID);
129 
130  virtual int PropertyID();
131  virtual void PropertyID(int iID, bool bCreateDataTypes = true);
132 
133  virtual std::string SourceDataTypeID();
134  virtual void SourceDataTypeID(std::string strTypeID);
135 
136  virtual std::string TargetDataTypeID();
137  virtual void TargetDataTypeID(std::string strTypeID);
138 
139  virtual std::string PropertyName();
140  virtual void PropertyName(std::string strName);
141 
142  virtual bool InLink();
143  virtual void InLink(bool bVal);
144 
145  virtual float AppliedValue();
146  virtual void AppliedValue(float fltVal);
147 
148  virtual float *GetDataPointer(const std::string &strDataType);
149  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
150  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
151 
152  virtual void SetupIO();
153  virtual void StepIO();
154  virtual void ShutdownIO();
155 
156  virtual void Initialize();
157  virtual void ResetSimulation();
158  virtual void StepSimulation();
159  virtual void Load(CStdXml &oXml);
160  };
161 
162  }
163 }
std::string m_strSourceDataTypeID
ID of the source data type. This is only used during loading.
Root namespace for the base simulation library for AnimatLab.
RemoteControlData m_Data
This is a set of data that is associated with this linkage.
AnimatBase * m_lpSource
Source object we are inserting from.
float * m_lpTargetData
Pointer to the external value of the linked target.
std::string m_strProperty
The array index of this button.
int m_iTargetDataType
integer index of the target data type
AnimatBase * m_lpTarget
Target object we are inserting into.
std::string m_strPropertyName
Name of the property that will be used for the data type if required.
std::string m_strSourceID
ID of the source. This is only used during loading.
int m_iChangeSimStepCount
The number of simulation time slices to keep a start/stop signal active.
Animat base class.
Definition: AnimatBase.h:36
float m_fltAppliedValue
The total value applied during a time step.
float * m_lpSourceData
Pointer to the source data variable.
std::string m_strTargetDataTypeID
ID of the target data type. This is only used during loading.
std::string m_strTargetID
ID of the target. This is only used during loading.
RemoteControl * m_lpParentRemoteControl
Pointer tho the parent remote control.