AnimatLab  2
Test
HiC884Controller.cpp
1 // HiC884Controller.cpp: implementation of the HiC884Controller 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 HiC884Controller::HiC884Controller()
20 {
21  m_iPortNumber = 3;
22 }
23 
24 HiC884Controller::~HiC884Controller()
25 {
26  try
27  {
28  }
29  catch(...)
30  {Std_TraceMsg(0, "Caught Error in desctructor of HiC884Controller\r\n", "", -1, false, true);}
31 }
32 
33 void HiC884Controller::PortNumber(int iPort)
34 {
35  Std_IsAboveMin((int) 0, iPort, true, "PortNumber", true);
36  m_iPortNumber = iPort;
37 }
38 
39 int HiC884Controller::PortNumber() {return m_iPortNumber;}
40 
41 #pragma region DataAccesMethods
42 
43 float *HiC884Controller::GetDataPointer(const std::string &strDataType)
44 {
45  std::string strType = Std_CheckString(strDataType);
46 
47  return RobotIOControl::GetDataPointer(strDataType);
48 }
49 
50 bool HiC884Controller::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
51 {
52  std::string strType = Std_CheckString(strDataType);
53 
54  if(RobotIOControl::SetData(strDataType, strValue, false))
55  return true;
56 
57  if(strType == "PORTNUMBER")
58  {
59  PortNumber((int) atoi(strValue.c_str()));
60  return true;
61  }
62 
63  //If it was not one of those above then we have a problem.
64  if(bThrowError)
65  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
66 
67  return false;
68 }
69 
70 void HiC884Controller::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
71 {
72  RobotIOControl::QueryProperties(aryProperties);
73 
74  aryProperties.Add(new TypeProperty("PortNumber", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
75 }
76 
77 #pragma endregion
78 
80 {
81  OpenIO();
82 
83  StartIOThread();
84 
85  RobotIOControl::Initialize();
86 }
87 
88 bool HiC884Controller::OpenIO()
89 {
90  //Open acuator communications ports here
91  return true;
92 }
93 
94 void HiC884Controller::CloseIO()
95 {
96  //Close acuator communications ports here
97 }
98 
100 {
101  RobotIOControl::Load(oXml);
102 
103  oXml.IntoElem();
104  PortNumber(oXml.GetChildInt("PortNumber", m_iPortNumber));
105  oXml.OutOfElem();
106 }
107 
108 
109  } // Robotics
110 } //HybridInterfaceSim
111 
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 bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
Definition: StdXml.cpp:456
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
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 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 Initialize()
Initializes this object.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.