YARP
Yet Another Robot Platform
fakeAnalogSensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEVICE_FAKE_ANALOGSENSOR
10 #define YARP_DEVICE_FAKE_ANALOGSENSOR
11 
12 #include <yarp/os/PeriodicThread.h>
13 
14 #include <yarp/dev/all.h>
15 #include <yarp/dev/IAnalogSensor.h>
16 
17 #include <mutex>
18 
35 {
36 private:
37 
38  std::mutex mutex;
39 
40  std::string name; // device name
41  unsigned int channelsNum;
42  short status;
43  double timeStamp;
44  yarp::sig::Vector data;
45 
46 public:
47  FakeAnalogSensor(double period = 0.02);
48 
50 
51  bool open(yarp::os::Searchable& config) override;
52  bool close() override;
53 
54  //IAnalogSensor interface
55  int getChannels() override;
56  int getState(int ch) override;
57  int read(yarp::sig::Vector &out) override;
58 
59  int calibrateSensor() override;
60  int calibrateSensor(const yarp::sig::Vector& v) override;
61 
62  int calibrateChannel(int ch) override;
63  int calibrateChannel(int ch, double v) override;
64 
65  // RateThread interface
66  void run() override;
67  bool threadInit() override;
68  void threadRelease() override;
69 };
70 
71 
72 #endif // YARP_DEVICE_FAKE_ANALOGSENSOR
FakeAnalogSensor::FakeAnalogSensor
FakeAnalogSensor(double period=0.02)
Definition: fakeAnalogSensor.cpp:22
FakeAnalogSensor::threadRelease
void threadRelease() override
Release method.
Definition: fakeAnalogSensor.cpp:157
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
FakeAnalogSensor::run
void run() override
Loop function.
Definition: fakeAnalogSensor.cpp:140
FakeAnalogSensor::calibrateSensor
int calibrateSensor() override
Calibrates the whole sensor.
Definition: fakeAnalogSensor.cpp:106
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
all.h
yarp::sig::VectorOf< double >
yarp::dev::IAnalogSensor
A generic interface to sensors (gyro, a/d converters).
Definition: IAnalogSensor.h:31
FakeAnalogSensor::calibrateChannel
int calibrateChannel(int ch) override
Calibrates one single channel.
Definition: fakeAnalogSensor.cpp:127
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
FakeAnalogSensor::getChannels
int getChannels() override
Get the number of channels of the sensor.
Definition: fakeAnalogSensor.cpp:100
PeriodicThread.h
FakeAnalogSensor::close
bool close() override
Close the DeviceDriver.
Definition: fakeAnalogSensor.cpp:75
FakeAnalogSensor::threadInit
bool threadInit() override
Initialization method.
Definition: fakeAnalogSensor.cpp:134
FakeAnalogSensor
fakeAnalogSensor: Fake analog sensor device for testing purpose and reference for new analog devices
Definition: fakeAnalogSensor.h:35
FakeAnalogSensor::getState
int getState(int ch) override
Check the state value of a given channel.
Definition: fakeAnalogSensor.cpp:93
FakeAnalogSensor::~FakeAnalogSensor
~FakeAnalogSensor()
Definition: fakeAnalogSensor.cpp:31
FakeAnalogSensor::read
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
Definition: fakeAnalogSensor.cpp:84
IAnalogSensor.h
analog sensor interface
FakeAnalogSensor::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: fakeAnalogSensor.cpp:37