yocto_motor.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_motor.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindMotor(), the high-level API for Motor 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_MOTOR_H
42 #define YOCTO_MOTOR_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YMotor return codes)
50 //--- (end of YMotor return codes)
51 //--- (YMotor definitions)
52 class YMotor; // forward declaration
53 
54 typedef void (*YMotorValueCallback)(YMotor *func, const string& functionValue);
55 #ifndef _Y_MOTORSTATUS_ENUM
56 #define _Y_MOTORSTATUS_ENUM
57 typedef enum {
68 #endif
69 #define Y_DRIVINGFORCE_INVALID (YAPI_INVALID_DOUBLE)
70 #define Y_BRAKINGFORCE_INVALID (YAPI_INVALID_DOUBLE)
71 #define Y_CUTOFFVOLTAGE_INVALID (YAPI_INVALID_DOUBLE)
72 #define Y_OVERCURRENTLIMIT_INVALID (YAPI_INVALID_INT)
73 #define Y_FREQUENCY_INVALID (YAPI_INVALID_DOUBLE)
74 #define Y_STARTERTIME_INVALID (YAPI_INVALID_INT)
75 #define Y_FAILSAFETIMEOUT_INVALID (YAPI_INVALID_UINT)
76 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
77 //--- (end of YMotor definitions)
78 
79 //--- (YMotor declaration)
90 #ifdef __BORLANDC__
91 #pragma option push -w-8022
92 #endif
93 //--- (end of YMotor declaration)
94 protected:
95  //--- (YMotor attributes)
96  // Attributes (function value cache)
98  double _drivingForce;
99  double _brakingForce;
102  double _frequency;
105  string _command;
107 
108  friend YMotor *yFindMotor(const string& func);
109  friend YMotor *yFirstMotor(void);
110 
111  // Function-specific method for parsing of JSON output and caching result
112  virtual int _parseAttr(YJSONObject* json_val);
113 
114  // Constructor is protected, use yFindMotor factory function to instantiate
115  YMotor(const string& func);
116  //--- (end of YMotor attributes)
117 
118 public:
119  ~YMotor();
120  //--- (YMotor accessors declaration)
121 
122  static const Y_MOTORSTATUS_enum MOTORSTATUS_IDLE = Y_MOTORSTATUS_IDLE;
123  static const Y_MOTORSTATUS_enum MOTORSTATUS_BRAKE = Y_MOTORSTATUS_BRAKE;
124  static const Y_MOTORSTATUS_enum MOTORSTATUS_FORWD = Y_MOTORSTATUS_FORWD;
125  static const Y_MOTORSTATUS_enum MOTORSTATUS_BACKWD = Y_MOTORSTATUS_BACKWD;
126  static const Y_MOTORSTATUS_enum MOTORSTATUS_LOVOLT = Y_MOTORSTATUS_LOVOLT;
127  static const Y_MOTORSTATUS_enum MOTORSTATUS_HICURR = Y_MOTORSTATUS_HICURR;
128  static const Y_MOTORSTATUS_enum MOTORSTATUS_HIHEAT = Y_MOTORSTATUS_HIHEAT;
129  static const Y_MOTORSTATUS_enum MOTORSTATUS_FAILSF = Y_MOTORSTATUS_FAILSF;
130  static const Y_MOTORSTATUS_enum MOTORSTATUS_INVALID = Y_MOTORSTATUS_INVALID;
131  static const double DRIVINGFORCE_INVALID;
132  static const double BRAKINGFORCE_INVALID;
133  static const double CUTOFFVOLTAGE_INVALID;
134  static const int OVERCURRENTLIMIT_INVALID = YAPI_INVALID_INT;
135  static const double FREQUENCY_INVALID;
136  static const int STARTERTIME_INVALID = YAPI_INVALID_INT;
137  static const int FAILSAFETIMEOUT_INVALID = YAPI_INVALID_UINT;
138  static const string COMMAND_INVALID;
139 
159  Y_MOTORSTATUS_enum get_motorStatus(void);
160 
162  { return this->get_motorStatus(); }
163 
164  int set_motorStatus(Y_MOTORSTATUS_enum newval);
166  { return this->set_motorStatus(newval); }
167 
181  int set_drivingForce(double newval);
182  inline int setDrivingForce(double newval)
183  { return this->set_drivingForce(newval); }
184 
193  double get_drivingForce(void);
194 
195  inline double drivingForce(void)
196  { return this->get_drivingForce(); }
197 
210  int set_brakingForce(double newval);
211  inline int setBrakingForce(double newval)
212  { return this->set_brakingForce(newval); }
213 
222  double get_brakingForce(void);
223 
224  inline double brakingForce(void)
225  { return this->get_brakingForce(); }
226 
242  int set_cutOffVoltage(double newval);
243  inline int setCutOffVoltage(double newval)
244  { return this->set_cutOffVoltage(newval); }
245 
257  double get_cutOffVoltage(void);
258 
259  inline double cutOffVoltage(void)
260  { return this->get_cutOffVoltage(); }
261 
271  int get_overCurrentLimit(void);
272 
273  inline int overCurrentLimit(void)
274  { return this->get_overCurrentLimit(); }
275 
290  int set_overCurrentLimit(int newval);
291  inline int setOverCurrentLimit(int newval)
292  { return this->set_overCurrentLimit(newval); }
293 
306  int set_frequency(double newval);
307  inline int setFrequency(double newval)
308  { return this->set_frequency(newval); }
309 
317  double get_frequency(void);
318 
319  inline double frequency(void)
320  { return this->get_frequency(); }
321 
332  int get_starterTime(void);
333 
334  inline int starterTime(void)
335  { return this->get_starterTime(); }
336 
349  int set_starterTime(int newval);
350  inline int setStarterTime(int newval)
351  { return this->set_starterTime(newval); }
352 
365  int get_failSafeTimeout(void);
366 
367  inline int failSafeTimeout(void)
368  { return this->get_failSafeTimeout(); }
369 
384  int set_failSafeTimeout(int newval);
385  inline int setFailSafeTimeout(int newval)
386  { return this->set_failSafeTimeout(newval); }
387 
388  string get_command(void);
389 
390  inline string command(void)
391  { return this->get_command(); }
392 
393  int set_command(const string& newval);
394  inline int setCommand(const string& newval)
395  { return this->set_command(newval); }
396 
424  static YMotor* FindMotor(string func);
425 
437  virtual int registerValueCallback(YMotorValueCallback callback);
439 
440  virtual int _invokeValueCallback(string value);
441 
448  virtual int keepALive(void);
449 
454  virtual int resetStatus(void);
455 
466  virtual int drivingForceMove(double targetPower,int delay);
467 
478  virtual int brakingForceMove(double targetPower,int delay);
479 
480 
481  inline static YMotor* Find(string func)
482  { return YMotor::FindMotor(func); }
483 
491  YMotor *nextMotor(void);
492  inline YMotor *next(void)
493  { return this->nextMotor();}
494 
504  static YMotor* FirstMotor(void);
505  inline static YMotor* First(void)
506  { return YMotor::FirstMotor();}
507 #ifdef __BORLANDC__
508 #pragma option pop
509 #endif
510  //--- (end of YMotor accessors declaration)
511 };
512 
513 //--- (YMotor functions declaration)
514 
542 inline YMotor* yFindMotor(const string& func)
543 { return YMotor::FindMotor(func);}
553 inline YMotor* yFirstMotor(void)
554 { return YMotor::FirstMotor();}
555 
556 //--- (end of YMotor functions declaration)
557 
558 #endif
int setFrequency(double newval)
Definition: yocto_motor.h:307
Y_MOTORSTATUS_enum _motorStatus
Definition: yocto_motor.h:97
YMotor * yFindMotor(const string &func)
Definition: yocto_motor.h:542
int setStarterTime(int newval)
Definition: yocto_motor.h:350
static const string COMMAND_INVALID
Definition: yocto_motor.h:138
Y_MOTORSTATUS_enum motorStatus(void)
Definition: yocto_motor.h:161
static const double CUTOFFVOLTAGE_INVALID
Definition: yocto_motor.h:133
int _starterTime
Definition: yocto_motor.h:103
static const double FREQUENCY_INVALID
Definition: yocto_motor.h:135
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
static YMotor * FindMotor(string func)
double _brakingForce
Definition: yocto_motor.h:99
int starterTime(void)
Definition: yocto_motor.h:334
double cutOffVoltage(void)
Definition: yocto_motor.h:259
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
int setCommand(const string &newval)
Definition: yocto_motor.h:394
static YMotor * First(void)
Definition: yocto_motor.h:505
string _command
Definition: yocto_motor.h:105
int setFailSafeTimeout(int newval)
Definition: yocto_motor.h:385
int overCurrentLimit(void)
Definition: yocto_motor.h:273
double frequency(void)
Definition: yocto_motor.h:319
double drivingForce(void)
Definition: yocto_motor.h:195
double _drivingForce
Definition: yocto_motor.h:98
YMotorValueCallback _valueCallbackMotor
Definition: yocto_motor.h:106
int _overCurrentLimit
Definition: yocto_motor.h:101
void(* YMotorValueCallback)(YMotor *func, const string &functionValue)
Definition: yocto_motor.h:54
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setBrakingForce(double newval)
Definition: yocto_motor.h:211
double _frequency
Definition: yocto_motor.h:102
YMotor * yFirstMotor(void)
Definition: yocto_motor.h:553
int setMotorStatus(Y_MOTORSTATUS_enum newval)
Definition: yocto_motor.h:165
int failSafeTimeout(void)
Definition: yocto_motor.h:367
static const double BRAKINGFORCE_INVALID
Definition: yocto_motor.h:132
static YMotor * Find(string func)
Definition: yocto_motor.h:481
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
double _cutOffVoltage
Definition: yocto_motor.h:100
int setOverCurrentLimit(int newval)
Definition: yocto_motor.h:291
YMotor * next(void)
Definition: yocto_motor.h:492
Y_MOTORSTATUS_enum
Definition: yocto_motor.h:57
int setDrivingForce(double newval)
Definition: yocto_motor.h:182
static YMotor * FirstMotor(void)
double brakingForce(void)
Definition: yocto_motor.h:224
string command(void)
Definition: yocto_motor.h:390
static const double DRIVINGFORCE_INVALID
Definition: yocto_motor.h:131
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
int _failSafeTimeout
Definition: yocto_motor.h:104
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
int setCutOffVoltage(double newval)
Definition: yocto_motor.h:243


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