AdvancedHMI Software
General Category => Support Questions => Topic started by: Aviraj on November 30, 2015, 02:20:59 PM
-
Hi
This might be an extremely straightforward question for a lot of you, but somehow, I cant seem to get around it. I have a few Momentary Buttons on my HMI that are used to turn on/off certain PLCs mnually. What I am looking to do is turn on/off these PLCs at the fixed time of the day automatically!
I have the DateTime control on the Form and I can successfully extract the time out of it. I can also check if it is the correct time to turn on the PLCs or not.
What I am having trouble with is that how do I send that on/off message to the PLC through the momentary button. I initially thought that the Momentary Button would have a 'value' property which I can set to True or False. However, it does not have that property.
Would greatly appreciate any assistance in solving this issue.
Thanks in advance
Aviraj
-
How about calling the click event?
-
Hi rbelknap
Could you show me with the help of some sample code please ?
Thanks
Aviraj
-
You can try
button.performclick ()
or
call button_click(me, eventargs.empty)
just replace button with the name of your button.
-
Hi
So i tried your solution, and unfortunately, that did not work.
Something else maybe ?
Thanks a lot
Aviraj
-
What do you have in PLCAddressClick and OutputType properties of your button?
-
I just tried this and can't seem to make it work either.
My guess, after looking at the momentary button code is because the PLC click stuff is being done on mousedown.
When we just call the performClick method or the _click event handler is doesn't fire the mouse events.
I also tried it with the basicbutton since the momentarybutton doesn't have the performClick method
I knew calling the click event seemed a little simple.
Hopefully Archie can come up with a way around this for you.
-
So my PLCAddressClick has the register address in it: 05121 and the OutputType is 'Toggle'
-
Add a DateTime to your form, then add this code:
Private Sub DateTime1_TextChanged(sender As Object, e As EventArgs) Handles DateTime1.TextChanged
Dim CurrentDateTime As Date
If Date.TryParse(DateTime1.Text, CurrentDateTime) Then
Dim DifferenceOfTime As TimeSpan = CurrentDateTime.Subtract("12:08")
If DifferenceOfTime.Minutes = 0 Then
'* Our time is on the same minute as target, so set the bit
ModbusTCPCom1.Write("05121",1)
End If
End If
End Sub
-
Ok great, Thanks Archie
I will try that and get back with the results.
Thanks
Aviraj