Author Topic: what is the best way to click more than one button at the same way  (Read 1132 times)

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
hello

in my project

i have 5 doors

2 doors connected to plc1
2 doors connected to plc2
1 door connected to plc3

each door uses a different register to close it

which mean i already have 5 buttons to close doors

what i need to do
is one button to click on them all to close all the doors at the same time
like an emergency close
and i prefer if there is a password the user should put to close down all doors

and with thanks :)




Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: what is the best way to click more than one button at the same way
« Reply #1 on: May 24, 2019, 08:33:19 AM »
Add a button to the form
Double click the button to get back to the code
Add this code for each button you want to click:
        Button1.PerformClick()

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: what is the best way to click more than one button at the same way
« Reply #2 on: May 24, 2019, 11:29:33 AM »
I am not sure if that will work properly if he is using the BasicButton controls instead of the Button controls.

This because of the MouseDown and the MouseUp events which are a part of the BasicButton control.

If correct then maybe use the drivers themselves to write to PLCs.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: what is the best way to click more than one button at the same way
« Reply #3 on: May 24, 2019, 02:01:14 PM »
Godra is correct, the PerformClick will not make a BasicButton write to the PLC. A better solution is what Godra mentions. Or yet another solution would be to define another bit in the PLC that would be the "master close"

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: what is the best way to click more than one button at the same way
« Reply #4 on: May 24, 2019, 03:09:03 PM »
OK CAN YOU GIVE ME THE CODE I SHOULD USE ?
BUT I NEED THE CODE TO USE THE PLC ADDRESS AND IP AND TCPIP PORT
CAUSE THE I NEED TO CLOSE MULTI DOORS
EACH DOOR IS CONNECTED TO A DIFFERENT PLC

SO I NEED A GLOBAL CODE AND THEN I WILL REWRITE IT FOR MULTI PLCS
BY THE WAY AM USING THE DRIVER ModbusTCPCom AND THE BUTTON IS IN TOGGLE MODE
« Last Edit: May 24, 2019, 03:11:35 PM by oqapsking »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: what is the best way to click more than one button at the same way
« Reply #5 on: May 24, 2019, 07:37:28 PM »
Are you using a separate driver for each of your 3 PLCs and what value closes the door?

The code could possibly look like this:

Code: [Select]
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(300) With {
            .PasswordChar = True,
            .ForeColor = Color.Red,
            .Text = "ENTER PASSCODE"
        }
        Dim dr As DialogResult = PassCodeKeypad.ShowDialog()
        If dr = DialogResult.Cancel Then Exit Sub
        If PassCodeKeypad.Value <> "1234" Then
            MsgBox("INVALID PASSCODE!")
        Else
            ModbusTCPCom1.Write("000001", "1")
            ModbusTCPCom1.Write("000002", "1")
            ModbusTCPCom2.Write("000001", "1")
            ModbusTCPCom2.Write("000002", "1")
            ModbusTCPCom3.Write("000001", "1")
        End If
    End Sub

« Last Edit: May 24, 2019, 08:43:03 PM by Godra »

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: what is the best way to click more than one button at the same way
« Reply #6 on: May 24, 2019, 08:57:42 PM »
Thank you very much
It seems exactly as i need i will try it when am on the pc and will tell you about it

And with a pass code :) thats great

Thanks

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: what is the best way to click more than one button at the same way
« Reply #7 on: May 25, 2019, 10:12:57 PM »
it worked with me as like this

Code: [Select]
Private Sub CloseDownbtn_Click(sender As Object, e As EventArgs) Handles CloseDownbtn.Click
        Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(300) With {
            .PasswordChar = True,
            .ForeColor = Color.Red,
            .Text = "ENTER PASSCODE"
        }
        Dim dr As DialogResult = PassCodeKeypad.ShowDialog()
        If dr = DialogResult.Cancel Then Exit Sub
        If PassCodeKeypad.Value <> "1234" Then
            MsgBox("INVALID PASSCODE!")
        Else
            eGroundTCP.BeginWrite("02080", 1, New String() {"1"})
            eGroundTCP.BeginWrite("02082", 1, New String() {"1"})

            eF1TCP.BeginWrite("02080", 1, New String() {"1"})
            eF1TCP.BeginWrite("02082", 1, New String() {"1"})
            eF22TCP.BeginWrite("02080", 1, New String() {"1"})



        End If
    End Sub

i opened the basicbutton.vb
and used the toggle code

thanks for your help