7#ifndef __CANBUS_VIRTUAL_ANALOG_SENSOR_H__
8#define __CANBUS_VIRTUAL_ANALOG_SENSOR_H__
13#include <yarp/os/PeriodicThread.h>
14#include <yarp/dev/ControlBoardInterfaces.h>
15#include <yarp/dev/IVirtualAnalogSensor.h>
16#include <yarp/dev/PolyDriver.h>
17#include <yarp/dev/CanBusInterface.h>
18#include <yarp/sig/Vector.h>
20using namespace yarp::os;
27 ANALOG_FORMAT_ERR = 0,
28 ANALOG_FORMAT_8_BIT = 8,
29 ANALOG_FORMAT_16_BIT = 16,
36 ANALOG_NOT_RESPONDING=-1,
70 virtual bool open(yarp::os::Searchable& config);
87 bool decode8 (
const unsigned char *msg,
int msg_id,
double *
data);
88 bool decode16(
const unsigned char *msg,
int msg_id,
double *
data);
89 bool sensor_start (yarp::os::Searchable& config);
91 bool readFullScaleAnalog(
int ch);
134 AnalogDataFormat dataFormat;
135 yarp::os::Bottle initMsg;
136 yarp::os::Bottle speedMsg;
137 yarp::os::Bottle closeMsg;
138 std::string deviceIdentifier;
140 short useCalibration;
141 bool isVirtualSensor; //RANDAZ
143 bool decode8(const unsigned char *msg, int id, double *data);
144 bool decode16(const unsigned char *msg, int id, double *data);
147 TBR_CanBackDoor* backDoor; //RANDAZ
151 bool handleAnalog(void *);
160 void getCounters(unsigned int &sat, unsigned int &err, unsigned int &to)
167 void setDeviceId(std::string id)
172 std::string getDeviceId()
174 return deviceIdentifier;
191 short getUseCalibration()
192 {return useCalibration;}
193 double* getScaleFactor()
194 {return scaleFactor;}
195 double getScaleFactor(int chan)
197 if (chan>=0 && chan<data->size())
198 return scaleFactor[chan];
203 bool open(int channels, AnalogDataFormat f, short bId, short useCalib, bool isVirtualSensor);
yarp::dev::VAS_status status
yarp::sig::Vector scaleFactor
virtual int getVirtualAnalogSensorChannels()
virtual yarp::dev::VAS_status getVirtualAnalogSensorStatus(int ch)
AnalogDataFormat dataFormat
~CanBusVirtualAnalogSensor()
virtual bool updateVirtualAnalogSensorMeasure(int ch, double &measure)
virtual void threadRelease()
CanBusVirtualAnalogSensor(int period=20)
virtual bool threadInit()
ICanBufferFactory * pCanBufferFactory
virtual bool open(yarp::os::Searchable &config)