yocto_proximity.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_proximity.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindProximity(), the high-level API for Proximity 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_PROXIMITY_H
42 #define YOCTO_PROXIMITY_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YProximity return codes)
50 //--- (end of YProximity return codes)
51 //--- (YProximity definitions)
52 class YProximity; // forward declaration
53 
54 typedef void (*YProximityValueCallback)(YProximity *func, const string& functionValue);
55 class YMeasure; // forward declaration
56 typedef void (*YProximityTimedReportCallback)(YProximity *func, YMeasure measure);
57 #ifndef _Y_ISPRESENT_ENUM
58 #define _Y_ISPRESENT_ENUM
59 typedef enum {
64 #endif
65 #ifndef _Y_PROXIMITYREPORTMODE_ENUM
66 #define _Y_PROXIMITYREPORTMODE_ENUM
67 typedef enum {
73 #endif
74 #define Y_SIGNALVALUE_INVALID (YAPI_INVALID_DOUBLE)
75 #define Y_DETECTIONTHRESHOLD_INVALID (YAPI_INVALID_UINT)
76 #define Y_LASTTIMEAPPROACHED_INVALID (YAPI_INVALID_LONG)
77 #define Y_LASTTIMEREMOVED_INVALID (YAPI_INVALID_LONG)
78 #define Y_PULSECOUNTER_INVALID (YAPI_INVALID_LONG)
79 #define Y_PULSETIMER_INVALID (YAPI_INVALID_LONG)
80 //--- (end of YProximity definitions)
81 
82 //--- (YProximity declaration)
93 #ifdef __BORLANDC__
94 #pragma option push -w-8022
95 #endif
96 //--- (end of YProximity declaration)
97 protected:
98  //--- (YProximity attributes)
99  // Attributes (function value cache)
100  double _signalValue;
110 
111  friend YProximity *yFindProximity(const string& func);
112  friend YProximity *yFirstProximity(void);
113 
114  // Function-specific method for parsing of JSON output and caching result
115  virtual int _parseAttr(YJSONObject* json_val);
116 
117  // Constructor is protected, use yFindProximity factory function to instantiate
118  YProximity(const string& func);
119  //--- (end of YProximity attributes)
120 
121 public:
122  ~YProximity();
123  //--- (YProximity accessors declaration)
124 
125  static const double SIGNALVALUE_INVALID;
126  static const int DETECTIONTHRESHOLD_INVALID = YAPI_INVALID_UINT;
127  static const Y_ISPRESENT_enum ISPRESENT_FALSE = Y_ISPRESENT_FALSE;
128  static const Y_ISPRESENT_enum ISPRESENT_TRUE = Y_ISPRESENT_TRUE;
129  static const Y_ISPRESENT_enum ISPRESENT_INVALID = Y_ISPRESENT_INVALID;
130  static const s64 LASTTIMEAPPROACHED_INVALID = YAPI_INVALID_LONG;
131  static const s64 LASTTIMEREMOVED_INVALID = YAPI_INVALID_LONG;
132  static const s64 PULSECOUNTER_INVALID = YAPI_INVALID_LONG;
133  static const s64 PULSETIMER_INVALID = YAPI_INVALID_LONG;
134  static const Y_PROXIMITYREPORTMODE_enum PROXIMITYREPORTMODE_NUMERIC = Y_PROXIMITYREPORTMODE_NUMERIC;
135  static const Y_PROXIMITYREPORTMODE_enum PROXIMITYREPORTMODE_PRESENCE = Y_PROXIMITYREPORTMODE_PRESENCE;
136  static const Y_PROXIMITYREPORTMODE_enum PROXIMITYREPORTMODE_PULSECOUNT = Y_PROXIMITYREPORTMODE_PULSECOUNT;
137  static const Y_PROXIMITYREPORTMODE_enum PROXIMITYREPORTMODE_INVALID = Y_PROXIMITYREPORTMODE_INVALID;
138 
146  double get_signalValue(void);
147 
148  inline double signalValue(void)
149  { return this->get_signalValue(); }
150 
161  int get_detectionThreshold(void);
162 
163  inline int detectionThreshold(void)
164  { return this->get_detectionThreshold(); }
165 
178  int set_detectionThreshold(int newval);
179  inline int setDetectionThreshold(int newval)
180  { return this->set_detectionThreshold(newval); }
181 
191  Y_ISPRESENT_enum get_isPresent(void);
192 
194  { return this->get_isPresent(); }
195 
206  s64 get_lastTimeApproached(void);
207 
208  inline s64 lastTimeApproached(void)
209  { return this->get_lastTimeApproached(); }
210 
221  s64 get_lastTimeRemoved(void);
222 
223  inline s64 lastTimeRemoved(void)
224  { return this->get_lastTimeRemoved(); }
225 
235  s64 get_pulseCounter(void);
236 
237  inline s64 pulseCounter(void)
238  { return this->get_pulseCounter(); }
239 
240  int set_pulseCounter(s64 newval);
241  inline int setPulseCounter(s64 newval)
242  { return this->set_pulseCounter(newval); }
243 
251  s64 get_pulseTimer(void);
252 
253  inline s64 pulseTimer(void)
254  { return this->get_pulseTimer(); }
255 
266  Y_PROXIMITYREPORTMODE_enum get_proximityReportMode(void);
267 
269  { return this->get_proximityReportMode(); }
270 
285  int set_proximityReportMode(Y_PROXIMITYREPORTMODE_enum newval);
287  { return this->set_proximityReportMode(newval); }
288 
316  static YProximity* FindProximity(string func);
317 
329  virtual int registerValueCallback(YProximityValueCallback callback);
331 
332  virtual int _invokeValueCallback(string value);
333 
347 
348  virtual int _invokeTimedReportCallback(YMeasure value);
349 
357  virtual int resetCounter(void);
358 
359 
360  inline static YProximity* Find(string func)
361  { return YProximity::FindProximity(func); }
362 
370  YProximity *nextProximity(void);
371  inline YProximity *next(void)
372  { return this->nextProximity();}
373 
383  static YProximity* FirstProximity(void);
384  inline static YProximity* First(void)
385  { return YProximity::FirstProximity();}
386 #ifdef __BORLANDC__
387 #pragma option pop
388 #endif
389  //--- (end of YProximity accessors declaration)
390 };
391 
392 //--- (YProximity functions declaration)
393 
421 inline YProximity* yFindProximity(const string& func)
422 { return YProximity::FindProximity(func);}
433 { return YProximity::FirstProximity();}
434 
435 //--- (end of YProximity functions declaration)
436 
437 #endif
s64 lastTimeRemoved(void)
Y_PROXIMITYREPORTMODE_enum proximityReportMode(void)
Y_ISPRESENT_enum
int setProximityReportMode(Y_PROXIMITYREPORTMODE_enum newval)
YProximityValueCallback _valueCallbackProximity
YProximityTimedReportCallback _timedReportCallbackProximity
static YProximity * First(void)
int setPulseCounter(s64 newval)
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
double _signalValue
s64 pulseTimer(void)
static YProximity * FirstProximity(void)
int detectionThreshold(void)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
Y_ISPRESENT_enum _isPresent
YProximity * yFirstProximity(void)
static const double SIGNALVALUE_INVALID
YProximity * next(void)
Y_PROXIMITYREPORTMODE_enum
s64 lastTimeApproached(void)
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
int setDetectionThreshold(int newval)
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
s64 pulseCounter(void)
int _detectionThreshold
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
s64 _lastTimeApproached
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
YProximity * yFindProximity(const string &func)
static YProximity * FindProximity(string func)
Y_ISPRESENT_enum isPresent(void)
static YProximity * Find(string func)
Y_PROXIMITYREPORTMODE_enum _proximityReportMode
double signalValue(void)
void(* YProximityTimedReportCallback)(YProximity *func, YMeasure measure)
void(* YProximityValueCallback)(YProximity *func, const string &functionValue)


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