6 #define GAR(type, name) type x; int ret = CPhidgetMotorControl_get ## name (motor_handle_, &x); assert(ret == EPHIDGET_OK); return x; 7 #define GAR_I(type, name, i) type x; int ret = CPhidgetMotorControl_get ## name (motor_handle_, i, &x); assert(ret == EPHIDGET_OK); return x; 10 #define SET(name, x) int ret = CPhidgetMotorControl_set ## name (motor_handle_, x); assert(ret == EPHIDGET_OK); 11 #define SET_I(name, x, i) int ret = CPhidgetMotorControl_set ## name (motor_handle_, i, x); assert(ret == EPHIDGET_OK); 32 CPhidgetMotorControl_set_OnInputChange_Handler(motor_handle_,
InputChangeHandler,
this);
47 GAR_I(
double, Velocity, index);
52 SET_I(Velocity, velocity, index);
57 GAR_I(
double, Acceleration, index);
62 SET_I(Acceleration, acceleration, index);
67 GAR_I(
double, AccelerationMax, index);
72 GAR_I(
double, AccelerationMin, index);
77 GAR_I(
double, Current, index);
88 int ret = CPhidgetMotorControl_getInputState(
motor_handle_, index, &state);
90 assert(ret == EPHIDGET_OK);
92 return state == PTRUE;
97 GAR(
int, EncoderCount);
102 GAR_I(
int, EncoderPosition, index);
107 SET_I(EncoderPosition, position, index);
112 GAR_I(
int, BackEMFSensingState, index);
117 SET_I(BackEMFSensingState, bEMFState, index);
122 GAR_I(
double, BackEMF, index);
127 GAR(
double, SupplyVoltage);
132 GAR_I(
double, Braking, index);
137 SET_I(Braking, braking, index);
142 GAR(
int, SensorCount);
147 GAR_I(
int, SensorValue, index);
152 GAR_I(
int, SensorRawValue, index);
157 GAR(
int, Ratiometric);
162 SET(Ratiometric, ratiometric);
185 ((
MotorController*)userPtr)->encoderPositionChangeHandler(index, time, positionChange);
191 ((
MotorController*)userPtr)->encoderPositionUpdateHandler(index, positionChange);
double getVelocity(int index)
void setRatiometric(int ratiometric)
static int InputChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int inputState)
double getCurrent(int index)
virtual void backEMFUpdateHandler(int index, double voltage)
virtual void encoderPositionUpdateHandler(int index, int positionChange)
void setEncoderPosition(int index, int position)
virtual void registerHandlers()
static int EncoderPositionChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int time, int positionChange)
static int SensorUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int sensorValue)
virtual void currentUpdateHandler(int index, double current)
static int EncoderPositionUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, int positionChange)
static int BackEMFUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double voltage)
bool getInputState(int index)
double getAcceleration(int index)
int getEncoderPosition(int index)
int getBackEMFSensingState(int index)
static int CurrentChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double current)
int getSensorRawValue(int index)
#define SET_I(name, x, i)
CPhidgetMotorControlHandle motor_handle_
virtual void encoderPositionChangeHandler(int index, int time, int positionChange)
virtual void sensorUpdateHandler(int index, int sensorValue)
static int VelocityChangeHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double velocity)
void setVelocity(int index, double velocity)
virtual void inputChangeHandler(int index, int inputState)
double getBackEMF(int index)
int getSensorValue(int index)
void setAcceleration(int index, double acceleration)
#define GAR_I(type, name, i)
double getBraking(int index)
void setBraking(int index, double braking)
double getSupplyVoltage()
void setBackEMFSensingState(int index, int bEMFState)
double getAccelerationMax(int index)
void init(CPhidgetHandle handle)
virtual void velocityChangeHandler(int index, double velocity)
virtual void currentChangeHandler(int index, double current)
double getAccelerationMin(int index)
static int CurrentUpdateHandler(CPhidgetMotorControlHandle phid, void *userPtr, int index, double current)