Skip to main content
Version: 6.11

Signal Replace Module

The Signal Replace module allows pre-processing of signals before they are interpreted by Patriot. Using Regular Expressions, matching signals can be modified to replace or remove sections. This is useful for removing extra data, changing client ID formats, or any other case where the signal format is not quite right.

The Signal Replace module is required to use these features.

Setup

Signal Replacements can be added from the task settings page, in System > Tasks > Task Settings.

Signal Replace Task Settings
Signal Replace Task Settings

Signal Replace has the following fields

Pattern: The Regular Expression pattern that is used to find matching signals. The Quick Reference contains information about the available special pattern characters available.

Replacement: When a match is found, it is replaced with the Replacement value. Substitutions are available, that will fill in sections from the matched signal.

A task can support multiple Signal Replacements. When a signal is received, each pattern is tested in order to see if it is a match. If multiple patterns match a single signal, only the first pattern replacement is applied. The pattern order can be changed using the Up and Down arrows to make sure that the correct pattern is applied.

Examples

Pattern:

1234

In this simple example, we look for the text 1234 with spaces around it.

Replacement:

4321

Wherever we see ' 1234 ', we will replace it with ' 4321 '.

info

This example is extremely simple, and is likely to cause problems replacing unexpected data in signals. Generally, it is better to use the most specific pattern possible, such as the below example, to make sure that only the exact signals you are expecting are modified.

Pattern

(?<header>^.\w{2} )(?<clientId>2520)(?<footer> 18 [13ERP]\d{3} \w{2} .[0-9A-F]{3} ?.$)

In this example, we look for a Contact ID signal from client 2520, and replace the client ID so that the signal is instead logged to client 2222.

(?<header>^.\\w{2} )

Starting at the beginning of the signal (^), look for any character (.) followed by two word characters (\\w{2}) then a space. Save this part of the signal using the name header.

(?<clientId>2520)

Look for the exact characters '2520'. Save this part of the signal using the name clientId.

(?<footer> 18 \[13ERP\]\\d{3} \\w{2} .\[0-9A-F\]{3} ?.$)

Look for the exact characters ' 18 ', then any one of the characters 1, 3, E, R, or P (\[13ERP\]). After that, look for 3 numbers (\\d{3}), a space, then two word letters (\\w{2}). Another space, then any character. Next, looks for any 3 hexadecimal numbers (\[0-9A-F\]{3}), an optional space, and then finally any character. Finally we check that this is the end of the signal with ($). We save this entire part of the signal using the name footer.

Replacement

${header}2222${footer}

When we find a match, we replace the match (in this case, the entire signal) with the following:

${header}

The data from the signal that was saved in the header section

2222

The literal characters '2222'

${footer}

The data from the signal that was saved in the footer section.

Example Signal

<0A>11 2520 18 E401 01 U003 <0D>

header gets set to <0A>11

clientId gets set to 2520

footer gets set to 18 E401 01 U003 <0D>

After the replacement is applied, the signal becomes:

<0A>11 2222 18 E401 01 U003 <0D>

note

<0A> and <0D> represent special characters.