AdvancedHMI Software

General Category => Open Discussion => Topic started by: tamnguyen408 on July 12, 2016, 02:03:34 PM

Title: PLC Online/Offline
Post by: tamnguyen408 on July 12, 2016, 02:03:34 PM
Hi all,

How do I check PLC online or offline when Program starting up? Thanks in advance
Title: Re: PLC Online/Offline
Post by: Archie on July 12, 2016, 05:48:00 PM
If you did not set SuppressErrorDisplay to True, then most controls will display a message indicating a connection could not be made.

Most of the drivers also have 3 events:

ConnectionEstablished
ConnectionClosed
ComError

You can make event handlers for these events to know when there is a connection issue.
Title: Re: PLC Online/Offline
Post by: tamnguyen408 on July 13, 2016, 09:16:52 AM
Thanks, Archie
will take a look tonight
Title: Re: PLC Online/Offline
Post by: tamnguyen408 on July 13, 2016, 12:21:04 PM
Hi Archie,

I have not check my program yet.
Please! Give me an example code how to check connection established function call?
many thanks,
Title: Re: PLC Online/Offline
Post by: Archie on July 13, 2016, 01:39:45 PM
The easiest way may be to perform a read in a Try-Catch block:

Code: [Select]
Try
  ModbusTCPCom1.Read("40001")
catch ex as exception
  msgbox "Failed to read." & ex.message
end try

You can double click in a blank area of the form to get to the form load event and put the above code.
Title: Re: PLC Online/Offline
Post by: tamnguyen408 on July 13, 2016, 04:08:49 PM
Thank you very much Archie
Title: Re: PLC Online/Offline
Post by: tamnguyen408 on July 13, 2016, 11:05:12 PM
Thanks for your help... Archie
It works both VB.NET and C#