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.

CCS: GUI Composer: Button to send parameter all at once

Tool/software: Code Composer Studio

On my Gui Composer application are several Tabs with several numberboxes. These boxes contain parameter for the target application. Every time i need to restart the target, all these parameters are not send automatical to the target. I need to change the values to trigger a send to target. Is there a way to send the values of all numberboxes at once to the target? Maybe triggered by a button or by a command from the target. I use a serial link with the JSON protocol for target connection.

Thanks

  • Erik,

    I have contacted an expert about this. We will get back to you as soon as we have more information.
    Thanks for your patience.

  • Hi Erik,

    You can add a button to your design and than add a click listener in javascript. In the click listener handler, get the values from the widgets and the target variable bindings. Then set the values from the widget to the target variable bindings with the force write flag.

    Create a new javascript file using the menu in the Designer and uncomment the the sample "init" code at the end of the file. Add this sample code in the this.async callback function.

    templateObj.$.ti_widget_button.addEventListener('click', () => {
        const value = templateObj.$.ti_widget_textbox.value;
        const blink = gc.databind.registry.getBinding('ti_model_streaming.blink');
        blink.setValue(value, null /* progressMonitor */, true /* force write */);
    });

    Regards,
    Patrick

  • Hi Patrick,

    thanks for that quick reply. I implemented these according your instructions.And it works perfekt.

    Thanks

    Regards

    Erik

  • Hi Patrik,

    i discovered, that for a single Value it works, but with multiple values, only the first will be send.

    Here is my implementation:

    var initComplete = false;
    var templateObj;

    // Wait for DOMContentLoaded event before trying to access the application template
    var init = function() {
        templateObj = document.querySelector('#template_obj');

        // Wait for the template to fire a dom-change event to indicate that it has been 'stamped'
        // before trying to access components in the application.
        templateObj.addEventListener('dom-change',function(){
            if (initComplete) return;
            this.async(function(){
                initComplete = true;
                console.log("Application template has been stamped.");
                  // Now that the template has been stamped, you can use 'automatic node finding' $ syntax to access widgets.
                  // e.g. to access a widget with an id of 'widget_id' you can use templateObj.$.widgetId
                  
                  templateObj.$.ti_widget_button.addEventListener('click', () => {
                      update_element("ti_widget_numberbox_heater_base","a");
                      update_element("ti_widget_numberbox_heater_anode_reduction","b");
                    update_element("ti_widget_numberbox_heater_keeper_reduction","c");
                    update_element("ti_widget_numberbox3","d");//Keeper
                    update_element("ti_widget_numberbox4","e");//Keeper
                    update_element("ti_widget_numberbox5","f");//Keeper
                    update_element("ti_widget_numberbox6","g");//Anode Set current
                });

            },1);

        });
    };

    templateObj = document.querySelector('#template_obj');
    if (templateObj) {
        init();
    } else {
        document.addEventListener('DOMContentLoaded',init.bind(this))
    }

    function update_element(sID,binding){
        var obj = document.getElementById(sID);
        const value = obj.value;
        //const value = templateObj.$.ti_widget_numberbox_heater_base.value;
        const a = gc.databind.registry.getBinding('ti_model_streaming.' + binding);
        a.setValue(value, null /* progressMonitor */, true /* force write */);
    }

  • It is strange, can you try flipping the heater_base and heater_anode_reduction around and see if both will get set?

    In the debugger, call the a.getValue() and compare the current value before calling a.setValue(), is the current value different than what you are trying to set?

  • When i flip the calls, there is no difference, only the first will be transmitted.

    I add a console log as shown:

    function update_element(sID,binding){
        var obj = document.getElementById(sID);
        const value = obj.value;
    
        const a = gc.databind.registry.getBinding('ti_model_streaming.' + binding);
        console.log(value + " - " + a.getValue()  + " - " +  binding);
        a.setValue(value, null /* progressMonitor */, true /* force write */);
    }

    I get the log and also it works somehow for more items. The log:

    First time:

    0.8 - undefined - b
    2 - undefined - a
    0.8 - undefined - c
    0 - undefined - d
    0 - undefined - e
    0 - undefined - f
    0 - undefined - g

    subsequent:

    0.8 - 0.8 - b
    2 - 2 - a
    0.8 - 0.8 - c
    0 - 0 - d
    0 - 0 - e
    0 - 0 - f
    0 - 0 - g

    With the log activated, more items will be send, sometimes all. But not reliable. For me it looks like the changes will not be queued. So the transport layer is bussy with the first item, and drop the following.

    Regards

    Erik

  • Hello Erik,

    I have created a demo and published to the Gallery here https://dev.ti.com/gallery/view/4199/Demo_SendValuesWithButton/ver/1.0.0/.

    This demo is using a MSP432 with xds program model. See the javascript file in the app for the set value implementation. It has two implementations, one is serialized and the other is not. The firmware binary (.out) is also included in the app.

    In your app, try converting the widget's value to a number and see if it works for you. i.e a.setValue(+value, null, true);

    Regards,
    Patrick

  • Hi Patrick,

    thanks for your support. Finally it works. I implemented the serialized version. Also an other issue caused a problem:

    The log from the TI agent:

    press the button:

    {\"ti_model_program\":{\"b\":0.8}}\n"]}
    {\"ti_model_program\":{\"a\":2}}\n"]}
    {\"ti_model_program\":{\"c\":0.8}}\n"]}

    change a single value:

    {\"a\":2.1}\n"]}

    The string "ti_model_program" caused buffer overflow on my target ans was also not expected by the target.

    i changed

    const binding = gc.databind.registry.getBinding('ti_model_program.'+ bindingId);

    to

    const binding = gc.databind.registry.getBinding(bindingId);

    The issue is closed. Great support, thanks

    Regards,

    Erik