AdvancedHMI Software

General Category => Open Discussion => Topic started by: phuz on October 12, 2015, 04:25:51 PM

Title: Timeouts for WRITE connections
Post by: phuz on October 12, 2015, 04:25:51 PM
Hello, I have been using this software for about a year and I am now trying to add some functionality, but I am noticing that there is a timeout period of about 5 seconds when trying to read/write to an offline PLC.  Could someone be kind enough to point out where this resides within the code?  I cannot find it for the life of me!
Title: Re: Timeouts for WRITE connections
Post by: bachphi on October 13, 2015, 08:36:07 AM
This is the case where I would advocate to have a property IsConnected to check for PLC connected before writing tag. I use ConnectionEstablished event instead.

Code: [Select]

    'Events
    Private Sub EthernetIPforCLXCom1_ConnectionClosed(sender As Object, e As EventArgs) Handles PLC.ConnectionClosed
        PLCIsConnected = False
    End Sub
    Private Sub EthernetIPforCLXCom1_ConnectionEstablished(sender As Object, e As EventArgs) Handles PLC.ConnectionEstablished
        PLCIsConnected = True
    End Sub
Title: Re: Timeouts for WRITE connections
Post by: Darrell on October 18, 2015, 10:20:29 AM
Most of the HMI's I've built lately , I've  added a button to connect/disconnect on each screen , each screen has a timer counting from the plc so I know I have communications. Seems to give me a lot less grief on busy networks . How would I implement this so that when the connect button is clicked or when comms is established , a message pops up to say comms established and then disappears , if comms are lost another message would automatically pop up saying so.

Darrell
Title: Re: Timeouts for WRITE connections
Post by: Noe on October 28, 2015, 11:20:44 AM
Hi Darrel

Could you share an example to know how you get this done?
Title: Re: Timeouts for WRITE connections
Post by: Darrell on October 29, 2015, 12:30:03 PM
I used 2 buttons and a textbox , would have preferred to use only one button and have the text change as to what state its in , but don't how,

but this works fine for me.

Code for connect button to enable subscriptions

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button6.Click
        EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = "False"
        TextBox1.Text = EthernetIPforPLCSLCMicroCom1.IPAddress
End Sub

Code for connect button to disable subscriptions

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button7.Click
        EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = "True"
        TextBox1.Text = EthernetIPforPLCSLCMicroCom1.IPAddress
End Sub


Title: Re: Timeouts for WRITE connections
Post by: Noe on October 29, 2015, 03:13:11 PM
Thanks! I'll give it a try next time I have a chance.
Title: Re: Timeouts for WRITE connections
Post by: rbelknap on November 05, 2015, 12:53:43 PM
Darrell,

If you're looking to just use one button as a toggle, there are a couple of ways to do it.

You could do something like this:
Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button6.Click
        'Toggle the subscriptions
        EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = Not EthernetIPforPLCSLCMicroCom1.DisableSubscriptions

        TextBox1.Text = EthernetIPforPLCSLCMicroCom1.IPAddress

        'Change the button Text
        If EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = "True" Then
            Button6.Text = "Disable"
        Else
            Button6.Text = "Enable"
        End If
    End Sub

You could put all of it inside the if statement.

Rich