From b5a456fd15e2127a7ff72776ca9009e55e612580 Mon Sep 17 00:00:00 2001 From: Bob Long Date: Tue, 12 Nov 2024 15:51:02 +1100 Subject: [PATCH] CustomWarning: fix repeattime logic The RepeatTime setting was also the worst-case detection time --- ExtLibs/Utilities/Warnings/CustomWarning.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ExtLibs/Utilities/Warnings/CustomWarning.cs b/ExtLibs/Utilities/Warnings/CustomWarning.cs index 88d84e3d8c..00c25adcc0 100644 --- a/ExtLibs/Utilities/Warnings/CustomWarning.cs +++ b/ExtLibs/Utilities/Warnings/CustomWarning.cs @@ -183,40 +183,45 @@ public bool CheckValue(bool userepeattime = true) if (userepeattime && DateTime.Now < lastrepeat.AddSeconds(RepeatTime)) return false; - lastrepeat = DateTime.Now; + bool condition = false; switch (ConditionType) { case Conditional.EQ: if (GetValue == Warning) - return true; + condition = true; break; case Conditional.GT: if (GetValue > Warning) - return true; + condition = true; break; case Conditional.GTEQ: if (GetValue >= Warning) - return true; + condition = true; break; case Conditional.LT: if (GetValue < Warning) - return true; + condition = true; break; case Conditional.LTEQ: if (GetValue <= Warning) - return true; + condition = true; break; case Conditional.NEQ: if (GetValue != Warning) - return true; + condition = true; break; case Conditional.NONE: break; } - return false; + if (condition) + { + lastrepeat = DateTime.Now; + } + + return condition; }