Device Emulators

Pathfinder Core PRO can emulate other routing systems. This can be particularly useful if you need to interface with an automation system that has not implemented any of the protocols that drive Axia routing systems.

Click the Device Emulators link in the navigation bar to display the list of device emulators currently defined in the system.

Reference

Notes

1

The name of the emulator.

2

The type of the emulator (Generic Emulator, Probel General Router, Probel General Switcher).

3

The connection type to be used with the emulator.

4

The Port used for the connection.

5

Click edit to modify the associated emulator’s properties.

6

Click the minus icon to remove the associated emulator.

7

Click the plus icon to add a new emulator. Pathfinder Core PRO currently supports three types of device emulation, each presenting slightly different configuration options depending on the emulator type.

Creating a Generic Emulator

  • Click the plus icon in the Device Emulators page to create a new emulator

  • Type a unique Name for this emulator and select Generic Emulator from the Emulator Type drop-down list

  • Complete the Connection Settings; the Generic Device Emulator is just a TCP/UDP connection that can be used to send and receive custom messages from an automation system or some other third-party system

Field

Description

Connection Type

From the drop-down list, select either TCP/UDP Listener or TCP/UDP Client, depending on whether:

  • The system using this emulator will establish the connection to Pathfinder Core PRO (an inbound connection—select TCP/UDP Listener) or,

  • Pathfinder Core PRO should initiate the connection to the other device (an outbound connection—select TCP/UDP Client.)

Port

If the other device is initiating the connection to Pathfinder Core PRO (Pathfinder Core PRO is the TCP/UDP Listener) type the port on which Pathfinder Core PRO will listen for the connection.

If Pathfinder Core PRO needs to initiate and maintain the connection (Pathfinder Core PRO is the TCP/UDP Client) type the IP address and port of the device to which Pathfinder Core PRO should connect.

Important Note: Pathfinder Core Pro does not currently support serial ports. If you need serial port control, investigate serial-to-TCP converter solutions, or use Pathfinder’s Port Router application to bridge the serial data to TCP data.

  • Type your initialization message in the Init Message field; this message will be sent when this Generic Emulator connects allowing the emulator to automatically send login or other initialization messages, including special escape characters (see the Escape Characters section later in this chapter) In the case of Listener types, this message will be sent to each client that connects to the listener. In the case of Client connection types, this message will be sent each time the client connects. Generic Device Emulators have a write-only property that can be used by Logic Flows called ToSend. This property allows you to create a flow to send any kind of data out of the Generic Emulator you wish.

  • Generic emulators also have a Ping Message field and Ping Interval field which are optional.

    • For situations where you are using a TCP client and you want to check to make sure the connection is still alive, sending a periodic ping can force the network to validate that. Leaving the PingMessage blank will mean this feature is not used.

    • When a remote device closes its TCP connection normally, there is a handshake that takes place that tells us the connection has been closed. The emulator will then try to start re-establishing the connection. However, if the remote device loses power or the connection dies in a way that does not allow the handshake to take place, then the DeviceEmulator will not know the connection is dead until either a failed operating system keepalive packet failure (which might take up to an hour or two) or until we attempt to send a message to the remote device.

    • The ping message and ping interval allow you to define a message that gets sent every so often to make sure the connection is still working. These messages should be something that makes sense to the application on the remote end.

    • It also allows us to test not only that the connection is still intact but that the application at the remote end is still responding. Note that it still may take longer than the interval time to detect a failure (often 15 to 60 seconds). Therefore, it does not make sense to set the interval too low.

  • Generic Device Emulator can trigger actions based on incoming data; to define these actions, we create Watchers. Each Watcher looks for information coming to the emulator port and when it sees that data, it briefly sets the Watcher’s Triggered property to True. To create a new Watcher, click the Add button and select the newly created Watcher from the list.

With the new Watcher selected, type a Name for this Watcher and the Value being watched for in the Name and Value fields directly below the Watcher list.

You can edit an existing Watcher by clicking on the Watcher entry in the list and updating the values in these Name and Value fields.

  • When all fields are complete, click Apply to save your changes and create the Emulator.

Escape Characters

Both the ToSend properties and the Watcher values support several special character strings to represent special characters:

Escape Sequence

Character

\cr

Carriage Return

\lf

Line Feed

\t

Tab

\

used to un-escape an escape

\%XX

Hex value where XX is a two-character hex value for the character to send or receive.

Therefore, a Watcher that is watching for "MyName\cr\lf" is looking for the string “MyName” followed by a carriage return and line feed.

In the case of double slashes, such as "MyName\\cr\\lf", the double slashes are converted to a single literal slash for the case where you actually want to send the value “\cr\lf.”

Using Watchers in Logic Flows

The Name of the Watcher is used to identify the Watcher in the system and will appear as an object underneath the Emulator in the Logic Flows property selection tree.

In the example above, we have created a single Watcher on this device emulator named Hello, and it is watching for the value Hello. When we see the word “Hello” come into this emulator, then the Watcher’s momentary Triggered property will be set to True and then reset to False until the next time the value “Hello” is registered.

We can create a Logic Flow where the Start Point is the Triggered property of the Watcher and do anything we like in the system when we see the string “Hello” come in through the Device Emulator port.

In this Logic Flow we have defined that every time we see the string “Hello” on the Watcher in question, we will activate the scene AllTo1.

Additional Emulator Properties for Logic Flows

Additional properties related to Generic Emulators that may be used in Flows include:

  • Connected – This property will be True if there are any clients connected or if the TCP client is successfully connected and False otherwise

  • ConnectedCount – This property will retain the number of currently connected clients to the emulator

  • ConnectionLost – This property will switch to True and then back to False when a client disconnects

  • ConnectionObtained – This property will switch to True and then back to False each time a client connects

  • TriggeredValue - When the Watcher input is discovered, that value will be assigned to the TriggeredValue property momentarily and then the value will be set back to blank. It is momentary in order to raise changes when the same value enters the emulator repeatedly

Watchers and Regular Expressions

Generic Device Emulator Watchers also support the use of regular expressions or Regexes. Pathfinder Code PRO uses the Microsoft .NET variation of regular expressions—an advanced language used for pattern matching in textual information.

Regular expressions parse the Watcher’s input relative to the regular expression pattern, tripping the Watcher’s Triggered property to True in case of a match. Pathfinder Code PRO Watchers make use of two flavors of regular expressions:

  1. Regex.Match(<expression_pattern>)

  2. Regex.IsMatch(<expression_pattern>)

To add a regular expression to a Watcher, type the RegEx statement in the Watcher Value field:

Regex.Match Method

Regex.Match evaluates Watcher input against the expression, with valid matches resulting in the Triggered property being set to True. However, because a Regex can be used to match multiple different chunks of text, it is often also useful to have the exact chunk of text that was matched available to a Logic Flow. That is where the TriggeredValue property comes in.

Typing a Value like this Regex.Match(..ll.)will match any series of five characters where the third and fourth characters are l.

Watcher inputs like Yello, Hello, Mello, hhlll, hhllh, will trip the Watcher’s Triggered property to True and allow the TriggeredValue property to pass the input value that resulted in the match.

As another example, to extract a duration from a satellite message such as "CBS050", we could use this regular expression in the Watcher’s Value field:

Regex.Match((?<=CBS).{3})

This Regex would set the Watcher’s Triggered property to True any time it sees six characters where the first three are CBS and allow the TriggeredValue property to pass only three characters that fall after the CBS. In this example, the TriggeredValue property would equal 050. This expression makes use of the look-behind assertion of regular expressions.

A different Watcher could then be created for a different show from the same Emulator.

Regex.Match((?<=NBC).{3})

Regex.IsMatch Method

Regex.IsMatch() performs a similar function except rather than passing the value of the match, the TriggeredValue will output True if a match exists. This makes this method largely redundant since a match will also set the Triggered property to True, but there are times when this method can be useful in Logic Flows as discussed below.

Special Characters

Carriage returns and line feeds must be considered when the incoming data is a line‑based protocol. Failing to properly account for these special characters when parsing incoming data will cause incorrect results.

If your Watcher input will include carriage returns and line feeds at the end of each message, you could use something like (.*\r\n) or ((?s).*). The latter uses single-line mode.

Escape Sequence

Character

\r

Carriage Return

\n

Line Feed (new line)

\t

Tab

\e

Escape

Modifying Default Behavior

There are several options that can be used within the expression to modify the function of the pattern matcher. For example, by default, the dot or period character ( . ) matches any character except the new line. If you want it to match the new line character as well, you can enable the single line option to modify the function of the wildcard within the pattern matcher:

Regex((?s).*).

The inline ?s modifies the regular expression engine to use the single line option when analyzing. These modifying options are documented here:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular- expression-options

Regular expressions are extremely advanced and can appear to be very complicated. One joke about regular expressions is that once you solve a problem with a regular expression you now have two problems. However, they can also be awesomely powerful for the situations where they are needed.

They are part of one of the most commonly used and advanced text pattern matching and manipulation languages across all programming languages used today. However, they will also be slower and more CPU intensive than the normal matches Pathfinder Core PRO performs because they have not been optimized at compile time in the same way as the native code. This is only one reason why they should be used with caution and sparingly. Use them only when you need them and not when Pathfinder Core PRO’s inherent pattern matching is a better option.

Also, test thoroughly. It is quite easy to design a regular expression that you think is correct but misses certain edge cases. The regex tester listed in the links below can be very useful in this case.

Again, this is an advanced feature and incorrect use can cause unpredictable results. But it is also a very powerful tool for certain situations.

Learn more about Regular expressions using these links:

Probel General Router and General Switcher

There are two Probel routing protocols supported by Pathfinder Core PRO: Probel General Router and Probel General Switcher. The syntax of these protocols is different so it is important to consult the automation system’s manual regarding which protocol to use.

In both cases, the protocol provides routing control. As a result, after selecting this protocol type, the web page will present a drop-down list with the available routers so that you can choose which router the Emulator will control.

  • Click the plus icon in the Device Emulators page to create a new emulator.

  • Type a unique Name for this emulator and select either Probel General Switcher or Probel General Router from the Emulator Type drop-down list.

  • Complete the Connection Settings.

Field

Description

Connection Type

From the drop-down list, select either TCP Listener or TCP Client, depending on whether:

  • The system using this emulator will establish the connection to Pathfinder Core PRO (an inbound connection—select TCP Listener) or,

  • Pathfinder Core PRO should initiate the connection to the other device (an outbound connection—select TCP Client.)

Port

If the other device is initiating the connection to Pathfinder Core PRO (Pathfinder Core PRO is the TCP Listener) type the port on which Pathfinder Core PRO will listen for the connection.

If Pathfinder Core PRO needs to initiate and maintain the connection (Pathfinder Core PRO is the TCP Client) type the IP address and port of the device to which Pathfinder Core PRO should connect.

  • Type Matrix and Level values, and select a Router from the drop-down list. When all fields are complete, click Apply to save your changes and create the Emulator.

Last updated