LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Labview front panel from python

I have a requirement where a piece of python code needs to update graph(xy) and string indicator on labview. The python code is called using LabPython toolkit. But is there a way from python to update the labview controls and indicator using ActiveX? Since my python app will run for several minutes before completing the task, it would be nice to update the progress on the labview application. Has anyone done this before?
0 Kudos
Message 1 of 11
(4,864 Views)
> labview controls and indicator using ActiveX? Since my python app will
> run for several minutes before completing the task, it would be nice
> to update the progress on the labview application. Has anyone done
> this before?

I think people have done this before, but not me personally. The
ActiveX interface allows you to specify a value change on a particular
set of controls by writing name/value pairs to the SetControlValues or
something similar. If you have a way to invoke the ActiveX method, then
that should get you there.

Greg McKaskle
0 Kudos
Message 2 of 11
(4,863 Views)
I found out how to do this. He is how you can access labview from python..

>>> import win32com.client
>>> labview = win32com.client.Dispatch("Labview.Application")

Once you have the object, then get a reference to the VI and then you can read or write to a control

VI = labview.getvireference(r'VI path')
VI.setcontrolvalue('control','value')...

It works. Its pretty simple. The various activex properties and methods are available in labview\help\axprop.chm (or axprop.hlp)

Anand.
0 Kudos
Message 3 of 11
(4,864 Views)
Is this also possible with a labview exe program?

I tried this:
import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'python.vi')
VI.setcontrolvalue('Numerisch','5')

and it works fine. But when i replaced the python.vi trough a compiled python.exe i get this errormessage:

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<COMObject Labview.Application>", line 2, in getvireference
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (5507, 'LabVIEW', 'LabVIEW :LabVIEW:  Datei nicht gefunden. Die Datei wurde eventuell verschoben oder gel\xf6scht, oder der Dateipfad wurde bez\xfcglich Ihrer Plattform nicht korrekt formatiert. Beispiel: verwenden Sie \\ als Pfadseparator auf Windowsplattformen, : auf Macintosh u', None, 0, 0), None)

Is it possible to updating a labview exe front panal from python?

regards

marcel

0 Kudos
Message 4 of 11
(4,646 Views)

Hello,

If you build your exe with the option to include the activeX server, then you'll be able to change the value of and access front panel controls and indicators using ActiveX.  The interface is what you're used to from VI Server for accessing VIs in the LabVIEW development environment.

The following document describes this in more detail and provides an example using Visual Basic:

Title: Calling LabVIEW Applications from Visual Basic Using ActiveX

URL: http://digital.ni.com/public.nsf/websearch/862567530005F09E86256843004469C8?OpenDocument

I hope this helps!

Best Regards,

JLS

 

 

Best,
JLS
Sixclear
0 Kudos
Message 5 of 11
(4,628 Views)
Hello JLS

Thanks for your answer.

Because i didnt get an answer i oppened a second tread:

http://forums.ni.com/ni/board/message?board.id=170&message.id=199564

Activex server is on. But I still doesnt work with the exe.

Because I dont have VB I couldnt find any solution

regards

marcel

0 Kudos
Message 6 of 11
(4,609 Views)

Hello,

Is it that you're having problems with ActiveX in Python?  If you can get the ActiveX API on Python's side to work (with any ActiveX server), then you should be able to apply that same kind of programming to access the LabVIEW exe - I'm sorry, but I am not familiar with Python so I can't provide you more specific information from that end.

Definitely repost and hopefully we'll get to the bottom of it!

JLS

Best,
JLS
Sixclear
0 Kudos
Message 7 of 11
(4,590 Views)
 Hi JLS

Thank you for your help. Now it works. The Solution:

import win32com.client
labview = win32com.client.Dispatch("Python.Application")
VI = labview.getvireference(r'c:\temp\python.exe\python.vi')
VI.setcontrolvalue('Numerisch','5')

Kind regards

Marcel
0 Kudos
Message 8 of 11
(4,552 Views)

How to read it?

 

I tried with VI.readcontrolvalue("Numeric")

but its not working..

 

 

0 Kudos
Message 9 of 11
(3,854 Views)

sorry, I got it

Its VI.getcontrolvalue('Numeric')

0 Kudos
Message 10 of 11
(3,846 Views)