Author Topic: PLC Online/Offline  (Read 2832 times)

tamnguyen408

  • Newbie
  • *
  • Posts: 14
    • View Profile
PLC Online/Offline
« 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

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: PLC Online/Offline
« Reply #1 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.

tamnguyen408

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: PLC Online/Offline
« Reply #2 on: July 13, 2016, 09:16:52 AM »
Thanks, Archie
will take a look tonight

tamnguyen408

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: PLC Online/Offline
« Reply #3 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,

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: PLC Online/Offline
« Reply #4 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.

tamnguyen408

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: PLC Online/Offline
« Reply #5 on: July 13, 2016, 04:08:49 PM »
Thank you very much Archie

tamnguyen408

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: PLC Online/Offline
« Reply #6 on: July 13, 2016, 11:05:12 PM »
Thanks for your help... Archie
It works both VB.NET and C#