Hi,
is there a possibility to change more than one signal with one single Toggle Switch? Unfortunately, I can't combine them with another variable, because the signals are in different CAN messages.
Could I maybe execute a macro when turning the switch on a different macro when switching back off?
I don't want to use a "button" because the user won't be able to see the current state then.
Thanks,
Markus
Change more than one signal with a Toggle Switch
Re: Change more than one signal with a Toggle Switch
The only possiblity to do this is to assign a virtual signal to the Toggle switch and to run a VBS macro that continuously watches the value of this signal. When the signal value changes because the user has pushed the switch, the macro can change all required CAN signal values. Here is a macro example:
Code: Select all
Sub ProcessToggleSwitch()
Dim ToggleSig, CANSig1, CANSig2, OldToggleValue
Set ToggleSig = Signals("MyVirtualVar")
Set CANSig1 = Signals("MyCANSignal1")
Set CANSig2 = Signals("MyCANSignal2")
OldToggleValue = ToggleSig.Value
While True
If ToggleSig.Value <> OldToggleValue Then
If ToggleSig.Value = 0 Then
CANSig1.Value = 1
CANSig2.Value = 2
Else
CANSig1.Value = 10
CANSig2.Value = 20
End If
OldToggleValue = ToggleSig.Value
End If
Wait 10
Wend
End Sub
Re: Change more than one signal with a Toggle Switch
The proposed solution works. Thank you 
One follow up question: Can I autostart this macro as soon as the panel goes into execution mode?

One follow up question: Can I autostart this macro as soon as the panel goes into execution mode?
Re: Change more than one signal with a Toggle Switch
No, unfortunately this is not possible. But you could start the macro when you load the project containing the panel.
See Project settings -> 'Execute command after loading project'. Enter the macro name in the field, save the panel in execution mode, then save and reopen the project.
See Project settings -> 'Execute command after loading project'. Enter the macro name in the field, save the panel in execution mode, then save and reopen the project.