Author Topic: Handle onChange of button state  (Read 918 times)

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Handle onChange of button state
« on: June 28, 2017, 07:31:06 PM »
How can I generate an event for the AdvancedHMIControls when the state of the button changes? Not when the button is clicked but when it changes on the PLC side and updates. Without it triggering twice when the btn.Click handle is also used.
« Last Edit: June 28, 2017, 07:38:34 PM by anthony92 »

Phrog30

  • Guest
Re: Handle onChange of button state
« Reply #1 on: June 28, 2017, 07:51:40 PM »
I would subscribe to the address and then use data change event.  Subscribing to data in this case would have nothing to do with the button, but the data itself.  Does this need to happen for each instance of a button, or just on a form or two?

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Handle onChange of button state
« Reply #2 on: June 28, 2017, 11:46:02 PM »
It should only monitor the changing state of several buttons on a single form.

Would handle .EnabledChanged work to achieve this? Then I could remove all mentions of .click and rely on the other handle instead.

Being able to monitor this is important as I want to update the form based on this button changing. But do not want to have to resort to a timer.

Phrog30

  • Guest
Re: Handle onChange of button state
« Reply #3 on: June 29, 2017, 10:18:04 AM »
EnabledChanged occurs when the control.enabled property value has changed.  If the button isn't enabled then you couldn't click on it to start with.  What are you wanting to update on your form?  Also, the last post you said button changing, but in your first post you said you didn't want the button value, rather the PLC value/feedback.  So, it's not real clear on what you want.  Instead of focusing on the button, explain exactly what it is on your form you want to update because there may be a better/easier way to do what you want.

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Handle onChange of button state
« Reply #4 on: June 29, 2017, 11:29:34 PM »
Sorry for the confusion, I haven't used vb in a while.

The update should update another application interfacing with the HMI to request new information for display. The PLC can update the state of the button (highlight) and so can the user. I can easily handle the button .click from the user but not when it is updated by the PLC.

The button is a AdvancedHMIControls.BasicButton and several of them are used.

I want to update only when the highlight changes for the button (ie button on and off).

There isn't other way I can think off other than just handling the changing state.


seth350

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Handle onChange of button state
« Reply #5 on: June 30, 2017, 12:05:22 AM »
I'll take a stab at this....

You want to "click" the button from the plc?
Or just do some event when the plc address' click value changes?

It sounds like you are setting a value with the button and another value is changing the highlight color.

Still, the datasubscriber onchange event should do what you want.
You will need an acknowledgement bit in the plc to set when your click tag is set. The acknowledgement bit should set if the plc received the button click or if the plc requests to change the highlighted color. Use the DataSubscribe to monitor the acknowledgement bit.

And don't be afraid of timers  :)