yocto_relay.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_relay.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindRelay(), the high-level API for Relay 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_RELAY_H
42 #define YOCTO_RELAY_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YRelay return codes)
50 //--- (end of YRelay return codes)
51 //--- (YRelay definitions)
52 class YRelay; // forward declaration
53 
54 typedef void (*YRelayValueCallback)(YRelay *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 #define Y_MAXTIMEONSTATEA_INVALID (YAPI_INVALID_LONG)
98 #define Y_MAXTIMEONSTATEB_INVALID (YAPI_INVALID_LONG)
99 #define Y_PULSETIMER_INVALID (YAPI_INVALID_LONG)
100 #define Y_COUNTDOWN_INVALID (YAPI_INVALID_LONG)
101 //--- (end of YRelay definitions)
102 
103 //--- (YRelay declaration)
116 #ifdef __BORLANDC__
117 #pragma option push -w-8022
118 #endif
119 //--- (end of YRelay declaration)
120 protected:
121  //--- (YRelay attributes)
122  // Attributes (function value cache)
132 
133  friend YRelay *yFindRelay(const string& func);
134  friend YRelay *yFirstRelay(void);
135 
136  // Function-specific method for parsing of JSON output and caching result
137  virtual int _parseAttr(YJSONObject* json_val);
138 
139  // Constructor is protected, use yFindRelay factory function to instantiate
140  YRelay(const string& func);
141  //--- (end of YRelay attributes)
142 
143 public:
144  ~YRelay();
145  //--- (YRelay accessors declaration)
146 
147  static const Y_STATE_enum STATE_A = Y_STATE_A;
148  static const Y_STATE_enum STATE_B = Y_STATE_B;
149  static const Y_STATE_enum STATE_INVALID = Y_STATE_INVALID;
150  static const Y_STATEATPOWERON_enum STATEATPOWERON_UNCHANGED = Y_STATEATPOWERON_UNCHANGED;
151  static const Y_STATEATPOWERON_enum STATEATPOWERON_A = Y_STATEATPOWERON_A;
152  static const Y_STATEATPOWERON_enum STATEATPOWERON_B = Y_STATEATPOWERON_B;
153  static const Y_STATEATPOWERON_enum STATEATPOWERON_INVALID = Y_STATEATPOWERON_INVALID;
154  static const s64 MAXTIMEONSTATEA_INVALID = YAPI_INVALID_LONG;
155  static const s64 MAXTIMEONSTATEB_INVALID = YAPI_INVALID_LONG;
156  static const Y_OUTPUT_enum OUTPUT_OFF = Y_OUTPUT_OFF;
157  static const Y_OUTPUT_enum OUTPUT_ON = Y_OUTPUT_ON;
158  static const Y_OUTPUT_enum OUTPUT_INVALID = Y_OUTPUT_INVALID;
159  static const s64 PULSETIMER_INVALID = YAPI_INVALID_LONG;
161  static const s64 COUNTDOWN_INVALID = YAPI_INVALID_LONG;
162 
171  Y_STATE_enum get_state(void);
172 
173  inline Y_STATE_enum state(void)
174  { return this->get_state(); }
175 
186  int set_state(Y_STATE_enum newval);
187  inline int setState(Y_STATE_enum newval)
188  { return this->set_state(newval); }
189 
200  Y_STATEATPOWERON_enum get_stateAtPowerOn(void);
201 
203  { return this->get_stateAtPowerOn(); }
204 
216  int set_stateAtPowerOn(Y_STATEATPOWERON_enum newval);
218  { return this->set_stateAtPowerOn(newval); }
219 
228  s64 get_maxTimeOnStateA(void);
229 
230  inline s64 maxTimeOnStateA(void)
231  { return this->get_maxTimeOnStateA(); }
232 
243  int set_maxTimeOnStateA(s64 newval);
244  inline int setMaxTimeOnStateA(s64 newval)
245  { return this->set_maxTimeOnStateA(newval); }
246 
255  s64 get_maxTimeOnStateB(void);
256 
257  inline s64 maxTimeOnStateB(void)
258  { return this->get_maxTimeOnStateB(); }
259 
270  int set_maxTimeOnStateB(s64 newval);
271  inline int setMaxTimeOnStateB(s64 newval)
272  { return this->set_maxTimeOnStateB(newval); }
273 
282  Y_OUTPUT_enum get_output(void);
283 
284  inline Y_OUTPUT_enum output(void)
285  { return this->get_output(); }
286 
297  int set_output(Y_OUTPUT_enum newval);
298  inline int setOutput(Y_OUTPUT_enum newval)
299  { return this->set_output(newval); }
300 
311  s64 get_pulseTimer(void);
312 
313  inline s64 pulseTimer(void)
314  { return this->get_pulseTimer(); }
315 
316  int set_pulseTimer(s64 newval);
317  inline int setPulseTimer(s64 newval)
318  { return this->set_pulseTimer(newval); }
319 
330  int pulse(int ms_duration);
331 
332  YDelayedPulse get_delayedPulseTimer(void);
333 
335  { return this->get_delayedPulseTimer(); }
336 
337  int set_delayedPulseTimer(YDelayedPulse newval);
339  { return this->set_delayedPulseTimer(newval); }
340 
351  int delayedPulse(int ms_delay,int ms_duration);
352 
362  s64 get_countdown(void);
363 
364  inline s64 countdown(void)
365  { return this->get_countdown(); }
366 
394  static YRelay* FindRelay(string func);
395 
407  virtual int registerValueCallback(YRelayValueCallback callback);
409 
410  virtual int _invokeValueCallback(string value);
411 
412 
413  inline static YRelay* Find(string func)
414  { return YRelay::FindRelay(func); }
415 
423  YRelay *nextRelay(void);
424  inline YRelay *next(void)
425  { return this->nextRelay();}
426 
436  static YRelay* FirstRelay(void);
437  inline static YRelay* First(void)
438  { return YRelay::FirstRelay();}
439 #ifdef __BORLANDC__
440 #pragma option pop
441 #endif
442  //--- (end of YRelay accessors declaration)
443 };
444 
445 //--- (YRelay functions declaration)
446 
474 inline YRelay* yFindRelay(const string& func)
475 { return YRelay::FindRelay(func);}
485 inline YRelay* yFirstRelay(void)
486 { return YRelay::FirstRelay();}
487 
488 //--- (end of YRelay functions declaration)
489 
490 #endif
s64 _countdown
Definition: yocto_relay.h:130
Y_OUTPUT_enum output(void)
Definition: yocto_relay.h:284
int setState(Y_STATE_enum newval)
Definition: yocto_relay.h:187
void(* YRelayValueCallback)(YRelay *func, const string &functionValue)
Definition: yocto_relay.h:54
static YRelay * FirstRelay(void)
Y_STATE_enum state(void)
Definition: yocto_relay.h:173
int setMaxTimeOnStateB(s64 newval)
Definition: yocto_relay.h:271
YRelay * yFindRelay(const string &func)
Definition: yocto_relay.h:474
Y_STATEATPOWERON_enum stateAtPowerOn(void)
Definition: yocto_relay.h:202
Y_STATE_enum _state
Definition: yocto_relay.h:123
Y_STATEATPOWERON_enum _stateAtPowerOn
Definition: yocto_relay.h:124
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
int setStateAtPowerOn(Y_STATEATPOWERON_enum newval)
Definition: yocto_relay.h:217
static YRelay * Find(string func)
Definition: yocto_relay.h:413
bool operator==(const YDelayedPulse &o) const
Definition: yocto_relay.h:92
int setMaxTimeOnStateA(s64 newval)
Definition: yocto_relay.h:244
YRelay * yFirstRelay(void)
Definition: yocto_relay.h:485
static YRelay * FindRelay(string func)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
Y_OUTPUT_enum _output
Definition: yocto_relay.h:127
s64 _maxTimeOnStateA
Definition: yocto_relay.h:125
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
s64 pulseTimer(void)
Definition: yocto_relay.h:313
int setPulseTimer(s64 newval)
Definition: yocto_relay.h:317
YRelayValueCallback _valueCallbackRelay
Definition: yocto_relay.h:131
s64 _pulseTimer
Definition: yocto_relay.h:128
static const YDelayedPulse DELAYEDPULSETIMER_INVALID
Definition: yocto_relay.h:160
Y_OUTPUT_enum
Definition: yocto_relay.h:74
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
YDelayedPulse _delayedPulseTimer
Definition: yocto_relay.h:129
s64 countdown(void)
Definition: yocto_relay.h:364
Y_STATEATPOWERON_enum
Definition: yocto_relay.h:65
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
s64 _maxTimeOnStateB
Definition: yocto_relay.h:126
YDelayedPulse delayedPulseTimer(void)
Definition: yocto_relay.h:334
Y_STATE_enum
Definition: yocto_relay.h:57
YRelay * next(void)
Definition: yocto_relay.h:424
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
int setOutput(Y_OUTPUT_enum newval)
Definition: yocto_relay.h:298
int setDelayedPulseTimer(YDelayedPulse newval)
Definition: yocto_relay.h:338
static YRelay * First(void)
Definition: yocto_relay.h:437
s64 maxTimeOnStateB(void)
Definition: yocto_relay.h:257
s64 maxTimeOnStateA(void)
Definition: yocto_relay.h:230
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