Added function to set the number of forced fast polls.

This commit is contained in:
2025-05-09 08:14:05 +02:00
parent b89fe41c6e
commit dbcfebc6de
3 changed files with 82 additions and 8 deletions

View File

@@ -645,6 +645,8 @@ extern "C" {
* @brief Set the threshold for the communication timeout frequency (FFI
* implementation)
*
* @param portName Name of the low-level asyn port the controller is
* using.
* @param comTimeoutWindow Size of the time window used to calculate
* the moving average of timeout events in seconds. Set this value to 0 to
* deactivate the watchdog.
@@ -688,11 +690,10 @@ static void setThresholdComTimeoutCallFunc(const iocshArgBuf *args) {
/**
* @brief Set the maximum number of subsequent timeouts (FFI implementation)
*
* @param comTimeoutWindow Size of the time window used to calculate
* the moving average of timeout events. Set this value to 0 to deactivate
* the watchdog.
* @param maxNumberTimeouts Maximum number of timeouts which may occur
* within the time window before the watchdog is triggered.
* @param portName Name of the low-level asyn port the controller is
* using.
* @param maxSubsequentTimeouts Maximum number of timeouts which may occur
* subsequently before an error is reported.
* @return asynStatus
*/
asynStatus setMaxSubsequentTimeouts(const char *portName,
@@ -746,12 +747,73 @@ static void setMaxSubsequentTimeoutsCallFunc(const iocshArgBuf *args) {
// =============================================================================
/**
* @brief Set the number of forced fast polls which happen after a call to
* `wakePoller`.
*
* @param portName Name of the low-level asyn port the controller is
* using.
* @param forcedFastPolls Number of fast polls done after calling
* `wakePoller`.
* @return asynStatus
*/
asynStatus setForcedFastPolls(const char *portName, int forcedFastPolls) {
void *ptr = findAsynPortDriver(portName);
if (ptr == nullptr) {
/*
We can't use asynPrint here since this macro would require us
to get a pasynOctetSyncIOipPort_ from a pointer to an asynPortDriver.
However, the given pointer is a nullptr and therefore doesn't
have a pasynOctetSyncIOipPort_! printf is an EPICS alternative which
works w/o that, but doesn't offer the comfort provided
by the asynTrace-facility
*/
errlogPrintf("Controller \"%s\" => %s, line %d:\nPort %s not found.",
portName, __PRETTY_FUNCTION__, __LINE__, portName);
return asynError;
}
// Unsafe cast of the pointer to an asynPortDriver
asynPortDriver *apd = (asynPortDriver *)(ptr);
// Safe downcast
sinqController *pC = dynamic_cast<sinqController *>(apd);
if (pC == nullptr) {
errlogPrintf(
"Controller \"%s\" => %s, line %d:\ncontroller on port %s is not a "
"turboPmacController.",
portName, __PRETTY_FUNCTION__, __LINE__, portName);
return asynError;
}
// Set the new value
pC->setForcedFastPolls(forcedFastPolls);
return asynSuccess;
}
static const iocshArg SetForcedFastPollsArg0 = {"Controller name (e.g. mcu1)",
iocshArgString};
static const iocshArg SetForcedFastPollsArg1 = {
"Number of fast polls after \"waking\" the poller (e.g. after issueing a "
"move command).",
iocshArgInt};
static const iocshArg *const SetForcedFastPollsArgs[] = {
&SetForcedFastPollsArg0, &SetForcedFastPollsArg1};
static const iocshFuncDef setForcedFastPollsDef = {"setForcedFastPolls", 2,
SetForcedFastPollsArgs};
static void setForcedFastPollsCallFunc(const iocshArgBuf *args) {
setForcedFastPolls(args[0].sval, args[1].ival);
}
// =============================================================================
// This function is made known to EPICS in sinqMotor.dbd and is called by EPICS
// in order to register all functions in the IOC shell
static void sinqControllerRegister(void) {
iocshRegister(&setThresholdComTimeoutDef, setThresholdComTimeoutCallFunc);
iocshRegister(&setMaxSubsequentTimeoutsDef,
setMaxSubsequentTimeoutsCallFunc);
iocshRegister(&setForcedFastPollsDef, setForcedFastPollsCallFunc);
}
epicsExportRegistrar(sinqControllerRegister);