Author Topic: Communications and Simulation Mode  (Read 6118 times)

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
Communications and Simulation Mode
« on: October 21, 2013, 01:02:33 PM »
I would like to be able to run my HMI while offline, typically with other drivers when starting I would check status of the communication connection, if it was negative, I would give the user the option to Try Again, Abort, or Simulate.  Simulate mode would allow the program to run and not create errors.  This allows the end user to program recipes, look at data, ... while offline.  How can I implement this with your drivers without encapsulating your class?  I am using the EthernetIPforPLCSLCMicroCom.  Thank you.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Communications and Simulation Mode
« Reply #1 on: October 21, 2013, 07:28:06 PM »
You may be able to handle the ComError event and if there is an error then set the DisableSubscriptions to true. That will only work if you are using the built in controls. If you are reading/writing using code, then you will have to modify your code to stop reading when there is a com error.

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Communications and Simulation Mode
« Reply #2 on: October 22, 2013, 10:42:27 AM »
Thank you Archie, I will implement your suggestions, most of my calls are in my code, but I am still considering using your controls for a few items.  If you could consider the disable comms as a feature request I would appreciate it.  I have to do this in almost every HMI I write and it would be great to have it included in your code to simplify the interface.

lnw32

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Communications and Simulation Mode
« Reply #3 on: November 06, 2013, 09:10:55 AM »
You may be able to handle the ComError event and if there is an error then set the DisableSubscriptions to true. That will only work if you are using the built in controls. If you are reading/writing using code, then you will have to modify your code to stop reading when there is a com error.

Where do I find the ComError event?

I'm using EthernetIPforPLCSLCMicroCom1

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Communications and Simulation Mode
« Reply #4 on: November 06, 2013, 09:21:28 AM »
Where do I find the ComError event?

I'm using EthernetIPforPLCSLCMicroCom1
If you select the driver instance on your form, then go to the Properties window and click the lightening bolt. You will then see a list of all the events. You can double click to the right of the event name and it will setup an event handler for you.

lnw32

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Communications and Simulation Mode
« Reply #5 on: November 06, 2013, 09:51:56 AM »
HI Archie, Thanks for the fast reply. I don't see the event. I do see events, just not that one. I'm using version 3.59. I took a snippet of the listed events but I don't know how to include an image so I'll just list them. ConnectionEstablished, DataReceived, DownloadProgress, UnsolictedMessageReceived, UploadProgress. I don't know if this makes a difference but I'm using vs2013RC. I'm about to upgrade to vs2013RTM. Windows 7 Professional 32bit.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Communications and Simulation Mode
« Reply #6 on: November 06, 2013, 09:58:54 AM »
You are right, that event only exists for the ControlLogix driver. I didn't realize it wasn't implemented on the SLC driver. I will put it on the list to get it implemented.

lnw32

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Communications and Simulation Mode
« Reply #7 on: November 06, 2013, 03:51:11 PM »
Hi Archie,

This is NOT something I absolutely need since my code won't normally run without being connected to a PLC.

Following makulais question and your replay I have tried to allow my HMI to run without being connected. I tried to use the disable subscriptions and I still get errors. It's as if I didn't issue the command at all. The HMI will be unresponsive and when I close I have to use the "environment.exit" or use task manager to end the process.

However, when I connect to the PLC and start the software, the disable subscriptions works.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Communications and Simulation Mode
« Reply #8 on: November 06, 2013, 06:51:41 PM »
Following makulais question and your replay I have tried to allow my HMI to run without being connected. I tried to use the disable subscriptions and I still get errors. It's as if I didn't issue the command at all. The HMI will be unresponsive and when I close I have to use the "environment.exit" or use task manager to end the process.

However, when I connect to the PLC and start the software, the disable subscriptions works.
Disabling subscriptions only stops the polling, but does not stop it from connecting and in some cases validating the tag with the PLC. In the SLC driver, you can make a little "hack" to get around this. After connecting, the driver will get the processor type in order to know what commands to use.

In AllenBradleyPCCC.vb at line 427 is a function of GetProcessorType. By modifying this to return the known processor, it will skip trying to connect to the processor. You can check the comments for the code of your processor type and modify like this

Code: [Select]
    Public Function GetProcessorType() As Integer
        If m_ProcessorType <> 0 Then
            Return m_ProcessorType
        Else
            Return &H49  '* force it to be a SLC 5/03 processor

lnw32

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Communications and Simulation Mode
« Reply #9 on: November 07, 2013, 07:27:41 AM »
Thanks,

lnw32

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Communications and Simulation Mode
« Reply #10 on: November 07, 2013, 09:14:30 AM »
Hi Archie,

Worked Like a champ!!

I Disable subscriptions by default now and only enable them after I find (ping) the address of the PLC. The HMI no longer becomes sluggish. I still get one error in VS

Below is what I did to your code. By the way I didn't see an entry for the ML1400 I'm using so I just did a message box and display what the return value was and then forced it. I also kept the commented code in my machine but left it out here for clarity.


    Public Function GetProcessorType() As Integer
        If m_ProcessorType <> 0 Then
            Return m_ProcessorType
        Else
           
            Return 159 ' Value that was returned when connected to ML1400
     
        End If
   End Function

Thanks,

Larry