47 "PROPERTIES.CANBOARDS.PROTOCOL.major";
51 Bottle propertyCanBoardProtocolMinor = Bottle(propertyCanBoardProtocol.findGroup(
"minor"));
52 if (propertyCanBoardProtocolMinor.isNull())
54 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards() cannot find "
55 "PROPERTIES.CANBOARDS.PROTOCOL.minor";
59 Bottle propertyCanBoardFirmware = Bottle(propertyCanBoard.findGroup(
"FIRMWARE"));
60 if (propertyCanBoardFirmware.isNull())
62 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards() cannot find "
63 "PROPERTIES.CANBOARDS.FIRMWARE";
67 Bottle propertyCanBoardFirmwareMajor = Bottle(propertyCanBoardFirmware.findGroup(
"major"));
68 if (propertyCanBoardFirmwareMajor.isNull())
70 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards() cannot find "
71 "PROPERTIES.CANBOARDS.FIRMWARE.major";
75 Bottle propertyCanBoardFirmwareMinor = Bottle(propertyCanBoardFirmware.findGroup(
"minor"));
76 if (propertyCanBoardFirmwareMinor.isNull())
78 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards() cannot find "
79 "PROPERTIES.CANBOARDS.FIRMWARE.minor";
83 Bottle propertyCanBoardFirmwareBuild = Bottle(propertyCanBoardFirmware.findGroup(
"build"));
84 if (propertyCanBoardFirmwareBuild.isNull())
86 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards() cannot find "
87 "PROPERTIES.CANBOARDS.FIRMWARE.build";
92 if (propertyCanBoardType.size() != propertyCanBoardProtocolMajor.size())
94 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards --> protocol major size";
97 if (propertyCanBoardProtocolMajor.size() != propertyCanBoardProtocolMinor.size())
99 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards --> protocol minor size";
102 if (propertyCanBoardProtocolMinor.size() != propertyCanBoardFirmwareMajor.size())
104 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards --> firmware major size";
107 if (propertyCanBoardFirmwareMajor.size() != propertyCanBoardFirmwareMinor.size())
109 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards --> firmware minor size";
112 if (propertyCanBoardFirmwareMinor.size() != propertyCanBoardFirmwareBuild.size())
114 yError() <<
"ServiceParserMultipleFt::checkPropertyCanBoards --> firmware build size";
118 size_t size = propertyCanBoardType.size();
119 for (
int index = 1; index < size; ++index)
121 std::string boardType = propertyCanBoardType.get(index).asString();
124 if (currentBoard == eobrd_unknown)
127 int protocolMajor = propertyCanBoardProtocolMajor.get(index).asInt32();
128 int protocolMinor = propertyCanBoardProtocolMinor.get(index).asInt32();
129 int firmwareMajor = propertyCanBoardFirmwareMajor.get(index).asInt32();
130 int firmwareMinor = propertyCanBoardFirmwareMinor.get(index).asInt32();
131 int firmwareBuild = propertyCanBoardFirmwareBuild.get(index).asInt32();
133 for (
auto &[key, current] :
ftInfo_)
135 if (current.board != currentBoard)
137 current.majorProtocol = protocolMajor;
138 current.minorProtocol = protocolMinor;
139 current.majorFirmware = firmwareMajor;
140 current.minorFirmware = firmwareMinor;
141 current.buildFirmware = firmwareBuild;
150 Bottle propertySensors = Bottle(property.findGroup(
"SENSORS"));
151 if (propertySensors.isNull())
153 yError() <<
"ServiceParserMultipleFt::checkPropertySensors() cannot find "
154 "PROPERTIES.SENSORS";
158 Bottle propertySensorsId = Bottle(propertySensors.findGroup(
"id"));
159 if (propertySensorsId.isNull())
161 yError() <<
"ServiceParserMultipleFt::checkPropertySensors() cannot find "
162 "PROPERTIES.SENSORS.id";
166 Bottle propertySensorsBoard = Bottle(propertySensors.findGroup(
"board"));
167 if (propertySensorsBoard.isNull())
169 yError() <<
"ServiceParserMultipleFt::checkPropertySensors() cannot find "
170 "PROPERTIES.SENSORS.type";
174 Bottle propertySensorsLocation = Bottle(propertySensors.findGroup(
"location"));
175 if (propertySensorsLocation.isNull())
177 yError() <<
"ServiceParserMultipleFt::checkPropertySensors() cannot find "
178 "PROPERTIES.SENSORS.location";
182 Bottle propertySensorsFrameName = Bottle(propertySensors.findGroup(
"framename"));
183 if (propertySensorsFrameName.isNull())
185 yWarning() <<
"ServiceParserMultipleFt::checkPropertySensors() cannot find "
186 "PROPERTIES.SENSORS.frameName";
190 if (propertySensorsId.size() != propertySensorsBoard.size())
192 yError() <<
"ServiceParserMultipleFt::checkPropertySensors --> board size";
195 if (propertySensorsBoard.size() != propertySensorsLocation.size())
197 yError() <<
"ServiceParserMultipleFt::checkPropertySensors --> location size";
200 if (!propertySensorsFrameName.isNull())
202 if (propertySensorsLocation.size() != propertySensorsFrameName.size())
204 yError() <<
"ServiceParserMultipleFt::checkPropertySensors --> framename size";
209 size_t sensorSize = propertySensorsId.size();
210 for (
size_t index = 1 ; index < sensorSize; index++)
212 std::string
id = propertySensorsId.get(index).asString();
213 std::string
board = propertySensorsBoard.get(index).asString();
215 if (currentBoard == eobrd_unknown)
218 std::string location = propertySensorsLocation.get(index).asString();
219 std::string frameName;
220 if (!propertySensorsFrameName.isNull())
222 frameName = propertySensorsFrameName.get(index).asString();
226 auto ¤tFt =
ftInfo_.at(
id);
230 currentFt.port = std::stoi(location.substr(3, 1));
232 catch (
const std::exception &)
234 yError() <<
"ServiceParser::checkPropertySensors() invalid can port";
239 currentFt.address = std::stoi(location.substr(5, location.size() - 5));
241 catch (
const std::exception &)
243 yError() <<
"ServiceParser::checkPropertySensors() invalid can address";
247 currentFt.board = currentBoard;
248 currentFt.frameName = frameName;
255 for (
int index = 0; index < propertySensorsId.size(); ++index)
257 if (
id == propertySensorsId.get(index).asString())
264 yError() <<
"ServiceParser::checkPropertySensors() try to enable not existing sensor:" << id;
274 Bottle settings = Bottle(service.findGroup(
"SETTINGS"));
275 if (settings.isNull())
277 yError() <<
"ServiceParserMultipleFt::checkSettings() cannot find SETTINGS";
281 Bottle settingsFtPeriod = Bottle(settings.findGroup(
"ftPeriod"));
282 if (settingsFtPeriod.isNull())
284 yError() <<
"ServiceParserMultipleFt::checkSettings() cannot find "
289 Bottle settingsTemperaturePeriod = Bottle(settings.findGroup(
"temperaturePeriod"));
290 if (settingsTemperaturePeriod.isNull())
292 yError() <<
"ServiceParserMultipleFt::checkSettings() for embObjMultipleFTsensors "
293 "device cannot find SETTINGS.temperaturePeriod";
297 Bottle settingsUseCalibration = Bottle(settings.findGroup(
"useCalibration"));
298 if (settingsUseCalibration.isNull())
300 yError() <<
"ServiceParserMultipleFt::checkSettings() cannot find "
301 "FT_SETTINGS.useCalibration";
305 Bottle settingsEnabledSensors = Bottle(settings.findGroup(
"enabledSensors"));
306 if (settingsEnabledSensors.isNull())
308 yError() <<
"ServiceParserMultipleFt::checkSettings() cannot find "
309 "SETTINGS.enabledSensors";
314 if (settingsEnabledSensors.size() != settingsFtPeriod.size())
316 yError() <<
"ServiceParserMultipleFt::checkSettings --> FtPeriod size";
319 if (settingsFtPeriod.size() != settingsTemperaturePeriod.size())
321 yError() <<
"ServiceParserMultipleFt::checkSettings --> "
322 "temperaturePeriod size";
325 if (settingsTemperaturePeriod.size() != settingsUseCalibration.size())
327 yError() <<
"ServiceParserMultipleFt::checkSettings --> usecalibration size";
331 size_t enabledSensorSize = settingsEnabledSensors.size();
332 if (enabledSensorSize > 4)
334 yError() <<
"ServiceParserMultipleFt::checkSettings --> too many sensors";
338 for (
size_t index = 1 ; index < enabledSensorSize; index++)
340 std::string
id = settingsEnabledSensors.get(index).asString();
341 uint8_t acquisitionRate = (uint8_t)settingsFtPeriod.get(index).asInt8();
342 uint32_t acquisitionTempRate = (uint32_t)settingsTemperaturePeriod.get(index).asInt32();
343 bool useCalibration = settingsUseCalibration.get(index).asBool();
344 eOas_ft_mode_t calib = eoas_ft_mode_calibrated;
347 calib = eoas_ft_mode_raw;
349 FtInfo currentSensor{acquisitionRate, acquisitionTempRate, calib};
354 if (settingsEnabledSensors.size() - 1 !=
ftInfo_.size())
356 yError() <<
"ServiceParserMultipleFt::checkSettings --> id duplicate name";
365 if (
false == service.check(
"type"))
367 yError() <<
"ServiceParserMultipleFt::check() cannot find SERVICE.type";
370 std::string serviceType = service.find(
"type").asString();
371 eOmn_serv_type_t serviceTypeEomn = eomn_string2servicetype(serviceType.c_str());
373 if (eomn_serv_AS_ft != serviceTypeEomn)
375 yError() <<
"ServiceParserMultipleFt::check() has found wrong SERVICE.type = " << serviceType <<
"it must be eomn_serv_AS_ft";
383 Bottle canMonitor = Bottle(service.findGroup(
"CANMONITOR"));
384 if (canMonitor.isNull())
386 yError() <<
"ServiceParserMultipleFt::check() cannot find PROPERTIES.CANMONITOR";
390 if (
false == canMonitor.check(
"checkPeriod"))
392 yError() <<
"ServiceParserMultipleFt::check() cannot find canMonitor.checkrate";
395 if (
false == canMonitor.check(
"ratePeriod"))
397 yError() <<
"ServiceParserMultipleFt::check() cannot find "
398 "canMonitor.periodicreportrate";
401 if (
false == canMonitor.check(
"reportMode"))
403 yError() <<
"ServiceParserMultipleFt::check() cannot find canMonitor.reportmode";
407 int checkPeriod = canMonitor.find(
"checkPeriod").asInt32();
408 if (checkPeriod > 254)
410 yError() <<
"ServiceParserMultipleFt::check() wrong canMonitor.checkPeriod "
414 int periodicreportrate = canMonitor.find(
"ratePeriod").asInt32();
415 if (periodicreportrate > 65535)
417 yError() <<
"ServiceParserMultipleFt::check() wrong canMonitor.ratePeriod "
421 std::string reportmode = canMonitor.find(
"reportMode").asString();
422 eObrd_canmonitor_reportmode_t reportmodeEobrd = (eObrd_canmonitor_reportmode_t)eoboards_string2reportmode(reportmode.c_str(), 1);
424 if (reportmodeEobrd == eobrd_canmonitor_reportmode_unknown)
426 yError() <<
"ServiceParserMultipleFt::check() wrong canMonitor.reportmode";
430 canMonitor_ = {(uint8_t)checkPeriod, (uint8_t)reportmodeEobrd, (uint16_t)periodicreportrate};
437 Bottle service(config.findGroup(
"SERVICE"));
438 if (service.isNull())
440 yError() <<
"ServiceParser::check() cannot find SERVICE group";
444 Bottle properties = Bottle(service.findGroup(
"PROPERTIES"));
445 if (properties.isNull())
447 yError() <<
"ServiceParser::check() cannot find PROPERTIES";
473 EOarray *ar = eo_array_New(eOas_ft_sensors_maxnumber,
sizeof(eOas_ft_sensordescriptor_t), (
void *)(&(
out.arrayofsensors)));
475 for (
const auto &[key, value] :
ftInfo_)
477 eOas_ft_sensordescriptor_t item;
478 if (!value.toEomn(item))
480 yError() <<
"ServiceParserMultipleFt::toEomn() wrong data for sensor";
483 eo_array_PushBack(ar, &item);
495 eObrd_type_t type = eoboards_string2type2(boardType.c_str(), eobool_true);
496 if (!eoas_ft_isboardvalid(eoboards_type2cantype(type)))
498 type = eoboards_string2type2(boardType.c_str(), eobool_false);
499 if (!eoas_ft_isboardvalid(eoboards_type2cantype(type)))
501 yError() <<
"checkBoardType --> unsupported board type:" << boardType;