yocto_steppermotor.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_steppermotor.h 29495 2017-12-22 16:45:20Z mvuilleu $
4  *
5  * Declares yFindStepperMotor(), the high-level API for StepperMotor 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_STEPPERMOTOR_H
42 #define YOCTO_STEPPERMOTOR_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YStepperMotor return codes)
50 //--- (end of YStepperMotor return codes)
51 //--- (YStepperMotor definitions)
52 class YStepperMotor; // forward declaration
53 
54 typedef void (*YStepperMotorValueCallback)(YStepperMotor *func, const string& functionValue);
55 #ifndef _Y_MOTORSTATE_ENUM
56 #define _Y_MOTORSTATE_ENUM
57 typedef enum {
66 #endif
67 #ifndef _Y_STEPPING_ENUM
68 #define _Y_STEPPING_ENUM
69 typedef enum {
77 #endif
78 #define Y_DIAGS_INVALID (YAPI_INVALID_UINT)
79 #define Y_STEPPOS_INVALID (YAPI_INVALID_DOUBLE)
80 #define Y_SPEED_INVALID (YAPI_INVALID_DOUBLE)
81 #define Y_PULLINSPEED_INVALID (YAPI_INVALID_DOUBLE)
82 #define Y_MAXACCEL_INVALID (YAPI_INVALID_DOUBLE)
83 #define Y_MAXSPEED_INVALID (YAPI_INVALID_DOUBLE)
84 #define Y_OVERCURRENT_INVALID (YAPI_INVALID_UINT)
85 #define Y_TCURRSTOP_INVALID (YAPI_INVALID_UINT)
86 #define Y_TCURRRUN_INVALID (YAPI_INVALID_UINT)
87 #define Y_ALERTMODE_INVALID (YAPI_INVALID_STRING)
88 #define Y_AUXMODE_INVALID (YAPI_INVALID_STRING)
89 #define Y_AUXSIGNAL_INVALID (YAPI_INVALID_INT)
90 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
91 //--- (end of YStepperMotor definitions)
92 
93 //--- (YStepperMotor declaration)
100 #ifdef __BORLANDC__
101 #pragma option push -w-8022
102 #endif
103 //--- (end of YStepperMotor declaration)
104 protected:
105  //--- (YStepperMotor attributes)
106  // Attributes (function value cache)
108  int _diags;
109  double _stepPos;
110  double _speed;
111  double _pullinSpeed;
112  double _maxAccel;
113  double _maxSpeed;
118  string _alertMode;
119  string _auxMode;
121  string _command;
123 
124  friend YStepperMotor *yFindStepperMotor(const string& func);
125  friend YStepperMotor *yFirstStepperMotor(void);
126 
127  // Function-specific method for parsing of JSON output and caching result
128  virtual int _parseAttr(YJSONObject* json_val);
129 
130  // Constructor is protected, use yFindStepperMotor factory function to instantiate
131  YStepperMotor(const string& func);
132  //--- (end of YStepperMotor attributes)
133 
134 public:
135  ~YStepperMotor();
136  //--- (YStepperMotor accessors declaration)
137 
138  static const Y_MOTORSTATE_enum MOTORSTATE_ABSENT = Y_MOTORSTATE_ABSENT;
139  static const Y_MOTORSTATE_enum MOTORSTATE_ALERT = Y_MOTORSTATE_ALERT;
140  static const Y_MOTORSTATE_enum MOTORSTATE_HI_Z = Y_MOTORSTATE_HI_Z;
141  static const Y_MOTORSTATE_enum MOTORSTATE_STOP = Y_MOTORSTATE_STOP;
142  static const Y_MOTORSTATE_enum MOTORSTATE_RUN = Y_MOTORSTATE_RUN;
143  static const Y_MOTORSTATE_enum MOTORSTATE_BATCH = Y_MOTORSTATE_BATCH;
144  static const Y_MOTORSTATE_enum MOTORSTATE_INVALID = Y_MOTORSTATE_INVALID;
145  static const int DIAGS_INVALID = YAPI_INVALID_UINT;
146  static const double STEPPOS_INVALID;
147  static const double SPEED_INVALID;
148  static const double PULLINSPEED_INVALID;
149  static const double MAXACCEL_INVALID;
150  static const double MAXSPEED_INVALID;
151  static const Y_STEPPING_enum STEPPING_MICROSTEP16 = Y_STEPPING_MICROSTEP16;
152  static const Y_STEPPING_enum STEPPING_MICROSTEP8 = Y_STEPPING_MICROSTEP8;
153  static const Y_STEPPING_enum STEPPING_MICROSTEP4 = Y_STEPPING_MICROSTEP4;
154  static const Y_STEPPING_enum STEPPING_HALFSTEP = Y_STEPPING_HALFSTEP;
155  static const Y_STEPPING_enum STEPPING_FULLSTEP = Y_STEPPING_FULLSTEP;
156  static const Y_STEPPING_enum STEPPING_INVALID = Y_STEPPING_INVALID;
157  static const int OVERCURRENT_INVALID = YAPI_INVALID_UINT;
158  static const int TCURRSTOP_INVALID = YAPI_INVALID_UINT;
159  static const int TCURRRUN_INVALID = YAPI_INVALID_UINT;
160  static const string ALERTMODE_INVALID;
161  static const string AUXMODE_INVALID;
162  static const int AUXSIGNAL_INVALID = YAPI_INVALID_INT;
163  static const string COMMAND_INVALID;
164 
173  Y_MOTORSTATE_enum get_motorState(void);
174 
176  { return this->get_motorState(); }
177 
185  int get_diags(void);
186 
187  inline int diags(void)
188  { return this->get_diags(); }
189 
204  int set_stepPos(double newval);
205  inline int setStepPos(double newval)
206  { return this->set_stepPos(newval); }
207 
216  double get_stepPos(void);
217 
218  inline double stepPos(void)
219  { return this->get_stepPos(); }
220 
229  double get_speed(void);
230 
231  inline double speed(void)
232  { return this->get_speed(); }
233 
244  int set_pullinSpeed(double newval);
245  inline int setPullinSpeed(double newval)
246  { return this->set_pullinSpeed(newval); }
247 
256  double get_pullinSpeed(void);
257 
258  inline double pullinSpeed(void)
259  { return this->get_pullinSpeed(); }
260 
271  int set_maxAccel(double newval);
272  inline int setMaxAccel(double newval)
273  { return this->set_maxAccel(newval); }
274 
282  double get_maxAccel(void);
283 
284  inline double maxAccel(void)
285  { return this->get_maxAccel(); }
286 
296  int set_maxSpeed(double newval);
297  inline int setMaxSpeed(double newval)
298  { return this->set_maxSpeed(newval); }
299 
307  double get_maxSpeed(void);
308 
309  inline double maxSpeed(void)
310  { return this->get_maxSpeed(); }
311 
320  Y_STEPPING_enum get_stepping(void);
321 
323  { return this->get_stepping(); }
324 
335  int set_stepping(Y_STEPPING_enum newval);
336  inline int setStepping(Y_STEPPING_enum newval)
337  { return this->set_stepping(newval); }
338 
346  int get_overcurrent(void);
347 
348  inline int overcurrent(void)
349  { return this->get_overcurrent(); }
350 
360  int set_overcurrent(int newval);
361  inline int setOvercurrent(int newval)
362  { return this->set_overcurrent(newval); }
363 
371  int get_tCurrStop(void);
372 
373  inline int tCurrStop(void)
374  { return this->get_tCurrStop(); }
375 
386  int set_tCurrStop(int newval);
387  inline int setTCurrStop(int newval)
388  { return this->set_tCurrStop(newval); }
389 
397  int get_tCurrRun(void);
398 
399  inline int tCurrRun(void)
400  { return this->get_tCurrRun(); }
401 
412  int set_tCurrRun(int newval);
413  inline int setTCurrRun(int newval)
414  { return this->set_tCurrRun(newval); }
415 
416  string get_alertMode(void);
417 
418  inline string alertMode(void)
419  { return this->get_alertMode(); }
420 
421  int set_alertMode(const string& newval);
422  inline int setAlertMode(const string& newval)
423  { return this->set_alertMode(newval); }
424 
425  string get_auxMode(void);
426 
427  inline string auxMode(void)
428  { return this->get_auxMode(); }
429 
430  int set_auxMode(const string& newval);
431  inline int setAuxMode(const string& newval)
432  { return this->set_auxMode(newval); }
433 
441  int get_auxSignal(void);
442 
443  inline int auxSignal(void)
444  { return this->get_auxSignal(); }
445 
456  int set_auxSignal(int newval);
457  inline int setAuxSignal(int newval)
458  { return this->set_auxSignal(newval); }
459 
460  string get_command(void);
461 
462  inline string command(void)
463  { return this->get_command(); }
464 
465  int set_command(const string& newval);
466  inline int setCommand(const string& newval)
467  { return this->set_command(newval); }
468 
496  static YStepperMotor* FindStepperMotor(string func);
497 
511 
512  virtual int _invokeValueCallback(string value);
513 
514  virtual int sendCommand(string command);
515 
522  virtual int reset(void);
523 
532  virtual int findHomePosition(double speed);
533 
544  virtual int changeSpeed(double speed);
545 
556  virtual int moveTo(double absPos);
557 
568  virtual int moveRel(double relPos);
569 
581  virtual int moveRelSlow(double relPos,double maxSpeed);
582 
591  virtual int pause(int waitMs);
592 
599  virtual int emergencyStop(void);
600 
609  virtual int alertStepOut(void);
610 
621  virtual int alertStepDir(int dir);
622 
629  virtual int abortAndBrake(void);
630 
637  virtual int abortAndHiZ(void);
638 
639 
640  inline static YStepperMotor* Find(string func)
641  { return YStepperMotor::FindStepperMotor(func); }
642 
650  YStepperMotor *nextStepperMotor(void);
651  inline YStepperMotor *next(void)
652  { return this->nextStepperMotor();}
653 
663  static YStepperMotor* FirstStepperMotor(void);
664  inline static YStepperMotor* First(void)
666 #ifdef __BORLANDC__
667 #pragma option pop
668 #endif
669  //--- (end of YStepperMotor accessors declaration)
670 };
671 
672 //--- (YStepperMotor functions declaration)
673 
701 inline YStepperMotor* yFindStepperMotor(const string& func)
702 { return YStepperMotor::FindStepperMotor(func);}
714 
715 //--- (end of YStepperMotor functions declaration)
716 
717 #endif
YStepperMotorValueCallback _valueCallbackStepperMotor
static const double MAXACCEL_INVALID
double maxAccel(void)
Y_MOTORSTATE_enum
static const string AUXMODE_INVALID
static const double MAXSPEED_INVALID
int setOvercurrent(int newval)
void(* YStepperMotorValueCallback)(YStepperMotor *func, const string &functionValue)
int setTCurrRun(int newval)
Y_MOTORSTATE_enum motorState(void)
int setAlertMode(const string &newval)
double speed(void)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
string command(void)
string alertMode(void)
static YStepperMotor * FindStepperMotor(string func)
int setAuxMode(const string &newval)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
Y_STEPPING_enum
int setStepPos(double newval)
int setTCurrStop(int newval)
double pullinSpeed(void)
string auxMode(void)
ROSLIB_DECL std::string command(const std::string &cmd)
static YStepperMotor * Find(string func)
static const double STEPPOS_INVALID
YStepperMotor * yFindStepperMotor(const string &func)
Y_STEPPING_enum _stepping
Y_STEPPING_enum stepping(void)
Y_MOTORSTATE_enum _motorState
int setAuxSignal(int newval)
int setMaxAccel(double newval)
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
YStepperMotor * yFirstStepperMotor(void)
static YStepperMotor * First(void)
static const double PULLINSPEED_INVALID
YStepperMotor * next(void)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
int setMaxSpeed(double newval)
static const string ALERTMODE_INVALID
static const string COMMAND_INVALID
static const double SPEED_INVALID
double stepPos(void)
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
double maxSpeed(void)
int setCommand(const string &newval)
int setStepping(Y_STEPPING_enum newval)
static YStepperMotor * FirstStepperMotor(void)
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
int setPullinSpeed(double newval)


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