yocto_power.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_power.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindPower(), the high-level API for Power 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_POWER_H
42 #define YOCTO_POWER_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YPower return codes)
50 //--- (end of YPower return codes)
51 //--- (YPower definitions)
52 class YPower; // forward declaration
53 
54 typedef void (*YPowerValueCallback)(YPower *func, const string& functionValue);
55 class YMeasure; // forward declaration
56 typedef void (*YPowerTimedReportCallback)(YPower *func, YMeasure measure);
57 #define Y_COSPHI_INVALID (YAPI_INVALID_DOUBLE)
58 #define Y_METER_INVALID (YAPI_INVALID_DOUBLE)
59 #define Y_METERTIMER_INVALID (YAPI_INVALID_UINT)
60 //--- (end of YPower definitions)
61 
62 //--- (YPower declaration)
72 #ifdef __BORLANDC__
73 #pragma option push -w-8022
74 #endif
75 //--- (end of YPower declaration)
76 protected:
77  //--- (YPower attributes)
78  // Attributes (function value cache)
79  double _cosPhi;
80  double _meter;
84 
85  friend YPower *yFindPower(const string& func);
86  friend YPower *yFirstPower(void);
87 
88  // Function-specific method for parsing of JSON output and caching result
89  virtual int _parseAttr(YJSONObject* json_val);
90 
91  // Constructor is protected, use yFindPower factory function to instantiate
92  YPower(const string& func);
93  //--- (end of YPower attributes)
94 
95 public:
96  ~YPower();
97  //--- (YPower accessors declaration)
98 
99  static const double COSPHI_INVALID;
100  static const double METER_INVALID;
101  static const int METERTIMER_INVALID = YAPI_INVALID_UINT;
102 
112  double get_cosPhi(void);
113 
114  inline double cosPhi(void)
115  { return this->get_cosPhi(); }
116 
117  int set_meter(double newval);
118  inline int setMeter(double newval)
119  { return this->set_meter(newval); }
120 
130  double get_meter(void);
131 
132  inline double meter(void)
133  { return this->get_meter(); }
134 
142  int get_meterTimer(void);
143 
144  inline int meterTimer(void)
145  { return this->get_meterTimer(); }
146 
174  static YPower* FindPower(string func);
175 
187  virtual int registerValueCallback(YPowerValueCallback callback);
189 
190  virtual int _invokeValueCallback(string value);
191 
205 
206  virtual int _invokeTimedReportCallback(YMeasure value);
207 
215  virtual int reset(void);
216 
217 
218  inline static YPower* Find(string func)
219  { return YPower::FindPower(func); }
220 
228  YPower *nextPower(void);
229  inline YPower *next(void)
230  { return this->nextPower();}
231 
241  static YPower* FirstPower(void);
242  inline static YPower* First(void)
243  { return YPower::FirstPower();}
244 #ifdef __BORLANDC__
245 #pragma option pop
246 #endif
247  //--- (end of YPower accessors declaration)
248 };
249 
250 //--- (YPower functions declaration)
251 
279 inline YPower* yFindPower(const string& func)
280 { return YPower::FindPower(func);}
290 inline YPower* yFirstPower(void)
291 { return YPower::FirstPower();}
292 
293 //--- (end of YPower functions declaration)
294 
295 #endif
static const double COSPHI_INVALID
Definition: yocto_power.h:99
static YPower * FindPower(string func)
static const double METER_INVALID
Definition: yocto_power.h:100
YPower * next(void)
Definition: yocto_power.h:229
int meterTimer(void)
Definition: yocto_power.h:144
static YPower * First(void)
Definition: yocto_power.h:242
YPowerValueCallback _valueCallbackPower
Definition: yocto_power.h:82
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
double _cosPhi
Definition: yocto_power.h:79
static YPower * FirstPower(void)
double _meter
Definition: yocto_power.h:80
YPower * yFindPower(const string &func)
Definition: yocto_power.h:279
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
static YPower * Find(string func)
Definition: yocto_power.h:218
int setMeter(double newval)
Definition: yocto_power.h:118
double cosPhi(void)
Definition: yocto_power.h:114
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
void(* YPowerTimedReportCallback)(YPower *func, YMeasure measure)
Definition: yocto_power.h:56
YPower * yFirstPower(void)
Definition: yocto_power.h:290
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
void(* YPowerValueCallback)(YPower *func, const string &functionValue)
Definition: yocto_power.h:54
int _meterTimer
Definition: yocto_power.h:81
double meter(void)
Definition: yocto_power.h:132
YPowerTimedReportCallback _timedReportCallbackPower
Definition: yocto_power.h:83


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