phytron: home_zero and initialize some variables
Some checks failed
Test And Build / Build (push) Successful in 7s
Test And Build / Lint (push) Failing after 7s

This commit is contained in:
2025-09-11 11:27:56 +02:00
parent 683fa2138f
commit ed0525e811
2 changed files with 37 additions and 28 deletions

View File

@@ -56,7 +56,7 @@ January 2019
* \param[in] numAxes The number of axes that this controller supports * \param[in] numAxes The number of axes that this controller supports
*/ */
PhytronController::PhytronController(const char *portName, const char *PhytronPortName, const char *sel , PhytronController::PhytronController(const char *portName, const char *PhytronPortName, const char *sel ,
int encX, int encY) int encX, int encY, int homeZeroX, int homeZeroY)
: SINQController(portName, PhytronPortName,2) : SINQController(portName, PhytronPortName,2)
{ {
asynStatus status; asynStatus status;
@@ -82,8 +82,8 @@ PhytronController::PhytronController(const char *portName, const char *PhytronPo
new PhytronDoseAxis(this, 1, encX); new PhytronDoseAxis(this, 1, encX);
new PhytronDoseAxis(this, 2, encY); new PhytronDoseAxis(this, 2, encY);
} else { } else {
new PhytronAxis(this, 1, encX); new PhytronAxis(this, 1, encX, homeZeroX);
new PhytronAxis(this, 2, encY); new PhytronAxis(this, 2, encY, homeZeroY);
} }
@@ -92,7 +92,7 @@ PhytronController::PhytronController(const char *portName, const char *PhytronPo
PhytronDoseController::PhytronDoseController(const char *portName, const char *PhytronPortName, const char *sel , PhytronDoseController::PhytronDoseController(const char *portName, const char *PhytronPortName, const char *sel ,
int encX, int encY) int encX, int encY)
: PhytronController(portName, PhytronPortName, sel, encX, encY) : PhytronController(portName, PhytronPortName, sel, encX, encY, 0, 0)
{ {
new PhytronDoseAxis(this, 1, encX); new PhytronDoseAxis(this, 1, encX);
new PhytronDoseAxis(this, 2, encY); new PhytronDoseAxis(this, 2, encY);
@@ -106,9 +106,9 @@ PhytronDoseController::PhytronDoseController(const char *portName, const char *P
* \param[in] numAxes The number of axes that this controller supports * \param[in] numAxes The number of axes that this controller supports
*/ */
extern "C" int PhytronCreateController(const char *portName, const char *PhytronPortName, const char *selector, extern "C" int PhytronCreateController(const char *portName, const char *PhytronPortName, const char *selector,
int encX, int encY) int encX, int encY, int homeZeroX, int homeZeroY)
{ {
new PhytronController(portName, PhytronPortName,selector, encX, encY); new PhytronController(portName, PhytronPortName,selector, encX, encY, homeZeroX, homeZeroY);
return(asynSuccess); return(asynSuccess);
} }
@@ -178,10 +178,10 @@ PhytronDoseAxis* PhytronDoseController::getAxis(int axisNo)
asynStatus PhytronController::transactController(int axisNo,char command[COMLEN], char reply[COMLEN]) asynStatus PhytronController::transactController(int axisNo,char command[COMLEN], char reply[COMLEN])
{ {
asynStatus status; asynStatus status = asynSuccess;
size_t in, out; size_t in = 0, out = 0;
int reason; int reason = 0;
char myReply[COMLEN+10], myCommand[COMLEN+10], *pPtr; char myReply[COMLEN+10] = {0}, myCommand[COMLEN+10] = {0}, *pPtr = {0};
SINQAxis *axis = getAxis(axisNo); SINQAxis *axis = getAxis(axisNo);
@@ -237,7 +237,7 @@ asynStatus PhytronController::transactController(int axisNo,char command[COMLEN]
* *
* Initializes register numbers, etc. * Initializes register numbers, etc.
*/ */
PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc) PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc, int homeZero)
: SINQAxis(pC, axisNo), : SINQAxis(pC, axisNo),
pC_(pC) pC_(pC)
{ {
@@ -251,7 +251,8 @@ PhytronAxis::PhytronAxis(PhytronController *pC, int axisNo, int enc)
brakeIO = -1; brakeIO = -1;
next_poll = -1; next_poll = -1;
homing = 0; homing = 0;
homing_direction = 0; homing_direction = 0;
home_zero = homeZero;
} }
int PhytronAxis::setBrake(int brakeNO) int PhytronAxis::setBrake(int brakeNO)
@@ -467,8 +468,6 @@ asynStatus PhytronAxis::poll(bool *moving)
{ {
asynStatus comStatus = asynSuccess; asynStatus comStatus = asynSuccess;
char command[COMLEN], reply[COMLEN]; char command[COMLEN], reply[COMLEN];
double lowlim;
// protect against excessive polling // protect against excessive polling
if(time(NULL) < next_poll){ if(time(NULL) < next_poll){
@@ -538,12 +537,15 @@ asynStatus PhytronAxis::poll(bool *moving)
if(!*moving) { if(!*moving) {
if(homing){ if(homing){
if(homing_direction) { double home_pos = 0.0;
pC_->getDoubleParam(axisNo_,pC_->motorHighLimit_,&lowlim); if(!home_zero) {
} else { if(homing_direction) {
pC_->getDoubleParam(axisNo_,pC_->motorLowLimit_,&lowlim); pC_->getDoubleParam(axisNo_,pC_->motorHighLimit_,&home_pos);
} } else {
setPosition(lowlim); pC_->getDoubleParam(axisNo_,pC_->motorLowLimit_,&home_pos);
}
}
setPosition(home_pos);
setIntegerParam(pC_->motorStatusAtHome_, true); setIntegerParam(pC_->motorStatusAtHome_, true);
} else { } else {
/* /*
@@ -616,7 +618,7 @@ asynStatus PhytronAxis::poll(bool *moving)
*/ */
PhytronDoseAxis::PhytronDoseAxis(PhytronController *pC, int axisNo, int enc) PhytronDoseAxis::PhytronDoseAxis(PhytronController *pC, int axisNo, int enc)
: PhytronAxis(pC, axisNo, enc) : PhytronAxis(pC, axisNo, enc, 0)
{ {
if(axisNo == 1){ if(axisNo == 1){
doseChar = '3'; doseChar = '3';
@@ -720,15 +722,20 @@ static const iocshArg PhytronCreateControllerArg1 = {"Phytron port name", iocshA
static const iocshArg PhytronCreateControllerArg2 = {"Phytron Selector", iocshArgString}; static const iocshArg PhytronCreateControllerArg2 = {"Phytron Selector", iocshArgString};
static const iocshArg PhytronCreateControllerArg3 = {"EncoderX", iocshArgInt}; static const iocshArg PhytronCreateControllerArg3 = {"EncoderX", iocshArgInt};
static const iocshArg PhytronCreateControllerArg4 = {"EncoderY", iocshArgInt}; static const iocshArg PhytronCreateControllerArg4 = {"EncoderY", iocshArgInt};
static const iocshArg PhytronCreateControllerArg5 = {"HomeZeroX", iocshArgInt};
static const iocshArg PhytronCreateControllerArg6 = {"HomeZeroY", iocshArgInt};
static const iocshArg * const PhytronCreateControllerArgs[] = {&PhytronCreateControllerArg0, static const iocshArg * const PhytronCreateControllerArgs[] = {&PhytronCreateControllerArg0,
&PhytronCreateControllerArg1, &PhytronCreateControllerArg1,
&PhytronCreateControllerArg2, &PhytronCreateControllerArg2,
&PhytronCreateControllerArg3, &PhytronCreateControllerArg3,
&PhytronCreateControllerArg4}; &PhytronCreateControllerArg4,
static const iocshFuncDef PhytronCreateControllerDef = {"PhytronCreateController", 5, PhytronCreateControllerArgs}; &PhytronCreateControllerArg5,
&PhytronCreateControllerArg6};
static const iocshFuncDef PhytronCreateControllerDef = {"PhytronCreateController", 7, PhytronCreateControllerArgs};
static void PhytronCreateContollerCallFunc(const iocshArgBuf *args) static void PhytronCreateContollerCallFunc(const iocshArgBuf *args)
{ {
PhytronCreateController(args[0].sval, args[1].sval, args[2].sval, args[3].ival,args[4].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}; static const iocshArg PhytronDoseCreateControllerArg0 = {"Port name", iocshArgString};

View File

@@ -30,7 +30,7 @@ class PhytronAxis : public SINQAxis
{ {
public: public:
/* These are the methods we override from the base class */ /* These are the methods we override from the base class */
PhytronAxis(class PhytronController *pC, int axis, int enc); PhytronAxis(class PhytronController *pC, int axis, int enc, int homeZero);
void report(FILE *fp, int level); void report(FILE *fp, int level);
asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration); asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration);
asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration); asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration);
@@ -52,6 +52,8 @@ protected:
int encoder; int encoder;
int haveBrake; int haveBrake;
int brakeIO; int brakeIO;
int home_zero;
friend class PhytronController; friend class PhytronController;
}; };
@@ -74,7 +76,7 @@ PhytronDoseController *pC_;
class PhytronController : public SINQController { class PhytronController : public SINQController {
public: public:
PhytronController(const char *portName, const char *PhytronPortName, const char *selector, PhytronController(const char *portName, const char *PhytronPortName, const char *selector,
int encX, int encY); int encX, int encY, int homeZeroX, int homeZeroY);
void report(FILE *fp, int level); void report(FILE *fp, int level);
PhytronAxis* getAxis(asynUser *pasynUser); PhytronAxis* getAxis(asynUser *pasynUser);