Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekateros::HekXmlCfg Class Reference

HekXmlCfg Hekateros XML configuration class. More...

#include <hekXmlCfg.h>

Inheritance diagram for hekateros::HekXmlCfg:

Public Member Functions

 HekXmlCfg ()
 Default constructor.
 
virtual ~HekXmlCfg ()
 Destructor.
 
virtual int load (HekDesc &desc, const std::string &strSearchPath=HekSysCfgPath, const std::string &strXmlFileName=HekEtcCfg, bool bAllInstances=false)
 Load XML file into DOM and set the Hekateros description. More...
 
virtual int loadFile (const std::string &strXmlFileName=HekEtcCfg)
 Load XML file into DOM. More...
 
virtual int loadFile (HekDesc &desc, const std::string &strXmlFileName=HekEtcCfg)
 Load XML file into DOM and set the Hekateros description. More...
 
virtual int saveFile (const std::string &strXmlFileName=HekEtcCfg)
 Save DOM to XML file. More...
 
virtual int saveFile (const HekDesc &desc, const std::string &strXmlFileName=HekEtcCfg)
 Set DOM from Hekateros description and save XML file. More...
 
virtual int createTemplateFile (const std::string &strXmlFileName=HekEtcCfg)
 Create a template Hekateros XML configuration file. More...
 
virtual int setHekDescFromDOM (HekDesc &desc)
 Set Hekateros description for DOM. More...
 
virtual int setDOMFromHekDesc (const HekDesc &desc)
 Set the DOM from the Hekateros description. More...
 

Protected Member Functions

virtual int setHekArmDescFromDOM (TiXmlElement *pElemMaj, HekDescArm *pDesc)
 Set Hekateros robotic base description from the DOM. More...
 
virtual int setHekEEDescFromDOM (TiXmlElement *pElemMaj, HekDescEE *pDesc)
 Set Hekateros end effector description for DOM. More...
 
int strToProdSizeCode (const std::string &str, int &val)
 Convert string to Hekateros product size code. More...
 
int prodSizeToStr (const int val, std::string &str)
 Convert product size to string equivalent. More...
 

Protected Attributes

std::string m_strMajElemArm
 robotic arm major element name
 
std::string m_strMajElemEE
 end effector major element name
 
std::string m_strAttrProdId
 product id attribute name
 
std::string m_strElemProdName
 product name element name
 
std::string m_strElemProdBrief
 product brief element name
 
std::string m_strElemProdHwVer
 product hardware version element name
 
std::string m_strElemProdDoF
 egrees of freedom element name
 
std::string m_strElemProdSize
 product size element name
 

Detailed Description

HekXmlCfg Hekateros XML configuration class.

Definition at line 73 of file hekXmlCfg.h.

Member Function Documentation

int HekXmlCfg::createTemplateFile ( const std::string &  strXmlFileName = HekEtcCfg)
virtual

Create a template Hekateros XML configuration file.

Any current DOM is not accessed nor altered.

Parameters
strXmlFileNameXML file path name.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 128 of file hekXmlCfg.cxx.

Referenced by saveFile().

129 {
130  FILE *fp;
131 
132  if( strXmlFileName.empty() )
133  {
134  setErrorMsg("No file name.");
135  LOGERROR("%s", m_bufErrMsg);
136  return -HEK_ECODE_XML;
137  }
138 
139  m_strXmlFileName = strXmlFileName;
140 
141  // open file
142  if( (fp = fopen(m_strXmlFileName.c_str(), "w+")) == NULL )
143  {
144  setErrorMsg("%s: %s(errno=%d).",
145  m_strXmlFileName.c_str(), strerror(errno), errno);
146  LOGERROR("%s", m_bufErrMsg);
147  return -HEK_ECODE_XML;
148  }
149 
150  makeXmlHead();
151  makeXmlTail();
152 
153  //
154  // XML head.
155  //
156  fprintf(fp, " <!-- RoadNarrows Hekateros Top-Level Configuration -->\n");
157  fprintf(fp, "%s", m_strXmlHead.c_str());
158 
159  //
160  // Robotic base major element.
161  //
162  fprintf(fp, " <!-- Hekateros robotic base -->\n");
163  fprintf(fp, " <%s product_id=\"PRODID\">\n", m_strMajElemArm.c_str());
164 
165  fprintf(fp, " <%s>PRODNAME</%s>\n",
166  m_strElemProdName.c_str(), m_strElemProdName.c_str());
167 
168  fprintf(fp, " <%s>\n PRODBRIEF\n </%s>\n",
169  m_strElemProdBrief.c_str(), m_strElemProdBrief.c_str());
170 
171  fprintf(fp, " <%s>PRODHWVER</%s>\n",
172  m_strElemProdHwVer.c_str(), m_strElemProdHwVer.c_str());
173 
174  fprintf(fp, " <%s>DOF</%s>\n",
175  m_strElemProdDoF.c_str(), m_strElemProdDoF.c_str());
176 
177  fprintf(fp, " <%s>PRODSIZE</%s>\n",
178  m_strElemProdSize.c_str(), m_strElemProdSize.c_str());
179 
180  fprintf(fp, " </%s>\n\n", m_strMajElemArm.c_str());
181 
182  //
183  // End effector major element.
184  //
185  fprintf(fp, " <!-- Hekateros end effector tool -->\n");
186  fprintf(fp, " <%s product_id=\"EEPRODID\">\n", m_strMajElemEE.c_str());
187 
188  fprintf(fp, " <%s>PRODNAME</%s>\n",
189  m_strElemProdName.c_str(), m_strElemProdName.c_str());
190 
191  fprintf(fp, " <%s>\n EEPRODBRIEF\n </%s>\n",
192  m_strElemProdBrief.c_str(), m_strElemProdBrief.c_str());
193 
194  fprintf(fp, " <%s>EEPRODHWVER</%s>\n",
195  m_strElemProdHwVer.c_str(), m_strElemProdHwVer.c_str());
196 
197  fprintf(fp, " <%s>EEDOF</%s>\n",
198  m_strElemProdDoF.c_str(), m_strElemProdDoF.c_str());
199 
200  fprintf(fp, " <%s>EEPRODSIZE</%s>\n",
201  m_strElemProdSize.c_str(), m_strElemProdSize.c_str());
202 
203  fprintf(fp, " </%s>\n\n", m_strMajElemEE.c_str());
204 
205 
206  //
207  // XML tail
208  //
209  fprintf(fp, "%s", m_strXmlTail.c_str());
210 
211  fclose(fp);
212 
213  LOGDIAG3("Created file %s.", m_strXmlFileName.c_str());
214 
215  return HEK_OK;
216 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
std::string m_strElemProdName
product name element name
Definition: hekXmlCfg.h:226
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
std::string m_strElemProdDoF
egrees of freedom element name
Definition: hekXmlCfg.h:229
std::string m_strMajElemEE
end effector major element name
Definition: hekXmlCfg.h:224
std::string m_strElemProdSize
product size element name
Definition: hekXmlCfg.h:230
std::string m_strElemProdHwVer
product hardware version element name
Definition: hekXmlCfg.h:228
std::string m_strMajElemArm
robotic arm major element name
Definition: hekXmlCfg.h:223
std::string m_strElemProdBrief
product brief element name
Definition: hekXmlCfg.h:227
int HekXmlCfg::load ( HekDesc desc,
const std::string &  strSearchPath = HekSysCfgPath,
const std::string &  strXmlFileName = HekEtcCfg,
bool  bAllInstances = false 
)
virtual

Load XML file into DOM and set the Hekateros description.

Parameters
[out]desc

Definition at line 69 of file hekXmlCfg.cxx.

References hekateros::split().

Referenced by ~HekXmlCfg().

73 {
74  vector<string> vecPath; // vector of search paths
75  string fqname; // fully qualified file name
76  bool bFoundInstance; // [not] found instance
77  size_t i; // working index
78  int rc; // return code
79 
80  split(strSearchPath, ':', vecPath);
81 
82  bFoundInstance = false;
83  rc = HEK_OK;
84 
85  for(i=0; i<vecPath.size(); ++i)
86  {
87  fqname = vecPath[i] + '/' + strXmlFileName;
88  if( access(fqname.c_str(), F_OK) == 0 )
89  {
90  LOGDIAG3("Loading Hekateros description XML file: %s.", fqname.c_str());
91 
92  bFoundInstance = true;
93 
94  if( (rc = Xml::loadFile(fqname)) < 0 )
95  {
96  LOGERROR("Parse of Hekateros description from XML file %s failed.",
97  fqname.c_str());
98  rc = -HEK_ECODE_XML;
99  }
100  else
101  {
102  rc = setHekDescFromDOM(desc);
103  }
104 
105  if( rc == HEK_OK )
106  {
107  LOGDIAG2("Hekateros description from XML file %s loaded.",
108  fqname.c_str());
109  }
110 
111  if( !bAllInstances )
112  {
113  break;
114  }
115  }
116  }
117 
118  if( !bFoundInstance )
119  {
120  LOGERROR("XML file %s not found.", strXmlFileName.c_str());
121  rc = -HEK_ECODE_XML;
122  }
123 
124  return rc;
125 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
virtual int setHekDescFromDOM(HekDesc &desc)
Set <b><i>Hekateros</i></b> description for DOM.
Definition: hekXmlCfg.cxx:218
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Split string at the delimiter character.
virtual int hekateros::HekXmlCfg::loadFile ( const std::string &  strXmlFileName = HekEtcCfg)
inlinevirtual

Load XML file into DOM.

Parameters
strXmlFileNameXML file path name.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 126 of file hekXmlCfg.h.

References hekateros::HEK_ECODE_XML, and hekateros::HEK_OK.

127  {
128  int rc;
129 
130  rc = Xml::loadFile(strXmlFileName);
131 
132  return rc < 0? -HEK_ECODE_XML: HEK_OK;
133  }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
virtual int hekateros::HekXmlCfg::loadFile ( HekDesc desc,
const std::string &  strXmlFileName = HekEtcCfg 
)
inlinevirtual

Load XML file into DOM and set the Hekateros description.

Parameters
desc

Definition at line 143 of file hekXmlCfg.h.

References hekateros::HEK_ECODE_XML, hekateros::HEK_OK, and setHekDescFromDOM().

145  {
146  int rc;
147 
148  if( (rc = Xml::loadFile(strXmlFileName)) == OK )
149  {
150  rc = setHekDescFromDOM(desc);
151  }
152 
153  return rc < 0? -HEK_ECODE_XML: HEK_OK;
154  }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
virtual int setHekDescFromDOM(HekDesc &desc)
Set <b><i>Hekateros</i></b> description for DOM.
Definition: hekXmlCfg.cxx:218
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
int HekXmlCfg::prodSizeToStr ( const int  val,
std::string &  str 
)
protected

Convert product size to string equivalent.

Parameters
[in]valProduct size enumerate.
[out]strConverted string equivalent.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 497 of file hekXmlCfg.cxx.

498 {
499  int rc = HEK_OK;
500 
501  switch(val)
502  {
503  case HekProdSizeUnknown:
504  str = "?";
505  break;
506  case HekProdSizeStd:
507  str = "N";
508  break;
509  case HekProdSizeShort:
510  str = "S";
511  break;
512  case HekProdSizeLong:
513  str = "L";
514  break;
515  default:
516  LOGERROR("%c: Unknown product size code.", val);
517  rc = -HEK_ECODE_XML;
518  break;
519  }
520 
521  return rc;
522 }
standard (normal) size
Definition: hekateros.h:230
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
virtual int hekateros::HekXmlCfg::saveFile ( const std::string &  strXmlFileName = HekEtcCfg)
inlinevirtual

Save DOM to XML file.

Parameters
strXmlFileNameXML file path name.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 163 of file hekXmlCfg.h.

References hekateros::HEK_ECODE_XML, and hekateros::HEK_OK.

164  {
165  int rc;
166 
167  rc = Xml::saveFile(strXmlFileName);
168 
169  return rc < 0? -HEK_ECODE_XML: HEK_OK;
170  }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
virtual int hekateros::HekXmlCfg::saveFile ( const HekDesc desc,
const std::string &  strXmlFileName = HekEtcCfg 
)
inlinevirtual

Set DOM from Hekateros description and save XML file.

Parameters
desc

Definition at line 180 of file hekXmlCfg.h.

References createTemplateFile(), hekateros::HEK_ECODE_XML, hekateros::HEK_OK, hekateros::HekEtcCfg, setDOMFromHekDesc(), and setHekDescFromDOM().

182  {
183  int rc;
184 
185  if( (rc = setDOMFromHekDesc(desc)) == HEK_OK )
186  {
187  rc = Xml::saveFile(strXmlFileName);
188  }
189 
190  return rc < 0? -HEK_ECODE_XML: HEK_OK;
191  }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
virtual int setDOMFromHekDesc(const HekDesc &desc)
Set the DOM from the <b><i>Hekateros</i></b> description.
Definition: hekXmlCfg.cxx:272
int HekXmlCfg::setDOMFromHekDesc ( const HekDesc desc)
virtual

Set the DOM from the Hekateros description.

Parameters
desc

Definition at line 272 of file hekXmlCfg.cxx.

Referenced by saveFile().

273 {
274  // TODO
275  return -HEK_ECODE_GEN;
276 }
static const int HEK_ECODE_GEN
general, unspecified error
Definition: hekateros.h:72
int HekXmlCfg::setHekArmDescFromDOM ( TiXmlElement *  pElemMaj,
HekDescArm pDesc 
)
protectedvirtual

Set Hekateros robotic base description from the DOM.

Parameters
pElemMajPointer to major DOM base description element.
pDescPoint to Hekateros robotic base description.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 278 of file hekXmlCfg.cxx.

279 {
280  TiXmlElement *pElem;
281  const char *sValue;
282  string str;
283  int eProdId;
284  string strProdName;
285  string strProdBrief;
286  string strHwVer;
287  int nDoF = 0;
288  int eProdSize = HekProdSizeUnknown;
289  int rc;
290 
291  if( (rc = strToInt(elemAttr(pElemMaj, m_strAttrProdId), eProdId)) < 0 )
292  {
293  setErrorMsg("%s: No %s attribute of <%s> found or value not an integer.",
294  m_strXmlFileName.c_str(),
295  m_strAttrProdId.c_str(),
296  m_strMajElemArm.c_str());
297  LOGERROR("%s", m_bufErrMsg);
298  return -HEK_ECODE_XML;
299  }
300 
301  // child elements
302  for(pElem = pElemMaj->FirstChildElement();
303  pElem != NULL;
304  pElem = pElem->NextSiblingElement())
305  {
306  if( (sValue = pElem->Value()) == NULL )
307  {
308  continue;
309  }
310 
311  // product name
312  else if( !strcasecmp(sValue, m_strElemProdName.c_str()) )
313  {
314  strProdName = elemText(pElem);
315  }
316 
317  // product brief
318  else if( !strcasecmp(sValue, m_strElemProdBrief.c_str()) )
319  {
320  strProdBrief = elemText(pElem);
321  }
322 
323  // product hardware version
324  else if( !strcasecmp(sValue, m_strElemProdHwVer.c_str()) )
325  {
326  strHwVer = elemText(pElem);
327  }
328 
329  // degrees of freedom
330  else if( !strcasecmp(sValue, m_strElemProdDoF.c_str()) )
331  {
332  str = elemText(pElem);
333  if( !str.empty() )
334  {
335  if( (rc = strToInt(str, nDoF)) < 0 )
336  {
337  setErrorMsg("%s: Element <%s> text \"%s\" not an integer.",
338  m_strXmlFileName.c_str(), m_strElemProdDoF.c_str(), str.c_str());
339  LOGERROR("%s", m_bufErrMsg);
340  return -HEK_ECODE_XML;
341  }
342  }
343  }
344 
345  // product size
346  else if( !strcasecmp(sValue, m_strElemProdSize.c_str()) )
347  {
348  str = elemText(pElem);
349  if( !str.empty() )
350  {
351  if( (rc = strToProdSizeCode(str, eProdSize)) < 0 )
352  {
353  setErrorMsg("%s: Element <%s> text \"%s\" not a recognized "
354  "product size.",
355  m_strXmlFileName.c_str(), m_strElemProdSize.c_str(), str.c_str());
356  LOGERROR("%s", m_bufErrMsg);
357  return -HEK_ECODE_XML;
358  }
359  }
360  }
361  }
362 
363  pDesc->setDesc(eProdId, strProdName, strProdBrief, strHwVer, nDoF, eProdSize);
364 
365  LOGDIAG3("%s: Hekateros robotic base description set.",
366  m_strXmlFileName.c_str());
367 
368  return HEK_OK;
369 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
std::string m_strElemProdName
product name element name
Definition: hekXmlCfg.h:226
std::string m_strAttrProdId
product id attribute name
Definition: hekXmlCfg.h:225
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
std::string m_strElemProdDoF
egrees of freedom element name
Definition: hekXmlCfg.h:229
std::string m_strElemProdSize
product size element name
Definition: hekXmlCfg.h:230
std::string m_strElemProdHwVer
product hardware version element name
Definition: hekXmlCfg.h:228
int strToProdSizeCode(const std::string &str, int &val)
Convert string to <b><i>Hekateros</i></b> product size code.
Definition: hekXmlCfg.cxx:464
std::string m_strMajElemArm
robotic arm major element name
Definition: hekXmlCfg.h:223
std::string m_strElemProdBrief
product brief element name
Definition: hekXmlCfg.h:227
int HekXmlCfg::setHekDescFromDOM ( HekDesc desc)
virtual

Set Hekateros description for DOM.

Parameters
desc

Definition at line 218 of file hekXmlCfg.cxx.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDesc::getEEDesc(), hekateros::HekDescEE::resetDesc(), and hekateros::HekDescArm::resetDesc().

Referenced by loadFile(), and saveFile().

219 {
220  HekDescArm *pDescArm;
221  HekDescEE *pDescEE;
222  TiXmlElement *pElem;
223  const char *sValue;
224  const char *sAttr;
225  const char *sText;
226  int n;
227  int rc;
228 
229  //
230  // Subsection descriptions.
231  //
232  pDescArm = desc.getArmDesc();
233  pDescEE = desc.getEEDesc();
234 
235  pDescArm->resetDesc();
236  pDescEE->resetDesc();
237 
238  if( m_pElemRoot == NULL )
239  {
240  setErrorMsg("Missing DOM and/or <%s> root element missing.",
241  m_strRootElemName.c_str());
242  LOGERROR("%s", m_bufErrMsg);
243  return -HEK_ECODE_XML;
244  }
245 
246  // search secion elements
247  for(pElem = m_pElemRoot->FirstChildElement();
248  pElem != NULL;
249  pElem = pElem->NextSiblingElement())
250  {
251  if( (sValue = pElem->Value()) == NULL )
252  {
253  continue;
254  }
255 
256  // robotic base description
257  else if( !strcasecmp(sValue, m_strMajElemArm.c_str()) )
258  {
259  setHekArmDescFromDOM(pElem, pDescArm);
260  }
261 
262  // end effecotr description
263  else if( !strcasecmp(sValue, m_strMajElemEE.c_str()) )
264  {
265  setHekEEDescFromDOM(pElem, pDescEE);
266  }
267  }
268 
269  return HEK_OK;
270 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
Hekateros end effector tool description class.
Definition: hekDescEE.h:71
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
void resetDesc()
Reset base description to the "unitialized" values.
Definition: hekDescArm.cxx:98
std::string m_strMajElemEE
end effector major element name
Definition: hekXmlCfg.h:224
Hekateros robotic arm (manipulator) description class.
Definition: hekDescArm.h:77
HekDescEE * getEEDesc()
Get the <b><i>Hekateros</i></b> end effector product description.
Definition: hekDesc.h:187
void resetDesc()
Reset base description to the "unitialized" values.
Definition: hekDescEE.cxx:97
std::string m_strMajElemArm
robotic arm major element name
Definition: hekXmlCfg.h:223
virtual int setHekEEDescFromDOM(TiXmlElement *pElemMaj, HekDescEE *pDesc)
Set <b><i>Hekateros</i></b> end effector description for DOM.
Definition: hekXmlCfg.cxx:371
virtual int setHekArmDescFromDOM(TiXmlElement *pElemMaj, HekDescArm *pDesc)
Set <b><i>Hekateros</i></b> robotic base description from the DOM.
Definition: hekXmlCfg.cxx:278
int HekXmlCfg::setHekEEDescFromDOM ( TiXmlElement *  pElemMaj,
HekDescEE pDesc 
)
protectedvirtual

Set Hekateros end effector description for DOM.

Parameters
pElemMajPointer to major DOM base description element.
pDescPoint to Hekateros end effector description.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 371 of file hekXmlCfg.cxx.

372 {
373  TiXmlElement *pElem;
374  const char *sValue;
375  string str;
376  int eProdId;
377  string strProdName;
378  string strProdBrief;
379  string strHwVer;
380  int nDoF = 0;
381  int eProdSize = HekProdSizeUnknown;
382  int rc;
383 
384  if( (rc = strToInt(elemAttr(pElemMaj, m_strAttrProdId), eProdId)) < 0 )
385  {
386  setErrorMsg("%s: No %s attribute of <%s> found or value not an integer.",
387  m_strXmlFileName.c_str(),
388  m_strAttrProdId.c_str(),
389  m_strMajElemArm.c_str());
390  LOGERROR("%s", m_bufErrMsg);
391  return -HEK_ECODE_XML;
392  }
393 
394  // child elements
395  for(pElem = pElemMaj->FirstChildElement();
396  pElem != NULL;
397  pElem = pElem->NextSiblingElement())
398  {
399  if( (sValue = pElem->Value()) == NULL )
400  {
401  continue;
402  }
403 
404  // product name
405  else if( !strcasecmp(sValue, m_strElemProdName.c_str()) )
406  {
407  strProdName = elemText(pElem);
408  }
409 
410  // product brief
411  else if( !strcasecmp(sValue, m_strElemProdBrief.c_str()) )
412  {
413  strProdBrief = elemText(pElem);
414  }
415 
416  // product hardware version
417  else if( !strcasecmp(sValue, m_strElemProdHwVer.c_str()) )
418  {
419  strHwVer = elemText(pElem);
420  }
421 
422  // degrees of freedom
423  else if( !strcasecmp(sValue, m_strElemProdDoF.c_str()) )
424  {
425  str = elemText(pElem);
426  if( !str.empty() )
427  {
428  if( (rc = strToInt(str, nDoF)) < 0 )
429  {
430  setErrorMsg("%s: Element <%s> text \"%s\" not an integer.",
431  m_strXmlFileName.c_str(), m_strElemProdDoF.c_str(), str.c_str());
432  LOGERROR("%s", m_bufErrMsg);
433  return -HEK_ECODE_XML;
434  }
435  }
436  }
437 
438  // product size
439  else if( !strcasecmp(sValue, m_strElemProdSize.c_str()) )
440  {
441  str = elemText(pElem);
442  if( !str.empty() )
443  {
444  if( (rc = strToProdSizeCode(str, eProdSize)) < 0 )
445  {
446  setErrorMsg("%s: Element <%s> text \"%s\" not a recognized "
447  "product size.",
448  m_strXmlFileName.c_str(), m_strElemProdSize.c_str(), str.c_str());
449  LOGERROR("%s", m_bufErrMsg);
450  return -HEK_ECODE_XML;
451  }
452  }
453  }
454  }
455 
456  pDesc->setDesc(eProdId, strProdName, strProdBrief, strHwVer, nDoF, eProdSize);
457 
458  LOGDIAG3("%s: Hekateros end effector description set.",
459  m_strXmlFileName.c_str());
460 
461  return HEK_OK;
462 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
std::string m_strElemProdName
product name element name
Definition: hekXmlCfg.h:226
std::string m_strAttrProdId
product id attribute name
Definition: hekXmlCfg.h:225
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
std::string m_strElemProdDoF
egrees of freedom element name
Definition: hekXmlCfg.h:229
std::string m_strElemProdSize
product size element name
Definition: hekXmlCfg.h:230
std::string m_strElemProdHwVer
product hardware version element name
Definition: hekXmlCfg.h:228
int strToProdSizeCode(const std::string &str, int &val)
Convert string to <b><i>Hekateros</i></b> product size code.
Definition: hekXmlCfg.cxx:464
std::string m_strMajElemArm
robotic arm major element name
Definition: hekXmlCfg.h:223
std::string m_strElemProdBrief
product brief element name
Definition: hekXmlCfg.h:227
int HekXmlCfg::strToProdSizeCode ( const std::string &  str,
int &  val 
)
protected

Convert string to Hekateros product size code.

Parameters
[in]strString in hex, decimal, or octal format.
[out]valConverted product size.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 464 of file hekXmlCfg.cxx.

465 {
466  int rc = HEK_OK;
467 
468  if( str.empty() )
469  {
470  val = HekProdSizeUnknown;
471  }
472  else if( !strcmp(str.c_str(), HekProdSizeStrUnknown) )
473  {
474  val = HekProdSizeUnknown;
475  }
476  else if( !strcmp(str.c_str(), HekProdSizeStrStd) )
477  {
478  val = HekProdSizeStd;
479  }
480  else if( !strcmp(str.c_str(), HekProdSizeStrShort) )
481  {
482  val = HekProdSizeShort;
483  }
484  else if( !strcmp(str.c_str(), HekProdSizeStrLong) )
485  {
486  val = HekProdSizeLong;
487  }
488  else
489  {
490  LOGERROR("%s: Unknown product size code.", str.c_str());
491  rc = -HEK_ECODE_XML;
492  }
493 
494  return rc;
495 }
standard (normal) size
Definition: hekateros.h:230
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
const char *const HekProdSizeStrStd
standard (normal) size
Definition: hekateros.h:242
const char *const HekProdSizeStrShort
short
Definition: hekateros.h:243
static const int HEK_ECODE_XML
XML error.
Definition: hekateros.h:91
const char *const HekProdSizeStrLong
long
Definition: hekateros.h:244
const char *const HekProdSizeStrUnknown
Common <b><i>Hekateros</i></b> product size codes as strings.
Definition: hekateros.h:241

The documentation for this class was generated from the following files: