AnimatLab  2
Test
HiM110Actuator.cpp
1 // HiM110Actuator.cpp: implementation of the HiM110Actuator class.
2 //
4 
5 #include "StdAfx.h"
6 #include <stdarg.h>
7 #include "HiC884Controller.h"
8 #include "HiM110Actuator.h"
9 
10 namespace HybridInterfaceSim
11 {
12  namespace Robotics
13  {
14 
16 // Construction/Destruction
18 
19 HiM110Actuator::HiM110Actuator()
20 {
21 }
22 
23 HiM110Actuator::~HiM110Actuator()
24 {
25  try
26  {
27  }
28  catch(...)
29  {Std_TraceMsg(0, "Caught Error in desctructor of HiM110Actuator\r\n", "", -1, false, true);}
30 }
31 
32 #pragma region DataAccesMethods
33 
34 float *HiM110Actuator::GetDataPointer(const std::string &strDataType)
35 {
36  std::string strType = Std_CheckString(strDataType);
37 
38  //if(strType == "READPARAMTIME")
39  // return &m_fltReadParamTime;
40  //else
41  return RobotPartInterface::GetDataPointer(strDataType);
42 }
43 
44 bool HiM110Actuator::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
45 {
46  std::string strType = Std_CheckString(strDataType);
47 
48  if(RobotPartInterface::SetData(strDataType, strValue, false))
49  return true;
50 
51  if(strType == "SERVOID")
52  {
53  //ServoID((int) atoi(strValue.c_str()));
54  return true;
55  }
56 
57  //If it was not one of those above then we have a problem.
58  if(bThrowError)
59  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
60 
61  return false;
62 }
63 
64 void HiM110Actuator::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
65 {
66  RobotPartInterface::QueryProperties(aryProperties);
67 
68  aryProperties.Add(new TypeProperty("ReadParamTime", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
69 
70  aryProperties.Add(new TypeProperty("ServoID", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
71 }
72 
73 #pragma endregion
74 
75 
77 {
78  RobotPartInterface::Initialize();
79 
80  //m_lpHinge = dynamic_cast<Hinge *>(m_lpPart);
81  m_lpParentC884 = dynamic_cast<HiC884Controller *>(m_lpParentIOControl);
82 }
83 
85 {
86  //Put setup code here if needed.
87 }
88 
89 void HiM110Actuator::StepIO(int iPartIdx)
90 {
91  //Send actual move commands here.
92 }
93 
95 {
96  //If you need to do motor specific shutdown it goes here.
97 }
98 
100 {
101  RobotPartInterface::StepSimulation();
102 
103  //Transfer data from the motor back to the sim and
104  //sim data that will go to the motor here.
105 }
106 
108 {
110 }
111 
113 {
114  RobotPartInterface::Load(oXml);
115 
116  oXml.IntoElem();
117 
118  oXml.OutOfElem();
119 }
120 
121  } // Robotics
122 } //HybridInterfaceSim
123 
virtual void StepIO(int iPartIdx)
This method is used to send/recieve the actual IO. This will often be in a seperate thread than the S...
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void Initialize()
Initializes this object.
A standard xml manipulation class.
Definition: StdXml.h:19
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.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void SetupIO()
This method is called after all connections to whatever control board have been made. It is meant to be used to setup connection information specific to this part. For example, We connect to a Firmata microcontroller like an Arduino, and then do a setup that could take some time. We should not attempt to setup any of the pins until after the board itself has been setup. After that we need to loop through and setup all the parts. That is what this method is for.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
virtual void ShutdownIO()
This method is called just before the IO thread is closed down. It gives the IO objects a chance to d...
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual void StepSimulation()
Step the simulation for this object.