Problem mit Python und LabVIEW via ActiveX & win32com

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Martin
User
Beiträge: 3
Registriert: Freitag 24. Juni 2005, 14:13

Folgendes Problem:

Die Übertragung der Parameter beim aufruf der "Call" methode funktioniert nur in eine Richtung (Python -> LV).
In die andere Richtung werden die Daten nicht verändert.

-------------
oViTest = oLv.GetVIReference(strVi,"",True) # get reference to LabVIEW VI

bError = True # preset bool before call
strResult = "" # preset string

arParNames = ["strEntry","strOutput","bError"] # first and second are strings, third is bool
arParVals = ["Hello World", strResult, bError] # the 3 parameter values

oViTest .Call(arParNames,arParVals)

# hier nach dem call ist die Liste arParVals nicht geändert, sollte aber sein.
-------------------------
Aus LV-Doc
paramNames : array of strings by ref (Names of the front panel objects that act as input and output parameters to the call).
paramVals: array of variants by ref (Input values for the input parameters and return values from the output parameters in the order in which the names were specified in paramNames)

Der "strResult" und "bError" sind nach dem call nicht geändert.

Hat schon mal jemand dieses Interface zu LabVIEW genutzt ?
Welcher Python Typ soll verwendet werden damit Python ihn in ein "array of variants by ref" wandeln kann ?

BTW: ich verwende "Static Dispatch" mittels makepy.

In anderen sprachen funktionierts (VBScript, JScript)

Danke im Vorraus
Martin
CM
User
Beiträge: 2464
Registriert: Sonntag 29. August 2004, 19:47
Kontaktdaten:

Besser spät und wenig als gar nicht ...

Hallo Martin

vielleicht hast Du den Thread von John gelesen. Jedenfalls hat er sein Problem gelöst. Er hat - wie man ja weiter unten im Thread lesen kann - anderswo gepostet und dort berichtet. Dem würde ich mal nachgehen und ihm ggf. direkt anschreiben, auch wenn es schwierig werden dürfte nur mittels "privater Nachricht".

Tut mir leid, mehr habe ich nicht in petto, aber vielleicht brachte es ja etwas Dich darauf aufmerksam zu machen - ansonsten antwortet ja scheinbar niemand.

Gruß,
Christian
Martin
User
Beiträge: 3
Registriert: Freitag 24. Juni 2005, 14:13

Hier ist die Lösung:

siehe auch
http://mail.python.org/pipermail/python ... 03477.html

Martin
> It doesn´t work with the following code:
...

> "D:\Python24\Lib\site-packages\win32com\client\makepy.py",
> line 306, in GenerateChildFromTypeLibSpec
> __import__("win32com.gen_py." + dir_name + "." + child)
> ImportError: No module named _Iapplication

That is probably a bug related to tracking down dependent typelibs. Maybe you could add an entry at sourceforge?

> But now I ran into another problem.
> There is no data coming back from LabVIEW via the Call method.
> The arParVals List is unchanged after the call. Normaly the last two
> elements should held the result of the VI call.
> In the other directon it´s working, I´m able to see the string "Hello
> World" in LabVIEW.

Note that in Python, "out" values (including in-out) are always *returned* from the function. Thus you probably want something like:

rc, newVals = oViTest.Call(arParNames,arParVals)

where 'rc' is whatever 'Call' returns - or, if 'Call' has no return value (ie a 'void' function, or 'procedure'), simply:

newVals = oViTest.Call(arParNames,arParVals)

Mark
Antworten