Compare commits

...

4 Commits
0.7.0 ... 0.8.0

Author SHA1 Message Date
83a74ce8d0 Added new sinqMotor version as minimum requirement 2025-03-19 15:04:16 +01:00
445dd44c19 Removed a doubling of functionality
ipPortUser / lowLevelPortUser are already defined in the sinqMotor
library
2025-03-10 17:02:28 +01:00
d471041c59 Removed friend class declaration and replaced access to private
properties with accessors
2025-03-10 16:55:10 +01:00
967613447b Added error reset function. 2025-03-10 14:31:15 +01:00
5 changed files with 240 additions and 167 deletions

View File

@ -14,7 +14,7 @@ REQUIRED+=sinqMotor
motorBase_VERSION=7.2.2
# Specify the version of sinqMotor we want to build against
sinqMotor_VERSION=0.8.0
sinqMotor_VERSION=0.9.0
# These headers allow to depend on this library for derived drivers.
HEADERS += src/turboPmacAxis.h

View File

@ -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__,
@ -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__,
@ -185,12 +186,19 @@ asynStatus turboPmacAxis::init() {
motorPosition = motorPosition / motorRecResolution;
// Store these values in the parameter library
status = pC_->setDoubleParam(axisNo_, pC_->motorPosition_, motorPosition);
status = pC_->setDoubleParam(axisNo_, pC_->motorPosition(), motorPosition);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorPosition_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Initial motor status is idle
status = pC_->setIntegerParam(axisNo_, pC_->motorStatusDone(), 1);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorStatusDone_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Write to the motor record fields
status = setVeloFields(motorVelocity, 0.0, motorVmax);
if (status != asynSuccess) {
@ -207,7 +215,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 +253,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);
@ -277,14 +315,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__,
@ -296,7 +334,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_",
@ -306,12 +344,20 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
// Read the previous motor position
pl_status =
pC_->getDoubleParam(axisNo_, pC_->motorPosition_, &previousPosition);
pC_->getDoubleParam(axisNo_, pC_->motorPosition(), &previousPosition);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Read the previous motor position
pl_status = pC_->getIntegerParam(axisNo_, pC_->motorStatusDone(),
&previousStatusDone);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorStatusDone_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
}
// Transform from EPICS to motor coordinates (see comment in
// turboPmacAxis::atFirstPoll)
previousPosition = previousPosition * motorRecResolution;
@ -345,7 +391,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 +404,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 +421,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 +444,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 +467,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 +499,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 +507,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 +522,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 +531,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
}
if (resetCountStatus) {
pC_->msgPrintControl_.resetCount(keyStatus);
pC_->getMsgPrintControl().resetCount(keyStatus, pC_->asynUserSelf());
}
if (*moving) {
@ -504,17 +556,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 +579,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 +603,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 +618,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 +626,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 +641,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 +656,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 +674,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 +686,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 +702,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 +713,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 +728,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 +741,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 +755,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 +768,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 +782,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 +793,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 +819,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 +833,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 +841,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,7 +870,7 @@ 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__);
@ -828,7 +880,7 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
// turboPmacAxis::init())
currentPosition = currentPosition / motorRecResolution;
pl_status = setDoubleParam(pC_->motorPosition_, currentPosition);
pl_status = setDoubleParam(pC_->motorPosition(), currentPosition);
if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_,
__PRETTY_FUNCTION__, __LINE__);
@ -857,13 +909,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 +925,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 +935,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 +957,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 +981,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 +1026,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::reset() {
// 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 +1091,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 +1107,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 +1122,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_",
@ -1096,9 +1181,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 +1220,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 +1229,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 +1239,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 +1262,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 +1277,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 +1309,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 +1330,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 +1347,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_",
@ -1309,7 +1394,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 +1403,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 +1439,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 +1506,4 @@ static void turboPmacAxisRegister(void) {
}
epicsExportRegistrar(turboPmacAxisRegister);
} // extern "C"
} // extern "C"

View File

@ -81,6 +81,14 @@ class turboPmacAxis : public sinqAxis {
*/
asynStatus init();
/**
* @brief Reset the axis error
*
* @param on
* @return asynStatus
*/
asynStatus reset();
/**
* @brief Enable / disable the axis.
*
@ -112,9 +120,6 @@ class turboPmacAxis : public sinqAxis {
// The axis status is used when enabling / disabling the motor
int axisStatus_;
private:
friend class turboPmacController;
};
#endif

View File

@ -49,27 +49,12 @@ turboPmacController::turboPmacController(const char *portName,
asynStatus status = asynSuccess;
// Initialization of all member variables
lowLevelPortUser_ = nullptr;
comTimeout_ = comTimeout;
// Maximum allowed number of subsequent timeouts before the user is
// informed.
maxSubsequentTimeouts_ = 10;
// =========================================================================;
/*
We try to connect to the port via the port name provided by the constructor.
If this fails, the function is terminated via exit
*/
pasynOctetSyncIO->connect(ipPortConfigName, 0, &lowLevelPortUser_, NULL);
if (status != asynSuccess || lowLevelPortUser_ == nullptr) {
errlogPrintf("Controller \"%s\" => %s, line %d\nFATAL ERROR "
"(cannot connect to MCU controller).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__);
exit(-1);
}
// =========================================================================
// Create additional parameter library entries
@ -103,15 +88,15 @@ turboPmacController::turboPmacController(const char *portName,
const char *message_from_device =
"\006"; // Hex-code for ACK (acknowledge) -> Each message from the MCU
// is terminated by this value
status = pasynOctetSyncIO->setInputEos(
lowLevelPortUser_, message_from_device, strlen(message_from_device));
status = pasynOctetSyncIO->setInputEos(ipPortUser_, message_from_device,
strlen(message_from_device));
if (status != asynSuccess) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"Controller \"%s\" => %s, line %d\nFATAL ERROR "
"(setting input EOS failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(lowLevelPortUser_);
pasynOctetSyncIO->disconnect(ipPortUser_);
exit(-1);
}
@ -123,7 +108,7 @@ turboPmacController::turboPmacController(const char *portName,
"with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(lowLevelPortUser_);
pasynOctetSyncIO->disconnect(ipPortUser_);
exit(-1);
}
}
@ -254,8 +239,8 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
trying to reconnect. If the problem persists, ask them to call the support
*/
status = pasynOctetSyncIO->write(lowLevelPortUser_, fullCommand,
fullComandLength, comTimeout_, &nbytesOut);
status = pasynOctetSyncIO->write(ipPortUser_, fullCommand, fullComandLength,
comTimeout_, &nbytesOut);
msgPrintControlKey writeKey =
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
@ -279,7 +264,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
checkMaxSubsequentTimeouts(timeoutCounter, axis);
timeoutCounter += 1;
status = pasynOctetSyncIO->write(lowLevelPortUser_, fullCommand,
status = pasynOctetSyncIO->write(ipPortUser_, fullCommand,
fullComandLength, comTimeout_,
&nbytesOut);
if (status != asynTimeout) {
@ -300,12 +285,12 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
stringifyAsynStatus(status), msgPrintControl_.getSuffix());
}
} else {
msgPrintControl_.resetCount(writeKey);
msgPrintControl_.resetCount(writeKey, pasynUserSelf);
}
// Read the response from the MCU buffer
status = pasynOctetSyncIO->read(lowLevelPortUser_, response, MAXBUF_,
comTimeout_, &nbytesIn, &eomReason);
status = pasynOctetSyncIO->read(ipPortUser_, response, MAXBUF_, comTimeout_,
&nbytesIn, &eomReason);
msgPrintControlKey readKey =
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);
@ -330,9 +315,8 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
checkMaxSubsequentTimeouts(timeoutCounter, axis);
timeoutCounter += 1;
status =
pasynOctetSyncIO->read(lowLevelPortUser_, response, MAXBUF_,
comTimeout_, &nbytesIn, &eomReason);
status = pasynOctetSyncIO->read(ipPortUser_, response, MAXBUF_,
comTimeout_, &nbytesIn, &eomReason);
if (status != asynTimeout) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line "
@ -351,7 +335,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
stringifyAsynStatus(status), msgPrintControl_.getSuffix());
}
} else {
msgPrintControl_.resetCount(readKey);
msgPrintControl_.resetCount(readKey, pasynUserSelf);
}
if (timeoutStatus == asynError) {
@ -377,7 +361,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
eomReason, msgPrintControl_.getSuffix());
}
} else {
msgPrintControl_.resetCount(terminateKey);
msgPrintControl_.resetCount(terminateKey, pasynUserSelf);
}
/*
@ -412,7 +396,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
modResponse, command);
status = asynError;
} else {
msgPrintControl_.resetCount(numResponsesKey);
msgPrintControl_.resetCount(numResponsesKey, pasynUserSelf);
}
// Create custom error messages for different failure modes, if no error

View File

@ -73,9 +73,6 @@ class turboPmacController : public sinqController {
*/
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
protected:
asynUser *lowLevelPortUser_;
/**
* @brief Send a command to the hardware and receive a response
*
@ -118,12 +115,16 @@ class turboPmacController : public sinqController {
const char *functionName,
int lineNumber);
protected:
// Accessors for additional PVs
int rereadEncoderPosition() { return rereadEncoderPosition_; }
int readConfig() { return readConfig_; }
// Set the maximum buffer size. This is an empirical value which must be
// large enough to avoid overflows for all commands to the device /
// responses from it.
static const uint32_t MAXBUF_ = 200;
protected:
/*
Timeout for the communication process in seconds
*/
@ -136,8 +137,6 @@ class turboPmacController : public sinqController {
int rereadEncoderPosition_;
int readConfig_;
#define LAST_turboPmac_PARAM readConfig_
friend class turboPmacAxis;
};
#define NUM_turboPmac_DRIVER_PARAMS \
(&LAST_turboPmac_PARAM - &FIRST_turboPmac_PARAM + 1)