CommandFusion Wiki

Documentation Resources

User Tools

Site Tools


Sidebar

software:gui-designer:system-manager:feedback-parsing:feedback-parsing

Feedback Parsing

CommandFusion Viewer Solutions are capable of full 2 way communications with External Systems. This means that they can both send commands and receive feedback.
Parsing feedback involves grabbing the data received from the system, and turning it into usable data for GUI objects, such as button states, gauge levels, dynamic image paths and text.

How Feedback Parsing Works

The main idea behind parsing feedback is that you capture elements of the feedback data, and assign it to a join (be it digital, analog or serial) which can then be used by GUI Objects on the same join.
For instance, a button in your GUI might be on digital join 10. Then you might assign an element of the feedback data to digital join 10, and whenever that data is received from the system (such as power state for example), the button on join 10 would react and change state depending on the captured data value. If you have multiple buttons on the same join 10, all buttons would react to the captured data, allowing you to show feedback data on multiple pages if necessary.

Regular Expressions

The method used to capture elements of feedback data is called 'Regular Expressions' (or more commonly known as regex). Regex is used in almost all programming languages, and is a VERY powerful way of matching data and capturing elements of data from a string.
A great resource for learning to use regex is http://www.regular-expressions.info. This website has many examples and covers regex syntax as used in a variety of programming languages. The flavor of regex used in your GUI project depends on the Viewer being used.
iViewer for example is an iPhone OS application, and uses the RegexKitLite Library. Most regex flavors are VERY similar, and only have tiny differences in syntax that you will not come across in your day to day regex usage with guiDesigner.
For a listing of the regex syntax used in iViewer, please see the ICU Syntax section of the RegexKitLite home page.
For a good tutorial on regular expressions see this page http://tech.pro/tutorial/1214/javascript-regular-expression-enlightenment Note that this is targeted towards regular expression use in JavaScript, but the same basic principals apply here.

Capture Groups

CommandFusion Viewers use regex capture groups to manipulate feedback data into useable GUI object data. Within a particular regex, capture groups are defined by the parts in round brackets.
The easiest way to show how capture groups work is to give an example:

Lets say a Plasma TV sends the following string out when is it powered on:

a 01 OK01x

The same TV also sends the following string out when is it powered off:

a 01 OK00x 

The only part of these messages we are interested in are the last two digits just before the final x, so an example of a regex used to capture this data (and use to assign to a digital join for example) would be:

a \d{1,2} OK(\d{1,2})x

Note the use of brackets around the data we want to capture. \d{1,2} simply means “1 or 2 decimal characters, 0-9”. This was used incase the TV sometimes sent a single 0 or 1 (without the leading 0).
Another way of writing the regex to get the same result would be:

a\s\d\d\sOK(\d\d)x

\s simply means “space character”. If you wanted to ensure that the matched feedback was part of a single message sent from the system, you can use the ^ (caret) and the $ (dollar sign) characters to specify that the regex must match the start and end of the feedback string.

^a \d{1,2} OK(\d{1,2})x$

Doing this ensures the feedback string is not part of a larger message sent from the system.

You can also use multiple capture groups in a single regex. Each capture group can then be assigned to a join type and number.

Regex Examples

More examples can be found on our Regex Examples page. Feel free to add your own examples to that page.

Regex Tester

guiDesigner has a built in Regular Expression Testing Tool (Regex Tester) that allows you to test your regular expressions against test data (messages you expect your system to send).
To open the Regex Tester (if its not already visible in the guiDesigner window) simply press the 'Show/Hide Regex Tester' toolbar button in the main window toolbar. The Regex Tester is a dockable window you can place anywhere within the guiDesigner window for convenience.

Assigning Captured Data to Joins

Once you have your regex working nicely against your system feedback test data, you need to assign the captured data to a join number so that it can be displayed on the interface of the Viewer.
Please see the System Manager page for details on how to accomplish this.

software/gui-designer/system-manager/feedback-parsing/feedback-parsing.txt · Last modified: 2013/05/20 00:35 by aaron