190 lines
7.2 KiB
C++
190 lines
7.2 KiB
C++
/********************************************
|
|
* pmacController.h
|
|
*
|
|
* PMAC Asyn motor based on the
|
|
* asynMotorController class.
|
|
*
|
|
* Matthew Pearson
|
|
* 23 May 2012
|
|
*
|
|
*
|
|
* Modified to use the MsgTxt field for SINQ
|
|
*
|
|
* Mark Koennecke, January 2019
|
|
********************************************/
|
|
|
|
#ifndef pmacController_H
|
|
#define pmacController_H
|
|
|
|
#include "SINQController.h"
|
|
#include "asynMotorAxis.h"
|
|
#include "pmacAxis.h"
|
|
|
|
#define PMAC_C_GlobalStatusString "PMAC_C_GLOBALSTATUS"
|
|
#define PMAC_C_CommsErrorString "PMAC_C_COMMSERROR"
|
|
|
|
class pmacController : public SINQController {
|
|
|
|
public:
|
|
pmacController(const char *portName, const char *lowLevelPortName, int lowLevelPortAddress, int numAxes, double movingPollPeriod,
|
|
double idlePollPeriod, const int& extraParams=2);
|
|
|
|
virtual ~pmacController();
|
|
|
|
asynStatus printConnectedStatus(void);
|
|
|
|
/* These are the methods that we override */
|
|
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
|
|
asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
|
|
void report(FILE *fp, int level);
|
|
pmacAxis* getAxis(asynUser *pasynUser);
|
|
pmacAxis* getAxis(int axisNo);
|
|
asynStatus poll();
|
|
|
|
|
|
protected:
|
|
pmacAxis **pAxes_; /**< Array of pointers to axis objects */
|
|
|
|
#define FIRST_PMAC_PARAM PMAC_C_GlobalStatus__
|
|
int PMAC_C_GlobalStatus_;
|
|
int PMAC_C_CommsError_;
|
|
#define LAST_PMAC_PARAM PMAC_C_CommsError__
|
|
void debugFlow(const char *message);
|
|
asynStatus lowLevelWriteRead(int axisNo, const char *command, char *response);
|
|
|
|
private:
|
|
asynUser* lowLevelPortUser_;
|
|
epicsUInt32 debugFlag_;
|
|
int lowLevelPortConnect(const char *port, int addr, asynUser **ppasynUser, char *inputEos, char *outputEos);
|
|
|
|
//static class data members
|
|
|
|
static const epicsUInt32 PMAC_MAXBUF_;
|
|
static const epicsFloat64 PMAC_TIMEOUT_;
|
|
|
|
|
|
static const epicsUInt32 PMAC_STATUS1_MAXRAPID_SPEED;
|
|
static const epicsUInt32 PMAC_STATUS1_ALT_CMNDOUT_MODE;
|
|
static const epicsUInt32 PMAC_STATUS1_SOFT_POS_CAPTURE;
|
|
static const epicsUInt32 PMAC_STATUS1_ERROR_TRIGGER;
|
|
static const epicsUInt32 PMAC_STATUS1_FOLLOW_ENABLE;
|
|
static const epicsUInt32 PMAC_STATUS1_FOLLOW_OFFSET;
|
|
static const epicsUInt32 PMAC_STATUS1_PHASED_MOTOR;
|
|
static const epicsUInt32 PMAC_STATUS1_ALT_SRC_DEST;
|
|
static const epicsUInt32 PMAC_STATUS1_USER_SERVO;
|
|
static const epicsUInt32 PMAC_STATUS1_USER_PHASE;
|
|
static const epicsUInt32 PMAC_STATUS1_HOMING;
|
|
static const epicsUInt32 PMAC_STATUS1_BLOCK_REQUEST;
|
|
static const epicsUInt32 PMAC_STATUS1_DECEL_ABORT;
|
|
static const epicsUInt32 PMAC_STATUS1_DESIRED_VELOCITY_ZERO;
|
|
static const epicsUInt32 PMAC_STATUS1_DATABLKERR;
|
|
static const epicsUInt32 PMAC_STATUS1_DWELL;
|
|
static const epicsUInt32 PMAC_STATUS1_INTEGRATE_MODE;
|
|
static const epicsUInt32 PMAC_STATUS1_MOVE_TIME_ON;
|
|
static const epicsUInt32 PMAC_STATUS1_OPEN_LOOP;
|
|
static const epicsUInt32 PMAC_STATUS1_AMP_ENABLED;
|
|
static const epicsUInt32 PMAC_STATUS1_X_SERVO_ON;
|
|
static const epicsUInt32 PMAC_STATUS1_POS_LIMIT_SET;
|
|
static const epicsUInt32 PMAC_STATUS1_NEG_LIMIT_SET;
|
|
static const epicsUInt32 PMAC_STATUS1_MOTOR_ON;
|
|
|
|
static const epicsUInt32 PMAC_STATUS2_IN_POSITION;
|
|
static const epicsUInt32 PMAC_STATUS2_WARN_FOLLOW_ERR;
|
|
static const epicsUInt32 PMAC_STATUS2_ERR_FOLLOW_ERR;
|
|
static const epicsUInt32 PMAC_STATUS2_AMP_FAULT;
|
|
static const epicsUInt32 PMAC_STATUS2_NEG_BACKLASH;
|
|
static const epicsUInt32 PMAC_STATUS2_I2T_AMP_FAULT;
|
|
static const epicsUInt32 PMAC_STATUS2_I2_FOLLOW_ERR;
|
|
static const epicsUInt32 PMAC_STATUS2_TRIGGER_MOVE;
|
|
static const epicsUInt32 PMAC_STATUS2_PHASE_REF_ERR;
|
|
static const epicsUInt32 PMAC_STATUS2_PHASE_SEARCH;
|
|
static const epicsUInt32 PMAC_STATUS2_HOME_COMPLETE;
|
|
static const epicsUInt32 PMAC_STATUS2_POS_LIMIT_STOP;
|
|
static const epicsUInt32 PMAC_STATUS2_DESIRED_STOP;
|
|
static const epicsUInt32 PMAC_STATUS2_FORE_IN_POS;
|
|
static const epicsUInt32 PMAC_STATUS2_NA14;
|
|
static const epicsUInt32 PMAC_STATUS2_ASSIGNED_CS;
|
|
|
|
/*Global status ???*/
|
|
static const epicsUInt32 PMAC_GSTATUS_CARD_ADDR;
|
|
static const epicsUInt32 PMAC_GSTATUS_ALL_CARD_ADDR;
|
|
static const epicsUInt32 PMAC_GSTATUS_RESERVED;
|
|
static const epicsUInt32 PMAC_GSTATUS_PHASE_CLK_MISS;
|
|
static const epicsUInt32 PMAC_GSTATUS_MACRO_RING_ERRORCHECK;
|
|
static const epicsUInt32 PMAC_GSTATUS_MACRO_RING_COMMS;
|
|
static const epicsUInt32 PMAC_GSTATUS_TWS_PARITY_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_CONFIG_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_ILLEGAL_LVAR;
|
|
static const epicsUInt32 PMAC_GSTATUS_REALTIME_INTR;
|
|
static const epicsUInt32 PMAC_GSTATUS_FLASH_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_DPRAM_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_CKSUM_ACTIVE;
|
|
static const epicsUInt32 PMAC_GSTATUS_CKSUM_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_LEADSCREW_COMP;
|
|
static const epicsUInt32 PMAC_GSTATUS_WATCHDOG;
|
|
static const epicsUInt32 PMAC_GSTATUS_SERVO_REQ;
|
|
static const epicsUInt32 PMAC_GSTATUS_DATA_GATHER_START;
|
|
static const epicsUInt32 PMAC_GSTATUS_RESERVED2;
|
|
static const epicsUInt32 PMAC_GSTATUS_DATA_GATHER_ON;
|
|
static const epicsUInt32 PMAC_GSTATUS_SERVO_ERROR;
|
|
static const epicsUInt32 PMAC_GSTATUS_CPUTYPE;
|
|
static const epicsUInt32 PMAC_GSTATUS_REALTIME_INTR_RE;
|
|
static const epicsUInt32 PMAC_GSTATUS_RESERVED3;
|
|
|
|
static const epicsUInt32 PMAC_HARDWARE_PROB;
|
|
static const epicsUInt32 PMAX_AXIS_GENERAL_PROB1;
|
|
static const epicsUInt32 PMAX_AXIS_GENERAL_PROB2;
|
|
|
|
friend class pmacAxis;
|
|
friend class pmacHRPTAxis;
|
|
friend class SeleneAxis;
|
|
friend class LiftAxis;
|
|
friend class pmacV3Axis;
|
|
};
|
|
|
|
#define NUM_PMAC_PARAMS (&LAST_PMAC_PARAM - &FIRST_PMAC_PARAM + 1)
|
|
|
|
#define MotorSetPositionString "SET_MOTOR_POSITION"
|
|
|
|
class SeleneController : public pmacController {
|
|
public:
|
|
SeleneController(const char *portName, const char *lowLevelPortName, int lowLevelPortAddress,
|
|
int numAxes, double movingPollPeriod, double idlePollPeriod);
|
|
|
|
~SeleneController(void) { }
|
|
|
|
// overloaded because we have a different command to set the limits
|
|
asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
|
|
|
|
friend class SeleneAxis;
|
|
friend class pmacAxis;
|
|
|
|
protected:
|
|
int setMotorPosition_;
|
|
|
|
};
|
|
|
|
#define EnableAxisString "ENABLE_AXIS"
|
|
#define AxisStateString "AXIS_STATE"
|
|
|
|
class pmacV3Controller : public pmacController {
|
|
public:
|
|
pmacV3Controller(const char *portName, const char *lowLevelPortName,
|
|
int lowLevelPortAddress, int numAxes, double movingPollPeriod,
|
|
double idlePollPeriod, const int &extraParams = 2);
|
|
|
|
// overloaded because we want to enable/disable the motor
|
|
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
|
|
|
|
// overloaded because we want to read the axis state
|
|
asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
|
|
|
|
friend class pmacV3Axis;
|
|
friend class pmacAxis;
|
|
|
|
protected:
|
|
int enableAxis_;
|
|
};
|
|
|
|
#endif /* pmacController_H */
|