VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
measurement_api.h
Go to the documentation of this file.
1#ifndef VITROIO_SDK_MEASUREMENT_API_H
2#define VITROIO_SDK_MEASUREMENT_API_H
3
4#include <mbed.h>
5
7
9
10namespace vitroio
11{
12
13namespace sdk
14{
15
27#define VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE 2
28
40template <uint32_t MaxParams>
41class MeasurementApi : private NonCopyable< MeasurementApi<MaxParams> >
42{
43public:
48 typedef Callback<void(SensorParameterValue*, int)> OnNewValuesCallback;
49
72 EventQueue* targetQueue,
73 uint32_t eventQueueSize = VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE);
74
89 osPriority priority = osPriorityNormal,
90 uint32_t eventQueueSize = VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE);
91
96
105 bool isValid() const;
106
117
123 void setPollTime(unsigned int seconds);
124
133
141
146
147private:
148 bool valid_;
149
150 EventQueue evQueue_;
151 Thread* evQueueThread_;
152 Mutex pollMutex_;
153 int pollEventId_;
154 unsigned int pollTimeS_;
155 uint32_t parametersCount_;
156 OnNewValuesCallback onNewValuesCallback_;
157
158 uint32_t valuesCount_;
159 SensorParameterValue valuesBuffer_[MaxParams];
160
162
163 void getValues();
164 void pollValues();
165};
166
167#include <vitroio-sdk/measurement-api/impl/measurement_api.hpp>
168
173} // namespace sdk
174
175} // namespace vitroio
176
177#endif // VITROIO_SDK_MEASUREMENT_API_H
Virtual class providing interface for sensor interfaces classes.
Definition: abstract_sensor_interface.h:50
Class is responsible for cycling readings of measurement data using registered sensors.
Definition: measurement_api.h:42
void setOnNewValuesCallback(OnNewValuesCallback callback)
Function sets callback which will be called when the new values are read.
MeasurementApi(osPriority priority=osPriorityNormal, uint32_t eventQueueSize=VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE)
Contructor creates internal event loop using thread with priority priority.
void stopMeasurements()
Function stops reading of measurements values.
bool isValid() const
Function allows to check whether the object is in valid state.
MeasurementApi(EventQueue *targetQueue, uint32_t eventQueueSize=VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE)
Contructor chains an internal event queue to the targetQueue.
void startMeasurements()
Function starts cycling reading of measurement values.
~MeasurementApi()
Destructor frees resources and stops event loop.
bool registerSensor(AbstractSensorInterface *sensorIf)
Function registers sensor from which the measurement data is to be read.
void setPollTime(unsigned int seconds)
Function sets interval between readings of measurement values.
Callback< void(SensorParameterValue *, int)> OnNewValuesCallback
Type defines signature of callback function which is to be called when a new measurement values are r...
Definition: measurement_api.h:48
Definition: list.h:24
#define VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE
Defines default size of internal event queue for MeasurementApi .
Definition: measurement_api.h:27
The namespace contains all of components of vitro-shard-sdk and components based on the sdk....
Definition: can_layer.h:9
Structure representing sensor parameters values.
Definition: abstract_sensor_interface.h:23