Improved homing doc, fixed wrong setting of motorStatusHomed and added check to move
This commit is contained in:
+32
-15
@@ -72,7 +72,7 @@ sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
||||
Initialize the parameter library entry for the motor message text, because
|
||||
it is read during the first poll before it has been written to.
|
||||
*/
|
||||
status = setStringParam(pC_->motorMessageText(), "");
|
||||
status = setStringParam(pC_->motorErrorMessage(), "");
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
|
||||
@@ -143,7 +143,7 @@ sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Set the homing-related flags
|
||||
// Motor is assumed to not being in a homing run at IOC startup.
|
||||
status = setIntegerParam(pC_->motorStatusHome(), 0);
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
@@ -154,7 +154,9 @@ sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
||||
pC_->stringifyAsynStatus(status));
|
||||
exit(-1);
|
||||
}
|
||||
status = setIntegerParam(pC_->motorStatusHomed(), 0);
|
||||
|
||||
// Motor is assumed to not be at the home position at IOC startup.
|
||||
status = setIntegerParam(pC_->motorStatusAtHome(), 0);
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
|
||||
@@ -164,7 +166,9 @@ sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
||||
pC_->stringifyAsynStatus(status));
|
||||
exit(-1);
|
||||
}
|
||||
status = setIntegerParam(pC_->motorStatusAtHome(), 0);
|
||||
|
||||
// Motor is assumed to not have been homed in the past.
|
||||
status = setIntegerParam(pC_->motorStatusHomed(), 0);
|
||||
if (status != asynSuccess) {
|
||||
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d:\nFATAL ERROR "
|
||||
@@ -232,14 +236,14 @@ asynStatus sinqAxis::forcedPoll(bool *moving) {
|
||||
pSinqA_->lastPollTime = ts;
|
||||
|
||||
/*
|
||||
If the "motorMessageText" record currently contains an error message, it
|
||||
If the "motorErrorMessage" record currently contains an error message, it
|
||||
should be shown for at least one poll period. To assure this, it is read out
|
||||
here from the paramLib into "waitingMessage". If no new error message was
|
||||
added to the parameter library at the end of the poll cycle, the
|
||||
"waitingMessage" is briefly put into the paramLib again, then the PVs are
|
||||
updated and then the message text is cleared again.
|
||||
*/
|
||||
getAxisParamChecked(this, motorMessageText,
|
||||
getAxisParamChecked(this, motorErrorMessage,
|
||||
static_cast<char *>(waitingMessage));
|
||||
|
||||
// Clear the communication
|
||||
@@ -271,16 +275,16 @@ asynStatus sinqAxis::forcedPoll(bool *moving) {
|
||||
If doPoll cleared the error message paramLib entry, but an old message
|
||||
is still waiting, set the old message.
|
||||
*/
|
||||
getAxisParamChecked(this, motorMessageText,
|
||||
getAxisParamChecked(this, motorErrorMessage,
|
||||
static_cast<char *>(newMessage));
|
||||
if (newMessage[0] == '\0') {
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
setAxisParamChecked(this, motorErrorMessage,
|
||||
static_cast<char *>(waitingMessage));
|
||||
}
|
||||
setAxisParamChecked(this, motorStatusProblem, true);
|
||||
} else {
|
||||
// No errors are waiting -> Clear everything.
|
||||
setAxisParamChecked(this, motorMessageText, "");
|
||||
setAxisParamChecked(this, motorErrorMessage, "");
|
||||
setAxisParamChecked(this, motorStatusProblem, false);
|
||||
}
|
||||
|
||||
@@ -330,7 +334,7 @@ asynStatus sinqAxis::forcedPoll(bool *moving) {
|
||||
Delete the error message AFTER updating the PVs so it is not there anymore
|
||||
during the next poll.
|
||||
*/
|
||||
setAxisParamChecked(this, motorMessageText, "");
|
||||
setAxisParamChecked(this, motorErrorMessage, "");
|
||||
|
||||
return poll_status;
|
||||
}
|
||||
@@ -348,9 +352,23 @@ asynStatus sinqAxis::move(double position, int relative, double minVelocity,
|
||||
// Status of parameter library operations
|
||||
asynStatus status = asynSuccess;
|
||||
double motorRecRes = 0.0;
|
||||
char encType[pC_->MAXBUF_] = {0};
|
||||
int motorStatHomed = 0;
|
||||
|
||||
// =========================================================================
|
||||
|
||||
/*
|
||||
Check if the motor is allowed to move: If the motor hasn't been homed in the
|
||||
past and has an incremental encoder, it needs to be homed first!
|
||||
*/
|
||||
getAxisParamChecked(this, encoderType, &encType);
|
||||
getAxisParamChecked(this, motorStatusHomed, &motorStatHomed);
|
||||
if (strcmp(encType, IncrementalEncoder) == 0 && motorStatHomed == 0) {
|
||||
setAxisParamChecked(this, motorErrorMessage,
|
||||
"Motor needs to be homed first.");
|
||||
return asynError;
|
||||
}
|
||||
|
||||
// Store the target position internally
|
||||
getAxisParamChecked(this, motorRecResolution, &motorRecRes);
|
||||
pSinqA_->targetPosition = position * motorRecRes;
|
||||
@@ -367,7 +385,6 @@ asynStatus sinqAxis::move(double position, int relative, double minVelocity,
|
||||
|
||||
// Since the move command was successfull, we assume that the motor has
|
||||
// started its movement.
|
||||
setAxisParamChecked(this, motorStatusHomed, false);
|
||||
setAxisParamChecked(this, motorStatusAtHome, false);
|
||||
|
||||
// Needed for adaptive polling
|
||||
@@ -410,7 +427,7 @@ asynStatus sinqAxis::home(double minVelocity, double maxVelocity,
|
||||
|
||||
} else if (status == asynError) {
|
||||
// asynError means that we tried to home an absolute encoder
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
setAxisParamChecked(this, motorErrorMessage,
|
||||
"Can't home a motor with absolute encoder");
|
||||
|
||||
status = assertConnected();
|
||||
@@ -547,7 +564,7 @@ asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
|
||||
"vmax=%lf.\n",
|
||||
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
|
||||
vbas, vmax);
|
||||
setAxisParamChecked(this, motorMessageText,
|
||||
setAxisParamChecked(this, motorErrorMessage,
|
||||
"Lower speed limit must not be smaller than "
|
||||
"upper speed limit. Please call the support.");
|
||||
return asynError;
|
||||
@@ -561,7 +578,7 @@ asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
|
||||
velo, vbas, vmax);
|
||||
|
||||
setAxisParamChecked(
|
||||
this, motorMessageText,
|
||||
this, motorErrorMessage,
|
||||
"Speed is not inside limits. Set a new valid speed and try "
|
||||
"to move the motor. Otherwise, please call the support.");
|
||||
return asynError;
|
||||
@@ -704,7 +721,7 @@ asynStatus sinqAxis::checkMovTimeoutWatchdog(bool moving) {
|
||||
}
|
||||
|
||||
setAxisParamChecked(
|
||||
this, motorMessageText,
|
||||
this, motorErrorMessage,
|
||||
"Exceeded expected arrival time. Check if the axis is blocked.");
|
||||
setAxisParamChecked(this, motorStatusProblem, true);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user