Page 1 of 1
Display CAN Signals on Instrument Panel
Posted: Fri 19. May 2017, 04:20
by akanti
Hello,
I am trying to display certain signals that are visible in the Receive/Transmit tab in a Text Box like object on the Instrument Panel. The signal should only be displayed if it has a certain value.
Is this possible with the existing features?
Thanks!
Re: Display CAN Signals on Instrument Panel
Posted: Fri 19. May 2017, 11:44
by PEAK-Support
at the moment you could not hide/show a control via script. This is a feature that comes only in the PCAN-Explorer 6 Version within the next weeks. You could try to set the x/y position depending on the signal to a negative value, so that the control is out off the view if the signal is not valid. Problem is, that you also do not see the control in Design mode! A second solution could be the using of the scene feature - but this enable / disable always a complete panel.
Re: Display CAN Signals on Instrument Panel
Posted: Fri 19. May 2017, 19:21
by akanti
U.Wilhelm wrote:at the moment you could not hide/show a control via script. This is a feature that comes only in the PCAN-Explorer 6 Version within the next weeks. You could try to set the x/y position depending on the signal to a negative value, so that the control is out off the view if the signal is not valid. Problem is, that you also do not see the control in Design mode! A second solution could be the using of the scene feature - but this enable / disable always a complete panel.
Thank you for your reply Mr. Wilhelm,
Could you please tell me how a Received Signal Value can be used to move a Control?
And what are the steps for the scene feature be used?
Re: Display CAN Signals on Instrument Panel
Posted: Wed 24. May 2017, 16:51
by PEAK-Support
Here a simple code sample how to get the reference to a Label on a panel:
Code: Select all
Dim PanelDoc, panel, scene, label, i
Set PanelDoc = Documents.Open("Panel1.ipf")
If Not PanelDoc Is Nothing Then
Set panel = PanelDoc.ActiveWindow.Object
Set scene = PanelDoc.ActiveWindow.Object.ActiveScene
For i = 1 to scene.Controls.Count
If scene.Controls.Item(i).Name = "myLabel" Then
Set label = scene.Controls.Item(i)
End If
Next
End If
later on in the code, you could use the reference to set properties while your script is running:
Code: Select all
' Create the sinus signal
x = 0
Do While StopSig.Value = 0
x = x + .05
SinusSig.Value = Sin(x) * 50
label.Left = SinusSig.Value + 260
label.Top = SinusSig.Value + 50
label.Caption = SinusSig.Value
Wait 50
Loop
So you could move the object (in this case a label) to any place on your panel you like. See my sample screen. (animated GIF) If you use negative positions, the control is not visible anymore. (be carefull! if you stop the macro, and the position is not visible, you could not "find" the control on the panel..)
How to work with different scene is part of the online help. It is also well documented.
Re: Display CAN Signals on Instrument Panel
Posted: Thu 25. May 2017, 19:25
by akanti
Thank You!