Added connection assertion and moved msgPrintControl to key

This commit is contained in:
2025-04-25 15:54:41 +02:00
parent c7936191d9
commit dd0610fd99
5 changed files with 72 additions and 21 deletions
+42 -1
View File
@@ -296,6 +296,11 @@ asynStatus sinqAxis::move(double position, int relative, double minVelocity,
return status;
}
status = assertConnected();
if (status != asynSuccess) {
return status;
}
// Since the move command was successfull, we assume that the motor has
// started its movement.
status = setIntegerParam(pC_->motorStatusHomed(), 0);
@@ -363,6 +368,11 @@ asynStatus sinqAxis::home(double minVelocity, double maxVelocity,
__LINE__);
}
status = assertConnected();
if (status != asynSuccess) {
return status;
}
// Update the motor record
return callParamCallbacks();
@@ -376,11 +386,16 @@ asynStatus sinqAxis::home(double minVelocity, double maxVelocity,
__LINE__);
}
status = assertConnected();
if (status != asynSuccess) {
return status;
}
// Update the motor record
return callParamCallbacks();
} else {
// Bubble up all other problems
return status;
return assertConnected();
}
}
@@ -391,6 +406,7 @@ asynStatus sinqAxis::doHome(double minVelocity, double maxVelocity,
asynStatus sinqAxis::reset() {
asynStatus status = doReset();
if (status == asynSuccess) {
// Perform some fast polls
pC_->lock();
@@ -403,6 +419,12 @@ asynStatus sinqAxis::reset() {
}
pC_->unlock();
}
asynStatus pl_status = assertConnected();
if (pl_status != asynSuccess) {
return pl_status;
}
return status;
}
@@ -456,6 +478,25 @@ asynStatus sinqAxis::setMotorPosition(double motorPosition) {
return status;
}
asynStatus sinqAxis::assertConnected() {
asynStatus status = asynSuccess;
int connected = 0;
status = pC_->getIntegerParam(axisNo(), pC_->motorConnected(), &connected);
if (status != asynSuccess) {
return pC_->paramLibAccessFailed(status, "motorConnected", axisNo(),
__PRETTY_FUNCTION__, __LINE__);
}
if (connected == 0) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line "
"%d:\nAxis is not connected, all commands are ignored.\n",
pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__);
}
return asynSuccess;
}
asynStatus sinqAxis::setVeloFields(double velo, double vbas, double vmax) {
asynStatus status = asynSuccess;
int variableSpeed = 0;