yocto_digitalio.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_digitalio.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindDigitalIO(), the high-level API for DigitalIO 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_DIGITALIO_H
42 #define YOCTO_DIGITALIO_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YDigitalIO return codes)
50 //--- (end of YDigitalIO return codes)
51 //--- (YDigitalIO definitions)
52 class YDigitalIO; // forward declaration
53 
54 typedef void (*YDigitalIOValueCallback)(YDigitalIO *func, const string& functionValue);
55 #ifndef _Y_OUTPUTVOLTAGE_ENUM
56 #define _Y_OUTPUTVOLTAGE_ENUM
57 typedef enum {
63 #endif
64 #define Y_PORTSTATE_INVALID (YAPI_INVALID_UINT)
65 #define Y_PORTDIRECTION_INVALID (YAPI_INVALID_UINT)
66 #define Y_PORTOPENDRAIN_INVALID (YAPI_INVALID_UINT)
67 #define Y_PORTPOLARITY_INVALID (YAPI_INVALID_UINT)
68 #define Y_PORTDIAGS_INVALID (YAPI_INVALID_UINT)
69 #define Y_PORTSIZE_INVALID (YAPI_INVALID_UINT)
70 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
71 //--- (end of YDigitalIO definitions)
72 
73 //--- (YDigitalIO declaration)
83 #ifdef __BORLANDC__
84 #pragma option push -w-8022
85 #endif
86 //--- (end of YDigitalIO declaration)
87 protected:
88  //--- (YDigitalIO attributes)
89  // Attributes (function value cache)
95  int _portSize;
97  string _command;
99 
100  friend YDigitalIO *yFindDigitalIO(const string& func);
101  friend YDigitalIO *yFirstDigitalIO(void);
102 
103  // Function-specific method for parsing of JSON output and caching result
104  virtual int _parseAttr(YJSONObject* json_val);
105 
106  // Constructor is protected, use yFindDigitalIO factory function to instantiate
107  YDigitalIO(const string& func);
108  //--- (end of YDigitalIO attributes)
109 
110 public:
111  ~YDigitalIO();
112  //--- (YDigitalIO accessors declaration)
113 
114  static const int PORTSTATE_INVALID = YAPI_INVALID_UINT;
115  static const int PORTDIRECTION_INVALID = YAPI_INVALID_UINT;
116  static const int PORTOPENDRAIN_INVALID = YAPI_INVALID_UINT;
117  static const int PORTPOLARITY_INVALID = YAPI_INVALID_UINT;
118  static const int PORTDIAGS_INVALID = YAPI_INVALID_UINT;
119  static const int PORTSIZE_INVALID = YAPI_INVALID_UINT;
120  static const Y_OUTPUTVOLTAGE_enum OUTPUTVOLTAGE_USB_5V = Y_OUTPUTVOLTAGE_USB_5V;
121  static const Y_OUTPUTVOLTAGE_enum OUTPUTVOLTAGE_USB_3V = Y_OUTPUTVOLTAGE_USB_3V;
122  static const Y_OUTPUTVOLTAGE_enum OUTPUTVOLTAGE_EXT_V = Y_OUTPUTVOLTAGE_EXT_V;
123  static const Y_OUTPUTVOLTAGE_enum OUTPUTVOLTAGE_INVALID = Y_OUTPUTVOLTAGE_INVALID;
124  static const string COMMAND_INVALID;
125 
133  int get_portState(void);
134 
135  inline int portState(void)
136  { return this->get_portState(); }
137 
148  int set_portState(int newval);
149  inline int setPortState(int newval)
150  { return this->set_portState(newval); }
151 
160  int get_portDirection(void);
161 
162  inline int portDirection(void)
163  { return this->get_portDirection(); }
164 
176  int set_portDirection(int newval);
177  inline int setPortDirection(int newval)
178  { return this->set_portDirection(newval); }
179 
189  int get_portOpenDrain(void);
190 
191  inline int portOpenDrain(void)
192  { return this->get_portOpenDrain(); }
193 
205  int set_portOpenDrain(int newval);
206  inline int setPortOpenDrain(int newval)
207  { return this->set_portOpenDrain(newval); }
208 
217  int get_portPolarity(void);
218 
219  inline int portPolarity(void)
220  { return this->get_portPolarity(); }
221 
235  int set_portPolarity(int newval);
236  inline int setPortPolarity(int newval)
237  { return this->set_portPolarity(newval); }
238 
248  int get_portDiags(void);
249 
250  inline int portDiags(void)
251  { return this->get_portDiags(); }
252 
260  int get_portSize(void);
261 
262  inline int portSize(void)
263  { return this->get_portSize(); }
264 
273  Y_OUTPUTVOLTAGE_enum get_outputVoltage(void);
274 
276  { return this->get_outputVoltage(); }
277 
289  int set_outputVoltage(Y_OUTPUTVOLTAGE_enum newval);
291  { return this->set_outputVoltage(newval); }
292 
293  string get_command(void);
294 
295  inline string command(void)
296  { return this->get_command(); }
297 
298  int set_command(const string& newval);
299  inline int setCommand(const string& newval)
300  { return this->set_command(newval); }
301 
329  static YDigitalIO* FindDigitalIO(string func);
330 
342  virtual int registerValueCallback(YDigitalIOValueCallback callback);
344 
345  virtual int _invokeValueCallback(string value);
346 
357  virtual int set_bitState(int bitno,int bitstate);
358 
368  virtual int get_bitState(int bitno);
369 
379  virtual int toggle_bitState(int bitno);
380 
392  virtual int set_bitDirection(int bitno,int bitdirection);
393 
403  virtual int get_bitDirection(int bitno);
404 
417  virtual int set_bitPolarity(int bitno,int bitpolarity);
418 
429  virtual int get_bitPolarity(int bitno);
430 
443  virtual int set_bitOpenDrain(int bitno,int opendrain);
444 
456  virtual int get_bitOpenDrain(int bitno);
457 
470  virtual int pulse(int bitno,int ms_duration);
471 
485  virtual int delayedPulse(int bitno,int ms_delay,int ms_duration);
486 
487 
488  inline static YDigitalIO* Find(string func)
489  { return YDigitalIO::FindDigitalIO(func); }
490 
498  YDigitalIO *nextDigitalIO(void);
499  inline YDigitalIO *next(void)
500  { return this->nextDigitalIO();}
501 
511  static YDigitalIO* FirstDigitalIO(void);
512  inline static YDigitalIO* First(void)
513  { return YDigitalIO::FirstDigitalIO();}
514 #ifdef __BORLANDC__
515 #pragma option pop
516 #endif
517  //--- (end of YDigitalIO accessors declaration)
518 };
519 
520 //--- (YDigitalIO functions declaration)
521 
549 inline YDigitalIO* yFindDigitalIO(const string& func)
550 { return YDigitalIO::FindDigitalIO(func);}
561 { return YDigitalIO::FirstDigitalIO();}
562 
563 //--- (end of YDigitalIO functions declaration)
564 
565 #endif
Y_OUTPUTVOLTAGE_enum
int portPolarity(void)
int setPortPolarity(int newval)
int portState(void)
int setPortState(int newval)
int setPortOpenDrain(int newval)
int portDiags(void)
void(* YDigitalIOValueCallback)(YDigitalIO *func, const string &functionValue)
YDigitalIO * next(void)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
int portDirection(void)
int setOutputVoltage(Y_OUTPUTVOLTAGE_enum newval)
static YDigitalIO * Find(string func)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
string _command
Y_OUTPUTVOLTAGE_enum _outputVoltage
int setCommand(const string &newval)
int portOpenDrain(void)
YDigitalIO * yFindDigitalIO(const string &func)
static const string COMMAND_INVALID
static YDigitalIO * First(void)
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
YDigitalIOValueCallback _valueCallbackDigitalIO
static YDigitalIO * FirstDigitalIO(void)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
string command(void)
int portSize(void)
int setPortDirection(int newval)
YDigitalIO * yFirstDigitalIO(void)
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
static YDigitalIO * FindDigitalIO(string func)
Y_OUTPUTVOLTAGE_enum outputVoltage(void)


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