Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Data Formatting and Transformation

From Texas Instruments Wiki
Jump to: navigation, search

Processing Data going to widget (incoming) and leaving the widget (outgoing)

Pre processing functions may be used to transform data that is going to be displayed in the widget or leaving the widget before it is sent to the target. The most common use of pre processing functions is to control the format of displayed data. These functions need to be created in JavaScript and can be added to app.js file as it is automatically loaded by GUI Composer application. A good resource for syntax and available functions in javascript is at www.w3schools.com/js/default.asp


PrePostDiagram.png



1. Create an application, add a widget and specify a variable in its value binding. Then click on "..." button beside a binding that you specified. This opens a new dialog allowing you to format the value of a variable before it is displayed in the widget. It also contains edit boxes to specify javascript functions that will be called. PreProcessingFunction will be called when data is sent from the target to the widget allowing you to control how data is displayed. PostProcessing function will be called in reverse direction, when a user modifies widgets value and it is being sent to the target. 

2. The easiest way to enter the logic of pre/post processing functions is to click on Edit button in the dialog where pre/post processing function name is specified. GUI Composer designer will then open app.js file and create a prototype function where you need to fill in the processing logic. 

E.g. data formatting
function ToQ24_RoundTo2Decimals(oldValue) {
   var toQ24 = oldValue/(Math.pow(2,24));
   var result = new Number(Math.round(toQ24 * 100)/100);
   var s = result.toString();
   return (s)
};


function FromQ24(oldValue) {
   var result = Math.round(oldValue*(Math.pow(2,24)));
   return ( result )
};



This modem_m3_gc_app.zip contains a sample application that is based on example that is part of GUI Composer Runtime which includes an example of preprocessing functions.