diff --git a/sinqEPICSApp/src/PhytronDriver.cpp b/sinqEPICSApp/src/PhytronDriver.cpp index 88372b2..23d528d 100644 --- a/sinqEPICSApp/src/PhytronDriver.cpp +++ b/sinqEPICSApp/src/PhytronDriver.cpp @@ -48,7 +48,7 @@ January 2019 #include "PhytronDriver.h" #include -#define IDLEPOLL 60 +#define IDLEPOLL 5 /** Creates a new PhytronController object. * \param[in] portName The name of the asyn port that will be created for this driver @@ -56,7 +56,7 @@ January 2019 * \param[in] numAxes The number of axes that this controller supports */ PhytronController::PhytronController(const char *portName, const char *PhytronPortName, const char *sel , - int encX, int encY, int homeZeroX, int homeZeroY) + int encX, int encY, int ignoreLimitsX, int ignoreLimitsY) : SINQController(portName, PhytronPortName,2) { asynStatus status; @@ -82,8 +82,8 @@ PhytronController::PhytronController(const char *portName, const char *PhytronPo new PhytronDoseAxis(this, 1, encX); new PhytronDoseAxis(this, 2, encY); } else { - new PhytronAxis(this, 1, encX, homeZeroX); - new PhytronAxis(this, 2, encY, homeZeroY); + new PhytronAxis(this, 1, encX, ignoreLimitsX); + new PhytronAxis(this, 2, encY, ignoreLimitsY); } @@ -106,9 +106,9 @@ PhytronDoseController::PhytronDoseController(const char *portName, const char *P * \param[in] numAxes The number of axes that this controller supports */ extern "C" int PhytronCreateController(const char *portName, const char *PhytronPortName, const char *selector, - int encX, int encY, int homeZeroX, int homeZeroY) + int encX, int encY, int ignoreLimitsX, int ignoreLimitsY) { - new PhytronController(portName, PhytronPortName,selector, encX, encY, homeZeroX, homeZeroY); + new PhytronController(portName, PhytronPortName,selector, encX, encY, ignoreLimitsX, ignoreLimitsY); return(asynSuccess); } @@ -237,11 +237,12 @@ asynStatus PhytronController::transactController(int axisNo,char command[COMLEN] * * Initializes register numbers, etc. */ -PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc, int homeZero) +PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc, int ignoreLimits) : SINQAxis(pC, axisNo), pC_(pC) { encoder = enc; + ignore_limits = ignoreLimits; if(axisNo == 1){ phytronChar = 'X'; } else { @@ -251,8 +252,7 @@ PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc, int homeZer brakeIO = -1; next_poll = -1; homing = 0; - homing_direction = 0; - home_zero = homeZero; + homing_direction = 0; } int PhytronAxis::setBrake(int brakeNO) @@ -437,8 +437,9 @@ asynStatus PhytronAxis::setPosition(double position) errlogPrintf("PhytronAxis::setPosition called with %lf\n", position); - sprintf(command, "%s%cP22S%f", pC_->selector,phytronChar, position/1000.); - status = pC_->transactController(axisNo_,command,reply); + // writing encoder register is wrong + //sprintf(command, "%s%cP22S%f", pC_->selector,phytronChar, position/1000.); + //status = pC_->transactController(axisNo_,command,reply); sprintf(command, "%s%cP20S%f", pC_->selector,phytronChar, position/1000.); status = pC_->transactController(axisNo_,command,reply); next_poll = -1; @@ -537,16 +538,7 @@ asynStatus PhytronAxis::poll(bool *moving) if(!*moving) { if(homing){ - double home_pos = 0.0; - if(!home_zero) { - if(homing_direction) { - pC_->getDoubleParam(axisNo_,pC_->motorHighLimit_,&home_pos); - } else { - pC_->getDoubleParam(axisNo_,pC_->motorLowLimit_,&home_pos); - } - } - setPosition(home_pos); - setIntegerParam(pC_->motorStatusAtHome_, true); + setIntegerParam(pC_->motorStatusAtHome_, true); } else { /* check limits and errors, upper @@ -558,7 +550,7 @@ asynStatus PhytronAxis::poll(bool *moving) updateMsgTxtFromDriver("No connection to phytron controller"); goto skip; } - if(strstr(reply,"ACKE") != NULL){ + if(strstr(reply,"ACKE") != NULL && ignore_limits == 0){ setIntegerParam(pC_->motorStatusHighLimit_, true); updateMsgTxtFromDriver("Hit High Limit"); comStatus = asynError; @@ -577,7 +569,7 @@ asynStatus PhytronAxis::poll(bool *moving) updateMsgTxtFromDriver("No connection to phytron controller"); goto skip; } - if(strstr(reply,"ACKE") != NULL){ + if(strstr(reply,"ACKE") != NULL && ignore_limits == 0){ setIntegerParam(pC_->motorStatusLowLimit_, true); updateMsgTxtFromDriver("Low Limit Hit"); comStatus = asynError; @@ -722,20 +714,19 @@ static const iocshArg PhytronCreateControllerArg1 = {"Phytron port name", iocshA static const iocshArg PhytronCreateControllerArg2 = {"Phytron Selector", iocshArgString}; static const iocshArg PhytronCreateControllerArg3 = {"EncoderX", iocshArgInt}; static const iocshArg PhytronCreateControllerArg4 = {"EncoderY", iocshArgInt}; -static const iocshArg PhytronCreateControllerArg5 = {"HomeZeroX", iocshArgInt}; -static const iocshArg PhytronCreateControllerArg6 = {"HomeZeroY", iocshArgInt}; +static const iocshArg PhytronCreateControllerArg5 = {"IgnoreLimitsX", iocshArgInt}; +static const iocshArg PhytronCreateControllerArg6 = {"IgnoreLimitsY", iocshArgInt}; static const iocshArg * const PhytronCreateControllerArgs[] = {&PhytronCreateControllerArg0, &PhytronCreateControllerArg1, &PhytronCreateControllerArg2, - &PhytronCreateControllerArg3, + &PhytronCreateControllerArg3, &PhytronCreateControllerArg4, &PhytronCreateControllerArg5, &PhytronCreateControllerArg6}; static const iocshFuncDef PhytronCreateControllerDef = {"PhytronCreateController", 7, PhytronCreateControllerArgs}; static void PhytronCreateContollerCallFunc(const iocshArgBuf *args) { - PhytronCreateController(args[0].sval, args[1].sval, args[2].sval, args[3].ival, args[4].ival, - args[5].ival, args[6].ival); + PhytronCreateController(args[0].sval, args[1].sval, args[2].sval, args[3].ival,args[4].ival, args[5].ival, args[6].ival); } static const iocshArg PhytronDoseCreateControllerArg0 = {"Port name", iocshArgString}; diff --git a/sinqEPICSApp/src/PhytronDriver.h b/sinqEPICSApp/src/PhytronDriver.h index 1b37953..edb23ed 100644 --- a/sinqEPICSApp/src/PhytronDriver.h +++ b/sinqEPICSApp/src/PhytronDriver.h @@ -30,7 +30,7 @@ class PhytronAxis : public SINQAxis { public: /* These are the methods we override from the base class */ - PhytronAxis(class PhytronController *pC, int axis, int enc, int homeZero); + PhytronAxis(class PhytronController *pC, int axis, int enc, int ignoreLimits); void report(FILE *fp, int level); asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration); asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration); @@ -50,10 +50,9 @@ protected: int homing_direction; /*1 forward, 0 backwards */ time_t next_poll; int encoder; + int ignore_limits; int haveBrake; int brakeIO; - int home_zero; - friend class PhytronController; }; @@ -76,7 +75,7 @@ PhytronDoseController *pC_; class PhytronController : public SINQController { public: PhytronController(const char *portName, const char *PhytronPortName, const char *selector, - int encX, int encY, int homeZeroX, int homeZeroY); + int encX, int encY, int ignoreLimitsX, int ignoreLimitsY); void report(FILE *fp, int level); PhytronAxis* getAxis(asynUser *pasynUser);