Multiple use of same binding

Hello everyone

we have a special mode on our maschines where the operator can change to a “recipe prepare” mode. In this mode all variables are disabled except the ones saved in a recipe.

like this he can prepare a new recipe directly on the maschine without interrupting the producing maschine.

In VC4 we could do that with a style in which the StatusDatapoint was defined and linked to a variable already. So everytime a added a new Input with this style, the statusdatapoint was connected to the correct variable without the need of any additional work and we could disable all these variables in the application by setting the statusdatapoint correctly.

How to solve that in mappView? I bind the “Enable” of a widget to a session variable which is set by the application to “false” to disable the specific widget.

BUT I have to do that binding for every single widget again and again and again….. is there a easier way to go? Can I assign a “default binding” somehow?

The widgets to disable are all over the visualisation and not just on one page, so I can’t just disable a groupbox.

Hello, you can achieve a similar result in mapp View. Create a style for your widgets and bind the enable property to a global variable (e.g., gRecipeMode). In your application logic, toggle this variable to disable/enable all widgets using that style. For widgets that should always be active in recipe mode, you can either use a different style or override the enable property on the specific widget instance.

How can I define a bind to the enable property in a style? I thought only styleable properties are possible to define in a style?

Because I actually did exactly what you said but I added the bind to the enable property by hand for each widget.

Hi Stefan,

there is no direct way of doing this but with AS6 we introduced a cool new feature ‘event scripting’ where you can create you own Java Script code.

Event script editor (JavaScript)

With a script you can search all widgets for a certain name and then manipulate them all. The following script runs on the content ‘contentStart’ and will be trigger when the OPC UA variable numEnable changes. Then it will look for all widgets that contain "‘NumericInput” in its name and then set the enable of this widgets to the OPC UA value.

/** 
* @eventScriptSetId contentStart 
* @contentId contentStart 
*/ 
opcua('::AsGlobalPV:numEnable').valueChanged(function(e){
    const opc_value = e.detail.newValue

    for (const key of Object.keys(widgets)) {
        if(key.startsWith("NumericInput")){
            widgets[key].setEnable(opc_value)
        }
    }
    
}); 

:information_source: There are a few important function and performance notes that I have to make here

  • mapp Script is an extra license
  • The function that I use to list all widgets is undocumented and not official
  • Since you can not cast widgets, you can only manipulate basic properties that all widgets have
  • Make sure that the OPC UA variable does not change too fast
  • The function searches all widgets on that content, so you must make sure that there is a limited number of widgets. You can always create a container on your page where most widgets are matches and you dont search the complete page.

Test the function on a real target (not your laptop) to make sure that performance is ok.

Happy coding

Stephan

1 Like

Hi @Stefan_Ruttimann, I have marked one answer as a possible solution, but you can update us on what the final solution was for you :slight_smile: