I have a question about dynamic binding in WDTC. Here’s my use case:
I need to fetch information from an OpcUa server, but the number of nodes isn’t known at widget compilation time—all the data is retrieved at runtime.
Currently, I’m using an OpcUa read for each node I gather at runtime, with a time interval to avoid spamming the server. However, these nodes aren’t properties of my widget; they’re only used internally in the widget’s code.
To optimize this, I’d like to use bindings to:
Avoid spamming the OpcUa server.
Only fetch values when they change.
The issue is that bindings seem to require properties and their getters/setters to be pre-declared.
Is there a way to pass a custom callback to a dynamic binding? This would allow me to handle the data dynamically without declaring everything upfront.
A dynamic binding, is still a binding. For that reason you need everything, which is also needed for a normal binding - which includes the getters and setters of a property to bind. For this use case there are at least two workarounds:
Widgets can be created at runtime, too. So it would be possible to implement a simple widget, which basically has only a (bindable) “value”. At runtime you create as many instances of this widget as child of your widget … then you can bind your data to these widgets. A example which goes in that direction can be found in the WDTC - under “usecases”, there is a widget “DynamicBindings” - check this out!
We also support mapp Connect - it is a different technology package, not directly related to the WDTC, but with mapp Connect you have all the OPC-UA functions on a “low level”, which allows you to create real OPC-UA subscriptions, etc. This can also be used within the WDTC.
It might also be worth to look into “MotionPad” … The MotionPad also created dynamic bindings and arranges itself internally.