RockerSwitch

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
Haller
Posts: 6
Joined: Wed 1. Nov 2017, 13:25

RockerSwitch

Post by Haller » Wed 1. Nov 2017, 13:30

How can I assign two signals to one Rockerswitch?

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: RockerSwitch

Post by M.Maidhof » Wed 1. Nov 2017, 17:36

Hi,

use a virtual signal for your Rockerswitch and a VBmacro, which will set the value of both signals by the virtual signal.

regards

Michael

Haller
Posts: 6
Joined: Wed 1. Nov 2017, 13:25

Re: RockerSwitch

Post by Haller » Tue 14. Nov 2017, 13:41

Can you give me an example, I've looked in the example macros but cann't find it?

Regards

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: RockerSwitch

Post by M.Maidhof » Tue 14. Nov 2017, 14:26

Hi,

here the macro:

Code: Select all

Sub Toggleswitch()
Dim test1, test2, virtual

Set test1 = Signals("Test1")
Set test2 = Signals("Test2")

Set virtual = Signals("VirtualVar1")
If virtual Is Nothing Then
' Signal not found, create and initialize new one
Set virtual = Signals.Add("VirtualVar1")
End If

While True
test1.Value = virtual.Value
test2.Value = virtual.Value
Wait(10) ' Prevent 100% CPU load
Wend

End Sub
here the symbolfile:

Code: Select all

FormatVersion=5.0 // Do not edit this line!
Title="Symbols file2"

{SENDRECEIVE}

[Symbol1]
ID=100h
DLC=1
Var=Test1 unsigned 0,8

[Symbol2]
ID=200h
DLC=1
Var=Test2 unsigned 0,8

{VIRTUALVARS}
Var=VirtualVar1 unsigned
Here the PE6 with a Panel using the Slider to change the virtual signal:
PE6_Rockerswitch.JPG
PE6_Rockerswitch.JPG (104.4 KiB) Viewed 9166 times

Haller
Posts: 6
Joined: Wed 1. Nov 2017, 13:25

Re: RockerSwitch

Post by Haller » Fri 17. Nov 2017, 14:28

Thank you, I've got it working ;)

Haller
Posts: 6
Joined: Wed 1. Nov 2017, 13:25

Re: RockerSwitch

Post by Haller » Tue 28. Nov 2017, 20:53

Hello Michael,

I've made the following macro, it's setting the 4 signals, Activeren, optoeren, override and torque.
If they are set I cann't reset them, it should reset when the vertical slider is below 600.
Vertical slider signal is virtual signal "Toeren".

If Toeren > 600 then set -> 4 signals, Activeren, optoeren, override and torque
If Toeren < 600 then reset -> 4 signals, Activeren, optoeren, override and torque

Is it possible to do this and how?

Kind regards,

Jeroen
Attachments
Macro1.pem
Set/reset more signals
(724 Bytes) Downloaded 718 times

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: RockerSwitch

Post by M.Maidhof » Thu 30. Nov 2017, 11:24

Hi,

your description is not really clear for me (don´t know what reset means for you), but please try the following:

Code: Select all

'------------------------------------------------------------------------------
'FILE DESCRIPTION: Toeren
'------------------------------------------------------------------------------
Sub VerticalSlider1()
Dim Activeren, overide, Optoeren, Torque, virtual

Set Activeren = Signals("ESCEnable1")
Set Optoeren = Signals("ReqSpeedLimit1")
Set overide = Signals ("OverrideCntrlMode1ESC")
Set Torque = Signals ("RegTorqLimit1")
Set virtual = Signals("Toeren")
If virtual Is Nothing Then
' Signal not found, create and initialize new one
Set virtual = Signals.Add("Toeren")
End If

While True
  If virtual.Value > 600 Then
    Activeren.Value = 1
    Optoeren.Value = virtual.Value
    overide.Value = 1
    Torque.Value = 100
  Else
    ' Here reset values
    Activeren.Value = 0
    Optoeren.Value = virtual.Value
    overide.Value = 0
    Torque.Value = 0
  End If
  Wait(10) ' Prevent 100% CPU load
Wend

End Sub
you can also remove the Else part, if you don´t like to to touch the signals in that case

regards

Michael

Haller
Posts: 6
Joined: Wed 1. Nov 2017, 13:25

Re: RockerSwitch

Post by Haller » Fri 1. Dec 2017, 17:05

Hello Michael,

Great, thanks got it working

Kind regards,

Jeroen Dirks

Post Reply