Kallisto Linux API
Library for interacting with Kallisto devices
sensor.hpp
Go to the documentation of this file.
1 
42 #ifndef SENSOR_HPP
43 #define SENSOR_HPP
44 
45 #include <string>
46 #include <sstream>
47 #include <chrono>
48 
49 namespace kallisto {
50 namespace hardware {
54 class Sensor {
55 public:
61  enum class SensorType {
62  /*
63  * NOTE: DO NOT FORGET TO UPDATE getValueArraySize(SensorType type) FOR NEW SENSORS
64  */
65 
69  ACCELEROMETER = 1,
73  MAGNETIC_FIELD = 2,
77  GYROSCOPE = 4,
81  PRESSURE = 6,
85  RELATIVE_HUMIDITY = 12,
90 
91  /*
92  * Custom Sensors
93  */
94 
98  BATTERY_SOC = 100,
106  RSSI = 102,
107 
111  ANALOG = 150,
115  CO2_CONCENTRATION = 151,
119  TVOC_CONCENTRATION = 152
120  };
121 
127  enum class ReportingMode {
132  REPORTING_MODE_CONTINUOUS = 0,
137  REPORTING_MODE_ON_CHANGE = 1,
142  REPORTING_MODE_ONE_SHOT = 2,
147  REPORTING_MODE_SPECIAL_TRIGGER = 3
148  };
149 
150 protected:
152  const unsigned int m_handle; //Unique identifier fot the sensor
154  const std::string m_name; //Name of the sensor
156  const std::string m_address; //MAC address of the Kallisto that contains this sensor
158  const std::string m_vendor; //Sensor vendor
160  const unsigned int m_version; //Sensor version
162  const SensorType m_type; //Sensor type
164  const std::string m_string_type; //String describing a type
166  const ReportingMode m_reporting_mode; //Reporting mode
168  const unsigned int m_identifier; //Sensor identifier. Allows to distinguish two equal sensors in same Kallisto
170  const float m_max_range; //Maximum value measured
172  const float m_resolution; //Sensor resolution
174  const float m_power; //Power rating
176  const std::chrono::microseconds m_min_delay; //Minimum delay between samples, in microseconds
178  const std::chrono::microseconds m_max_delay; //Maximum delay between samples, in microseconds
179 
183  Sensor(unsigned int handle, std::string name, std::string address, std::string vendor, unsigned int version, SensorType type, std::string string_type, ReportingMode reporting_mode,
184  unsigned int identifier, float max_range, float resolution, float power, std::chrono::microseconds min_delay, std::chrono::microseconds max_delay);
185 
189  virtual ~Sensor();
190 
194  Sensor(Sensor const&) = delete;
195  Sensor(Sensor&&) = delete;
196  void operator=(Sensor const&) = delete;
197  void operator=(Sensor &&) = delete;
198 
199 public:
203  unsigned int getHandle() const;
204 
208  std::string getName() const;
209 
213  std::string getAddress() const;
214 
218  std::string getVendor() const;
219 
223  unsigned int getVersion() const;
224 
228  SensorType getType() const;
229 
233  std::string getStringType() const;
234 
239 
243  unsigned int getIdentifier() const;
244 
248  float getMaximumRange() const;
249 
253  float getResolution() const;
254 
258  float getPower() const;
259 
265  std::chrono::microseconds getMinDelay() const;
274  std::chrono::microseconds getMaxDelay() const;
275 
277  std::string toString();
278 
279  bool operator== (const Sensor &other) const;
280  bool operator!= (const Sensor &other) const;
287  static unsigned int getValueArraySize(SensorType type);
288 };
289 
290 } /* namespace hardware */
291 } /* namespace kallisto */
292 
293 #endif // SENSOR_HPP
const SensorType m_type
Definition: sensor.hpp:161
ReportingMode getReportingMode() const
const std::chrono::microseconds m_max_delay
Definition: sensor.hpp:177
const float m_resolution
Definition: sensor.hpp:171
std::string getAddress() const
Definition: bluetooth_adapter.hpp:52
std::string getVendor() const
unsigned int getIdentifier() const
const unsigned int m_handle
Definition: sensor.hpp:151
SensorType
Definition: sensor.hpp:60
Sensor(unsigned int handle, std::string name, std::string address, std::string vendor, unsigned int version, SensorType type, std::string string_type, ReportingMode reporting_mode, unsigned int identifier, float max_range, float resolution, float power, std::chrono::microseconds min_delay, std::chrono::microseconds max_delay)
static unsigned int getValueArraySize(SensorType type)
std::chrono::microseconds getMinDelay() const
std::string getStringType() const
unsigned int getVersion() const
const std::chrono::microseconds m_min_delay
Definition: sensor.hpp:175
const ReportingMode m_reporting_mode
Definition: sensor.hpp:165
const unsigned int m_version
Definition: sensor.hpp:159
const std::string m_name
Definition: sensor.hpp:153
SensorType getType() const
const float m_power
Definition: sensor.hpp:173
unsigned int getHandle() const
const float m_max_range
Definition: sensor.hpp:169
std::chrono::microseconds getMaxDelay() const
const std::string m_string_type
Definition: sensor.hpp:163
const std::string m_address
Definition: sensor.hpp:155
const std::string m_vendor
Definition: sensor.hpp:157
float getMaximumRange() const
const unsigned int m_identifier
Definition: sensor.hpp:167
std::string getName() const
ReportingMode
Definition: sensor.hpp:126