AnimatLab  2
Test
RobotIOControl.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 namespace AnimatSim
10 {
11  namespace Robotics
12  {
13 
34  class ANIMAT_PORT RobotIOControl : public AnimatBase
35  {
36  protected:
39 
42  CStdPtrArray<RobotPartInterface> m_aryParts;
43 
46 
49 
52 
54  bool m_bStopIO;
55 
57  bool m_bPauseIO;
58 
61 
64 
67 
70 
71  //Temporary if def to prevent this from showing up in ManagedAnimatTools. Will get rid of this
72  //once I get rid of that library.
73 #ifndef STD_DO_NOT_ADD_BOOST
74  boost::thread m_ioThread;
76 
78  boost::interprocess::interprocess_mutex m_WaitForIOSetupMutex;
79 
81  boost::interprocess::interprocess_condition m_WaitForIOSetupCond;
82 #endif
83 
86 
87  virtual RobotPartInterface *LoadPartInterface(CStdXml &oXml);
88  virtual RobotPartInterface *AddPartInterface(std::string strXml);
89  virtual void RemovePartInterface(std::string strID, bool bThrowError = true);
90  virtual int FindChildListPos(std::string strID, bool bThrowError = true);
91 
92  virtual void StartIOThread();
93  virtual void ProcessIO();
94  virtual void ExitIOThread();
95  virtual bool OpenIO() = 0;
96  virtual void CloseIO() = 0;
97 
98  virtual void WaitWhilePaused();
99  virtual void WaitTillPaused();
100  virtual void WaitForThreadNotifyReady();
101  virtual void StartPause();
102  virtual void ExitPause();
103 
104  public:
105  RobotIOControl(void);
106  virtual ~RobotIOControl(void);
107 
108  static RobotIOControl *CastToDerived(AnimatBase *lpBase) {return static_cast<RobotIOControl*>(lpBase);}
109 
110  virtual void ParentInterface(RobotInterface *lpParent);
111  virtual RobotInterface *ParentInterface();
112 
113  virtual CStdPtrArray<RobotPartInterface>* Parts();
114 
115  virtual void PauseIO(bool bVal);
116  virtual bool PauseIO();
117  virtual bool IOPaused();
118 
119  virtual float StepIODuration();
120 
121  virtual float *GetDataPointer(const std::string &strDataType);
122  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
123  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
124  virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError = true, bool bDoNotInit = false);
125  virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError = true);
126 
127  virtual void SetupIO();
128  virtual void StepIO();
129  virtual void ShutdownIO();
130 
131  virtual void Initialize();
132  virtual void SimStopping();
133  virtual void StepSimulation();
134  virtual void ResetSimulation();
135  virtual void AfterResetSimulation();
136  virtual void Load(CStdXml &oXml);
137  };
138 
139  }
140 }
Root namespace for the base simulation library for AnimatLab.
boost::interprocess::interprocess_condition m_WaitForIOSetupCond
Condition used to determine when the IO is setup.
bool m_bStopIO
Flags the thread processing loop to exit.
bool m_bWaitingForThreadNotify
Used to signal to the IO thread that we are waiting for their return signal.
RobotInterface * m_lpParentInterface
Pointer to the parent robot interface.
A Robot IO controller base class.
bool m_bIOPaused
Is set to true once the IO loop is paused.
CStdPtrArray< RobotPartInterface > m_aryParts
Animat base class.
Definition: AnimatBase.h:36
bool m_bPauseIO
Set to true to pause the IO processing. Set back to false to resume it.
int m_iCyclePartIdx
The index of the part that should be processed on the current step.
int m_iCyclePartCount
The total number of parts that are part of any round robin cycle of updates.
boost::interprocess::interprocess_mutex m_WaitForIOSetupMutex
Mutex responsible for waiting until the IO is finished setting up.
float m_fltStepIODuration
The time it takes to perform a step of the IO for all parts in this control.
bool m_bIOThreadProcessing
True while the io thread processing loop is going on.
bool m_bSetupComplete
Set to true once the IO is setup correctly.
The Robotics interface configures a simulation to run on a microcontroller board. ...
bool m_bSetupStarted
Set to true once the IO begins its setup.