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和 GUI Composer 2:JavaScript Getter 和 Setter 函数无法正常工作

Guru**** 2522770 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1033059/tms320f28335-ccsv9-3-0-and-gui-composer-2-javascript-getter-and-setter-functions-are-not-working-correctly

器件型号:TMS320F28335

您好!

 当我在调试器中更改变量时、文本框不会更新、反之亦然。

请 有人解释 getter 和设置函数如何与 GUI 和目标交互。

谢谢、

斯蒂芬

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;
          }
     );
}







  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Stephen:

    我需要跟进 GC 专家。 他们中有几人在星期二才离开,所以我可能无法在他们之前作出答复

    谢谢

    Ki  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    今天是假期、因此我明天将与专家跟进、并随时向您发送相关信息。

    谢谢

    Ki

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Stephen、

    从目标读取数据后、getter 会调用、然后再传递到小工具。 setter 也是如此、它是在将数据写入目标之前调用的。 这两个函数允许您在 widget 属性和 target 变量之间转换数据。

    如果您在代码中查看上面的行、第一个参数是 widget 属性(model.widget_id.property、widget 是模型)、第二个参数是 C/C++代码中的目标变量。 您对其进行了错误的布线、并且缺少 ti_widget_text_box_abc widget 的 Value 属性(应为 widget.ti_widget_textbox_abc.value)。 我假设您的目标变量是 abc。

    如果不需要转换数据,可以使用 Designer Properties (设计器属性)面板中的简单绑定方法。 单击链接图标并在 GUI 中输入您的目标变量。

    此致、
    Patrick