yocto_genericsensor.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_genericsensor.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindGenericSensor(), the high-level API for GenericSensor functions
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED 'AS IS' WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 
41 #ifndef YOCTO_GENERICSENSOR_H
42 #define YOCTO_GENERICSENSOR_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YGenericSensor return codes)
50 //--- (end of YGenericSensor return codes)
51 //--- (YGenericSensor definitions)
52 class YGenericSensor; // forward declaration
53 
54 typedef void (*YGenericSensorValueCallback)(YGenericSensor *func, const string& functionValue);
55 class YMeasure; // forward declaration
57 #ifndef _Y_SIGNALSAMPLING_ENUM
58 #define _Y_SIGNALSAMPLING_ENUM
59 typedef enum {
66 #endif
67 #define Y_SIGNALVALUE_INVALID (YAPI_INVALID_DOUBLE)
68 #define Y_SIGNALUNIT_INVALID (YAPI_INVALID_STRING)
69 #define Y_SIGNALRANGE_INVALID (YAPI_INVALID_STRING)
70 #define Y_VALUERANGE_INVALID (YAPI_INVALID_STRING)
71 #define Y_SIGNALBIAS_INVALID (YAPI_INVALID_DOUBLE)
72 //--- (end of YGenericSensor definitions)
73 
74 //--- (YGenericSensor declaration)
85 #ifdef __BORLANDC__
86 #pragma option push -w-8022
87 #endif
88 //--- (end of YGenericSensor declaration)
89 protected:
90  //--- (YGenericSensor attributes)
91  // Attributes (function value cache)
92  double _signalValue;
93  string _signalUnit;
94  string _signalRange;
95  string _valueRange;
96  double _signalBias;
100 
101  friend YGenericSensor *yFindGenericSensor(const string& func);
102  friend YGenericSensor *yFirstGenericSensor(void);
103 
104  // Function-specific method for parsing of JSON output and caching result
105  virtual int _parseAttr(YJSONObject* json_val);
106 
107  // Constructor is protected, use yFindGenericSensor factory function to instantiate
108  YGenericSensor(const string& func);
109  //--- (end of YGenericSensor attributes)
110 
111 public:
112  ~YGenericSensor();
113  //--- (YGenericSensor accessors declaration)
114 
115  static const double SIGNALVALUE_INVALID;
116  static const string SIGNALUNIT_INVALID;
117  static const string SIGNALRANGE_INVALID;
118  static const string VALUERANGE_INVALID;
119  static const double SIGNALBIAS_INVALID;
120  static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_HIGH_RATE = Y_SIGNALSAMPLING_HIGH_RATE;
121  static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_HIGH_RATE_FILTERED = Y_SIGNALSAMPLING_HIGH_RATE_FILTERED;
122  static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_LOW_NOISE = Y_SIGNALSAMPLING_LOW_NOISE;
123  static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_LOW_NOISE_FILTERED = Y_SIGNALSAMPLING_LOW_NOISE_FILTERED;
124  static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_INVALID = Y_SIGNALSAMPLING_INVALID;
125 
137  int set_unit(const string& newval);
138  inline int setUnit(const string& newval)
139  { return this->set_unit(newval); }
140 
149  double get_signalValue(void);
150 
151  inline double signalValue(void)
152  { return this->get_signalValue(); }
153 
161  string get_signalUnit(void);
162 
163  inline string signalUnit(void)
164  { return this->get_signalUnit(); }
165 
173  string get_signalRange(void);
174 
175  inline string signalRange(void)
176  { return this->get_signalRange(); }
177 
187  int set_signalRange(const string& newval);
188  inline int setSignalRange(const string& newval)
189  { return this->set_signalRange(newval); }
190 
198  string get_valueRange(void);
199 
200  inline string valueRange(void)
201  { return this->get_valueRange(); }
202 
213  int set_valueRange(const string& newval);
214  inline int setValueRange(const string& newval)
215  { return this->set_valueRange(newval); }
216 
228  int set_signalBias(double newval);
229  inline int setSignalBias(double newval)
230  { return this->set_signalBias(newval); }
231 
241  double get_signalBias(void);
242 
243  inline double signalBias(void)
244  { return this->get_signalBias(); }
245 
260  Y_SIGNALSAMPLING_enum get_signalSampling(void);
261 
263  { return this->get_signalSampling(); }
264 
281  int set_signalSampling(Y_SIGNALSAMPLING_enum newval);
283  { return this->set_signalSampling(newval); }
284 
312  static YGenericSensor* FindGenericSensor(string func);
313 
327 
328  virtual int _invokeValueCallback(string value);
329 
343 
344  virtual int _invokeTimedReportCallback(YMeasure value);
345 
354  virtual int zeroAdjust(void);
355 
356 
357  inline static YGenericSensor* Find(string func)
358  { return YGenericSensor::FindGenericSensor(func); }
359 
367  YGenericSensor *nextGenericSensor(void);
368  inline YGenericSensor *next(void)
369  { return this->nextGenericSensor();}
370 
380  static YGenericSensor* FirstGenericSensor(void);
381  inline static YGenericSensor* First(void)
383 #ifdef __BORLANDC__
384 #pragma option pop
385 #endif
386  //--- (end of YGenericSensor accessors declaration)
387 };
388 
389 //--- (YGenericSensor functions declaration)
390 
418 inline YGenericSensor* yFindGenericSensor(const string& func)
419 { return YGenericSensor::FindGenericSensor(func);}
431 
432 //--- (end of YGenericSensor functions declaration)
433 
434 #endif
void(* YGenericSensorValueCallback)(YGenericSensor *func, const string &functionValue)
string valueRange(void)
static YGenericSensor * First(void)
void(* YGenericSensorTimedReportCallback)(YGenericSensor *func, YMeasure measure)
YGenericSensor * yFindGenericSensor(const string &func)
int setSignalSampling(Y_SIGNALSAMPLING_enum newval)
YGenericSensor * next(void)
int setSignalBias(double newval)
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
static YGenericSensor * FirstGenericSensor(void)
string signalRange(void)
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
Y_SIGNALSAMPLING_enum
static const string SIGNALRANGE_INVALID
static const double SIGNALBIAS_INVALID
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
string signalUnit(void)
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
YGenericSensor * yFirstGenericSensor(void)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
Y_SIGNALSAMPLING_enum _signalSampling
int setSignalRange(const string &newval)
static const string VALUERANGE_INVALID
Y_SIGNALSAMPLING_enum signalSampling(void)
static YGenericSensor * FindGenericSensor(string func)
double signalValue(void)
double signalBias(void)
static const string SIGNALUNIT_INVALID
YGenericSensorTimedReportCallback _timedReportCallbackGenericSensor
static YGenericSensor * Find(string func)
int setValueRange(const string &newval)
static const double SIGNALVALUE_INVALID
YGenericSensorValueCallback _valueCallbackGenericSensor
int setUnit(const string &newval)


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:11