Jump to content

TestScript: Free Python/LabVIEW Connector


Recommended Posts

https://www.winemantech.com/blog/testscript-python-labview-connector

From release blog...

Summary: Test engineers typically add manual-control screens to LabVIEW applications. While it would be helpful to repetitively execute varying parts of those manual-control screens, LabVIEW is not optimal for dynamic scripting, or on-the-fly sequencing with flow control.  (Imagine editing the source code of Excel each time you wanted to create a macro.)  And while Python is built for scripting, it requires advanced custom coding to interface with LabVIEW. 

Announcing TestScript: a free Python/LabVIEW connector from Wineman Technology that is simple to add to your existing LabVIEW application and abstracts complex Python coding,  allowing you to easily use Python to control LabVIEW or vice versa.

  • Like 2
Link to comment
  • 3 months later...

TestScript is written in Python 3.  If you are looking at calling Python 2.7 modules from LabVIEW, this is what Enthought's tool does (at present, anyhow).  TestScript enables you to use simplified Python 3 scripts to control a LabVIEW application or use a LabVIEW application to run and get results from a Python 3 script.  Because we've defined the Python-to-LabVIEW interface internally, scripts can literally be one line:

myVoltage = xDMMRead()

We can do this since, with comments and whitespace, TesScript contains 3,000 lines of Python code under the hood.  Can you write in Python 3?

And it's free.

Link to comment

For clarity:

Currently:  The Enthought Python Integration Toolkit for LabVIEW lets you "Call Python functions directly from LabVIEW, and pass arrays and other numerical data natively" in both Python 2.7 and 3.6, is available for sale at ni.com, includes the Canopy development environment, and from what I understand helps solve some deployment headaches (e.g. Python packages).

The Python node that got released with LabVIEW 2018 lets you call Python functions from LabVIEW in Python 2.7 and 3.6.

TestScript is a free tool that lets you use LabVIEW to run Python 3.x scripts (that call Python functions) and retrieve the results back in LabVIEW ***and also*** lets you launch a Python script from your LabVIEW application that calls LabVIEW functions (that you expose from your application) from Python (e.g. to automate your LabVIEW manual control screen behavior on-the-fly:  flip relay, acquire data, log data, repeat overnight).  Examples included.

Link to comment

I haven't head of TestScript before.  Sounds interesting.  But I have tried both the Enthought toolkit as well as the LabVIEW Python Node.

I've been majorly impressed with the Enthought toolkit.  I've passed fairly large data to/from Python and the performance has been pretty great.  And it certainly does solve some deployment headaches.  It has a building mechanism that is able to generate a self-contained python environment with only required libraries for running your code.  You can copy/paste this environment directly onto a deployed machine and it will run!  No need to install and configure a python environment from scratch for every deployed machine. 10/10 recommend

Link to comment

That's great insight.  At the end of the day, the Enthought toolkit and the LabVIEW 2018 Python Node are optimized for directly calling Python functions from LabVIEW.  Pretty cool.

TestScript is optimized for running Python scripts from LabVIEW which can call Python functions or custom LabVIEW functions.  If you return values (scalars or arrays) back to LabVIEW at the end of a script, they are returned as a string.  Example script we include (where we pass an array of numbers as a script argument when launching it from LabVIEW):

---

# Use list comprehension to create a list of floats to sum up.
addends = [float(i) for i in locals()['arguments']]

script_update(str(sum(addends)))

---

Since you're familiar with the tools, I'm interested in your feedback if you get a chance to checkout TestScript.  Just email testscript@winemantech.com to connect!

Jason

Link to comment

That sounds indeed like a gap-matching tool when it comes to calling LabVIEW code from Python!

I am urged to try it out ASAP, as I see that romance between LabVIEW and Python has already started, but still misses the spark. TestScript indeed promises a lot to kindle up this fire. 

Link to comment

I agree:  WYSIWYG DevX and parallelized UI, control, DAQ, and logging meets a readable, exploding, scientific text-based sequencing environment!

TestScript lets you expose any number of LabVIEW actions (flip relay, read DMM, turn on power supply, etc.) and call those directly in your Python script:  xFlipRelay(), xReadDMM(), xPowerSupplyOn().  We recommend having, for example, the front panel button that flips your relay call the same code as the corresponding Python function.  This way, the code behaves identically whether it's being called via manual control screen or Python script.

Please check out the examples, and reach out with product ideas!  We're already folding TestScript into our own projects and loving it.

Jason

Link to comment
  • 4 years later...

Now that we're Genuen, here's a new link to TestScript.  The download has been updated to include a simplified example (Scripting Example.vi) and a PDF you can share with your colleagues who may be skeptical about using Python and LabVIEW together. 

-------

Notes:

You can run multiple python scripts simultaneously.

TestScript has two fundamental parts that can be run on separate PCs:

  1. LabVIEW server
  2. Python server

You generally start the Python server from within your LabVIEW application (see aforementioned example), but you can also launch it via the command line on the target machine like this:

  • python TestScript_gui_and_exposed_functions.py [LabVIEW server IP address] [port 1] [port 2] [port 3]
  • python TestScript_gui_and_exposed_functions.py localhost 9007 9008 9009

Python scripts must be instantiated from the LabVIEW server (vs. something like PyCharm or the command line) --> so, while it does not feature “launch script from somewhere else” functionality at this time, you can send back script updates to your UI so you can see status (see example).

Edited by Bean
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.