AdvancedHMI Software

General Category => Support Questions => Topic started by: rmac on March 23, 2017, 06:24:21 PM

Title: Catching the exception
Post by: rmac on March 23, 2017, 06:24:21 PM
Is there a way to catch this exception inside the application?
It's clear I'm getting the error because there is no connection with the PLC, but I would like to be able to catch/report that, instead of getting this pop up message from .Net Framework.
If I hit Continue the program resumes operation, without showing any readings from the PLC of course.
Any help will be appreciated.
Title: Re: Catching the exception
Post by: Archie on March 23, 2017, 06:37:53 PM
Is this happening where you are performing a Write with your own code? If so, you need to be sure to wrap all of your Read and Writes in a Try-Catch
Code: [Select]
Try
    EthernetIPforSLCMicroCom1.Write("N7:0","1")
Catch ex as Exception
   msgbox("Write failed. " & ex.message)
End Try
[/doe]
Title: Re: Catching the exception
Post by: rmac on March 23, 2017, 06:50:41 PM
You are right. As usual.
I'm trying to write/send some values to the PLC from the code.
Will try your suggestion asap.
THANK YOU.
Title: Re: Catching the exception
Post by: rmac on March 23, 2017, 06:53:04 PM
Should I use Try for every read/write, or I can group several read/write operations inside one Try?
Title: Re: Catching the exception
Post by: rmac on March 23, 2017, 07:05:58 PM
I put a group of "write to PLC" commands inside the Try and it did work.
I realized that a reaction to the first one is enough.
Got my response to the exception "under control" now.

Thanks again Archie.
Much appreciation.