Reading different kind of control value in instruction panel by VBS marco

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
WillYang
Posts: 3
Joined: Wed 26. Jun 2024, 06:14

Reading different kind of control value in instruction panel by VBS marco

Post by WillYang » Wed 26. Jun 2024, 07:03

Hi there :

I'm using object to access the value of control in the panel,
the code I used is list as below:

Code: Select all

Sub test()
	Dim MyIpf, MyCtrl
	set MyIpf = Documents("MyIpfFileName.ipf").ActiveWindow.Object 
	Set MyCtrl = MyIpf.Scenes(1).Controls("Button1")
	msgbox "MyCtrl = "  & MyCtrl.Value
End Sub
I tried different cases :
CASE-1. When "myControl" is a "Value Edit Control" which is bounded to a numeric CAN signal, the value can be returned by myCtrl.Value
CASE-2. When "myControl" is a "Value Edit Control" which is bounded to a Enum attribution CAN signal, it will return the Enum string when using "myCtrl.Value"
CASE-3. When "myControl" is a "Button Control" or "ToggleSwitch control", the marco file(.pem) can be built, but it returns an error message while running.

My questions are: ,
1. how do I get the Enum value(1,2...n) in CASE-2 ?
2. how to read the toggle switch and/or button status in CASE-3 (ex: 0 = Off and 1 = On)?
3. where can I find the doc/help which describes the properties and method of each controls/indications in instrument panel?

Thanks!

WillYang
Posts: 3
Joined: Wed 26. Jun 2024, 06:14

Re: Reading different kind of control value in instruction panel by VBS marco

Post by WillYang » Wed 26. Jun 2024, 07:47

reply myself

for CASE-2 :

Code: Select all

Sub test()
	Dim MyIpf, MyCtrl, MyEnum,

	set MyIpf = Documents("E10_P1PseudoBatteryPanel.ipf").ActiveWindow.Object 
	Set MyCtrl = MyIpf.Scenes(1).Controls("id30C_stBatt")
	set MyEnum = MyCtrl.Signal.Enum
	msgbox "MyCtrl = "  & MyEnum.FindOrdinal(MyCtrl.Value)
End Sub

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Reading different kind of control value in instruction panel by VBS marco

Post by M.Heidemann » Wed 26. Jun 2024, 10:40

Hello,

as to your questions:

The Toggle-Switch Element has no "ON/OFF" boolean property,
it has a "OnValue" and a "OffValue", usally this intended to be
used in conjunction with a signal so it can set a signal depending on the state.

A button has no such property at all, it just uses "PushValue" and "ReleaseValue".

Ideally, you use them with Signals, these do not have to be part of Symbol in any way (Virtual Signals)
It makes it easier to gather their respective state depending on the signal value.

With the Instruments-Panel in Focus, press F1 and you will get the Instruments-Panel Help.

I think you should have a look first and see if this will answer your questions.

Specifically, refer to "Reference" -> "Instruments Panel Object Model"
IP-HELPFILE.png
IP-HELPFILE.png (47.75 KiB) Viewed 1292 times
Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

WillYang
Posts: 3
Joined: Wed 26. Jun 2024, 06:14

Re: Reading different kind of control value in instruction panel by VBS marco

Post by WillYang » Wed 26. Jun 2024, 11:56

Hi : M.Heidemann

Thanks for your reply, it really solved my problem!

Post Reply