11 #include <yarp/os/LogStream.h>
12 #include <yarp/os/Bottle.h>
15 using namespace yarp::os;
23 strncpy(_name, name,
sizeof(_name));
116 Bottle boardCfgDefGroup =config.findGroup(
"defaultCfgBoard",
"Default configuration for skin boards");
117 if (boardCfgDefGroup.isNull()==
true)
129 Bottle boardCfgDefGroup =config.findGroup(
"defaultCfgBoard",
"Default configuration for skin boards");
130 if (boardCfgDefGroup.isNull()==
true)
132 yError() <<
"skin " << _name <<
"defaultCfgBoard param is not present in config file";
136 xtmp = boardCfgDefGroup.findGroup(
"period");
139 yError() <<
"skin " << _name <<
"doesn't find period in defaultCfgBoard group in xml file";
142 boardCfg->
period = xtmp.get(1).asInt32();
144 xtmp = boardCfgDefGroup.findGroup(
"skinType");
147 yError() <<
"skin " << _name <<
"doesn't find skinType in defaultCfgBoard group in xml file";
150 boardCfg->
skinType= xtmp.get(1).asInt32();
152 xtmp = boardCfgDefGroup.findGroup(
"noLoad");
155 yError() <<
"skin " << _name <<
"doesn't find noLoad in defaultCfgBoard group in xml file";
158 boardCfg->
noLoad= xtmp.get(1).asInt32();
160 xtmp = boardCfgDefGroup.findGroup(
"diagnostic");
163 yError() <<
"skin " << _name <<
"doesn't find diagnostic in defaultCfgBoard group in xml file";
172 Bottle triangleCfgDefGroup =config.findGroup(
"defaultCfgTriangle",
"Default configuration for skin triangle");
174 if (triangleCfgDefGroup.isNull()==
true)
182 if(NULL == triangCfg)
185 Bottle triangleCfgDefGroup =config.findGroup(
"defaultCfgTriangle",
"Default configuration for skin triangle");
187 if (triangleCfgDefGroup.isNull()==
true)
189 yError() <<
"skin " << _name <<
"defaultCfgTriangle param is not present in config file";
194 xtmp = triangleCfgDefGroup.findGroup(
"enabled");
197 yError() <<
"skin " << _name <<
"doesn't find enabled in defaultCfgTriangle group in xml file";
200 triangCfg->
enabled = xtmp.get(1).asBool();
202 xtmp = triangleCfgDefGroup.findGroup(
"shift");
205 yError() <<
"skin " << _name <<
"doesn't find shift in defaultCfgTriangle group in xml file";
208 triangCfg->
shift = xtmp.get(1).asInt32();
210 xtmp = triangleCfgDefGroup.findGroup(
"cdcOffset");
213 yError() <<
"skin " << _name <<
"doesn't find cdcOffset in defaultCfgTriangle group in xml file";
216 triangCfg->
cdcOffset = xtmp.get(1).asInt32();
224 unsigned int numOfSets;
227 if((NULL == boardCfg) || (NULL == numofcfg))
230 Bottle boardCfgSpecialGroup = config.findGroup(
"specialCfgBoards",
"Special configuration for skin boards");
231 if(boardCfgSpecialGroup.isNull()==
true)
238 bNumOfset = boardCfgSpecialGroup.findGroup(
"numOfSets",
"number of special sets of triangles");
239 if(bNumOfset.isNull())
241 yError() <<
"skin " << _name <<
"numOfSet is missed from specialCfgBoards";
245 numOfSets = bNumOfset.get(1).asInt32();
246 if(numOfSets > *numofcfg)
248 yWarning() <<
"skin " << _name <<
"numOfSet is too big. Max is " << *numofcfg;
252 *numofcfg = numOfSets;
255 for(
unsigned int j=1;j<=*numofcfg;j++)
258 sprintf(
tmp,
"boardSetCfg%d", j);
260 Bottle &xtmp = boardCfgSpecialGroup.findGroup(
tmp);
263 yError() <<
"skin " << _name <<
"doesn't find " <<
tmp <<
"in specialCfgBoards group in xml file";
267 boardCfg[j-1].
patch = xtmp.get(1).asInt32();
270 boardCfg[j-1].
cfg.
period = xtmp.get(4).asInt32();
271 boardCfg[j-1].
cfg.
skinType = xtmp.get(5).asInt32();
272 boardCfg[j-1].
cfg.
noLoad = xtmp.get(6).asInt32();
281 unsigned int numOfSets;
283 if((NULL == triangleCfg) || (NULL == numofcfg))
286 Bottle triangleCfgSpecialGroup = config.findGroup(
"specialCfgTriangles",
"Special configuration for skin triangles");
287 if(triangleCfgSpecialGroup.isNull())
293 bNumOfset = triangleCfgSpecialGroup.findGroup(
"numOfSets",
"number of special sets of triangles");
294 if(bNumOfset.isNull())
296 yError() <<
"skin "<< _name <<
"numOfSet is missed from SpecialCfgTriangles";
300 numOfSets = bNumOfset.get(1).asInt32();
301 if(numOfSets > *numofcfg)
303 yWarning() <<
"skin " << _name <<
"numOfSets for specialCfgTriangles is too big!! Max is " << *numofcfg;
307 *numofcfg = numOfSets;
310 for(
unsigned int j=1;j<=*numofcfg;j++)
313 sprintf(
tmp,
"triangleSetCfg%d", j);
315 Bottle &xtmp = triangleCfgSpecialGroup.findGroup(
tmp);
318 yError() <<
"skin " << _name <<
"doesn't find " <<
tmp <<
"in SpecialCfgTriangles group in xml file";
322 triangleCfg[j-1].
patch = xtmp.get(1).asInt32();
323 triangleCfg[j-1].
boardAddr = xtmp.get(2).asInt32();
325 triangleCfg[j-1].
triangleEnd = xtmp.get(4).asInt32();
326 triangleCfg[j-1].
cfg.
enabled = xtmp.get(5).asInt32()==1;
327 triangleCfg[j-1].
cfg.
shift = xtmp.get(6).asInt32();
bool readDefaultBoardCfg(yarp::os::Searchable &config, SkinBoardCfgParam *boardCfg)
bool isDefaultBoardCfgPresent(yarp::os::Searchable &config)
bool readSpecialBoardCfg(yarp::os::Searchable &config, SpecialSkinBoardCfgParam *boardCfg, unsigned int *numofcfg)
bool readDefaultTriangleCfg(yarp::os::Searchable &config, SkinTriangleCfgParam *triangCfg)
bool readSpecialTriangleCfg(yarp::os::Searchable &config, SpecialSkinTriangleCfgParam *triangleCfg, unsigned int *numofcfg)
bool isDefaultTriangleCfgPresent(yarp::os::Searchable &config)