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

View File

@@ -1,6 +1,8 @@
#ifndef msgPrintControl_H
#define msgPrintControl_H
#define DefaultMaxRepetitions 4
#include <asynDriver.h>
#include <string.h>
#include <string>
@@ -21,8 +23,15 @@ class msgPrintControlKey {
const char *functionName_;
int line_;
/**
* @brief Maximum number of times a message is printed before it is
* suppressed. This number is not used as part of the hash.
*
*/
size_t maxRepetitions_;
msgPrintControlKey(char *controller_, int axisNo, const char *fileName,
int line);
int line, size_t maxRepetitions = DefaultMaxRepetitions);
bool operator==(const msgPrintControlKey &other) const {
return axisNo_ == other.axisNo_ && line_ == other.line_ &&
@@ -73,8 +82,6 @@ template <> struct hash<msgPrintControlKey> {
*/
class msgPrintControl {
public:
msgPrintControl(size_t maxRepetitions);
/**
* @brief Checks if the error message associated with "key" has been printed
* more than `this->maxRepetitions_` times in a row. If yes, returns false,
@@ -115,7 +122,8 @@ class msgPrintControl {
* @param pasynUser
*/
bool shouldBePrinted(char *controller, int axisNo, const char *functionName,
int line, bool wantToPrint, asynUser *pasynUser);
int line, bool wantToPrint, asynUser *pasynUser,
size_t maxRepetitions = DefaultMaxRepetitions);
/**
* @brief Reset the error message count incremented in `shouldBePrinted` for
@@ -129,13 +137,6 @@ class msgPrintControl {
*/
void resetCount(msgPrintControlKey &key, asynUser *pasynUser);
/**
* @brief Maximum number of times a message is printed before it is
* suppressed.
*
*/
size_t maxRepetitions_;
char *getSuffix();
private: