LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call compiled LabView from Delphi

Argh!  I've done this already, but try as I can, I can't remember how, nor can I find my simple example!

I have a Delphi program that needs to communicate with my LabView app.  The LabView app will be compiled into a standalone executable using the LabView (V7.1.1) Application Builder, as the target machines will not have LabView installed; hence, I can't take the approach of automating LabView.

For discussion purposes, the LabView app has a string control and a "go" button as controls, and a string indicator for indicators.  The Delphi client supplies an XML fragment as a text string to the LabView app's string control, then "hits" the go button.  The LabView app then processes the XML fragment, and outputs the results to the string indicator.

The LabView app is contained in a VI that has the aforementioned controls and indicator as input and output terminals, and has been compiled into an application with the "Enable ActiveX server" option selected.  The Delphi app is built using Delphi 2007 for Windows.
  1. How exactly do I import the LabView app into the Delphi programming environment?  I've tried many things, have gotten close, but I'm not sure if I've got it right.  I can connect to the LabView app, in that running the Delphi app starts up the LabView app, but I can't access the VI's controls or indicators.
  2. How do I access the VI's controls and indicators from Delphi?
  3. How do I simulate a button press?
This is very frustrating, as I had prototyped this six months ago!

Thanks for any help!
-Bob
0 Kudos
Message 1 of 4
(3,423 Views)
Okay, I figured out some of this, I think.  Specifically, I was able to import the LabView app as a component.  I can get the Delphi app to load the LabView app, and later quit it, but this is about it. The problem now comes down to how I interact with it. This is some code that I adapted from an old LabView example for automating LabView from Delphi.
... var   Form2: TForm2;   ParamNames,ParamVals : variant;   newapp: TApplication;   vi: Variant; ... ParamNames := VarArrayCreate([0, 2], varVariant); ParamVals := VarArrayCreate([0, 2], varVariant); ParamNames[0] := 'StringEntry'; ParamNames[1] := 'Add'; ParamNames[2] := 'LastEntry'; ... newapp.Connect; vi := newapp.GetVIReference('Dummy.vi');   // VI's file name is, indeed, 'Dummy.vi' ParamVals[0] := 'Hello'; ParamVals[1] := True; VI.Call(ParamNames, ParamVals);
The VI.Call() gives me an OLE exception "The VI is not in a state compatible with this operation".  Meanwhile, the LabView app has started and is hanging around in the background, until the Delphi app quits, which kills the LabView app, as designed - this part works fine! What am I doing wrong? Thanks! -Bob
0 Kudos
Message 2 of 4
(3,406 Views)

Hi Bob,

You can use LabVIEW as an ActiveX Server, and thus expose properties and methods to ActiveX client applications, such as the Delphi app you're referring to.  You can read and write front panel controls/indicators through the LabVIEW ActiveX Server interface, and it seems like this is what you are looking for. 

I'm not aware of a way to insert a LabVIEW front panel into an ActiveX container in another application, but even if you could, you would still need to use the ActiveX Server interface to actually access the data by the rest of the Delphi program.

The LabVIEW application doesn't even need to display the front panel, but can instead be called by the Delphi program, run in the background, and be polled/updated when needed by the Delphi application.

Donovan
0 Kudos
Message 3 of 4
(3,385 Views)
Hi Donovan,

@donovanb wrote:

Hi Bob,

You can use LabVIEW as an ActiveX Server, and thus expose properties and methods to ActiveX client applications, such as the Delphi app you're referring to.  You can read and write front panel controls/indicators through the LabVIEW ActiveX Server interface, and it seems like this is what you are looking for.

Yes, that is exactly what I am looking for!  Right now, I can only "see" a few, very generic methods, such as the GetVIReference() function in my second post.  What I don't get is what to do with my "newapp" variable; how to I access the front panel controls and indicators?

Looking back at my second post, it seems the VI.Call may not really be the right thing to do, is that right?  I have demonstrated to myself that the newapp.Connect call starts the LabView app - so then, I suppose the VI.Call is illegal, as the VI is already started - is that correct?

So I'm guessing that, after newapp.Connect, all I need to do is read/write the front panel controls/indicators, right?

But how?!!!

I'm not aware of a way to insert a LabVIEW front panel into an ActiveX container in another application, but even if you could, you would still need to use the ActiveX Server interface to actually access the data by the rest of the Delphi program.

That would be cool, but not necessary.  Probably, I'll end up bringing the LabView app to front, and just using its front panel as is.  That said, if someone know how...

The LabVIEW application doesn't even need to display the front panel, but can instead be called by the Delphi program, run in the background, and be polled/updated when needed by the Delphi application.

That's the other possibility...


Thanks!
-Bob
0 Kudos
Message 4 of 4
(3,382 Views)