Added documenation for enableDisable flag
This commit is contained in:
@@ -15,7 +15,14 @@
|
|||||||
|
|
||||||
struct turboPmacAxisImpl {
|
struct turboPmacAxisImpl {
|
||||||
bool waitForHandshake;
|
bool waitForHandshake;
|
||||||
bool waitForEnable;
|
/*
|
||||||
|
This flag is set to true, if the controller is currently enabling /
|
||||||
|
disabling the motor and false otherwise. This flag is used in the doPoll
|
||||||
|
method to check if the enableRBV PV should be set or not in order to prevent
|
||||||
|
a premature change of state (controller reports that the motor is already
|
||||||
|
enabled / disabled while it is not ready yet to receive new commands).
|
||||||
|
*/
|
||||||
|
bool enableDisable;
|
||||||
time_t timeAtHandshake;
|
time_t timeAtHandshake;
|
||||||
// The axis status is used when enabling / disabling the motor
|
// The axis status is used when enabling / disabling the motor
|
||||||
int axisStatus;
|
int axisStatus;
|
||||||
@@ -65,7 +72,7 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
|
|||||||
|
|
||||||
pTurboPmacA_ = std::make_unique<turboPmacAxisImpl>(
|
pTurboPmacA_ = std::make_unique<turboPmacAxisImpl>(
|
||||||
(turboPmacAxisImpl){.waitForHandshake = false,
|
(turboPmacAxisImpl){.waitForHandshake = false,
|
||||||
.waitForEnable = false,
|
.enableDisable = false,
|
||||||
.timeAtHandshake = 0,
|
.timeAtHandshake = 0,
|
||||||
.axisStatus = 0,
|
.axisStatus = 0,
|
||||||
.needInit = false});
|
.needInit = false});
|
||||||
@@ -366,8 +373,9 @@ asynStatus turboPmacAxis::doPoll(bool *moving) {
|
|||||||
// Store the axis status
|
// Store the axis status
|
||||||
pTurboPmacA_->axisStatus = axStatus;
|
pTurboPmacA_->axisStatus = axStatus;
|
||||||
|
|
||||||
// Update the enablement PV
|
// Update the enablement PV, if we are not in the middle of a enabling /
|
||||||
if (!(pTurboPmacA_->waitForEnable)) {
|
// disabling procedure.
|
||||||
|
if (!(pTurboPmacA_->enableDisable)) {
|
||||||
setAxisParamChecked(this, motorEnableRBV,
|
setAxisParamChecked(this, motorEnableRBV,
|
||||||
(axStatus != -3 && axStatus != -5));
|
(axStatus != -3 && axStatus != -5));
|
||||||
}
|
}
|
||||||
@@ -1066,8 +1074,6 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
pTurboPmacA_->waitForEnable = true;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Continue regardless of the status returned by the poll; we just want to
|
Continue regardless of the status returned by the poll; we just want to
|
||||||
find out whether the motor is currently moving or not. If the poll
|
find out whether the motor is currently moving or not. If the poll
|
||||||
@@ -1095,7 +1101,7 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
|
|
||||||
setAxisParamChecked(this, motorMessageText,
|
setAxisParamChecked(this, motorMessageText,
|
||||||
"Axis cannot be disabled while it is moving.");
|
"Axis cannot be disabled while it is moving.");
|
||||||
pTurboPmacA_->waitForEnable = false;
|
pTurboPmacA_->enableDisable = false;
|
||||||
return asynError;
|
return asynError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1107,7 +1113,6 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
"Controller \"%s\", axis %d => %s, line %d\nAxis is already %s.\n",
|
"Controller \"%s\", axis %d => %s, line %d\nAxis is already %s.\n",
|
||||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||||
on ? "enabled" : "disabled");
|
on ? "enabled" : "disabled");
|
||||||
pTurboPmacA_->waitForEnable = false;
|
|
||||||
return asynSuccess;
|
return asynSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1115,11 +1120,13 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
if (on != 0) {
|
if (on != 0) {
|
||||||
status = rereadEncoder();
|
status = rereadEncoder();
|
||||||
if (status != asynSuccess) {
|
if (status != asynSuccess) {
|
||||||
pTurboPmacA_->waitForEnable = false;
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now the actual enabling / disabling starts
|
||||||
|
pTurboPmacA_->enableDisable = true;
|
||||||
|
|
||||||
// Enable / disable the axis
|
// Enable / disable the axis
|
||||||
snprintf(command, sizeof(command), "M%2.2d14=%d", axisNo_, on);
|
snprintf(command, sizeof(command), "M%2.2d14=%d", axisNo_, on);
|
||||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_FLOW,
|
asynPrint(pC_->pasynUser(), ASYN_TRACE_FLOW,
|
||||||
@@ -1144,7 +1151,8 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
// Read the axis status
|
// Read the axis status
|
||||||
status = pC_->writeRead(axisNo_, command, response, 1);
|
status = pC_->writeRead(axisNo_, command, response, 1);
|
||||||
if (status != asynSuccess) {
|
if (status != asynSuccess) {
|
||||||
pTurboPmacA_->waitForEnable = false;
|
// Enabling / disabling procedure failed
|
||||||
|
pTurboPmacA_->enableDisable = false;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
nvals = sscanf(response, "%d", &pTurboPmacA_->axisStatus);
|
nvals = sscanf(response, "%d", &pTurboPmacA_->axisStatus);
|
||||||
@@ -1159,7 +1167,8 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
bool moving = false;
|
bool moving = false;
|
||||||
forcedPoll(&moving);
|
forcedPoll(&moving);
|
||||||
|
|
||||||
pTurboPmacA_->waitForEnable = false;
|
// Enabling / disabling procedure is completed (successfully)
|
||||||
|
pTurboPmacA_->enableDisable = false;
|
||||||
return asynSuccess;
|
return asynSuccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1185,9 @@ asynStatus turboPmacAxis::enable(bool on) {
|
|||||||
snprintf(command, sizeof(command), "Failed to %s within %d seconds",
|
snprintf(command, sizeof(command), "Failed to %s within %d seconds",
|
||||||
on ? "enable" : "disable", timeout_enable_disable);
|
on ? "enable" : "disable", timeout_enable_disable);
|
||||||
setAxisParamChecked(this, motorMessageText, command);
|
setAxisParamChecked(this, motorMessageText, command);
|
||||||
pTurboPmacA_->waitForEnable = false;
|
|
||||||
|
// Enabling / disabling procedure failed
|
||||||
|
pTurboPmacA_->enableDisable = false;
|
||||||
return asynError;
|
return asynError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user