Skip to content

Commit

Permalink
Add regex to aggregate equation operators (#91)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
SkylineThomasCR authored Nov 20, 2024
1 parent 98880bd commit a1d5511
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Protocol/Legacy/ProtocolChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ public List<IValidationResult> CheckTrendAlarm(XmlDocument xDoc) // M
/// <param name="xmlNsm">The namespace.</param>
private void CheckActionAttributes(XmlDocument xDoc, List<IValidationResult> resultMsg, XmlNamespaceManager xmlNsm)
{
string[] operators = { "<", ">", "==", "<=", ">=", "!=", "&lt;", "&gt;", "&lt;=", "&gt;=" };
string[] operators = { "<", ">", "==", "<=", ">=", "!=", "&lt;", "&gt;", "&lt;=", "&gt;=", "regex" };

// Action.On => done in CheckResponsePairGroup
// Action.Type options: semicolon separated.
Expand Down Expand Up @@ -1957,6 +1957,16 @@ private void CheckActionAttributes(XmlDocument xDoc, List<IValidationResult> 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; }
Expand Down Expand Up @@ -2038,6 +2048,16 @@ private void CheckActionAttributes(XmlDocument xDoc, List<IValidationResult> 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
Expand Down

0 comments on commit a1d5511

Please sign in to comment.