|
|
|
@ -54,13 +54,13 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
|
|
|
|
|
line 40). However, we want the IOC creation to stop completely, since this
|
|
|
|
|
is a configuration error.
|
|
|
|
|
*/
|
|
|
|
|
if (axisNo >= pC->numAxes_) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (axisNo >= pC->numAxes()) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d: FATAL ERROR: "
|
|
|
|
|
"Axis index %d must be smaller than the total number of axes "
|
|
|
|
|
"%d",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
axisNo_, pC->numAxes_);
|
|
|
|
|
axisNo_, pC->numAxes());
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -78,13 +78,14 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
|
|
|
|
|
|
|
|
|
|
// Initialize all member variables
|
|
|
|
|
waitForHandshake_ = false;
|
|
|
|
|
timeAtHandshake_ = 0;
|
|
|
|
|
axisStatus_ = 0;
|
|
|
|
|
|
|
|
|
|
// Provide initial values for some parameter library entries
|
|
|
|
|
status = pC_->setIntegerParam(axisNo_, pC_->rereadEncoderPosition_, 0);
|
|
|
|
|
status = pC_->setIntegerParam(axisNo_, pC_->rereadEncoderPosition(), 0);
|
|
|
|
|
if (status != asynSuccess) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
|
|
|
|
|
"(setting a parameter value failed with %s)\n. Terminating IOC",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
@ -93,10 +94,10 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// turboPmac motors can always be disabled
|
|
|
|
|
status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable_, 1);
|
|
|
|
|
status = pC_->setIntegerParam(axisNo_, pC_->motorCanDisable(), 1);
|
|
|
|
|
if (status != asynSuccess) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nFATAL ERROR "
|
|
|
|
|
"(setting a parameter value failed with %s)\n. Terminating IOC",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
@ -121,7 +122,7 @@ asynStatus turboPmacAxis::init() {
|
|
|
|
|
char command[pC_->MAXBUF_], response[pC_->MAXBUF_];
|
|
|
|
|
int nvals = 0;
|
|
|
|
|
double motorRecResolution = 0.0;
|
|
|
|
|
double motorPosition = 0.0;
|
|
|
|
|
double motorPos = 0.0;
|
|
|
|
|
double motorVelocity = 0.0;
|
|
|
|
|
double motorVmax = 0.0;
|
|
|
|
|
double motorAccel = 0.0;
|
|
|
|
@ -134,11 +135,11 @@ asynStatus turboPmacAxis::init() {
|
|
|
|
|
time_t now = time(NULL);
|
|
|
|
|
time_t maxInitTime = 60;
|
|
|
|
|
while (1) {
|
|
|
|
|
status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_,
|
|
|
|
|
status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(),
|
|
|
|
|
&motorRecResolution);
|
|
|
|
|
if (status == asynParamUndefined) {
|
|
|
|
|
if (now + maxInitTime < time(NULL)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line "
|
|
|
|
|
"%d\nInitializing the parameter library failed.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -165,7 +166,7 @@ asynStatus turboPmacAxis::init() {
|
|
|
|
|
if (status != asynSuccess) {
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
nvals = sscanf(response, "%d %lf %lf %lf %lf %d", &axStatus, &motorPosition,
|
|
|
|
|
nvals = sscanf(response, "%d %lf %lf %lf %lf %d", &axStatus, &motorPos,
|
|
|
|
|
&motorVmax, &motorVelocity, &motorAccel, &acoDelay);
|
|
|
|
|
|
|
|
|
|
// The acoDelay is given in milliseconds -> Convert to seconds, rounded up
|
|
|
|
@ -177,17 +178,20 @@ asynStatus turboPmacAxis::init() {
|
|
|
|
|
motorAccel = motorAccel * 1000;
|
|
|
|
|
|
|
|
|
|
if (nvals != 6) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Transform from motor to parameter library coordinates
|
|
|
|
|
motorPosition = motorPosition / motorRecResolution;
|
|
|
|
|
|
|
|
|
|
// Store these values in the parameter library
|
|
|
|
|
status = pC_->setDoubleParam(axisNo_, pC_->motorPosition_, motorPosition);
|
|
|
|
|
status = setMotorPosition(motorPos);
|
|
|
|
|
if (status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(status, "motorPosition_", axisNo_,
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initial motor status is idle
|
|
|
|
|
status = pC_->setIntegerParam(axisNo_, pC_->motorStatusDone(), 1);
|
|
|
|
|
if (status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(status, "motorStatusDone_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -207,7 +211,7 @@ asynStatus turboPmacAxis::init() {
|
|
|
|
|
// If we can't communicate with the parameter library, it doesn't make
|
|
|
|
|
// sense to try and upstream this to the user -> Just log the error
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\ncallParamCallbacks "
|
|
|
|
|
"failed with %s.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
@ -245,11 +249,41 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
double lowLimit = 0.0;
|
|
|
|
|
double limitsOffset = 0.0;
|
|
|
|
|
|
|
|
|
|
// Was the axis idle during the previous poll?
|
|
|
|
|
int previousStatusDone = 1;
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
// Are we currently waiting for a handshake?
|
|
|
|
|
if (waitForHandshake_) {
|
|
|
|
|
|
|
|
|
|
// Check if the handshake takes too long and communicate an error in
|
|
|
|
|
// this case. A handshake should not take more than 5 seconds.
|
|
|
|
|
time_t currentTime = time(NULL);
|
|
|
|
|
bool timedOut = (currentTime > timeAtHandshake_ + 5);
|
|
|
|
|
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, timedOut,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAsked for a "
|
|
|
|
|
"handshake at %ld s and didn't get a positive reply yet "
|
|
|
|
|
"(current time is %ld s).\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
timeAtHandshake_, currentTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (timedOut) {
|
|
|
|
|
pl_status =
|
|
|
|
|
setStringParam(pC_->motorMessageText(),
|
|
|
|
|
"Timed out while waiting for a handshake");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
|
__LINE__);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf(command, sizeof(command), "P%2.2d23 P%2.2d01", axisNo_,
|
|
|
|
|
axisNo_);
|
|
|
|
|
rw_status = pC_->writeRead(axisNo_, command, response, 2);
|
|
|
|
@ -259,8 +293,8 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
|
|
|
|
|
nvals = sscanf(response, "%d %d", &handshakePerformed, &error);
|
|
|
|
|
if (nvals != 2) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(
|
|
|
|
|
command, response, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error != 0) {
|
|
|
|
@ -277,14 +311,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
// poll. This is already part of the movement procedure.
|
|
|
|
|
*moving = true;
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusMoving_, *moving);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status,
|
|
|
|
|
"motorStatusMoving_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDone_, !(*moving));
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDone(), !(*moving));
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -295,8 +329,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Motor resolution from parameter library
|
|
|
|
|
pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_,
|
|
|
|
|
pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(),
|
|
|
|
|
&motorRecResolution);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_",
|
|
|
|
@ -305,16 +338,17 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read the previous motor position
|
|
|
|
|
pl_status =
|
|
|
|
|
pC_->getDoubleParam(axisNo_, pC_->motorPosition_, &previousPosition);
|
|
|
|
|
pl_status = motorPosition(&previousPosition);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pl_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Transform from EPICS to motor coordinates (see comment in
|
|
|
|
|
// turboPmacAxis::atFirstPoll)
|
|
|
|
|
previousPosition = previousPosition * motorRecResolution;
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorStatusDone(),
|
|
|
|
|
&previousStatusDone);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query the axis status
|
|
|
|
|
snprintf(command, sizeof(command),
|
|
|
|
@ -328,8 +362,8 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
nvals = sscanf(response, "%d %lf %d %lf %lf", &axStatus, ¤tPosition,
|
|
|
|
|
&error, &highLimit, &lowLimit);
|
|
|
|
|
if (nvals != 5) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -345,7 +379,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
by limitsOffset on both sides.
|
|
|
|
|
*/
|
|
|
|
|
pl_status =
|
|
|
|
|
pC_->getDoubleParam(axisNo_, pC_->motorLimitsOffset_, &limitsOffset);
|
|
|
|
|
pC_->getDoubleParam(axisNo_, pC_->motorLimitsOffset(), &limitsOffset);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorLimitsOffset_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -358,7 +392,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
axisStatus_ = axStatus;
|
|
|
|
|
|
|
|
|
|
// Update the enablement PV
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorEnableRBV_,
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorEnableRBV(),
|
|
|
|
|
(axStatus != -3 && axStatus != -5));
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorEnableRBV_", axisNo_,
|
|
|
|
@ -375,13 +409,19 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
switch (axStatus) {
|
|
|
|
|
case -6:
|
|
|
|
|
// Axis is stopping
|
|
|
|
|
*moving = true;
|
|
|
|
|
|
|
|
|
|
// If the axis was already idle during the last poll, it is not moving
|
|
|
|
|
if (previousStatusDone == 0) {
|
|
|
|
|
*moving = true;
|
|
|
|
|
} else {
|
|
|
|
|
*moving = false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case -5:
|
|
|
|
|
// Axis is deactivated
|
|
|
|
|
*moving = false;
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Deactivated");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Deactivated");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -392,18 +432,18 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
// Emergency stop
|
|
|
|
|
*moving = false;
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nEmergency stop "
|
|
|
|
|
"activated.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetCountStatus = false;
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Emergency stop");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Emergency stop");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -415,7 +455,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
// Disabled
|
|
|
|
|
*moving = false;
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Disabled");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Disabled");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -447,7 +487,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
*moving = true;
|
|
|
|
|
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is moving\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
|
|
|
|
@ -455,14 +495,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
default:
|
|
|
|
|
*moving = false;
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nReached "
|
|
|
|
|
"unreachable state P%2.2d00 = %d.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
axisNo_, axStatus, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
axisNo_, axStatus, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetCountStatus = false;
|
|
|
|
|
|
|
|
|
@ -470,7 +510,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"Unknown state P%2.2d00 = %d has been reached. Please call "
|
|
|
|
|
"the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -479,7 +519,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resetCountStatus) {
|
|
|
|
|
pC_->msgPrintControl_.resetCount(keyStatus);
|
|
|
|
|
pC_->getMsgPrintControl().resetCount(keyStatus, pC_->asynUserSelf());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*moving) {
|
|
|
|
@ -504,17 +544,17 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
case 1:
|
|
|
|
|
// EPICS should already prevent this issue in the first place,
|
|
|
|
|
// since it contains the user limits
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nTarget "
|
|
|
|
|
"position would exceed user limits.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_,
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(),
|
|
|
|
|
"Target position would exceed software "
|
|
|
|
|
"limits. Please call the support.");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
@ -527,19 +567,19 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
// Command not possible
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyStatus, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is "
|
|
|
|
|
"still moving, but received another move command. EPICS "
|
|
|
|
|
"should prevent this, check if *moving is set correctly.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_,
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(),
|
|
|
|
|
"Axis received move command while it is "
|
|
|
|
|
"still moving. Please call the support.");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
@ -551,13 +591,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
poll_status = asynError;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAir cushion "
|
|
|
|
|
"feedback stopped during movement (P%2.2d01 = %d).%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
axisNo_, error, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
axisNo_, error, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -566,7 +606,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"%d). Please call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -574,14 +614,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nNo air cushion "
|
|
|
|
|
"feedback before movement start (P%2.2d01 = %d).%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_,
|
|
|
|
|
error, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
error, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -589,7 +629,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"No air cushion feedback before movement start (P%2.2d01 = "
|
|
|
|
|
"%d). Please call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -604,14 +644,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
which is not properly homed or if a bug occured.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis hit the "
|
|
|
|
|
"controller limits.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -622,7 +662,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"Otherwise please call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -634,14 +674,14 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
case 11:
|
|
|
|
|
// Following error
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nMaximum allowed "
|
|
|
|
|
"following error exceeded.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -650,7 +690,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"Check if movement range is blocked. "
|
|
|
|
|
"Otherwise please call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, command);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), command);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -661,13 +701,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nSecurity "
|
|
|
|
|
"input is triggered (P%2.2d01 = %d).%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
axisNo_, error, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
axisNo_, error, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -676,7 +716,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"for errors (if available). Otherwise please call "
|
|
|
|
|
"the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, command);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), command);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -689,13 +729,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
case 13:
|
|
|
|
|
// Driver hardware error triggered
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nDriver "
|
|
|
|
|
"hardware error triggered.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -703,7 +743,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"Driver hardware error (P%2.2d01 = 13). "
|
|
|
|
|
"Please call the support.",
|
|
|
|
|
axisNo_);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, command);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), command);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -716,13 +756,13 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
// EPICS should already prevent this issue in the first place,
|
|
|
|
|
// since it contains the user limits
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nMove "
|
|
|
|
|
"command exceeds hardware limits (P%2.2d01 = %d).%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
axisNo_, error, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
axisNo_, error, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
@ -730,7 +770,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
"Move command exceeds hardware limits (P%2.2d01 = %d). Please "
|
|
|
|
|
"call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -741,21 +781,21 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
if (pC_->msgPrintControl_.shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->pasynUserSelf)) {
|
|
|
|
|
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
|
|
|
|
|
pC_->asynUserSelf())) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nUnknown error "
|
|
|
|
|
"P%2.2d01 = %d.%s\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, axisNo_,
|
|
|
|
|
error, pC_->msgPrintControl_.getSuffix());
|
|
|
|
|
error, pC_->getMsgPrintControl().getSuffix());
|
|
|
|
|
}
|
|
|
|
|
resetError = false;
|
|
|
|
|
|
|
|
|
|
snprintf(userMessage, sizeof(userMessage),
|
|
|
|
|
"Unknown error P%2.2d01 = %d. Please call the support.",
|
|
|
|
|
axisNo_, error);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, userMessage);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), userMessage);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -767,12 +807,12 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resetError) {
|
|
|
|
|
pC_->msgPrintControl_.resetCount(keyError);
|
|
|
|
|
pC_->getMsgPrintControl().resetCount(keyError, pC_->asynUserSelf());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the parameter library
|
|
|
|
|
if (error != 0) {
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem_, true);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -781,7 +821,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*moving == false) {
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorMoveToHome_, 0);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorMoveToHome(), 0);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -789,28 +829,28 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusMoving_, *moving);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusMoving(), *moving);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
|
__LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDone_, !(*moving));
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDone(), !(*moving));
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDirection_, direction);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusDirection(), direction);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusDirection_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
|
__LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status =
|
|
|
|
|
pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver_, highLimit);
|
|
|
|
|
pl_status = pC_->setDoubleParam(axisNo_, pC_->motorHighLimitFromDriver(),
|
|
|
|
|
highLimit);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorHighLimitFromDriver_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -818,22 +858,16 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status =
|
|
|
|
|
pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver_, lowLimit);
|
|
|
|
|
pC_->setDoubleParam(axisNo_, pC_->motorLowLimitFromDriver(), lowLimit);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorLowLimit_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Transform from motor to EPICS coordinates (see comment in
|
|
|
|
|
// turboPmacAxis::init())
|
|
|
|
|
currentPosition = currentPosition / motorRecResolution;
|
|
|
|
|
|
|
|
|
|
pl_status = setDoubleParam(pC_->motorPosition_, currentPosition);
|
|
|
|
|
pl_status = setMotorPosition(currentPosition);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pl_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return poll_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -857,13 +891,13 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV_, &enabled);
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV(), &enabled);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "enableMotorRBV_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_,
|
|
|
|
|
pl_status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution(),
|
|
|
|
|
&motorRecResolution);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorRecResolution_",
|
|
|
|
@ -873,7 +907,7 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
|
|
|
|
|
|
|
|
|
|
if (enabled == 0) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is disabled.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return asynSuccess;
|
|
|
|
@ -883,13 +917,13 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
|
|
|
|
|
motorCoordinatesPosition = position * motorRecResolution;
|
|
|
|
|
motorVelocity = maxVelocity * motorRecResolution;
|
|
|
|
|
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nStart of axis to "
|
|
|
|
|
"position %lf.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, position);
|
|
|
|
|
|
|
|
|
|
// Check if the speed is allowed to be changed
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorCanSetSpeed_,
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorCanSetSpeed(),
|
|
|
|
|
&motorCanSetSpeed);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorCanSetSpeed_",
|
|
|
|
@ -905,7 +939,7 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
|
|
|
|
|
motorVelocity);
|
|
|
|
|
writeOffset = strlen(command);
|
|
|
|
|
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nSetting speed "
|
|
|
|
|
"to %lf.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
@ -929,12 +963,12 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
|
|
|
|
|
if (rw_status != asynSuccess) {
|
|
|
|
|
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nStarting movement to "
|
|
|
|
|
"target position %lf failed.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
motorCoordinatesPosition);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem_, true);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -974,12 +1008,45 @@ asynStatus turboPmacAxis::stop(double acceleration) {
|
|
|
|
|
|
|
|
|
|
if (rw_status != asynSuccess) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nStopping the movement "
|
|
|
|
|
"failed.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem_, true);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
|
__LINE__);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rw_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asynStatus turboPmacAxis::doReset() {
|
|
|
|
|
|
|
|
|
|
// Status of read-write-operations of ASCII commands to the controller
|
|
|
|
|
asynStatus rw_status = asynSuccess;
|
|
|
|
|
|
|
|
|
|
// Status of parameter library operations
|
|
|
|
|
asynStatus pl_status = asynSuccess;
|
|
|
|
|
|
|
|
|
|
char command[pC_->MAXBUF_], response[pC_->MAXBUF_];
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
// Reset the error for this axis manually
|
|
|
|
|
snprintf(command, sizeof(command), "P%2.2d01=0", axisNo_);
|
|
|
|
|
rw_status = pC_->writeRead(axisNo_, command, response, 0);
|
|
|
|
|
|
|
|
|
|
if (rw_status != asynSuccess) {
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nResetting the "
|
|
|
|
|
"error failed\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorStatusProblem(), true);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -1006,7 +1073,7 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity,
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
pl_status = pC_->getStringParam(axisNo_, pC_->encoderType_,
|
|
|
|
|
pl_status = pC_->getStringParam(axisNo_, pC_->encoderType(),
|
|
|
|
|
sizeof(response), response);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo_,
|
|
|
|
@ -1022,14 +1089,14 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity,
|
|
|
|
|
return rw_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorMoveToHome_, 1);
|
|
|
|
|
pl_status = setIntegerParam(pC_->motorMoveToHome(), 1);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMoveToHome_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
|
__LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Homing");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Homing");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -1037,7 +1104,7 @@ asynStatus turboPmacAxis::doHome(double min_velocity, double max_velocity,
|
|
|
|
|
}
|
|
|
|
|
return callParamCallbacks();
|
|
|
|
|
} else {
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_,
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(),
|
|
|
|
|
"Can't home a motor with absolute encoder");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
@ -1075,16 +1142,16 @@ asynStatus turboPmacAxis::readEncoderType() {
|
|
|
|
|
|
|
|
|
|
int reponse_length = strlen(response);
|
|
|
|
|
if (reponse_length < 3) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We are only interested in the last two digits and the last value in
|
|
|
|
|
// the string before the terminator is \r
|
|
|
|
|
nvals = sscanf(response + (reponse_length - 3), "%2X", &encoder_id);
|
|
|
|
|
if (nvals != 1) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf(command, sizeof(command), "P46");
|
|
|
|
@ -1096,9 +1163,9 @@ asynStatus turboPmacAxis::readEncoderType() {
|
|
|
|
|
|
|
|
|
|
// If true, the encoder is incremental
|
|
|
|
|
if (encoder_id <= number_of_axes) {
|
|
|
|
|
pl_status = setStringParam(pC_->encoderType_, IncrementalEncoder);
|
|
|
|
|
pl_status = setStringParam(pC_->encoderType(), IncrementalEncoder);
|
|
|
|
|
} else {
|
|
|
|
|
pl_status = setStringParam(pC_->encoderType_, AbsoluteEncoder);
|
|
|
|
|
pl_status = setStringParam(pC_->encoderType(), AbsoluteEncoder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
@ -1135,7 +1202,7 @@ asynStatus turboPmacAxis::rereadEncoder() {
|
|
|
|
|
if (rw_status != asynSuccess) {
|
|
|
|
|
return rw_status;
|
|
|
|
|
}
|
|
|
|
|
pl_status = pC_->getStringParam(axisNo_, pC_->encoderType_,
|
|
|
|
|
pl_status = pC_->getStringParam(axisNo_, pC_->encoderType(),
|
|
|
|
|
sizeof(encoderType), encoderType);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "encoderType_", axisNo_,
|
|
|
|
@ -1144,7 +1211,7 @@ asynStatus turboPmacAxis::rereadEncoder() {
|
|
|
|
|
|
|
|
|
|
// Abort if the axis is incremental
|
|
|
|
|
if (strcmp(encoderType, IncrementalEncoder) == 0) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nEncoder is "
|
|
|
|
|
"not reread because it is incremental.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
@ -1154,19 +1221,19 @@ asynStatus turboPmacAxis::rereadEncoder() {
|
|
|
|
|
// Check if the axis is disabled. If not, inform the user that this
|
|
|
|
|
// is necessary
|
|
|
|
|
int enabled = 0;
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV_, &enabled);
|
|
|
|
|
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorEnableRBV(), &enabled);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "enableMotorRBV_", axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enabled == 1) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_WARNING,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_WARNING,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis must be "
|
|
|
|
|
"disabled before rereading the encoder.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
pl_status = setStringParam(
|
|
|
|
|
pC_->motorMessageText_,
|
|
|
|
|
pC_->motorMessageText(),
|
|
|
|
|
"Axis must be disabled before rereading the encoder.");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
@ -1177,7 +1244,7 @@ asynStatus turboPmacAxis::rereadEncoder() {
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(command, sizeof(command), "M%2.2d=15", axisNo_);
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nRereading absolute "
|
|
|
|
|
"encoder via command %s.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, command);
|
|
|
|
@ -1192,7 +1259,7 @@ asynStatus turboPmacAxis::rereadEncoder() {
|
|
|
|
|
// turn off parameter as finished rereading
|
|
|
|
|
// this will only be immediately noticed in the read back variable
|
|
|
|
|
// though
|
|
|
|
|
pl_status = pC_->setIntegerParam(pC_->rereadEncoderPosition_, 0);
|
|
|
|
|
pl_status = pC_->setIntegerParam(pC_->rereadEncoderPosition(), 0);
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "rereadEncoderPosition_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -1224,13 +1291,13 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
// actually be disabled in this state!
|
|
|
|
|
if (axisStatus_ == 1 || axisStatus_ == 2 || axisStatus_ == 3 ||
|
|
|
|
|
axisStatus_ == 4 || axisStatus_ == 5) {
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is not "
|
|
|
|
|
"idle and can therefore not be enabled / disabled.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
|
|
|
|
|
pl_status =
|
|
|
|
|
setStringParam(pC_->motorMessageText_,
|
|
|
|
|
setStringParam(pC_->motorMessageText(),
|
|
|
|
|
"Axis cannot be disabled while it is moving.");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
@ -1245,7 +1312,7 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
// was sent => Do nothing
|
|
|
|
|
if ((axisStatus_ != -3) == on) {
|
|
|
|
|
asynPrint(
|
|
|
|
|
pC_->pasynUserSelf, ASYN_TRACE_WARNING,
|
|
|
|
|
pC_->asynUserSelf(), ASYN_TRACE_WARNING,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is already %s.\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
on ? "enabled" : "disabled");
|
|
|
|
@ -1262,14 +1329,14 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
|
|
|
|
|
// Enable / disable the axis if it is not moving
|
|
|
|
|
snprintf(command, sizeof(command), "M%2.2d14=%d", axisNo_, on);
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\n%s axis\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
|
on ? "Enable" : "Disable");
|
|
|
|
|
if (on == 0) {
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Disabling ...");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Disabling ...");
|
|
|
|
|
} else {
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Enabling ...");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
|
|
|
|
|
}
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
@ -1295,8 +1362,8 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
}
|
|
|
|
|
nvals = sscanf(response, "%d", &axisStatus_);
|
|
|
|
|
if (nvals != 1) {
|
|
|
|
|
return pC_->errMsgCouldNotParseResponse(
|
|
|
|
|
command, response, axisNo_, __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
return pC_->couldNotParseResponse(command, response, axisNo_,
|
|
|
|
|
__PRETTY_FUNCTION__, __LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((axisStatus_ != -3) == on) {
|
|
|
|
@ -1309,7 +1376,7 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
|
|
|
|
|
// Failed to change axis status within timeout_enable_disable => Send a
|
|
|
|
|
// corresponding message
|
|
|
|
|
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW,
|
|
|
|
|
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
|
|
|
|
|
"Controller \"%s\", axis %d => %s, line %d\nFailed to %s axis "
|
|
|
|
|
"within %d seconds\n",
|
|
|
|
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
|
|
|
@ -1318,7 +1385,7 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|
|
|
|
// Output message to user
|
|
|
|
|
snprintf(command, sizeof(command), "Failed to %s within %d seconds",
|
|
|
|
|
on ? "enable" : "disable", timeout_enable_disable);
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText_, "Enabling ...");
|
|
|
|
|
pl_status = setStringParam(pC_->motorMessageText(), "Enabling ...");
|
|
|
|
|
if (pl_status != asynSuccess) {
|
|
|
|
|
return pC_->paramLibAccessFailed(pl_status, "motorMessageText_",
|
|
|
|
|
axisNo_, __PRETTY_FUNCTION__,
|
|
|
|
@ -1354,9 +1421,9 @@ asynStatus turboPmacCreateAxis(const char *portName, int axis) {
|
|
|
|
|
if (ptr == nullptr) {
|
|
|
|
|
/*
|
|
|
|
|
We can't use asynPrint here since this macro would require us
|
|
|
|
|
to get a lowLevelPortUser_ from a pointer to an asynPortDriver.
|
|
|
|
|
to get an asynUser from a pointer to an asynPortDriver.
|
|
|
|
|
However, the given pointer is a nullptr and therefore doesn't
|
|
|
|
|
have a lowLevelPortUser_! printf is an EPICS alternative which
|
|
|
|
|
have an asynUser! printf is an EPICS alternative which
|
|
|
|
|
works w/o that, but doesn't offer the comfort provided
|
|
|
|
|
by the asynTrace-facility
|
|
|
|
|
*/
|
|
|
|
@ -1421,4 +1488,4 @@ static void turboPmacAxisRegister(void) {
|
|
|
|
|
}
|
|
|
|
|
epicsExportRegistrar(turboPmacAxisRegister);
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
|
} // extern "C"
|
|
|
|
|