Code Monkey home page Code Monkey logo

python_labview_automation's Introduction

Python LabVIEW Automation (labview_automation)

Python LabVIEW Automation labview_automation is a Python package to make it easy to call LabVIEW VirtualInstruments (VIs) from Python. It includes a Pythonic interface to call VIs and a class to interact with LabVIEW executables on Windows.

To facilitate this interaction LabVIEW is started with a VI that listens for tcp messages. The Python interface sends BSON (see bsonspec.org) encoded messages to the VI which then performs the commands.

LabVIEW can be started on a remote machine using hoplite. Since the interface between Python and LabVIEW is tcp the messages can be sent to another machine.

Note on Security

Python LabVIEW Automation opens a TCP port and does not have any secure protocols currently implemented.

Support

Python LabVIEW Automation is not supported by National Instruments.

Installation

This package depends on hoplite. First install hoplite. When/if hoplite is added to PyPI then this manual step will not be needed.

labview_automation can be installed by cloning the master branch and then in a command line in the directory of setup.py run:

pip install --pre .

Simple Local Example

You can set controls on the front panel of the VIs that you execute by adding members to a dictionary where each member represents a different control of the given name. Controls can be numerics, strings, booleans, arrays, or clusters of the same types.

run_vi_synchronous runs the VI synchronously and returns a dictionary of all the indicators on the VI.

from labview_automation import LabVIEW
lv = LabVIEW()
lv.start() # Launches the active LabVIEW with the listener VI
with lv.client() as c:
    control_values = {
        "DBL Control": 5.0,
        "String Control": "Hello World!",
        "Error In": {
            "status": False,
            "code": 0,
            "source": ""
        }
    }
    indicators = c.run_vi_synchronous(
        vi_path, control_values)
    print(indicators['Result'])
    error_message = c.describe_error(indicators['Error Out'])
lv.kill() # Stop LabVIEW

Development

All LabVIEW code is developed using LabVIEW 2014 SP1 x86.

Pull requests for Python code should adhere to PEP8.

License

The MIT License (MIT) Copyright (c) 2016 National Instruments

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

python_labview_automation's People

Contributors

neilvana avatar noc0lour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python_labview_automation's Issues

ConfigParser is missing

Whenever I try to run the default script on Mac OS (LV properly installed), python does not seem to find ConfigParser.

Support for LabVIEW Objects

Attempting to use this with LabVIEW Objects results in a message complaining that the control or indicator cannot be converted to BSON. Is there a way to fix this? E.g. could we serialize objects into opaque binaries, and later convert binaries back into objects?

synchronous selected indicators

When I use 'run_vi_synchronous' can I synchronous only selected indicators? Because a lot of my indicators are 2D arrays which are not supported for converting to a BSON document...

TCP Connection will auto close

Python Code:
from labview_automation import LabVIEW

vi_path = 'C:\Users\Administrator\Desktop\add.vi'
lv = LabVIEW()
lv.start() # Launches the active LabVIEW with the listener VI
with lv.client() as c:
control_values = {
"a": 2,
"b": 5
}
indicators = c.run_vi_synchronous(
vi_path, control_values)
print(indicators['c'])
#error_message = c.describe_error(indicators['Error Out'])
#lv.kill() # Stop LabVIEW

LVAutomation Listener:
[2019/3/29 9:17:52] (GUID - 5c9cad606465322594000008) Command received.

Message: {
"run_options" : 0,
"indicator_names" : [],
"control_values" : {
"a" : 2,
"b" : 5
},
"vi_path" : "C:\Users\Administrator\Desktop\add.vi",
"command" : "run_vi",
"open_frontpanel" : false
}
[2019/3/29 9:17:52] (GUID - 5c9cad606465322594000008) Command sent successfully.

Message: {
"c" : 7.0000000000,
"RunVIState_Status" : false,
"RunVIState_Code" : 0,
"RunVIState_Source" : ""
}
[2019/3/29 9:17:52] (TCP Connection-5c9cad606465322594000008) Lost

Python Shell:

lv.client().run_vi_synchronous(vi_path, control_values)

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
lv.client().run_vi_synchronous(vi_path, control_values)
File "D:\Python\Python27\lib\site-packages\labview_automation\labview.py", line 175, in client
raise NotStartedError("You must start LabVIEW to get talk to it.")
NotStartedError: You must start LabVIEW to get talk to it.

Working with python 3

Will there be any support for python 3? It is giving me errors when python 3 imports the ConfigParser and _winreg modules, it is giving me module not found error. I realized that the names are configparser and winreg in python 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.