62 views
in GUI Development by

Hello,

I would like to close/discard a page based on the value of a variable.

Specifically, in my application I have parameter setup pages and a "work cycle" page that is displayed based on a start command, which can come from various sources (digital input, serial/LAN command, display button, etc.). Upon the start command, the interface sets variables on the device to execute the requested work cycle, execute the WorkCycleStart function in the device integration, and displays the CyclePage.

The machine is state-based, so when the work cycle is esecuted, the device status changes from "ready" to "running" (different values ​​of the DeviceStatus property). The change of the status is managed in the device integration code, which also updates the property value on the GUI (as explained in your DeviceIntegration examples). 

When the work cycle ends/interrupts, to exit the work cycle page, I have associated an observer to the state property in this page. When the variable changes and is no longer "Working" (value 5), the DismissDialog command is executed. 

 

However, I have the problem that if the work cycle is too short to display the work page (less than 100ms), the page is displayed, the value of the status variable is "ready," and the observer doesn't catch the change, so the work page remains displayed.

How can I strengthen the link between the page and the variable? The goal is to prevent the page from being displayed when the status is anything other than "working".

Furthermore, to start the work cycle from digital inputs, I have created observers in the "base" page (the one that loads when the application starts and above which various parameter settings pages are displayed) linked to the input properties. This allows me to start the cycle from any page.

Considering the suggestion in the previous ticket ("Update ValueDisplay Outlet from another page"), is it better to handle the start commands as a system event instead of using PropertyObservers? Below is an image of the Default page (which loads the FirstPage at startup) with the Start1Slot code called by the Start1Observer.

 

Thank you for support!

1 Answer

0 votes
by
Hello Nicola,

Yes, I would use system events for this. The events ensure that every trigger is sent. Conversely, notifications for property observers can accumulate if the value changes very quickly. In other words, property observers don't guarantee that every value change will trigger individual notifications. They are guaranteed to arrive after the value changes. However, the value can change multiple times in the meantime.

To avoid that we have overlooked another cause of the issue, I would suggest to make a test with only one System Event in the Device class. The event should be triggered when alternation from Working to Ready state occurs. Then add System Event Handler to the respective page and when the event arrives, dismiss the page. In the second pass, if this modification worked as expected, I would add other System Events for other state alternations and adapt all respective pages.

I hope it solves the issue.

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...