From a1d55114311d8a8853c3a6630b34176eed908c6e Mon Sep 17 00:00:00 2001 From: Thomas Cauwelier <101559931+SkylineThomasCR@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:09:26 +0100 Subject: [PATCH] Add regex to aggregate equation operators (#91) * Add regex to aggregate equation operators This operator was introduced in 10.1.8 by RN30199. See https://docs.dataminer.services/develop/devguide/Connector/Actions/ActionAggregate.html#equation * Support regex operation with empty pid * Removed result, but keep number validation. Only skip the validation if no valid regex attribute is found, otherwise give the same invalid syntax error. --- Protocol/Legacy/ProtocolChecks.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Protocol/Legacy/ProtocolChecks.cs b/Protocol/Legacy/ProtocolChecks.cs index 1341e59..3fbeee3 100644 --- a/Protocol/Legacy/ProtocolChecks.cs +++ b/Protocol/Legacy/ProtocolChecks.cs @@ -1745,7 +1745,7 @@ public List CheckTrendAlarm(XmlDocument xDoc) // M /// The namespace. private void CheckActionAttributes(XmlDocument xDoc, List resultMsg, XmlNamespaceManager xmlNsm) { - string[] operators = { "<", ">", "==", "<=", ">=", "!=", "<", ">", "<=", ">=" }; + string[] operators = { "<", ">", "==", "<=", ">=", "!=", "<", ">", "<=", ">=", "regex" }; // Action.On => done in CheckResponsePairGroup // Action.Type options: semicolon separated. @@ -1957,6 +1957,16 @@ private void CheckActionAttributes(XmlDocument xDoc, List res }); } + // pid is allowed to be empty when the regex attribute is used. + bool isRegexOperationWithAttributeValid = op == "regex" + && pid == String.Empty + && xnActionType.Attributes?.GetNamedItem("regex") != null; + + if (isRegexOperationWithAttributeValid) + { + continue; + } + if (Int32.TryParse(pid, out int id)) // Check if value is single number { if (ParameterIdSet.Contains(pid)) { continue; } @@ -2038,6 +2048,16 @@ private void CheckActionAttributes(XmlDocument xDoc, List res }); } + // pid is allowed to be empty when the regex attribute is used. + bool isRegexOperationWithAttributeValid = op == "regex" + && pid == String.Empty + && xnActionType.Attributes?.GetNamedItem("regex") != null; + + if (isRegexOperationWithAttributeValid) + { + continue; + } + if (!ParameterIdSet.Contains(pid)) { resultMsg.Add(new ValidationResult