Alex Pirciu
/
BFMC
a
Diff: include/Examples/Sensors/sensorpublisher.hpp
- Revision:
- 1:ceee5a608e7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/Examples/Sensors/sensorpublisher.hpp Thu Mar 28 07:44:42 2019 +0000 @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * @file SensorPublisher.hpp + * @author RBRO/PJ-IU + * @version V1.0.0 + * @date day-month-year + * @brief This file contains the class declaration for the sensor publisher + * functionality. Because template classes are used, the code was + * placed in a corresponding .inl file and not in a .cpp one. + ****************************************************************************** + */ + +/* Include guard */ +#ifndef SENSOR_PUBLISHER_HPP +#define SENSOR_PUBLISHER_HPP + +/* The mbed library */ +#include <mbed.h> +/* Container that encapsulates fixed size arrays */ +#include <array> +/* String types, character traits and a set of converting functions */ +#include <string> +#include<TaskManager/taskmanager.hpp> + + +namespace examples{ + namespace sensors + { + //! ProximityPublisher class. + /*! + * It inherits class task::CTask. + * It is used for publishing proximity sensor values. + */ + template <class C_Sensor,uint Nr_Senrsor> + class ProximityPublisher:public task::CTask + { + public: + /* Sensor array */ + using SensorArrayT = std::array<C_Sensor*,Nr_Senrsor>; + /* Constructor */ + ProximityPublisher(uint32_t,SensorArrayT,Serial&); + /* Serial callback attached to object */ + static void staticSerialCallback(void* obj,char const * a, char * b); + protected: + /* Run method */ + void _run(); + /* Serial callback */ + void serialCallback(char const * a, char * b); + private: + /* Sensor array */ + SensorArrayT m_sensors; + /* Reference to serial object */ + Serial& m_serial; + /* Active flag */ + bool m_isActivate; + }; + }; // namespace sensors +}; // namespace examples + +#include "sensorpublisher.inl" +#endif