VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
Measurement-api

Provides functionality of measurement system. More...

Files

file  debug.h
 The file defines debug macros.
 

Classes

class  vitroio::sdk::AbstractSensorDriver
 Virtual class providing interface for sensor drivers. More...
 
struct  vitroio::sdk::SensorParameterValue
 Structure representing sensor parameters values. More...
 
class  vitroio::sdk::AbstractSensorInterface
 Virtual class providing interface for sensor interfaces classes. More...
 
class  vitroio::sdk::MeasurementApi< MaxParams >
 Class is responsible for cycling readings of measurement data using registered sensors. More...
 

Macros

#define VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE   2
 Defines default size of internal event queue for MeasurementApi .
 
#define VITROIO_SDK_MEASUREMENT_API_HPP
 
#define VITROIO_SDK_DEBUG_H
 
#define _MEASUREMENT_API_MODULE_NAME_   "MEASUREMENT API"
 
#define _MEASUREMENT_API_INFO_(format, ...)
 
#define _MEASUREMENT_API_WARNING_(format, ...)
 
#define _MEASUREMENT_API_ERROR_(format, ...)
 
#define _MEASUREMENT_API_POLL_TIME_S_DEFAULT_   30
 

Functions

 vitroio::sdk::MeasurementApi< MaxParams >::MeasurementApi (EventQueue *targetQueue, uint32_t eventQueueSize=VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE)
 Contructor chains an internal event queue to the targetQueue.
 
 vitroio::sdk::MeasurementApi< MaxParams >::MeasurementApi (osPriority priority=osPriorityNormal, uint32_t eventQueueSize=VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE)
 Contructor creates internal event loop using thread with priority priority.
 
 vitroio::sdk::MeasurementApi< MaxParams >::~MeasurementApi ()
 Destructor frees resources and stops event loop.
 
bool vitroio::sdk::MeasurementApi< MaxParams >::isValid () const
 Function allows to check whether the object is in valid state.
 
bool vitroio::sdk::MeasurementApi< MaxParams >::registerSensor (AbstractSensorInterface *sensorIf)
 Function registers sensor from which the measurement data is to be read.
 
void vitroio::sdk::MeasurementApi< MaxParams >::setPollTime (unsigned int seconds)
 Function sets interval between readings of measurement values.
 
void vitroio::sdk::MeasurementApi< MaxParams >::setOnNewValuesCallback (OnNewValuesCallback callback)
 Function sets callback which will be called when the new values are read.
 
void vitroio::sdk::MeasurementApi< MaxParams >::startMeasurements ()
 Function starts cycling reading of measurement values.
 
void vitroio::sdk::MeasurementApi< MaxParams >::stopMeasurements ()
 Function stops reading of measurements values.
 

Detailed Description

Provides functionality of measurement system.

Required modules:

Macro Definition Documentation

◆ _MEASUREMENT_API_ERROR_

#define _MEASUREMENT_API_ERROR_ ( format,
... )
Value:
#define _MEASUREMENT_API_MODULE_NAME_
Definition measurement_api.h:6
#define VITROIO_DEBUG_ERROR(module, format,...)

◆ _MEASUREMENT_API_INFO_

#define _MEASUREMENT_API_INFO_ ( format,
... )
Value:
#define VITROIO_DEBUG_INFO(module, format,...)

◆ _MEASUREMENT_API_MODULE_NAME_

#define _MEASUREMENT_API_MODULE_NAME_   "MEASUREMENT API"

◆ _MEASUREMENT_API_POLL_TIME_S_DEFAULT_

#define _MEASUREMENT_API_POLL_TIME_S_DEFAULT_   30

◆ _MEASUREMENT_API_WARNING_

#define _MEASUREMENT_API_WARNING_ ( format,
... )
Value:
#define VITROIO_DEBUG_WARNING(module, format,...)

◆ VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE

#define VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE   2

Defines default size of internal event queue for MeasurementApi .

◆ VITROIO_SDK_DEBUG_H

#define VITROIO_SDK_DEBUG_H

◆ VITROIO_SDK_MEASUREMENT_API_HPP

#define VITROIO_SDK_MEASUREMENT_API_HPP

Function Documentation

◆ isValid()

template<uint32_t MaxParams>
bool vitroio::sdk::MeasurementApi< MaxParams >::isValid ( ) const

Function allows to check whether the object is in valid state.

Note
This method should be called always after creation of the object.
Returns
Function returns true if the object is valid or false otherwise.

◆ MeasurementApi() [1/2]

template<uint32_t MaxParams>
vitroio::sdk::MeasurementApi< MaxParams >::MeasurementApi ( EventQueue * targetQueue,
uint32_t eventQueueSize = VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE )
explicit

Contructor chains an internal event queue to the targetQueue.

There is not guarantee that the object is in valid state. User should call isValid() method to determine if the object was initialized successfully. When the object is in invalid state, the behaviour is undefined.

The contructor uses mbed::EventQueue::chain method for connection to targetQueue.

Note
Thread which handles targetQueue must be run before usage of this class (construction of the object can be done earlier).
Parameters
targetQueueExternal event queue to which the internal queue is to be chained
eventQueueSizeSize of internal event queue

◆ MeasurementApi() [2/2]

template<uint32_t MaxParams>
vitroio::sdk::MeasurementApi< MaxParams >::MeasurementApi ( osPriority priority = osPriorityNormal,
uint32_t eventQueueSize = VITROIO_MEASUREMENT_API_DEFAULT_EVENT_QUEUE_SIZE )
explicit

Contructor creates internal event loop using thread with priority priority.

There is not guarantee that the object is in valid state. User should call isValid() method to determine if the object was initialized successfully. When the object is in invalid state, the behaviour is undefined.

Parameters
priorityPriority of thread for handling internal event queue
eventQueueSizeSize of internal event queue

◆ registerSensor()

template<uint32_t MaxParams>
bool vitroio::sdk::MeasurementApi< MaxParams >::registerSensor ( AbstractSensorInterface * sensorIf)

Function registers sensor from which the measurement data is to be read.

Parameters
sensorIfPointer to sensor interface to register
Returns
Function returns true on success or false if parameters count exceeded MaxParams.

◆ setOnNewValuesCallback()

template<uint32_t MaxParams>
void vitroio::sdk::MeasurementApi< MaxParams >::setOnNewValuesCallback ( OnNewValuesCallback callback)

Function sets callback which will be called when the new values are read.

Note
Callback set by this method will be executed in another thread (event loop).

◆ setPollTime()

template<uint32_t MaxParams>
void vitroio::sdk::MeasurementApi< MaxParams >::setPollTime ( unsigned int seconds)

Function sets interval between readings of measurement values.

Parameters
secondsInterval in seconds

◆ startMeasurements()

template<uint32_t MaxParams>
void vitroio::sdk::MeasurementApi< MaxParams >::startMeasurements ( )

Function starts cycling reading of measurement values.

Note
Function is not blocking. When new values are read the callback set by client will be executed in another thread.

◆ stopMeasurements()

template<uint32_t MaxParams>
void vitroio::sdk::MeasurementApi< MaxParams >::stopMeasurements ( )

Function stops reading of measurements values.

◆ ~MeasurementApi()

template<uint32_t MaxParams>
vitroio::sdk::MeasurementApi< MaxParams >::~MeasurementApi ( )

Destructor frees resources and stops event loop.