This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28335: CCSv9.3.0 and GUI Composer 2: Javascript Getter and Setter functions are not working correctly

Guru 20075 points

Part Number: TMS320F28335

Hello,

The textbox doesn't get updated when I change the variable in the debugger and vice versa.

Could someone please explain how the getter and setting functions interact with the GUI and target.

Thanks,

Stephen

document.addEventListener('gc-databind-ready', function()
{
    /*
     * Add custom computed value databindings here, using the following method:
     *
     * function gc.databind.registry.bind(targetBinding, modelBinding, [getter], [setter]);
     *
     * param targetBinding - single binding string or expression, or array of binding strings for multi-way binding.
     * param modelBinding - single binding string or expression, or array of binding strings for multi-way binding.
     * param getter - (optional) - custom getter function for computing the targetBinding value(s) based on modelBinding value(s).
     * param setter - (optional) - custom setter function for computing the modelBinding value(s) based on targetBinding value(s).
     */

     // For example, a simple computed values based on simple expression
     // gc.databind.registry.bind('widget.id.propertyName', "targetVariable == 1 ? 'binding is one' : 'binding is not one'");

     // Or a custom two-way binding with custome getter and setter functions. (setter is optional) (getter only indicates one-way binding)
     // gc.databind.registry.bind('widget.id.propertyName', "targetVariable", function(value) { return value*5/9 + 32; }, function(value) { (return value-32)*9/5; });

     // Event 1 to n bindings

     gc.databind.registry.bind('abc',
          // dependant bindings needed in order to compute the date, in name/value pairs.
          "widget.ti_widget_textbox_abc",

          function(value)
          {
               // compute and return the string value to bind to the widget with id 'date'
               return value*2;
          },

          function(value)
          {
               // compute and return the string value to bind to the widget with id 'date'
               return value/2;
          }
     );
}







  • Hi Stephen,

    I'll need to follow up with the GC experts. Several of them are away until Tuesday so I may not be able to have a response until them

    Thanks

    ki 

  • Today is a holiday here so I will follow up with the experts tomorrow and keep you posted.

    Thanks

    ki

  • Hello Stephen,

    The getter is call after data is read from the target before it is pass to the widget. Same goes for setter, it is call before data is writter to the target. These two functions allow you to transform data between widget property and target variable.

    If you look at the line above in your code, the first parameter is the widget property (model.widget_id.property, widget is the model) and the second parameter is the target variable in your C/C++ code. You have it wired up incorrectly, and it is missing the value property for the ti_widget_text_box_abc widget (it should be widget.ti_widget_textbox_abc.value). I am assuming that your target variable is abc.

    If you don't need to transform your data, you can use the simple binding method in the Designer Properties panel. Click on the link icon and enter your target variables in the GUI.

    Regards,
    Patrick