/* * GluexXPSController.hh * * A class that inherits from motor's XPSController class to add extra * functionality that is required for GlueX motor applications. * * Created on: Apr 5, 2016 * Author: Hovanes Egiyan * * Modified on: Apr 11, 2016 * Vanik Kakoyan */ #ifndef GLUEXXPSCONTROLLER_HH_ #define GLUEXXPSCONTROLLER_HH_ /************/ /* Includes */ /************/ #include #include #include #include #include #include #include #include /* EPICS includes */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // for 'map_list_of()' #include #include #include "XPS_C8_drivers.h" #include "xps_ftp.h" #include "asynPortDriver.h" #include "XPSController.h" /* Status codes for PCO Set,Enable and Disable */ enum PcoStatus { PCO_STATUS_UNDEFINED, PCO_STATUS_SUCCESS, PCO_STATUS_FAILURE, PCO_STATUS_TIMEOUT }; /* Status codes for GroupReferencing/Start/Stop/ */ enum GroupReferencingStatus { GROUP_REFERENCING_STATUS_UNDEFINED, GROUP_REFERENCING_STATUS_SUCCESS, GROUP_REFERENCING_STATUS_FAILURE, GROUP_REFERENCING_STATUS_TIMEOUT }; // drvInfo strings for PCO parameters #define pcoSetString "PCO_SET" #define pcoEnableString "PCO_ENABLE" #define pcoDisableString "PCO_DISABLE" #define pcoMinPositionString "PCO_MIN_POSITION" #define pcoMaxPositionString "PCO_MAX_POSITION" #define pcoPositionStepString "PCO_POSITION_STEP" #define pcoPulseWidthString "PCO_PULSE_WIDTH" #define encoderSettlingTimeString "ENCODER_SETTLING_TIME" #define pcoMinPositionActualString "PCO_MIN_POSITION_ACTUAL" #define pcoMaxPositionActualString "PCO_MAX_POSITION_ACTUAL" #define pcoPositionStepActualString "PCO_POSITION_STEP_ACTUAL" #define pcoPulseWidthActualString "PCO_PULSE_WIDTH_ACTUAL" #define encoderSettlingTimeActualString "ENCODER_SETTLING_TIME_ACTUAL" #define pcoEnableDisableStateString "PCO_ENABLE_DISABLE_STATE" #define pcoPositionerNameString "PCO_POSITIONER_NAME" #define pcoMessageString "PCO_MESSAGE" #define pcoSetStatusString "PCO_SET_STATUS" #define pcoSetMessageString "PCO_SET_MESSAGE" #define pcoGetMessageString "PCO_GET_MESSAGE" #define pcoEnableStatusString "PCO_ENABLE_STATUS" #define pcoEnableMessageString "PCO_ENABLE_MESSAGE" #define pcoDisableStatusString "PCO_DISABLE_STATUS" #define pcoDisableMessageString "PCO_DISABLE_MESSAGE" #define positionerReferencingActionExecuteString "GROUP_REFERENCING_ACTIONEXECUTE" #define positionerReferencingActionExecuteStatusString "GROUP_REFERENCING_ACTIONEXECUTE_STATUS" #define positionerReferencingMessageString "GROUP_REFERENCING_MESSAGE" #define positionerReferencingParameterString "GROUP_REFERENCING_PARAMETER" #define positionerReferencingSensorString "GROUP_REFERENCING_SENSOR" #define positionerReferencingActionString "GROUP_REFERENCING_ACTION" //#define XPSReferencingPositionerNameString "GROUP_REFERENCING_POSITIONER_NAME" // drvInfo strings for PositionerError and PositionerStatus parameters #define positionerErrorString "POSITIONER_ERROR" #define positionerErrorStringString "POSITIONER_ERROR_STRING" #define positionerHardwareStatusString "POSITIONER_HARDWARE_STATUS" #define positionerHardwareStatusStringString "POSITIONER_HARDWARE_STATUS_STRING" // drvInfo strings for HomeSearchMaximumVelocity and HomePreset parameters from stages.ini file #define positionerHomeSearchMaxVelString "HOME_SEARCH_MAX_VEL" #define positionerHomePresetString "HOME_PRESET" class GluexXPSGroup; class GluexXPSAxis; class GluexXPSController: public XPSController { protected: // Map of all XPS controller drivers defined. The key is the asyn port name, // the value is the pointer to the corresponding GluexXPSController object. static std::map gxcDriverMap; // Map of declared groups for this controller std::map gxcGroupMap; // Number of declated axes. The XPSController class has an array of pointers // that keep track of these axes. unsigned gxcNumberOfAxes; // Here we follow the stadard C-like scheme used in asynPortDriver // for defining the parameters and their number. These parameters are // on top of the parameters defined in the XPSController class and should // be considered as the set of parameters belonging to the same driver. // Define the first parameter #define FIRST_GLUEX_XPS_PARAM pcoSet_ /* PCO parameters for this driver */ int pcoSet_; int pcoEnable_; int pcoDisable_; int pcoMinPosition_; int pcoMaxPosition_; int pcoPositionStep_; int pcoPulseWidth_; int encoderSettlingTime_; int pcoMinPositionActual_; int pcoMaxPositionActual_; int pcoPositionStepActual_; int pcoPulseWidthActual_; int encoderSettlingTimeActual_; int pcoEnableDisableState_; int pcoMessage_; int pcoPositionerName_; int pcoSetStatus_; int pcoSetMessage_; int pcoGetMessage_; int pcoEnableStatus_; int pcoEnableMessage_; int pcoDisableStatus_; int pcoDisableMessage_; /* Positioner referencing parameters */ int positionerReferencingActionExecute_; int positionerReferencingActionExecuteStatus_; int positionerReferencingMessage_; int positionerReferencingParameter_; int positionerReferencingSensor_; int positionerReferencingAction_; /* HomeSearchMaximumVelocity and HomePreset parameters */ int positionerHomeSearchMaxVel_; int positionerHomePreset_; /* PositionerError and PositionerStatus parameters */ int positionerError_; int positionerHardwareStatus_; int positionerHardwareStatusString_; int positionerErrorString_; // Define a macro for the last parameter. Make sure that if you add new parameters at the // bottom you also change its name in the define directive below. #define LAST_GLUEX_XPS_PARAM positionerErrorString_ // Define the number of parameters as the difference between pointer between last and first // integer parameter defined above. #define NUM_GLUEX_XPS_PARAMS ( (int)(&LAST_GLUEX_XPS_PARAM - &FIRST_GLUEX_XPS_PARAM + 1) ) public: GluexXPSController( const char *portName, const char *IPAddress, int IPPort, int numAxes, double movingPollPeriod, double idlePollPeriod, int enableSetPosition, double setPositionSettlingTime ); virtual ~GluexXPSController(); virtual GluexXPSAxis* addAxis( const int axis, const std::string positionerName, const double stepsPerUnit) ; // Add an XPS axis group with syn port name, group name groupName virtual GluexXPSGroup* addGroup( const std::string pName, const std::string groupName ); // virtual void assignAxesToGroups(); virtual inline std::map& getGroupMap() {return gxcGroupMap;} virtual inline int getNumberOfAxes() {return numAxes_;} // Override these functions defined for the base class virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value); /* These are the functions for PCO (Position Compare Output) */ virtual asynStatus getPco( size_t axis ); virtual asynStatus setPco( size_t axis ); virtual asynStatus enablePco( size_t axis ); virtual asynStatus disablePco( size_t axis ); /* This is the function for PositionerErrorGet and PositionerHardwareStatusGet */ virtual asynStatus getPositionerErrorAndHardwareStatus(size_t axis); /* This is the function for PositionerStageParameterGet */ virtual asynStatus getPositionerStageParameters(size_t axis); // Return reference to the map of GlueX XPS controller asyn drivers. static inline std::map& getDriverMap() { return gxcDriverMap; } // Return the pointer to GluexXPSController with asyn port name pName. // Return zero if such port name does not exist. static inline GluexXPSController* getDriver( const std::string pName ) { if( gxcDriverMap.count(pName)>0 ) return gxcDriverMap[pName]; else return 0; } virtual inline std::string getPortName() const {return std::string(portName);} virtual inline std::string getIPAddress() const {return std::string( IPAddress_ );} virtual inline int getIPPort() const { return IPPort_;} virtual inline int getPollSocket() const {return pollSocket_;} virtual inline int getPMoveSocket() const {return moveSocket_;} virtual inline int getNumberOfAxis() const {return numAxes_;} virtual inline XPSAxis** getAxisPointers() {return pAxes_;} friend class GluexXPSAxis; }; #endif /* GLUEXXPSCONTROLLER_HH_ */