diff --git a/iocBoot/iocsinqEPICS/motor.substitutions.el734 b/iocBoot/iocsinqEPICS/motor.substitutions.el734 index e8554a4..d285318 100644 --- a/iocBoot/iocsinqEPICS/motor.substitutions.el734 +++ b/iocBoot/iocsinqEPICS/motor.substitutions.el734 @@ -1,4 +1,4 @@ -file "$(MOTOR)/db/basic_asyn_motor.db" +qfile "$(MOTOR)/db/basic_asyn_motor.db" { pattern {P, N, M, DTYP, PORT, ADDR, DESC, EGU, DIR, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, DHLM, DLLM, INIT} diff --git a/sinqEPICSApp/src/EL734Driver.cpp b/sinqEPICSApp/src/EL734Driver.cpp index 78274a9..a3048b5 100644 --- a/sinqEPICSApp/src/EL734Driver.cpp +++ b/sinqEPICSApp/src/EL734Driver.cpp @@ -345,7 +345,7 @@ asynStatus EL734Axis::setPosition(double position) //static const char *functionName = "EL734Axis::setPosition"; char command[COMLEN], reply[COMLEN]; - sprintf(command, "P %d %f", axisNo_, position/1000.); + sprintf(command, "U %d %f", axisNo_, position/1000.); status = pC_->transactController(axisNo_,command,reply); next_poll = -1; @@ -401,7 +401,7 @@ asynStatus EL734Axis::poll(bool *moving) } else if(strstr(reply,"?BSY") != NULL){ *moving = true; setIntegerParam(pC_->motorStatusDone_, false); - updateMsgTxtFromDriver(NULL); + updateMsgTxtFromDriver(""); goto skip; } count = sscanf(reply,"%lf", &position); diff --git a/sinqEPICSApp/src/SINQAxis.cpp b/sinqEPICSApp/src/SINQAxis.cpp index bd7a6df..3a2b7d9 100644 --- a/sinqEPICSApp/src/SINQAxis.cpp +++ b/sinqEPICSApp/src/SINQAxis.cpp @@ -12,6 +12,7 @@ SINQAxis::SINQAxis(class SINQController *pC, int axis) : asynMotorAxis((asynMotorController *)pC, axis), pC_(pC) { + updateMsgTxtFromDriver(""); } @@ -22,6 +23,7 @@ void SINQAxis::updateMsgTxtFromDriver(const char *value) setStringParam(pC_->motorMessageText_,value); } else { pC_->setIntegerParam(axisNo_,pC_->motorMessageIsFromDriver_, 0); + setStringParam(pC_->motorMessageText_,""); } } diff --git a/sinqEPICSApp/src/pmacAxis.cpp b/sinqEPICSApp/src/pmacAxis.cpp index b08bc37..d821422 100644 --- a/sinqEPICSApp/src/pmacAxis.cpp +++ b/sinqEPICSApp/src/pmacAxis.cpp @@ -218,8 +218,6 @@ asynStatus pmacAxis::home(double min_velocity, double max_velocity, double accel asynStatus pmacAxis::moveVelocity(double min_velocity, double max_velocity, double acceleration) { asynStatus status = asynError; - char command[128] = {0}; - char response[32] = {0}; static const char *functionName = "pmacAxis::moveVelocity"; pC_->debugFlow(functionName); @@ -334,12 +332,9 @@ asynStatus pmacAxis::getAxisStatus(bool *moving) int cmdStatus = 0;; int done = 0; double position = 0; - double enc_position = 0; int nvals = 0; int axisProblemFlag = 0; - int limitsDisabledBit = 0; epicsUInt32 axErr = 0, axStat = 0, highLim = 0, lowLim= 0; - int errorPrintMin = 10000; char message[132], *axMessage; @@ -521,3 +516,30 @@ asynStatus pmacAxis::getAxisStatus(bool *moving) return asynSuccess; } +asynStatus pmacHRPTAxis::getAxisStatus(bool *moving) +{ + char command[pC_->PMAC_MAXBUF_]; + char response[pC_->PMAC_MAXBUF_]; + int cmdStatus = 0, nvals, crashSignal; + + asynStatus result = pmacAxis::getAxisStatus(moving); + sprintf(command,"P%2.2d53",axisNo_); + cmdStatus = pC_->lowLevelWriteRead(axisNo_,command,response); + nvals = sscanf(response,"%d",&crashSignal); + if(cmdStatus || nvals != 1){ + asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + "drvPmacAxisGetStatus: Failed to read crash flag Status: %d\nCommand :%s\nResponse:%s\n", + cmdStatus, command, response ); + } + if(crashSignal == 1) { + updateMsgTxtFromDriver("HSC: HRPT Slit Crash!!"); + asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + "drvPmacAxisGetStatus: HRPT Slit CRASH detected"); + *moving = false; + setIntegerParam(pC_->motorStatusMoving_, false); + setIntegerParam(pC_->motorStatusDone_, true); + setIntegerParam(pC_->motorStatusProblem_, true); + + } + return result; +} diff --git a/sinqEPICSApp/src/pmacAxis.h b/sinqEPICSApp/src/pmacAxis.h index 7eb488d..51c777e 100644 --- a/sinqEPICSApp/src/pmacAxis.h +++ b/sinqEPICSApp/src/pmacAxis.h @@ -33,7 +33,7 @@ class pmacAxis : public SINQAxis asynStatus poll(bool *moving); asynStatus setPosition(double position); - private: + protected: pmacController *pC_; asynStatus getAxisStatus(bool *moving); @@ -60,5 +60,19 @@ class pmacAxis : public SINQAxis friend class pmacController; }; +class pmacHRPTAxis : public pmacAxis +{ + public: + pmacHRPTAxis(pmacController *pController, int axisNo) : pmacAxis(pController,axisNo) {}; + /** + * Override getAxisStatus in order to read the special parameter indicating a + * slit blade crash at HRPT + */ + asynStatus getAxisStatus(bool *moving); + + protected: + friend class pmacController; + +}; #endif /* pmacAxis_H */ diff --git a/sinqEPICSApp/src/pmacController.cpp b/sinqEPICSApp/src/pmacController.cpp index 6d1769d..39d5434 100644 --- a/sinqEPICSApp/src/pmacController.cpp +++ b/sinqEPICSApp/src/pmacController.cpp @@ -558,9 +558,35 @@ asynStatus pmacCreateAxis(const char *pmacName, /* specify which control pC->unlock(); return asynSuccess; } +/** + * C wrapper for the pmacHRPTAxis constructor. + * See pmacHRPTAxis::pmacHRPTAxis. + * + */ +asynStatus pmacCreateHRPTAxis(const char *pmacName, /* specify which controller by port name */ + int axis) /* axis number (start from 1). */ +{ + pmacController *pC; + pmacAxis *pAxis; + + static const char *functionName = "pmacCreateHRPTAxis"; + + pC = (pmacController*) findAsynPortDriver(pmacName); + if (!pC) { + printf("%s:%s: Error port %s not found\n", + driverName, functionName, pmacName); + return asynError; + } + + pC->lock(); + pAxis = new pmacHRPTAxis(pC, axis); + pAxis = NULL; + pC->unlock(); + return asynSuccess; +} /** - * C Wrapper function for pmacAxis constructor. + * C Wrapper function for pmacHRPTAxis constructor. * See pmacAxis::pmacAxis. * This function allows creation of multiple pmacAxis objects with axis numbers 1 to numAxes. * @param pmacName Asyn port name for the controller (const char *) @@ -628,6 +654,18 @@ static void configpmacAxisCallFunc(const iocshArgBuf *args) pmacCreateAxis(args[0].sval, args[1].ival); } +/* pmacCreateHRPTAxis */ +static const iocshArg pmacCreateHRPTAxisArg0 = {"Controller port name", iocshArgString}; +static const iocshArg pmacCreateHRPTAxisArg1 = {"Axis number", iocshArgInt}; +static const iocshArg * const pmacCreateHRPTAxisArgs[] = {&pmacCreateAxisArg0, + &pmacCreateAxisArg1}; +static const iocshFuncDef configpmacHRPTAxis = {"pmacCreateHRPTAxis", 2, pmacCreateHRPTAxisArgs}; + +static void configpmacHRPTAxisCallFunc(const iocshArgBuf *args) +{ + pmacCreateHRPTAxis(args[0].sval, args[1].ival); +} + /* pmacCreateAxes */ static const iocshArg pmacCreateAxesArg0 = {"Controller port name", iocshArgString}; static const iocshArg pmacCreateAxesArg1 = {"Num Axes", iocshArgInt}; @@ -646,6 +684,7 @@ static void pmacControllerRegister(void) { iocshRegister(&configpmacCreateController, configpmacCreateControllerCallFunc); iocshRegister(&configpmacAxis, configpmacAxisCallFunc); + iocshRegister(&configpmacHRPTAxis, configpmacHRPTAxisCallFunc); iocshRegister(&configpmacAxes, configpmacAxesCallFunc); } epicsExportRegistrar(pmacControllerRegister); diff --git a/sinqEPICSApp/src/pmacController.h b/sinqEPICSApp/src/pmacController.h index 1500634..d794f2c 100644 --- a/sinqEPICSApp/src/pmacController.h +++ b/sinqEPICSApp/src/pmacController.h @@ -136,6 +136,7 @@ class pmacController : public SINQController { static const epicsUInt32 PMAX_AXIS_GENERAL_PROB2; friend class pmacAxis; + friend class pmacHRPTAxis; }; diff --git a/sinqEPICSApp/src/sinq.dbd b/sinqEPICSApp/src/sinq.dbd index 8d523dd..aec15c4 100644 --- a/sinqEPICSApp/src/sinq.dbd +++ b/sinqEPICSApp/src/sinq.dbd @@ -5,6 +5,7 @@ registrar(EL734Register) registrar(PhytronRegister) registrar(NanotecRegister) registrar(pmacControllerRegister) +registrar(pmacAsynIPPortRegister) #-------------------------------------------------------- # With the PSI module build system, including these items actually