AdvancedHMI Software

General Category => Support Questions => Topic started by: Aviraj on November 30, 2015, 02:20:59 PM

Title: Turning on a PLC at a fixed time of the day
Post 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
Title: Re: Turning on a PLC at a fixed time of the day
Post by: rbelknap on November 30, 2015, 02:43:52 PM
How about calling the click event?
Title: Re: Turning on a PLC at a fixed time of the day
Post by: Aviraj on November 30, 2015, 04:03:15 PM
Hi rbelknap

Could you show me with the help of some sample code please ?

Thanks

Aviraj
Title: Re: Turning on a PLC at a fixed time of the day
Post by: rbelknap on November 30, 2015, 04:09:08 PM
You can try

Code: [Select]

button.performclick ()

or

call button_click(me, eventargs.empty)


just replace button with the name of your button.
Title: Re: Turning on a PLC at a fixed time of the day
Post by: Aviraj on November 30, 2015, 04:38:35 PM
Hi

So i tried your solution, and unfortunately, that did not work.

Something else maybe ?

Thanks a lot

Aviraj
Title: Re: Turning on a PLC at a fixed time of the day
Post by: Archie on December 01, 2015, 07:12:31 AM
What do you have in PLCAddressClick and OutputType properties of your button?
Title: Re: Turning on a PLC at a fixed time of the day
Post by: rbelknap on December 01, 2015, 08:02:56 AM
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.
Title: Re: Turning on a PLC at a fixed time of the day
Post by: Aviraj on December 02, 2015, 09:02:51 AM
So my PLCAddressClick has the register address in it: 05121 and the OutputType is 'Toggle'

Title: Re: Turning on a PLC at a fixed time of the day
Post by: Archie on December 02, 2015, 11:43:19 AM
Add a DateTime to your form, then add this code:
Code: [Select]
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
Title: Re: Turning on a PLC at a fixed time of the day
Post by: Aviraj on December 02, 2015, 11:48:06 AM
Ok great, Thanks Archie

I will try that and get back with the results.

Thanks

Aviraj