Jump to content
Bean

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.