motor.h
Go to the documentation of this file.
1 #ifndef PHIDGETS_API_MOTOR_H
2 #define PHIDGETS_API_MOTOR_H
3 
4 #include "phidgets_api/phidget.h"
5 
6 namespace phidgets {
7 
8 class MotorController : public Phidget
9 {
10  public:
12 
13  virtual ~MotorController();
14 
15  // Motor specific
16  int getMotorCount();
17  double getVelocity(int index);
18  void setVelocity(int index, double velocity);
19  double getAcceleration(int index);
20  void setAcceleration(int index, double acceleration);
21  double getAccelerationMax(int index);
22  double getAccelerationMin(int index);
23  double getCurrent(int index);
24 
25  // Digital inputs
26  int getInputCount();
27  bool getInputState(int index);
28 
29  // Encoder inputs
30  int getEncoderCount();
31  int getEncoderPosition(int index);
32  void setEncoderPosition(int index, int position);
33 
34  // Back EMF
35  int getBackEMFSensingState(int index);
36  void setBackEMFSensingState(int index, int bEMFState);
37  double getBackEMF(int index);
38 
39  double getSupplyVoltage();
40 
41  double getBraking(int index);
42  void setBraking(int index, double braking);
43 
44  // Analog sensors
45  int getSensorCount();
46  int getSensorValue(int index);
47  int getSensorRawValue(int index);
48 
49  int getRatiometric();
50  void setRatiometric(int ratiometric);
51 
52  protected:
53  virtual void velocityChangeHandler(int index, double velocity);
54  virtual void currentChangeHandler(int index, double current);
55  virtual void inputChangeHandler(int index, int inputState);
56  virtual void encoderPositionChangeHandler(int index, int time,
57  int positionChange);
58  virtual void encoderPositionUpdateHandler(int index, int positionChange);
59  virtual void backEMFUpdateHandler(int index, double voltage);
60  virtual void sensorUpdateHandler(int index, int sensorValue);
61  virtual void currentUpdateHandler(int index, double current);
62 
63  private:
64  CPhidgetMotorControlHandle motor_handle_;
65 
66  static int VelocityChangeHandler(CPhidgetMotorControlHandle phid,
67  void *userPtr, int index, double velocity);
68  static int CurrentChangeHandler(CPhidgetMotorControlHandle phid,
69  void *userPtr, int index, double current);
70  static int InputChangeHandler(CPhidgetMotorControlHandle phid,
71  void *userPtr, int index, int inputState);
72  static int EncoderPositionChangeHandler(CPhidgetMotorControlHandle phid,
73  void *userPtr, int index, int time,
74  int positionChange);
75  static int EncoderPositionUpdateHandler(CPhidgetMotorControlHandle phid,
76  void *userPtr, int index,
77  int positionChange);
78  static int BackEMFUpdateHandler(CPhidgetMotorControlHandle phid,
79  void *userPtr, int index, double voltage);
80  static int SensorUpdateHandler(CPhidgetMotorControlHandle phid,
81  void *userPtr, int index, int sensorValue);
82  static int CurrentUpdateHandler(CPhidgetMotorControlHandle phid,
83  void *userPtr, int index, double current);
84 };
85 
86 } // namespace phidgets
87 
88 #endif // PHIDGETS_API_MOTOR_H
double getVelocity(int index)
Definition: motor.cpp:66
void setRatiometric(int ratiometric)
Definition: motor.cpp:181
static int InputChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int inputState)
Definition: motor.cpp:202
double getCurrent(int index)
Definition: motor.cpp:96
virtual void backEMFUpdateHandler(int index, double voltage)
Definition: motor.cpp:282
virtual void encoderPositionUpdateHandler(int index, int positionChange)
Definition: motor.cpp:276
void setEncoderPosition(int index, int position)
Definition: motor.cpp:126
static int EncoderPositionChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int time, int positionChange)
Definition: motor.cpp:210
static int SensorUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int sensorValue)
Definition: motor.cpp:236
virtual void currentUpdateHandler(int index, double current)
Definition: motor.cpp:294
static int EncoderPositionUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int positionChange)
Definition: motor.cpp:219
virtual ~MotorController()
Definition: motor.cpp:57
static int BackEMFUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double voltage)
Definition: motor.cpp:228
bool getInputState(int index)
Definition: motor.cpp:106
double getAcceleration(int index)
Definition: motor.cpp:76
int getEncoderPosition(int index)
Definition: motor.cpp:121
int getBackEMFSensingState(int index)
Definition: motor.cpp:131
static int CurrentChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double current)
Definition: motor.cpp:194
int getSensorRawValue(int index)
Definition: motor.cpp:171
CPhidgetMotorControlHandle motor_handle_
Definition: motor.h:64
virtual void encoderPositionChangeHandler(int index, int time, int positionChange)
Definition: motor.cpp:269
virtual void sensorUpdateHandler(int index, int sensorValue)
Definition: motor.cpp:288
static int VelocityChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double velocity)
Definition: motor.cpp:186
void setVelocity(int index, double velocity)
Definition: motor.cpp:71
virtual void inputChangeHandler(int index, int inputState)
Definition: motor.cpp:264
double getBackEMF(int index)
Definition: motor.cpp:141
int getSensorValue(int index)
Definition: motor.cpp:166
void setAcceleration(int index, double acceleration)
Definition: motor.cpp:81
double getBraking(int index)
Definition: motor.cpp:151
void setBraking(int index, double braking)
Definition: motor.cpp:156
void setBackEMFSensingState(int index, int bEMFState)
Definition: motor.cpp:136
double getAccelerationMax(int index)
Definition: motor.cpp:86
virtual void velocityChangeHandler(int index, double velocity)
Definition: motor.cpp:252
virtual void currentChangeHandler(int index, double current)
Definition: motor.cpp:258
double getAccelerationMin(int index)
Definition: motor.cpp:91
static int CurrentUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double current)
Definition: motor.cpp:244


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Fri Apr 9 2021 02:56:02