Link Search Menu Expand Document

RegEx and Tokens

Jan 1 2023 at 12:00 AM

After creation of a normal endpoint, select the endpoint to edit its' properties. Here, one will need to specify the gateway path. The gateway path will make use of tokens (as a unique placeholder) within a Regular Expression (RegEx). The tokens will be extracted and will be replaced with real values when rolling out and instance.

A RegEx is a sequence of characters that will define a search pattern, generally within a string. The RegEx structure can thus incorporate an amalgamation of message structures into one, thus affording the ability of templatization of multiple devices in one DT.

For example; if two different brands of Smart Batteries exist in the project, and the message structure for the data points coming from the devices differed, a RegEx could be used in a standard Smart Battery; DT on each generic endpoint in order to provide the ability to search the gateway before linking. Therefore, if the connected Smart Battery in question is a SHOTO battery, the RegEx will pick up the word SHOTO in the gateway, and link that form of the message structure to the endpoint.

Example of RegEx gateway path:

<gatewayID>.IOIO\|(SHOTO|NARADA):BATTERY<batteryNumber>\|(CELL05|NARADA).(VOLTAGE|CELL05VOLTAGE)
  • The items in the angular parenthesis/brackets, <, are tokens. These can be filled out within the template, such as the batteryNumber being set per battery in a template. Or, these values can be left blank to be specified during creation of an instance of a digital twin template, such as the unique Gateway ID, gatewayID, that will be different per site/group instance created.

  • The round parenthesis/brackets ("( )") is a method of grouping an operation.

  • The pipe symbol "|" is used as an "OR" function within the RegEx. If the need is for the gateway path to link to either "SHOTO" OR "NARADA", those two elements should be in brackets with a pipe between the characters in order to specify the choice between one or the other.

  • A period (".") is a place holder for any character.

  • A backslash ("\") in front of an operating character is a method of escaping that character in case that specific symbol is meant to be in the message structure. i.e.: A \| will indicate that the | is part of the message structure and should not function as an OR, but rather as a character in the string.

Once satisfied with the RegEx gateway path, the structure can be linked to that endpoint.

If the RegEx structure needs to change or be updated, one will need to unlink the existing gateway path, in order to insert the new structure and link.

Edit gateway path

Figure 1 - Edit gateway path

Continue reading