Author Topic: Forcing values for simulation/demo/testing  (Read 2171 times)

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Forcing values for simulation/demo/testing
« on: June 15, 2015, 04:28:10 PM »
I would like to be able to test and demo the project without connecting to an OPC server or to be able to overridethe values read from the OPC server (PLC). I would like to be able to show what happens on the screen when the status of a pump or other input changes without having to actually change the value in the OPC server. In pseudo-code something like this:

If DemoMode = ON then
         'read value from checkbox 
         PumpControl1.value = PumpControl1OverrideCheckbox.value
         
Else  'read value from PLC
         PumpControl1.value = OPC_PLCAddress123.value
End If

Is this possible?

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Forcing values for simulation/demo/testing
« Reply #1 on: June 15, 2015, 07:07:52 PM »
I will suggest a few things until Archie responds:

1) You could try setting the driver property DisableSubscriptions to True when in demo mode and to False when not.

2) Any of the free OPC simulation servers could be used for testing the application prior to deploying it (MatrikonOPC or Graybox servers).

3) To quickly read and write values to any of the tags, you could use KeypadHMI control found here:

http://advancedhmi.com/forum/index.php?topic=708.0

Just making a suggestion, not that I tried these the way you might need.
« Last Edit: June 15, 2015, 07:19:52 PM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Forcing values for simulation/demo/testing
« Reply #2 on: June 15, 2015, 08:55:17 PM »
Godra suggested one of the things I was going to say and that is to set DisableSubscriptions to True, then use the code to set Values

Another option I was thinking, but may be more trouble than it's worth, is to add a SimulatorCom to your form, then set the ComComponent of all your controls to SimulatorCom1. The down side to this is that it simply retains values in memory after writing to a variable, then sending the value back to something that requests the same variable. For instance, let's say you add a meter and set the PLCAddressValue to MyTag. Then you add a BasicLabel and set PLCAddressKeypad to MyTag. When you run the app and click the BasicLabel, you can enter a value. The value will then show up on the meter.

In non-simulate mode, you would change all of the ComComponent properties back to your real driver instance. I have never tried this during runtime, so I'm not sure if it would behave correctly.

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Forcing values for simulation/demo/testing
« Reply #3 on: June 16, 2015, 11:40:40 AM »
The DisableSubscriptions option sounds like it will work. I'm not as clear on what the SimulatorCom or the KeyPADHMI do.

Thanks!

Mikefly95

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Forcing values for simulation/demo/testing
« Reply #4 on: June 16, 2015, 12:18:21 PM »
You could use Debug/Release as well. If you are not familiar with this yes the hash tags are used.

#if DEBUG
      do this
#else
      do this
#endif

When you want to use the OPC change to Release.

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Forcing values for simulation/demo/testing
« Reply #5 on: June 16, 2015, 02:11:23 PM »
DisableSubscriptions doesn't seem to be available for individual controls. I went with this which works OK:
(for a 3-state checkbox)

    Private Sub InputOR_1_CheckedChanged(sender As Object, e As EventArgs) Handles Pump1ORCKB.CheckedChanged

        Select Case Pump1ORCKB.CheckState

            Case CheckState.Checked
                MainForm.WaterPump1.PLCAddressValue = ""
                MainForm.WaterPump1.Value = True

            Case CheckState.Unchecked
                MainForm.WaterPump1.PLCAddressValue = ""
                MainForm.WaterPump1.Value = False

            Case CheckState.Indeterminate
                MainForm.WaterPump1.PLCAddressValue = "Network.RATCO.Pump1 Status.Value"

        End Select

    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: Forcing values for simulation/demo/testing
« Reply #6 on: June 16, 2015, 02:23:47 PM »
DisableSubscriptions doesn't seem to be available for individual controls.
DiableSubscriptions stops all communications linked to that particular driver instance. If you wanted to stop a group of controls form communicating while leaving others working, then you would add more driver instances and set the ComComponent of each control to which driver instance you wanted it to use. You can then stop coms on specific group of controls.