Author Topic: Freezing when run without a PLC connected  (Read 937 times)

monteran

  • Newbie
  • *
  • Posts: 7
    • View Profile
Freezing when run without a PLC connected
« on: April 06, 2017, 04:03:16 PM »
I have an AdvancedHMI solution I am working with that has been a great help for me and my workflow the past few months. I am wrapping up a project and trying to iron out a few little hindrances before I call it a day and hand off the project to the next guy.

Specifically, one issue I have had is that when I debug the software on a PC that is not connected to the our AB CompactLogix PLC via Ethernet, after a few seconds the application will freeze and need to be restarted. No exceptions or anything seem to be called, and currently all of our code that reads from the PLC is handled in functions tied to buttons. Without touching any of those buttons, the various AdvancedHMI labels will show their typical errors and then the program stalls.

One detail I would like to clean up to figure out how to ensure that the program remains responsive when the PLC is not detected. In the worse case I can try and put up a error box to the user that allows them to know what the issue is. Both would be fine solutions, I suppose. I'm now in the "cleanup" phase where I'm adding in the necessary exception handling and other important usability items.

Any tips or tricks from the community would be appreciated. I certainly couldn't have gotten this system working without this forum.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Freezing when run without a PLC connected
« Reply #1 on: April 06, 2017, 04:35:38 PM »
I would use ConnectionEstablished event to set a flag:
PLCIsConnected = True

then use it thought out the program

If PLCIsConnected Then
           'Do your things
End If

===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

monteran

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Freezing when run without a PLC connected
« Reply #2 on: April 10, 2017, 09:09:55 PM »
Thank you bachpi. That works well for the few places that I have implemented so far.

Is there a way that I can use a DataSubscriber to monitor the change of a tag without it triggering on the initial startup of the program? I have a "test finished" flag that I set and I want to do some Excel generation after that flag is set, but it will call my function even when I just happen to turn on the program to a PLC that already has the flag high.

I guess I can just use a "last state" and "current state" variable or something.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Freezing when run without a PLC connected
« Reply #3 on: April 10, 2017, 09:19:39 PM »
In the DataChanged event, you can add a check condition for value=1 or True:

Code: [Select]
If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then
            '* Did it come back as True or 1?
            If String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1" Then
                'do your thing

            End If
        End If
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================