Change more than one signal with a Toggle Switch

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
Markus
Posts: 9
Joined: Thu 25. Sep 2014, 16:26

Change more than one signal with a Toggle Switch

Post by Markus » Thu 25. Sep 2014, 16:30

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

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Change more than one signal with a Toggle Switch

Post by K.Wolf » Mon 29. Sep 2014, 12:06

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

Markus
Posts: 9
Joined: Thu 25. Sep 2014, 16:26

Re: Change more than one signal with a Toggle Switch

Post by Markus » Mon 29. Sep 2014, 13:38

The proposed solution works. Thank you :)
One follow up question: Can I autostart this macro as soon as the panel goes into execution mode?

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Change more than one signal with a Toggle Switch

Post by K.Wolf » Tue 30. Sep 2014, 09:28

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.

Post Reply