Main movements implemented

Main movement of detector guide angle, angle offset and lift offset as
well as switch between working and changer position implemented.
This commit is contained in:
2025-03-20 16:27:28 +01:00
parent f256149eec
commit 566e3c950e
4 changed files with 75 additions and 41 deletions

View File

@ -127,8 +127,9 @@ asynStatus auxiliaryAxis::doPoll(bool *moving) {
pl_status = pC_->getIntegerParam(dTA_->axisNo_, pC_->motorStatusMoving(), pl_status = pC_->getIntegerParam(dTA_->axisNo_, pC_->motorStatusMoving(),
&isMoving); &isMoving);
if (pl_status != asynSuccess) { if (pl_status != asynSuccess) {
return pC_->paramLibAccessFailed(pl_status, "motorPosition_", axisNo_, return pC_->paramLibAccessFailed(pl_status, "motorStatusMoving_",
__PRETTY_FUNCTION__, __LINE__); dTA_->axisNo_, __PRETTY_FUNCTION__,
__LINE__);
} }
*moving = isMoving != 0; *moving = isMoving != 0;

View File

@ -50,10 +50,8 @@ class auxiliaryAxis : public turboPmacAxis {
asynStatus doPoll(bool *moving); asynStatus doPoll(bool *moving);
/** /**
* @brief Set the target value for the detector angle without starting a * @brief Set the target value for the detector angle and trigger a position
* movement * collection cycle
*
* TODO
* *
* @param position * @param position
* @param relative * @param relative

View File

@ -36,7 +36,7 @@ static void deferredMovementCollectorLoop(void *drvPvt) {
// Wait for 100 ms and then start the movement with the information // Wait for 100 ms and then start the movement with the information
// available // available
axis->startingDeferredMovement_ = true; axis->startingDeferredMovement_ = true;
epicsThreadSleep(0.1); epicsThreadSleep(axis->deferredMovementWait_);
axis->startCombinedMove(); axis->startCombinedMove();
// After the movement command has been send, reset the flag // After the movement command has been send, reset the flag
@ -81,6 +81,7 @@ detectorTowerAxis::detectorTowerAxis(detectorTowerController *pC, int axisNo,
targetPosition_ = 0.0; targetPosition_ = 0.0;
receivedTarget_ = false; receivedTarget_ = false;
startingDeferredMovement_ = false; startingDeferredMovement_ = false;
deferredMovementWait_ = 0.1; // seconds
liftOffsetAxis_ = liftOffsetAxis; liftOffsetAxis_ = liftOffsetAxis;
tiltOffsetAxis_ = tiltOffsetAxis; tiltOffsetAxis_ = tiltOffsetAxis;
liftOffsetAxis->dTA_ = this; liftOffsetAxis->dTA_ = this;
@ -297,28 +298,10 @@ asynStatus detectorTowerAxis::doPoll(bool *moving) {
// Axis ready // Axis ready
break; break;
case 2: case 2:
if (pC_->getMsgPrintControl().shouldBePrinted(keyPosState, true, // Axis is moving to or in changing position
pC_->asynUserSelf())) {
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
"Controller \"%s\", axis %d => %s, line %d\nAxis moving "
"to or in change "
"position.%s\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
pC_->getMsgPrintControl().getSuffix());
}
resetCountPosState = false;
break; break;
case 3: case 3:
if (pC_->getMsgPrintControl().shouldBePrinted(keyPosState, true, // Axis is moving to working state
pC_->asynUserSelf())) {
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_FLOW,
"Controller \"%s\", axis %d => %s, line %d\nAxis moving "
"to working position.%s\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
pC_->getMsgPrintControl().getSuffix());
}
resetCountPosState = false; resetCountPosState = false;
break; break;
default: default:
@ -857,9 +840,6 @@ asynStatus detectorTowerAxis::startCombinedMove() {
targetPosition_, liftOffsetAxis_->targetPosition_, targetPosition_, liftOffsetAxis_->targetPosition_,
tiltOffsetAxis_->targetPosition_); tiltOffsetAxis_->targetPosition_);
// DEBUG
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "%s\n", command);
// Lock the access to the controller since this function runs in another // Lock the access to the controller since this function runs in another
// thread than the poll method. // thread than the poll method.
pC_->lock(); pC_->lock();
@ -980,17 +960,13 @@ detectorTowerAxis::toggleWorkingChangerState(bool toChangingPosition) {
bool isAlreadyThere = (toChangingPosition == false && positionState == 1) || bool isAlreadyThere = (toChangingPosition == false && positionState == 1) ||
(toChangingPosition == true && positionState == 2); (toChangingPosition == true && positionState == 2);
if (pC_->getMsgPrintControl().shouldBePrinted( if (isAlreadyThere) {
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
isAlreadyThere, pC_->asynUserSelf())) {
asynPrint(pC_->asynUserSelf(), ASYN_TRACE_WARNING, asynPrint(pC_->asynUserSelf(), ASYN_TRACE_WARNING,
"Controller \"%s\", axis %d => %s, line %d\nAxis is already " "Controller \"%s\", axis %d => %s, line %d\nAxis is already "
"in %s position.%s\n", "in %s position.%s\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
toChangingPosition ? "changer" : "working", toChangingPosition ? "changer" : "working",
pC_->getMsgPrintControl().getSuffix()); pC_->getMsgPrintControl().getSuffix());
}
if (isAlreadyThere) {
return asynSuccess; return asynSuccess;
} }
@ -1155,11 +1131,66 @@ static void configDetectorTowerCreateAxisCallFunc(const iocshArgBuf *args) {
args[3].ival); args[3].ival);
} }
// This function is made known to EPICS in detectorTower.dbd and is called by // =============================================================================
// EPICS in order to register both functions in the IOC shell
/**
* @brief Set the setDeferredMovementWait (FFI implementation)
*
* @param portName Name of the controller
* @param axisNo Axis number
* @param scaleMovTimeout Scaling factor (in seconds)
* @return asynStatus
*/
asynStatus setDeferredMovementWait(const char *portName, int axisNo,
double deferredMovementWait) {
sinqController *pC;
pC = (sinqController *)findAsynPortDriver(portName);
if (pC == nullptr) {
errlogPrintf("Controller \"%s\" => %s, line %d:\nPort %s not found.",
portName, __PRETTY_FUNCTION__, __LINE__, portName);
return asynError;
}
asynMotorAxis *asynAxis = pC->getAxis(axisNo);
detectorTowerAxis *axis = dynamic_cast<detectorTowerAxis *>(asynAxis);
if (axis == nullptr) {
errlogPrintf("Controller \"%s\" => %s, line %d:\nAxis %d does not "
"exist or is not an instance of detectorTowerAxis.",
portName, __PRETTY_FUNCTION__, __LINE__, axisNo);
return asynError;
}
axis->deferredMovementWait_ = deferredMovementWait;
return asynSuccess;
}
static const iocshArg setDeferredMovementWaitArg0 = {"Controller port name",
iocshArgString};
static const iocshArg setDeferredMovementWaitArg1 = {"Axis number",
iocshArgInt};
static const iocshArg setDeferredMovementWaitArg2 = {
"Minimum time a deferred movement will be delayed in order to collect "
"commands in seconds",
iocshArgDouble};
static const iocshArg *const setDeferredMovementWaitArgs[] = {
&setDeferredMovementWaitArg0, &setDeferredMovementWaitArg1,
&setDeferredMovementWaitArg2};
static const iocshFuncDef setDeferredMovementWaitDef = {
"setDeferredMovementWait", 3, setDeferredMovementWaitArgs};
static void setDeferredMovementWaitCallFunc(const iocshArgBuf *args) {
setDeferredMovementWait(args[0].sval, args[1].ival, args[2].dval);
}
// =============================================================================
// This function is made known to EPICS in detectorTower.dbd and is
// called by EPICS in order to register both functions in the IOC shell
static void detectorTowerAxisRegister(void) { static void detectorTowerAxisRegister(void) {
iocshRegister(&configDetectorTowerCreateAxis, iocshRegister(&configDetectorTowerCreateAxis,
configDetectorTowerCreateAxisCallFunc); configDetectorTowerCreateAxisCallFunc);
iocshRegister(&setDeferredMovementWaitDef, setDeferredMovementWaitCallFunc);
} }
epicsExportRegistrar(detectorTowerAxisRegister); epicsExportRegistrar(detectorTowerAxisRegister);

View File

@ -60,10 +60,8 @@ class detectorTowerAxis : public turboPmacAxis {
asynStatus doPoll(bool *moving); asynStatus doPoll(bool *moving);
/** /**
* @brief Set the target value for the detector angle without starting a * @brief Set the target value for the detector angle and trigger a position
* movement * collection cycle
*
* TODO
* *
* @param position * @param position
* @param relative * @param relative
@ -115,6 +113,12 @@ class detectorTowerAxis : public turboPmacAxis {
// axes) // axes)
bool startingDeferredMovement_; bool startingDeferredMovement_;
/*
The collector cycle waits until this time in seconds has passed before
starting a deferred movement
*/
double deferredMovementWait_;
protected: protected:
detectorTowerController *pC_; detectorTowerController *pC_;
double targetPosition_; double targetPosition_;