From 76a91d4a2f7e2506149cee5bef383108ae05bfab Mon Sep 17 00:00:00 2001 From: smathis Date: Tue, 22 Apr 2025 11:43:47 +0200 Subject: [PATCH] Added message print control for movement timout watchdog --- src/sinqAxis.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/sinqAxis.cpp b/src/sinqAxis.cpp index bb9c045..b7b2be3 100644 --- a/src/sinqAxis.cpp +++ b/src/sinqAxis.cpp @@ -670,14 +670,22 @@ asynStatus sinqAxis::checkMovTimeoutWatchdog(bool moving) { return asynSuccess; } + // Create the unique callsite identifier manually so it can be used later in + // the shouldBePrinted calls. + msgPrintControlKey key = msgPrintControlKey(pC_->portName, axisNo_, + __PRETTY_FUNCTION__, __LINE__); + // Check if the expected time of arrival has been exceeded. if (expectedArrivalTime_ < time(NULL)) { // Check the watchdog - asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, - "Controller \"%s\", axis %d => %s, line %d:\nExceeded " - "expected arrival time %ld (current time is %ld).\n", - pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - expectedArrivalTime_, time(NULL)); + if (pC_->getMsgPrintControl().shouldBePrinted(key, true, + pC_->pasynUser())) { + asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, + "Controller \"%s\", axis %d => %s, line %d:\nExceeded " + "expected arrival time %ld (current time is %ld).\n", + pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, + expectedArrivalTime_, time(NULL)); + } pl_status = setStringParam( pC_->motorMessageText(), @@ -693,10 +701,11 @@ asynStatus sinqAxis::checkMovTimeoutWatchdog(bool moving) { pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", axisNo_, __PRETTY_FUNCTION__, __LINE__); } - - // Even if the movement timed out, the rest of the poll should continue. - return asynSuccess; + } else { + pC_->getMsgPrintControl().resetCount(key, pC_->pasynUser()); } + + // Even if the movement timed out, the rest of the poll should continue. return asynSuccess; } @@ -773,8 +782,7 @@ asynStatus setOffsetMovTimeout(const char *portName, int axisNo, sinqAxis *axis = dynamic_cast(asynAxis); if (axis == nullptr) { errlogPrintf("Controller \"%s\" => %s, line %d:\nAxis %d does not " - "exist or is not an " - "instance of sinqAxis.", + "exist or is not an instance of sinqAxis.", portName, __PRETTY_FUNCTION__, __LINE__, axisNo); }