yocto_rangefinder.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_rangefinder.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindRangeFinder(), the high-level API for RangeFinder 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_RANGEFINDER_H
42 #define YOCTO_RANGEFINDER_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YRangeFinder return codes)
50 //--- (end of YRangeFinder return codes)
51 //--- (YRangeFinder definitions)
52 class YRangeFinder; // forward declaration
53 
54 typedef void (*YRangeFinderValueCallback)(YRangeFinder *func, const string& functionValue);
55 class YMeasure; // forward declaration
56 typedef void (*YRangeFinderTimedReportCallback)(YRangeFinder *func, YMeasure measure);
57 #ifndef _Y_RANGEFINDERMODE_ENUM
58 #define _Y_RANGEFINDERMODE_ENUM
59 typedef enum {
66 #endif
67 #define Y_HARDWARECALIBRATION_INVALID (YAPI_INVALID_STRING)
68 #define Y_CURRENTTEMPERATURE_INVALID (YAPI_INVALID_DOUBLE)
69 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
70 //--- (end of YRangeFinder definitions)
71 
72 //--- (YRangeFinder declaration)
83 #ifdef __BORLANDC__
84 #pragma option push -w-8022
85 #endif
86 //--- (end of YRangeFinder declaration)
87 protected:
88  //--- (YRangeFinder attributes)
89  // Attributes (function value cache)
93  string _command;
96 
97  friend YRangeFinder *yFindRangeFinder(const string& func);
98  friend YRangeFinder *yFirstRangeFinder(void);
99 
100  // Function-specific method for parsing of JSON output and caching result
101  virtual int _parseAttr(YJSONObject* json_val);
102 
103  // Constructor is protected, use yFindRangeFinder factory function to instantiate
104  YRangeFinder(const string& func);
105  //--- (end of YRangeFinder attributes)
106 
107 public:
108  ~YRangeFinder();
109  //--- (YRangeFinder accessors declaration)
110 
111  static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_DEFAULT = Y_RANGEFINDERMODE_DEFAULT;
112  static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_LONG_RANGE = Y_RANGEFINDERMODE_LONG_RANGE;
113  static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_HIGH_ACCURACY = Y_RANGEFINDERMODE_HIGH_ACCURACY;
114  static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_HIGH_SPEED = Y_RANGEFINDERMODE_HIGH_SPEED;
115  static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_INVALID = Y_RANGEFINDERMODE_INVALID;
116  static const string HARDWARECALIBRATION_INVALID;
117  static const double CURRENTTEMPERATURE_INVALID;
118  static const string COMMAND_INVALID;
119 
133  int set_unit(const string& newval);
134  inline int setUnit(const string& newval)
135  { return this->set_unit(newval); }
136 
146  Y_RANGEFINDERMODE_enum get_rangeFinderMode(void);
147 
149  { return this->get_rangeFinderMode(); }
150 
164  int set_rangeFinderMode(Y_RANGEFINDERMODE_enum newval);
166  { return this->set_rangeFinderMode(newval); }
167 
168  string get_hardwareCalibration(void);
169 
170  inline string hardwareCalibration(void)
171  { return this->get_hardwareCalibration(); }
172 
173  int set_hardwareCalibration(const string& newval);
174  inline int setHardwareCalibration(const string& newval)
175  { return this->set_hardwareCalibration(newval); }
176 
184  double get_currentTemperature(void);
185 
186  inline double currentTemperature(void)
187  { return this->get_currentTemperature(); }
188 
189  string get_command(void);
190 
191  inline string command(void)
192  { return this->get_command(); }
193 
194  int set_command(const string& newval);
195  inline int setCommand(const string& newval)
196  { return this->set_command(newval); }
197 
225  static YRangeFinder* FindRangeFinder(string func);
226 
238  virtual int registerValueCallback(YRangeFinderValueCallback callback);
240 
241  virtual int _invokeValueCallback(string value);
242 
256 
257  virtual int _invokeTimedReportCallback(YMeasure value);
258 
267  virtual double get_hardwareCalibrationTemperature(void);
268 
278  virtual int triggerTemperatureCalibration(void);
279 
289  virtual int triggerSpadCalibration(void);
290 
303  virtual int triggerOffsetCalibration(double targetDist);
304 
317  virtual int triggerXTalkCalibration(double targetDist);
318 
327  virtual int cancelCoverGlassCalibrations(void);
328 
329 
330  inline static YRangeFinder* Find(string func)
331  { return YRangeFinder::FindRangeFinder(func); }
332 
340  YRangeFinder *nextRangeFinder(void);
341  inline YRangeFinder *next(void)
342  { return this->nextRangeFinder();}
343 
353  static YRangeFinder* FirstRangeFinder(void);
354  inline static YRangeFinder* First(void)
355  { return YRangeFinder::FirstRangeFinder();}
356 #ifdef __BORLANDC__
357 #pragma option pop
358 #endif
359  //--- (end of YRangeFinder accessors declaration)
360 };
361 
362 //--- (YRangeFinder functions declaration)
363 
391 inline YRangeFinder* yFindRangeFinder(const string& func)
392 { return YRangeFinder::FindRangeFinder(func);}
404 
405 //--- (end of YRangeFinder functions declaration)
406 
407 #endif
string command(void)
string _hardwareCalibration
static YRangeFinder * Find(string func)
YRangeFinderTimedReportCallback _timedReportCallbackRangeFinder
YRangeFinder * yFirstRangeFinder(void)
static const string HARDWARECALIBRATION_INVALID
YRangeFinderValueCallback _valueCallbackRangeFinder
Y_RANGEFINDERMODE_enum rangeFinderMode(void)
double currentTemperature(void)
void(* YRangeFinderTimedReportCallback)(YRangeFinder *func, YMeasure measure)
static YRangeFinder * FindRangeFinder(string func)
YRangeFinder * yFindRangeFinder(const string &func)
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
int setCommand(const string &newval)
Y_RANGEFINDERMODE_enum _rangeFinderMode
static const double CURRENTTEMPERATURE_INVALID
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
static YRangeFinder * FirstRangeFinder(void)
int setUnit(const string &newval)
static YRangeFinder * First(void)
static const string COMMAND_INVALID
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
int setRangeFinderMode(Y_RANGEFINDERMODE_enum newval)
int setHardwareCalibration(const string &newval)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
string hardwareCalibration(void)
double _currentTemperature
void(* YRangeFinderValueCallback)(YRangeFinder *func, const string &functionValue)
YRangeFinder * next(void)
Y_RANGEFINDERMODE_enum


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