From b83c9eb7d026ce242c970f9e1c4eb688e68d3436 Mon Sep 17 00:00:00 2001 From: MarkRivers Date: Mon, 28 Mar 2011 18:24:49 +0000 Subject: [PATCH] Added trailing _ to member variable names; eliminated abbreviations; changed indents from 4 to 2 spaces --- motorApp/MotorSrc/asynMotorDriver.h | 167 +++++++++++++++------------- 1 file changed, 92 insertions(+), 75 deletions(-) diff --git a/motorApp/MotorSrc/asynMotorDriver.h b/motorApp/MotorSrc/asynMotorDriver.h index 15c61ce7..74efc763 100644 --- a/motorApp/MotorSrc/asynMotorDriver.h +++ b/motorApp/MotorSrc/asynMotorDriver.h @@ -26,103 +26,120 @@ #define motorPgainString "MOTOR_PGAIN" #define motorIgainString "MOTOR_IGAIN" #define motorDgainString "MOTOR_DGAIN" -#define motorHighLimString "MOTOR_HIGH_LIMIT" -#define motorLowLimString "MOTOR_LOW_LIMIT" +#define motorHighLimitString "MOTOR_HIGH_LIMIT" +#define motorLowLimitString "MOTOR_LOW_LIMIT" #define motorSetClosedLoopString "MOTOR_SET_CLOSED_LOOP" #define motorStatusString "MOTOR_STATUS" #define motorUpdateStatusString "MOTOR_UPDATE_STATUS" #define motorStatusDirectionString "MOTOR_STATUS_DIRECTION" #define motorStatusDoneString "MOTOR_STATUS_DONE" -#define motorStatusHighLimitString "MOTOR_STATUS_HIGHLIMIT" -#define motorStatusAtHomeString "MOTOR_STATUS_ATHOME" +#define motorStatusHighLimitString "MOTOR_STATUS_HIGH_LIMIT" +#define motorStatusAtHomeString "MOTOR_STATUS_AT_HOME" #define motorStatusSlipString "MOTOR_STATUS_SLIP" #define motorStatusPowerOnString "MOTOR_STATUS_POWERED" -#define motorStatusFollowingErrorString "MOTOR_STATUS_FOLLOWINGERROR" +#define motorStatusFollowingErrorString "MOTOR_STATUS_FOLLOWING_ERROR" #define motorStatusHomeString "MOTOR_STATUS_HOME" -#define motorStatusHasEncoderString "MOTOR_STATUS_HASENCODER" +#define motorStatusHasEncoderString "MOTOR_STATUS_HAS_ENCODER" #define motorStatusProblemString "MOTOR_STATUS_PROBLEM" #define motorStatusMovingString "MOTOR_STATUS_MOVING" -#define motorStatusGainSupportString "MOTOR_STATUS_GAINSUPPORT" -#define motorStatusCommsErrorString "MOTOR_STATUS_COMMSERROR" -#define motorStatusLowLimitString "MOTOR_STATUS_LOWLIMIT" +#define motorStatusGainSupportString "MOTOR_STATUS_GAIN_SUPPORT" +#define motorStatusCommsErrorString "MOTOR_STATUS_COMMS_ERROR" +#define motorStatusLowLimitString "MOTOR_STATUS_LOW_LIMIT" #define motorStatusHomedString "MOTOR_STATUS_HOMED" typedef struct MotorStatus { - double position; - double encoder_posn; - double velocity; - epicsUInt32 status; + double position; + double encoderPosition; + double velocity; + epicsUInt32 status; } MotorStatus; #ifdef __cplusplus #include + /** Class from which motor drivers are directly derived. */ -class epicsShareFunc asynMotorDriver : public asynPortDriver { +class epicsShareFunc asynMotorAxis { public: - /* This is the constructor for the class. */ - asynMotorDriver(const char *portName, int maxAxes, int numParams, - int interfaceMask, int interruptMask, - int asynFlags, int autoConnect, int priority, int stackSize); + /* This is the constructor for the class. */ + asynMotorAxis(int axisNumber, class asynMotorController *pController); - /* These are the methods that we override from asynPortDriver */ - virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); - virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value); - virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer); - virtual asynStatus setIntegerParam(int list, int index, int value); - virtual asynStatus setDoubleParam(int list, int index, double value); - virtual asynStatus callParamCallbacks(int addr); - - /* These are the methods that are new to this class */ - virtual asynStatus moveAxis(asynUser *pasynUser, double position, int relative, double min_velocity, double max_velocity, double acceleration); - virtual asynStatus moveVelocityAxis(asynUser *pasynUser, double min_velocity, double max_velocity, double acceleration); - virtual asynStatus homeAxis(asynUser *pasynUser, double min_velocity, double max_velocity, double acceleration, int forwards); - virtual asynStatus stopAxis(asynUser *pasynUser, double acceleration); - virtual asynStatus profileMove(asynUser *pasynUser, int npoints, double positions[], double times[], int relative, int trigger); - virtual asynStatus triggerProfile(asynUser *pasynUser); - -protected: - int motorMoveRel; - #define FIRST_MOTOR_PARAM motorMoveRel - int motorMoveAbs; - int motorMoveVel; - int motorHome; - int motorStop; - int motorVelocity; - int motorVelBase; - int motorAccel; - int motorPosition; - int motorEncoderPosition; - int motorDeferMoves; - int motorResolution; - int motorEncRatio; - int motorPgain; - int motorIgain; - int motorDgain; - int motorHighLim; - int motorLowLim; - int motorSetClosedLoop; - int motorStatus; - int motorUpdateStatus; - int motorStatusDirection; - int motorStatusDone; - int motorStatusHighLimit; - int motorStatusAtHome; - int motorStatusSlip; - int motorStatusPowerOn; - int motorStatusFollowingError; - int motorStatusHome; - int motorStatusHasEncoder; - int motorStatusProblem; - int motorStatusMoving; - int motorStatusGainSupport; - int motorStatusCommsError; - int motorStatusLowLimit; - int motorStatusHomed; - #define LAST_MOTOR_PARAM motorStatusHomed + virtual asynStatus move(double position, int relative, double minVelocity, double maxVelocity, double acceleration); + virtual asynStatus moveVelocity(double minVelocity, double maxVelocity, double acceleration); + virtual asynStatus home(double minVelocity, double maxVelocity, double acceleration, int forwards); + virtual asynStatus stop(double acceleration); private: - MotorStatus *axisStatus; - int *axisStatusChanged; + int axisNumber_; + class asynMotorController *pController_; +}; + +/** Class from which motor drivers are directly derived. */ +class epicsShareFunc asynMotorController : public asynPortDriver { +public: + /* This is the constructor for the class. */ + asynMotorController(const char *portName, int maxAxes, int numParams, + int interfaceMask, int interruptMask, + int asynFlags, int autoConnect, int priority, int stackSize); + + /* These are the methods that we override from asynPortDriver */ + virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); + virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value); + virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer); + virtual asynStatus setIntegerParam(int list, int index, int value); + virtual asynStatus setDoubleParam(int list, int index, double value); + virtual asynStatus callParamCallbacks(int addr); + + /* These are the methods that are new to this class */ + virtual asynStatus moveAxis(asynUser *pasynUser, double position, int relative, double minVelocity, double maxVelocity, double acceleration); + virtual asynStatus moveVelocityAxis(asynUser *pasynUser, double minVelocity, double maxVelocity, double acceleration); + virtual asynStatus homeAxis(asynUser *pasynUser, double minVelocity, double maxVelocity, double acceleration, int forwards); + virtual asynStatus stopAxis(asynUser *pasynUser, double acceleration); + virtual asynStatus profileMove(asynUser *pasynUser, int npoints, double positions[], double times[], int relative, int trigger); + virtual asynStatus triggerProfile(asynUser *pasynUser); + +protected: + int motorMoveRel_; + #define FIRST_MOTOR_PARAM motorMoveRel_ + int motorMoveAbs_; + int motorMoveVel_; + int motorHome_; + int motorStop_; + int motorVelocity_; + int motorVelBase_; + int motorAccel_; + int motorPosition_; + int motorEncoderPosition_; + int motorDeferMoves_; + int motorResolution_; + int motorEncRatio_; + int motorPgain_; + int motorIgain_; + int motorDgain_; + int motorHighLimit_; + int motorLowLimit_; + int motorSetClosedLoop_; + int motorStatus_; + int motorUpdateStatus_; + int motorStatusDirection_; + int motorStatusDone_; + int motorStatusHighLimit_; + int motorStatusAtHome_; + int motorStatusSlip_; + int motorStatusPowerOn_; + int motorStatusFollowingError_; + int motorStatusHome_; + int motorStatusHasEncoder_; + int motorStatusProblem_; + int motorStatusMoving_; + int motorStatusGainSupport_; + int motorStatusCommsError_; + int motorStatusLowLimit_; + int motorStatusHomed_; + #define LAST_MOTOR_PARAM motorStatusHomed_ + +private: + MotorStatus *axisStatus_; + int *axisStatusChanged_; }; #define NUM_MOTOR_DRIVER_PARAMS (&LAST_MOTOR_PARAM - &FIRST_MOTOR_PARAM + 1)