Added forcedPoll method which skips the adaptive polling checks
The poll method does various tasks. One of them is skipping the poll if adaptive polling is enabled and certain conditions are fulfilled (see docs). However, sometimes it is needed to force a poll regardless. Therefore, a new method forcedPoll was added which is wrapped by poll now and does all tasks of the previous poll function except for the skip check.
This commit is contained in:
10
README.md
10
README.md
@@ -230,7 +230,15 @@ It calls `doReset` and performs some fast polls after `doReset` returns.
|
|||||||
- `doMove`: This is an empty function which should be overwritten by concrete driver implementations.
|
- `doMove`: This is an empty function which should be overwritten by concrete driver implementations.
|
||||||
- `home`: This function sets the internal status flags for the homing process and then calls doHome.
|
- `home`: This function sets the internal status flags for the homing process and then calls doHome.
|
||||||
- `doHome`: This is an empty function which should be overwritten by concrete driver implementations.
|
- `doHome`: This is an empty function which should be overwritten by concrete driver implementations.
|
||||||
- `poll`: This is a wrapper around `doPoll` which performs some bookkeeping tasks before and after calling `doPoll`:
|
- `poll`: This is a wrapper around `forcedPoll` which does the following checks before calling `forcedPoll`:
|
||||||
|
- Are there any outstanding fast polls (method `outstandingForcedFastPolls` of the controller returns a value greater zero)?
|
||||||
|
- Was the axis moving last time its status was polled?
|
||||||
|
- Is adaptive polling disabled?
|
||||||
|
- Did an idle period pass since the last poll?
|
||||||
|
If all of these conditions are false, no poll is performed. Otherwise, the `forcedPoll` method is called.
|
||||||
|
This method should not be called in the driver code itself if a poll is needed - use `forcedPoll` instead!
|
||||||
|
|
||||||
|
- `forcedPoll`: This is a wrapper around `doPoll` which performs some bookkeeping tasks before and after calling `doPoll`:
|
||||||
|
|
||||||
Before calling `doPoll`:
|
Before calling `doPoll`:
|
||||||
- Check if the paramLib already contains an old error message. If so, put it into a temporary bufffer
|
- Check if the paramLib already contains an old error message. If so, put it into a temporary bufffer
|
||||||
|
|||||||
@@ -171,14 +171,7 @@ sinqAxis::sinqAxis(class sinqController *pC, int axisNo)
|
|||||||
sinqAxis::~sinqAxis() = default;
|
sinqAxis::~sinqAxis() = default;
|
||||||
|
|
||||||
asynStatus sinqAxis::poll(bool *moving) {
|
asynStatus sinqAxis::poll(bool *moving) {
|
||||||
|
|
||||||
// Local variable declaration
|
|
||||||
asynStatus pl_status = asynSuccess;
|
|
||||||
asynStatus poll_status = asynSuccess;
|
|
||||||
int homing = 0;
|
|
||||||
int adaptivePolling = 0;
|
int adaptivePolling = 0;
|
||||||
char waitingMessage[pC_->MAXBUF_] = {0};
|
|
||||||
char newMessage[pC_->MAXBUF_] = {0};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If adaptive polling is enabled:
|
If adaptive polling is enabled:
|
||||||
@@ -201,9 +194,8 @@ asynStatus sinqAxis::poll(bool *moving) {
|
|||||||
Check if both adaptive polling is enabled and no forced fast polls are still
|
Check if both adaptive polling is enabled and no forced fast polls are still
|
||||||
required.
|
required.
|
||||||
*/
|
*/
|
||||||
if (adaptivePolling != 0 && pC_->outstandingForcedFastPolls() == 0) {
|
if (adaptivePolling != 0 && pC_->outstandingForcedFastPolls() == 0 &&
|
||||||
// Motor wasn't moving during the last poll
|
!pSinqA_->wasMoving) {
|
||||||
if (!pSinqA_->wasMoving) {
|
|
||||||
|
|
||||||
// Add the idle poll period
|
// Add the idle poll period
|
||||||
epicsTimeStamp earliestTimeNextPoll = pSinqA_->lastPollTime;
|
epicsTimeStamp earliestTimeNextPoll = pSinqA_->lastPollTime;
|
||||||
@@ -214,9 +206,21 @@ asynStatus sinqAxis::poll(bool *moving) {
|
|||||||
return asynSuccess;
|
return asynSuccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return forcedPoll(moving);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asynStatus sinqAxis::forcedPoll(bool *moving) {
|
||||||
|
|
||||||
|
// Local variable declaration
|
||||||
|
asynStatus pl_status = asynSuccess;
|
||||||
|
asynStatus poll_status = asynSuccess;
|
||||||
|
int homing = 0;
|
||||||
|
char waitingMessage[pC_->MAXBUF_] = {0};
|
||||||
|
char newMessage[pC_->MAXBUF_] = {0};
|
||||||
|
|
||||||
// Update the start time of the last poll
|
// Update the start time of the last poll
|
||||||
|
epicsTimeStamp ts;
|
||||||
|
epicsTimeGetCurrent(&ts);
|
||||||
pSinqA_->lastPollTime = ts;
|
pSinqA_->lastPollTime = ts;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -31,6 +31,27 @@ class epicsShareClass sinqAxis : public asynMotorAxis {
|
|||||||
*/
|
*/
|
||||||
~sinqAxis();
|
~sinqAxis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if a poll should be performed. If yes, call `forcedPoll`.
|
||||||
|
*
|
||||||
|
This is a wrapper around `forcedPoll` which does the following checks before
|
||||||
|
calling `forcedPoll`:
|
||||||
|
- Are there any outstanding fast polls (method `outstandingForcedFastPolls`
|
||||||
|
of the controller returns a value greater zero)?
|
||||||
|
- Was the axis moving last time its status was polled?
|
||||||
|
- Is adaptive polling disabled?
|
||||||
|
- Did an idle period pass since the last poll?
|
||||||
|
If all of these conditions are false, no poll is performed. Otherwise, the
|
||||||
|
`forcedPoll` method is called. This method should not be called in the
|
||||||
|
driver code itself if a poll is needed - use `forcedPoll` instead!
|
||||||
|
*
|
||||||
|
* @param moving Forwarded to `forcedPoll` or set to false
|
||||||
|
(depending on whether `forcedPoll was called`).
|
||||||
|
* @return asynStatus Forward the status of `forcedPoll` or set to
|
||||||
|
asynSuccess (depending on whether `forcedPoll was called`).
|
||||||
|
*/
|
||||||
|
virtual asynStatus poll(bool *moving);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform some standardized operations before and after the concrete
|
* @brief Perform some standardized operations before and after the concrete
|
||||||
`doPoll` implementation.
|
`doPoll` implementation.
|
||||||
@@ -46,7 +67,7 @@ class epicsShareClass sinqAxis : public asynMotorAxis {
|
|||||||
|
|
||||||
- The flags `motorStatusHome_`, `motorStatusHomed_` and
|
- The flags `motorStatusHome_`, `motorStatusHomed_` and
|
||||||
`motorStatusAtHome_` are set to their idle values (0, 1 and 1 respectively)
|
`motorStatusAtHome_` are set to their idle values (0, 1 and 1 respectively)
|
||||||
in the `poll()` method once the homing procedure is finished. See the
|
in the `forcedPoll()` method once the homing procedure is finished. See the
|
||||||
documentation of the `home()` method for more details.
|
documentation of the `home()` method for more details.
|
||||||
|
|
||||||
- Run `callParamCallbacks()`
|
- Run `callParamCallbacks()`
|
||||||
@@ -56,9 +77,9 @@ class epicsShareClass sinqAxis : public asynMotorAxis {
|
|||||||
* @param moving Forwarded to `doPoll`.
|
* @param moving Forwarded to `doPoll`.
|
||||||
* @return asynStatus Forward the status of `doPoll`, unless one of
|
* @return asynStatus Forward the status of `doPoll`, unless one of
|
||||||
the parameter library operation fails (in that case, returns the status of
|
the parameter library operation fails (in that case, returns the status of
|
||||||
the failed operation.
|
the failed operation).
|
||||||
*/
|
*/
|
||||||
virtual asynStatus poll(bool *moving);
|
virtual asynStatus forcedPoll(bool *moving);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implementation of the "proper", device-specific poll method. This
|
* @brief Implementation of the "proper", device-specific poll method. This
|
||||||
@@ -142,7 +163,7 @@ class epicsShareClass sinqAxis : public asynMotorAxis {
|
|||||||
*
|
*
|
||||||
* The flags `motorStatusHome_`, `motorStatusHomed_` and
|
* The flags `motorStatusHome_`, `motorStatusHomed_` and
|
||||||
`motorStatusAtHome_` are set to their idle values (0, 1 and 1 respectively)
|
`motorStatusAtHome_` are set to their idle values (0, 1 and 1 respectively)
|
||||||
in the `poll()` method once the homing procedure is finished.
|
in the `forcedPoll())` method once the homing procedure is finished.
|
||||||
*
|
*
|
||||||
* @param minVelocity Forwarded to `doHome`.
|
* @param minVelocity Forwarded to `doHome`.
|
||||||
* @param maxVelocity Forwarded to `doHome`.
|
* @param maxVelocity Forwarded to `doHome`.
|
||||||
|
|||||||
Reference in New Issue
Block a user