convertersystems / opc-ua-samples

Sample HMIs using OPC Unified Architecture (OPC UA) and Visual Studio.
MIT License
107 stars 43 forks source link

Timing at application startup #29

Closed abrasat closed 7 years ago

abrasat commented 7 years ago

The following problem occurs at startup if a opc-ua item has a constant value. The view model (containing the MonitoredItem attribute) is initialized and the monitored opc-ua item fetched, before the Urho object is created. The "Renderer" property is set only after the view model already received the opc-ua item value ( I tested with the debugger). This leads to the problem that the bindable property changes before the urho object was showed, and practically the urho code "misses" the property change.

protected async override void OnPropertyChanged([CallerMemberName] string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == "Renderer") { this.robotGame = await this.UrhoSurface.Show<RobotGame>(new ApplicationOptions(assetsFolder: "Data") { Orientation = ApplicationOptions.OrientationType.LandscapeAndPortrait }); } }

How could the startup order be changed, to avoid the problems that occur if a opc-ua item has a constant value ? (sorry, I cannot get the code formatted properly...)

awcullen commented 7 years ago

Thanks for reporting this issue. I've fixed the samples to use the initial values.