Author Topic: Enabling/Disabling specific drivers  (Read 1406 times)

mr14

  • Newbie
  • *
  • Posts: 12
    • View Profile
Enabling/Disabling specific drivers
« on: June 08, 2017, 06:18:02 AM »
In my project I have 10 drivers (Modbus_TCP) to communicate with 10 PLCs but not all the time, all the PLCs are on.
How can I enable or disable drivers according to operator request?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Enabling/Disabling specific drivers
« Reply #1 on: June 08, 2017, 08:18:11 AM »
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ModbusTCPCom1.DisableSubscriptions = Not ModbusTCPCom1.DisableSubscriptions
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ModbusTCPCom2.DisableSubscriptions = Not ModbusTCPCom2.DisableSubscriptions
End Sub

mr14

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Enabling/Disabling specific drivers
« Reply #2 on: June 08, 2017, 08:41:14 AM »
Thanks.

I will take this question one step forward.
In my application I have a form in which I see parameters from all PLCs. I want to give the operator an option to open another form (a pop-up if possible) where he could select (with check boxes) which PLCs to operate and it will affect the main form.

Is that possible?
« Last Edit: June 08, 2017, 08:51:08 AM by mr14 »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Enabling/Disabling specific drivers
« Reply #3 on: June 08, 2017, 09:19:07 AM »
I will give you the advanced technique for doing this using Application Settings:

- On your MainForm, select the first driver instance
- In the Properties Window, scroll to the top and look for (Application Settings)
- Click the + to expand that down
- Click in the Property Binding field, then click the ellipsis button to get a popup window
- The popup window will contain a list of properties, find DisableSubscriptions and click the drop down arrow
- Click the New link at the bottom of the list
- Another window will pop up. In this Window, set the Name to DisablePLC1
- Click OK to the 2 pop up windows to close them both

You will now have created an Application Setting in which its value will control the DisableSubscriptions property of your first driver. You now want to create a Checkbox that controls this Application Setting.

- With your MainForm open in design view, From the Toolbox in the All Windows Forms group, select and add a Checkbox to your form
- In the properties Window, scroll to the top and look for (Application Settings)
- Expand down the Application Settings
- You should now see a property named "Checked" in the Application Setting group
- Select this property and drop down the list to select DisablePLC1

When you run your application, the Checkbox will now control your first PLC driver. You will need to repeat this for each driver. In the example, I said to add the Checkbox to the MainForm, but you are free to add it to any form you choose.

mr14

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Enabling/Disabling specific drivers
« Reply #4 on: June 08, 2017, 09:39:48 AM »
great.

One last thing. Now, when the check box is checked, the PLC is disabled. I want that when it is checked the PLC will be enabled.
Can I add a NOT somewhere to do it?

Thanks