yocto_wakeupmonitor.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_wakeupmonitor.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindWakeUpMonitor(), the high-level API for WakeUpMonitor 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_WAKEUPMONITOR_H
42 #define YOCTO_WAKEUPMONITOR_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YWakeUpMonitor return codes)
50 //--- (end of YWakeUpMonitor return codes)
51 //--- (YWakeUpMonitor definitions)
52 class YWakeUpMonitor; // forward declaration
53 
54 typedef void (*YWakeUpMonitorValueCallback)(YWakeUpMonitor *func, const string& functionValue);
55 #ifndef _Y_WAKEUPREASON_ENUM
56 #define _Y_WAKEUPREASON_ENUM
57 typedef enum {
66 #endif
67 #ifndef _Y_WAKEUPSTATE_ENUM
68 #define _Y_WAKEUPSTATE_ENUM
69 typedef enum {
74 #endif
75 #define Y_POWERDURATION_INVALID (YAPI_INVALID_INT)
76 #define Y_SLEEPCOUNTDOWN_INVALID (YAPI_INVALID_INT)
77 #define Y_NEXTWAKEUP_INVALID (YAPI_INVALID_LONG)
78 #define Y_RTCTIME_INVALID (YAPI_INVALID_LONG)
79 //--- (end of YWakeUpMonitor definitions)
80 
81 //--- (YWakeUpMonitor declaration)
89 #ifdef __BORLANDC__
90 #pragma option push -w-8022
91 #endif
92 //--- (end of YWakeUpMonitor declaration)
93 protected:
94  //--- (YWakeUpMonitor attributes)
95  // Attributes (function value cache)
101  s64 _rtcTime;
104 
105  friend YWakeUpMonitor *yFindWakeUpMonitor(const string& func);
106  friend YWakeUpMonitor *yFirstWakeUpMonitor(void);
107 
108  // Function-specific method for parsing of JSON output and caching result
109  virtual int _parseAttr(YJSONObject* json_val);
110 
111  // Constructor is protected, use yFindWakeUpMonitor factory function to instantiate
112  YWakeUpMonitor(const string& func);
113  //--- (end of YWakeUpMonitor attributes)
114 
115 public:
116  ~YWakeUpMonitor();
117  //--- (YWakeUpMonitor accessors declaration)
118 
119  static const int POWERDURATION_INVALID = YAPI_INVALID_INT;
120  static const int SLEEPCOUNTDOWN_INVALID = YAPI_INVALID_INT;
121  static const s64 NEXTWAKEUP_INVALID = YAPI_INVALID_LONG;
122  static const Y_WAKEUPREASON_enum WAKEUPREASON_USBPOWER = Y_WAKEUPREASON_USBPOWER;
123  static const Y_WAKEUPREASON_enum WAKEUPREASON_EXTPOWER = Y_WAKEUPREASON_EXTPOWER;
124  static const Y_WAKEUPREASON_enum WAKEUPREASON_ENDOFSLEEP = Y_WAKEUPREASON_ENDOFSLEEP;
125  static const Y_WAKEUPREASON_enum WAKEUPREASON_EXTSIG1 = Y_WAKEUPREASON_EXTSIG1;
126  static const Y_WAKEUPREASON_enum WAKEUPREASON_SCHEDULE1 = Y_WAKEUPREASON_SCHEDULE1;
127  static const Y_WAKEUPREASON_enum WAKEUPREASON_SCHEDULE2 = Y_WAKEUPREASON_SCHEDULE2;
128  static const Y_WAKEUPREASON_enum WAKEUPREASON_INVALID = Y_WAKEUPREASON_INVALID;
129  static const Y_WAKEUPSTATE_enum WAKEUPSTATE_SLEEPING = Y_WAKEUPSTATE_SLEEPING;
130  static const Y_WAKEUPSTATE_enum WAKEUPSTATE_AWAKE = Y_WAKEUPSTATE_AWAKE;
131  static const Y_WAKEUPSTATE_enum WAKEUPSTATE_INVALID = Y_WAKEUPSTATE_INVALID;
132  static const s64 RTCTIME_INVALID = YAPI_INVALID_LONG;
133 
141  int get_powerDuration(void);
142 
143  inline int powerDuration(void)
144  { return this->get_powerDuration(); }
145 
156  int set_powerDuration(int newval);
157  inline int setPowerDuration(int newval)
158  { return this->set_powerDuration(newval); }
159 
167  int get_sleepCountdown(void);
168 
169  inline int sleepCountdown(void)
170  { return this->get_sleepCountdown(); }
171 
181  int set_sleepCountdown(int newval);
182  inline int setSleepCountdown(int newval)
183  { return this->set_sleepCountdown(newval); }
184 
192  s64 get_nextWakeUp(void);
193 
194  inline s64 nextWakeUp(void)
195  { return this->get_nextWakeUp(); }
196 
206  int set_nextWakeUp(s64 newval);
207  inline int setNextWakeUp(s64 newval)
208  { return this->set_nextWakeUp(newval); }
209 
219  Y_WAKEUPREASON_enum get_wakeUpReason(void);
220 
222  { return this->get_wakeUpReason(); }
223 
231  Y_WAKEUPSTATE_enum get_wakeUpState(void);
232 
234  { return this->get_wakeUpState(); }
235 
236  int set_wakeUpState(Y_WAKEUPSTATE_enum newval);
238  { return this->set_wakeUpState(newval); }
239 
240  s64 get_rtcTime(void);
241 
242  inline s64 rtcTime(void)
243  { return this->get_rtcTime(); }
244 
272  static YWakeUpMonitor* FindWakeUpMonitor(string func);
273 
287 
288  virtual int _invokeValueCallback(string value);
289 
293  virtual int wakeUp(void);
294 
305  virtual int sleep(int secBeforeSleep);
306 
319  virtual int sleepFor(int secUntilWakeUp,int secBeforeSleep);
320 
333  virtual int sleepUntil(int wakeUpTime,int secBeforeSleep);
334 
341  virtual int resetSleepCountDown(void);
342 
343 
344  inline static YWakeUpMonitor* Find(string func)
345  { return YWakeUpMonitor::FindWakeUpMonitor(func); }
346 
354  YWakeUpMonitor *nextWakeUpMonitor(void);
355  inline YWakeUpMonitor *next(void)
356  { return this->nextWakeUpMonitor();}
357 
367  static YWakeUpMonitor* FirstWakeUpMonitor(void);
368  inline static YWakeUpMonitor* First(void)
370 #ifdef __BORLANDC__
371 #pragma option pop
372 #endif
373  //--- (end of YWakeUpMonitor accessors declaration)
374 };
375 
376 //--- (YWakeUpMonitor functions declaration)
377 
405 inline YWakeUpMonitor* yFindWakeUpMonitor(const string& func)
406 { return YWakeUpMonitor::FindWakeUpMonitor(func);}
418 
419 //--- (end of YWakeUpMonitor functions declaration)
420 
421 #endif
Y_WAKEUPSTATE_enum _wakeUpState
static YWakeUpMonitor * FindWakeUpMonitor(string func)
int setPowerDuration(int newval)
Y_WAKEUPSTATE_enum wakeUpState(void)
static YWakeUpMonitor * Find(string func)
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
Y_WAKEUPSTATE_enum
int setNextWakeUp(s64 newval)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
int setWakeUpState(Y_WAKEUPSTATE_enum newval)
Y_WAKEUPREASON_enum
YWakeUpMonitor * next(void)
Y_WAKEUPREASON_enum _wakeUpReason
YWakeUpMonitorValueCallback _valueCallbackWakeUpMonitor
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setSleepCountdown(int newval)
static YWakeUpMonitor * FirstWakeUpMonitor(void)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
YWakeUpMonitor * yFirstWakeUpMonitor(void)
Y_WAKEUPREASON_enum wakeUpReason(void)
YWakeUpMonitor * yFindWakeUpMonitor(const string &func)
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
void(* YWakeUpMonitorValueCallback)(YWakeUpMonitor *func, const string &functionValue)
static YWakeUpMonitor * First(void)
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563


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