yocto_watchdog.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_watchdog.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindWatchdog(), the high-level API for Watchdog 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_WATCHDOG_H
42 #define YOCTO_WATCHDOG_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YWatchdog return codes)
50 //--- (end of YWatchdog return codes)
51 //--- (YWatchdog definitions)
52 class YWatchdog; // forward declaration
53 
54 typedef void (*YWatchdogValueCallback)(YWatchdog *func, const string& functionValue);
55 #ifndef _Y_STATE_ENUM
56 #define _Y_STATE_ENUM
57 typedef enum {
58  Y_STATE_A = 0,
59  Y_STATE_B = 1,
61 } Y_STATE_enum;
62 #endif
63 #ifndef _Y_STATEATPOWERON_ENUM
64 #define _Y_STATEATPOWERON_ENUM
65 typedef enum {
71 #endif
72 #ifndef _Y_OUTPUT_ENUM
73 #define _Y_OUTPUT_ENUM
74 typedef enum {
79 #endif
80 #ifndef _CLASS_YDELAYEDPULSE
81 #define _CLASS_YDELAYEDPULSE
83 public:
84  int target;
85  int ms;
86  int moving;
87 
90  {}
91 
92  bool operator==(const YDelayedPulse& o) const {
93  return (target == o.target) && (ms == o.ms) && (moving == o.moving);
94  }
95 };
96 #endif
97 #ifndef _Y_AUTOSTART_ENUM
98 #define _Y_AUTOSTART_ENUM
99 typedef enum {
100  Y_AUTOSTART_OFF = 0,
101  Y_AUTOSTART_ON = 1,
102  Y_AUTOSTART_INVALID = -1,
104 #endif
105 #ifndef _Y_RUNNING_ENUM
106 #define _Y_RUNNING_ENUM
107 typedef enum {
112 #endif
113 #define Y_MAXTIMEONSTATEA_INVALID (YAPI_INVALID_LONG)
114 #define Y_MAXTIMEONSTATEB_INVALID (YAPI_INVALID_LONG)
115 #define Y_PULSETIMER_INVALID (YAPI_INVALID_LONG)
116 #define Y_COUNTDOWN_INVALID (YAPI_INVALID_LONG)
117 #define Y_TRIGGERDELAY_INVALID (YAPI_INVALID_LONG)
118 #define Y_TRIGGERDURATION_INVALID (YAPI_INVALID_LONG)
119 //--- (end of YWatchdog definitions)
120 
121 //--- (YWatchdog declaration)
133 #ifdef __BORLANDC__
134 #pragma option push -w-8022
135 #endif
136 //--- (end of YWatchdog declaration)
137 protected:
138  //--- (YWatchdog attributes)
139  // Attributes (function value cache)
153 
154  friend YWatchdog *yFindWatchdog(const string& func);
155  friend YWatchdog *yFirstWatchdog(void);
156 
157  // Function-specific method for parsing of JSON output and caching result
158  virtual int _parseAttr(YJSONObject* json_val);
159 
160  // Constructor is protected, use yFindWatchdog factory function to instantiate
161  YWatchdog(const string& func);
162  //--- (end of YWatchdog attributes)
163 
164 public:
165  ~YWatchdog();
166  //--- (YWatchdog accessors declaration)
167 
168  static const Y_STATE_enum STATE_A = Y_STATE_A;
169  static const Y_STATE_enum STATE_B = Y_STATE_B;
170  static const Y_STATE_enum STATE_INVALID = Y_STATE_INVALID;
171  static const Y_STATEATPOWERON_enum STATEATPOWERON_UNCHANGED = Y_STATEATPOWERON_UNCHANGED;
172  static const Y_STATEATPOWERON_enum STATEATPOWERON_A = Y_STATEATPOWERON_A;
173  static const Y_STATEATPOWERON_enum STATEATPOWERON_B = Y_STATEATPOWERON_B;
174  static const Y_STATEATPOWERON_enum STATEATPOWERON_INVALID = Y_STATEATPOWERON_INVALID;
175  static const s64 MAXTIMEONSTATEA_INVALID = YAPI_INVALID_LONG;
176  static const s64 MAXTIMEONSTATEB_INVALID = YAPI_INVALID_LONG;
177  static const Y_OUTPUT_enum OUTPUT_OFF = Y_OUTPUT_OFF;
178  static const Y_OUTPUT_enum OUTPUT_ON = Y_OUTPUT_ON;
179  static const Y_OUTPUT_enum OUTPUT_INVALID = Y_OUTPUT_INVALID;
180  static const s64 PULSETIMER_INVALID = YAPI_INVALID_LONG;
182  static const s64 COUNTDOWN_INVALID = YAPI_INVALID_LONG;
183  static const Y_AUTOSTART_enum AUTOSTART_OFF = Y_AUTOSTART_OFF;
184  static const Y_AUTOSTART_enum AUTOSTART_ON = Y_AUTOSTART_ON;
185  static const Y_AUTOSTART_enum AUTOSTART_INVALID = Y_AUTOSTART_INVALID;
186  static const Y_RUNNING_enum RUNNING_OFF = Y_RUNNING_OFF;
187  static const Y_RUNNING_enum RUNNING_ON = Y_RUNNING_ON;
188  static const Y_RUNNING_enum RUNNING_INVALID = Y_RUNNING_INVALID;
189  static const s64 TRIGGERDELAY_INVALID = YAPI_INVALID_LONG;
190  static const s64 TRIGGERDURATION_INVALID = YAPI_INVALID_LONG;
191 
200  Y_STATE_enum get_state(void);
201 
202  inline Y_STATE_enum state(void)
203  { return this->get_state(); }
204 
215  int set_state(Y_STATE_enum newval);
216  inline int setState(Y_STATE_enum newval)
217  { return this->set_state(newval); }
218 
229  Y_STATEATPOWERON_enum get_stateAtPowerOn(void);
230 
232  { return this->get_stateAtPowerOn(); }
233 
245  int set_stateAtPowerOn(Y_STATEATPOWERON_enum newval);
247  { return this->set_stateAtPowerOn(newval); }
248 
257  s64 get_maxTimeOnStateA(void);
258 
259  inline s64 maxTimeOnStateA(void)
260  { return this->get_maxTimeOnStateA(); }
261 
272  int set_maxTimeOnStateA(s64 newval);
273  inline int setMaxTimeOnStateA(s64 newval)
274  { return this->set_maxTimeOnStateA(newval); }
275 
284  s64 get_maxTimeOnStateB(void);
285 
286  inline s64 maxTimeOnStateB(void)
287  { return this->get_maxTimeOnStateB(); }
288 
299  int set_maxTimeOnStateB(s64 newval);
300  inline int setMaxTimeOnStateB(s64 newval)
301  { return this->set_maxTimeOnStateB(newval); }
302 
311  Y_OUTPUT_enum get_output(void);
312 
313  inline Y_OUTPUT_enum output(void)
314  { return this->get_output(); }
315 
326  int set_output(Y_OUTPUT_enum newval);
327  inline int setOutput(Y_OUTPUT_enum newval)
328  { return this->set_output(newval); }
329 
340  s64 get_pulseTimer(void);
341 
342  inline s64 pulseTimer(void)
343  { return this->get_pulseTimer(); }
344 
345  int set_pulseTimer(s64 newval);
346  inline int setPulseTimer(s64 newval)
347  { return this->set_pulseTimer(newval); }
348 
359  int pulse(int ms_duration);
360 
361  YDelayedPulse get_delayedPulseTimer(void);
362 
364  { return this->get_delayedPulseTimer(); }
365 
366  int set_delayedPulseTimer(YDelayedPulse newval);
368  { return this->set_delayedPulseTimer(newval); }
369 
380  int delayedPulse(int ms_delay,int ms_duration);
381 
391  s64 get_countdown(void);
392 
393  inline s64 countdown(void)
394  { return this->get_countdown(); }
395 
403  Y_AUTOSTART_enum get_autoStart(void);
404 
406  { return this->get_autoStart(); }
407 
419  int set_autoStart(Y_AUTOSTART_enum newval);
420  inline int setAutoStart(Y_AUTOSTART_enum newval)
421  { return this->set_autoStart(newval); }
422 
430  Y_RUNNING_enum get_running(void);
431 
432  inline Y_RUNNING_enum running(void)
433  { return this->get_running(); }
434 
444  int set_running(Y_RUNNING_enum newval);
445  inline int setRunning(Y_RUNNING_enum newval)
446  { return this->set_running(newval); }
447 
457  int resetWatchdog(void);
458 
467  s64 get_triggerDelay(void);
468 
469  inline s64 triggerDelay(void)
470  { return this->get_triggerDelay(); }
471 
482  int set_triggerDelay(s64 newval);
483  inline int setTriggerDelay(s64 newval)
484  { return this->set_triggerDelay(newval); }
485 
493  s64 get_triggerDuration(void);
494 
495  inline s64 triggerDuration(void)
496  { return this->get_triggerDuration(); }
497 
507  int set_triggerDuration(s64 newval);
508  inline int setTriggerDuration(s64 newval)
509  { return this->set_triggerDuration(newval); }
510 
538  static YWatchdog* FindWatchdog(string func);
539 
551  virtual int registerValueCallback(YWatchdogValueCallback callback);
553 
554  virtual int _invokeValueCallback(string value);
555 
556 
557  inline static YWatchdog* Find(string func)
558  { return YWatchdog::FindWatchdog(func); }
559 
567  YWatchdog *nextWatchdog(void);
568  inline YWatchdog *next(void)
569  { return this->nextWatchdog();}
570 
580  static YWatchdog* FirstWatchdog(void);
581  inline static YWatchdog* First(void)
582  { return YWatchdog::FirstWatchdog();}
583 #ifdef __BORLANDC__
584 #pragma option pop
585 #endif
586  //--- (end of YWatchdog accessors declaration)
587 };
588 
589 //--- (YWatchdog functions declaration)
590 
618 inline YWatchdog* yFindWatchdog(const string& func)
619 { return YWatchdog::FindWatchdog(func);}
630 { return YWatchdog::FirstWatchdog();}
631 
632 //--- (end of YWatchdog functions declaration)
633 
634 #endif
s64 maxTimeOnStateB(void)
Y_RUNNING_enum running(void)
static YWatchdog * FindWatchdog(string func)
YDelayedPulse delayedPulseTimer(void)
int setPulseTimer(s64 newval)
int setTriggerDelay(s64 newval)
int setMaxTimeOnStateB(s64 newval)
Y_RUNNING_enum _running
s64 _triggerDuration
int setOutput(Y_OUTPUT_enum newval)
s64 _maxTimeOnStateB
static YWatchdog * FirstWatchdog(void)
Y_AUTOSTART_enum _autoStart
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
s64 _maxTimeOnStateA
s64 countdown(void)
YWatchdogValueCallback _valueCallbackWatchdog
bool operator==(const YDelayedPulse &o) const
Y_OUTPUT_enum
s64 triggerDelay(void)
s64 maxTimeOnStateA(void)
s64 triggerDuration(void)
int setAutoStart(Y_AUTOSTART_enum newval)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
YWatchdog * yFirstWatchdog(void)
YDelayedPulse _delayedPulseTimer
s64 pulseTimer(void)
Y_AUTOSTART_enum autoStart(void)
static YWatchdog * First(void)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
YWatchdog * next(void)
int setDelayedPulseTimer(YDelayedPulse newval)
int setStateAtPowerOn(Y_STATEATPOWERON_enum newval)
YWatchdog * yFindWatchdog(const string &func)
Y_STATE_enum state(void)
Y_OUTPUT_enum
Definition: yocto_relay.h:74
Y_STATEATPOWERON_enum _stateAtPowerOn
Y_AUTOSTART_enum
Definition: yocto_api.h:175
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setTriggerDuration(s64 newval)
Y_STATE_enum
Y_STATEATPOWERON_enum
Definition: yocto_relay.h:65
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
int setMaxTimeOnStateA(s64 newval)
Y_STATE_enum
Definition: yocto_relay.h:57
Y_STATEATPOWERON_enum stateAtPowerOn(void)
int setState(Y_STATE_enum newval)
static const YDelayedPulse DELAYEDPULSETIMER_INVALID
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
Y_OUTPUT_enum _output
int setRunning(Y_RUNNING_enum newval)
Y_STATE_enum _state
Y_RUNNING_enum
void(* YWatchdogValueCallback)(YWatchdog *func, const string &functionValue)
Y_STATEATPOWERON_enum
Y_OUTPUT_enum output(void)
static YWatchdog * Find(string func)
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