NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Exchange data with TestStand from a python thread

Hello all,

 

I have a Python script, running continously in a thread, to be launched by TestStand. I also need to have a TestStand Thread to get information from this python script, without stopping it.

 

So my question is :

- How can I exchange data from Python to TestStand asynchronously?

 

Why I expect :

- Have a method to put data in a TestStand Queue from Python. The Python script will call this method each time it receive a data.

- Pool this queue in TestStand (WaitForEvent?) and manage the sequence depending on the datas.

 

Regards,

pl75

0 Kudos
Message 1 of 14
(7,579 Views)

I just happened upon this tutorial.

 

Hope it helps.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 2 of 14
(7,531 Views)

 

 

Thank you,

 

 

Thank you,

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

 

Thank you,

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

It means, not by stdout, but by a TestStand API.  

Thank you,

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

It means, not by stdout, but by a TestStand API.

 

Regards,

pl.

 

 

 

Thank you,

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

It means, not by stdout, but by a TestStand API.

 

Regards,

pl.

 

 

 

0 Kudos
Message 3 of 14
(7,523 Views)

Thank you,

Thank you,

 

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

Thank you,

 

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

It means, not by stdout, but by a TestStand API.

Thank you,

 

 

This tutorial does not include what I need :

- Passing data, during run time, from Python to TestStand without exiting my Python script.

 

It means, not by stdout, but by a TestStand API.

 

Regards,

pl.

0 Kudos
Message 4 of 14
(7,515 Views)

I'm not that familiar with python. Does it support calling into COM APIs? If so then it should be possible to pass a COM reference for something like the SequenceContext and it could then programmatically access the data. Perhaps IronPython, based on .NET, could do this when called from the .NET adapter or .NET code module.

 

Hope this helps,

-Doug

0 Kudos
Message 5 of 14
(7,503 Views)

You can use the Python for Windows extensions (http://sourceforge.net/projects/pywin32/) and use code like the following to create and Engine:

 

 

import win32com.client

tsApp = win32com.client.Dispatch("TestStand.Engine.1")
print "TestStand %s.%s ready" % (tsApp.MajorVersion, tsApp.MinorVersion)
Hope that helps

 

Message 6 of 14
(7,483 Views)

Has anyone gotten this to work? The  below two lines of code return a "Class Not Registered Error". I also tried using "TS.iEngine" as the class string, since this is what LabVIEW seems to tall the Teststand engine. In that case, I get "Invalid Class String. I am able to open a reference to Excel without any problems by replaceing "Teststand.Engine.1" with "Excel".

 

Do I need to explicitly register the Teststand Engine with Windows? Or is there an additional "Import" I need in the python code?

 

import win32com.client
tsApp = win32com.client.Dispatch("Teststand.Engine.1")

0 Kudos
Message 7 of 14
(6,787 Views)

It definitely works for me. You have to make sure that the COM Server is registered (you can use version selector to do that). You can also use ActiveXHelper (http://www.nirsoft.net/utils/axhelper.html) to make sure that the server is registered and to get the server name (search for the file description "TestStand OLE API Library")

0 Kudos
Message 8 of 14
(6,782 Views)

Thanks for the reply! The problem turned out to be that I had 64-bit python installed. I installed the 32-bit versions of python and pywin, and now it works fine.

Message 9 of 14
(6,765 Views)

Anyone have example python code for passing a sequence context from Teststand to PyWin via the TS API?

0 Kudos
Message 10 of 14
(6,738 Views)