9 #include "EoProtocolAS.h"
13 using namespace yarp::os;
17 eo_ftsens_privData::eo_ftsens_privData(std::string name):
19 useCalibValues(false),
20 useTemperature(false),
21 scaleFactorIsFilled(false),
23 timestampTemperature(0.0),
24 timestampAnalogdata(0.0)
48 yError() <<
getBoardInfo() <<
"is missing some configuration parameter. Check logs and your config file.";
94 yDebug() <<
getBoardInfo() <<
"fillScaleFactor(): we DONT use calibration, thus all scale factors are set to 1.0";
117 bool gotFullScaleValues =
false;
123 EOnv *p_tmpNV = NULL;
124 eOas_arrayofupto12bytes_t fullscale_values = {0};
127 eo_array_New(6, 2, &fullscale_values);
129 eOprotID32_t id32_fullscale = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_status_fullscale);
134 const bool overrideROprotection =
true;
135 res->
setLocalValue(id32_fullscale, &fullscale_values, overrideROprotection);
139 eOas_strain_config_t strainConfig = {0};
141 strainConfig.mode = eoas_strainmode_acquirebutdonttx;
142 strainConfig.signaloncefullscale = eobool_true;
144 eOprotID32_t id32_strain_config = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_config);
149 while(!gotFullScaleValues && (timeout != 0))
152 SystemClock::delaySystem(1.0);
157 NVsize = eo_array_Size((EOarray *)&fullscale_values);
161 gotFullScaleValues =
true;
168 yWarning() <<
getBoardInfo() <<
"filling ScaleFactor ....";
172 if((
false == gotFullScaleValues) && (0 == timeout))
174 yError() <<
getBoardInfo() <<
"fillScaleFactor(): ETH Analog sensor: request for calibration parameters timed out ";
180 yError() <<
getBoardInfo() <<
"Analog sensor Calibration data has a different size from channels number in configuration file ";
185 if(gotFullScaleValues)
189 yWarning() <<
getBoardInfo() <<
"fillScaleFactor() detected that already has full scale values";
190 yDebug() <<
getBoardInfo() <<
"fillScaleFactor(): Fullscale values are: size=" << eo_array_Size((EOarray *)&fullscale_values) <<
" numchannel=" <<
strain_Channels;
196 uint8_t *msg = (uint8_t *) eo_array_At((EOarray *) &fullscale_values, i);
199 yError() <<
getBoardInfo() <<
"fillScaleFactor() doesn't receive data for channel " << i;
220 vector<eOprotID32_t> id32v(0);
221 eOprotID32_t id32 = eo_prot_ID32dummy;
226 id32 = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_status_calibratedvalues);
230 id32 = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_status_uncalibratedvalues);
233 id32v.push_back(id32);
240 id32 = eo_prot_ID32dummy;
242 id32 = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_temperature, 0, eoprot_tag_as_temperature_status);
243 id32v.push_back(id32);
259 const char * boardtype = eoboards_type2string2(
static_cast<eObrd_type_t
>(serviceConfig.
ethservice.configuration.data.as.strain.boardtype.type), eobool_true);
261 parser->
convert(serviceConfig.
ethservice.configuration.data.as.strain.canloc, loc,
sizeof(loc));
262 parser->
convert(serviceConfig.
ethservice.configuration.data.as.strain.boardtype.firmware, fir,
sizeof(fir));
263 parser->
convert(serviceConfig.
ethservice.configuration.data.as.strain.boardtype.protocol, pro,
sizeof(pro));
265 yInfo() <<
"The embObjFTsensor device using BOARD" << boardname <<
" w/ IP" << ipv4 <<
"has the following service config:";
268 yInfo() <<
"- STRAIN of type" << boardtype <<
"named" << serviceConfig.
nameOfStrain <<
"@" << loc <<
"with required protocol version =" << pro <<
"and required firmware version =" << fir;
274 eOas_strain_config_t strainConfig = {0};
277 strainConfig.signaloncefullscale = eobool_false;
278 strainConfig.mode = (
true == serviceConfig.
useCalibration) ? (eoas_strainmode_txcalibrateddatacontinuously) : (eoas_strainmode_txuncalibrateddatacontinuously);
282 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_strain, 0, eoprot_tag_as_strain_config);
286 yError() <<
getBoardInfo() <<
"FATAL: sendConfig2Strain() had an error while calling setcheckRemoteValue() for strain config ";
293 yDebug() <<
getBoardInfo() <<
"sendConfig2Strain() correctly configured strain coinfig ";
298 id32 = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_temperature, 0, eoprot_tag_as_temperature_config);
301 eOas_temperature_config_t tempconfig = {0};
304 tempconfig.enabled = 1;
311 yError() <<
getBoardInfo() <<
"FATAL: sendConfig2Strain(temperature) had an error while calling setcheckRemoteValue() for strain config ";
318 yDebug() <<
getBoardInfo() <<
"sendConfig2Strain() correctly configured strain coinfig ";
330 tempSrv.configuration.type = eomn_serv_AS_temperatures;
332 EOarray* array = eo_array_New(eOas_temperature_descriptors_maxnumber,
sizeof(eOas_temperature_descriptor_t), &(tempSrv.configuration.data.as.temperature.arrayofdescriptor));
333 eOas_temperature_descriptor_t descr= {0};
334 descr.typeofboard = ftSrv.configuration.data.as.strain.boardtype.type;
335 descr.typeofsensor = eoas_temperature_t1;
336 descr.on.can.place = eobrd_place_can;
337 descr.on.can.port = ftSrv.configuration.data.as.strain.canloc.port;
338 descr.on.can.addr = ftSrv.configuration.data.as.strain.canloc.addr;
339 eo_array_PushBack(array, &descr);
341 eOas_temperature_setof_boardinfos_t * boardInfoSet_ptr = &tempSrv.configuration.data.as.temperature.setofboardinfos;
342 eOresult_t
res = eoas_temperature_setof_boardinfos_clear(boardInfoSet_ptr);
345 yError() <<
getBoardInfo() <<
"Error in eoas_temperature_setof_boardinfos_clear()";
349 eObrd_info_t boardInfo = {0};
350 boardInfo.type = ftSrv.configuration.data.as.strain.boardtype.type;
351 memcpy(&boardInfo.protocol , &(ftSrv.configuration.data.as.strain.boardtype.protocol),
sizeof(eObrd_protocolversion_t));
352 memcpy(&boardInfo.firmware, &(ftSrv.configuration.data.as.strain.boardtype.firmware),
sizeof(eObrd_firmwareversion_t));
353 res = eoas_temperature_setof_boardinfos_add(boardInfoSet_ptr, &boardInfo);
356 yError() <<
getBoardInfo() <<
"Error in eoas_temperature_setof_boardinfos_add()";
bool convert(std::string const &fromstring, eOmc_actuator_t &toactuatortype, bool &formaterror)
bool parseService(yarp::os::Searchable &config, servConfigMais_t &maisconfig)
virtual const Properties & getProperties()=0
virtual bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries=10, const double waitbeforecheck=0.001, const double timeout=0.050)=0
virtual bool setRemoteValue(const eOprotID32_t id32, void *value)=0
virtual bool getLocalValue(const eOprotID32_t id32, void *value)=0
virtual bool setLocalValue(eOprotID32_t id32, const void *value, bool overrideROprotection=false)=0
bool serviceSetRegulars(eOmn_serv_category_t category, vector< eOprotID32_t > &id32vector, double timeout=0.500)
std::string getBoardInfo(void) const
eth::AbstractEthResource * res
void printServiceConfig(servConfigFTsensor_t &serviceConfig)
bool fromConfig(yarp::os::Searchable &config, servConfigFTsensor_t &serviceConfig)
bool initRegulars(servConfigFTsensor_t &serviceConfig)
std::vector< double > offset
bool fillScaleFactor(servConfigFTsensor_t &serviceConfig)
bool sendConfig2Strain(servConfigFTsensor_t &serviceConfig)
std::vector< double > scaleFactor
std::vector< double > analogdata
bool fillTemperatureEthServiceInfo(eOmn_serv_parameter_t &ftSrv, eOmn_serv_parameter_t &tempSrv)
Copyright (C) 2008 RobotCub Consortium.
int temperatureAcquisitionrate
eOmn_serv_parameter_t ethservice