ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

niveristand-python: Use a ChannelReference as parameter

Hello all,

 

I am currently working on a project using NI VeriStand 2021 R2, doing some RT measurements using niveristand-python.

The task is to measure the on-duration of several analog input channels of a PXI system.

 

To make my code reusable I am searching for a way to set the input channel as a parameter of the function that is calculating the on-duration.

As far as I understand, I would need to set a ChannelReference as a parameter...By now I was not sucessfull.

 

Does anyone have some suggestions for this?

 

 

Thank you!

 

PS: attached is some example python code that is working but using a fixed channel

0 Kudos
Message 1 of 8
(4,009 Views)

If you want to reuse the python script on different VeriStand projects, you should configure all those VeriStand projects to have the same channels name.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
0 Kudos
Message 2 of 8
(3,986 Views)

Well, ok...

 

But how can I handle different channels in the same VeriStand project without hard-coding them into the python module?

Any ideas?

 

Thank you.

0 Kudos
Message 3 of 8
(3,981 Views)

You can use the user channels. Hard code the user channel name in the python script, then change the mapping in VeriStand project as needed.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
0 Kudos
Message 4 of 8
(3,976 Views)

Thank you @ZYOng for your reply.

 

I know I can also go with the user channels. But hard coding is not the solution I am looking for.

However, it seems there is no other way for handling this problem.

0 Kudos
Message 5 of 8
(3,937 Views)

Hello ... Did you ever find a workaround for this ... I am trying to do the same thing but the Python implementation for Veristand is very limiting as well as incredibly non-pythonic.

 

Thanks

Randy

0 Kudos
Message 6 of 8
(2,802 Views)

Hi,

 

yes I found a workaraound.

I wrote a small python script that modifies the real time sequence file (it's an xml file). It changes the Default Channel to the channel I want to test.

I am then calling this script cyclically from within a TestStand sequence.

 

Regards

Johannes

0 Kudos
Message 7 of 8
(2,792 Views)

Do you mean you are changing the 

<Channel Path="Hardware/Truck_Hardware_Aliases_3WS/CAN1_state" />
based on the 
<Identifier>ch_can1_state</Identifier>
 
There has to be a better way.
 
Within TestStand they use the concept of FileGlobals, I am trying to figure out the equivalent in the Python implementation.
0 Kudos
Message 8 of 8
(2,271 Views)