LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameters between C# and Labview with ActiveX

Hello, I've two questions:

 

I would like to know what sort of variable types can I pass into labview from C# or python, using activeX. 

I guess they would be things like, number types, strings, etc. But what about paths, or error clusters?

 

Also in labview I normally pass in objects into my subvi's (since I use OOP). How would it be possible to do this from another language? 

 

Lets say I have a self defined database object that I normally pass around in labview. Can I call some factory method vi from C#, and get the control from the front panel after running the vi. Cast that as a generic object in C#, and then call another vi, and pass in the object? 

 

Like.

 

// Get a vi reference, and run my databaseFactory vi.

string databaseFactoryPath = ...;

VirtualInstrument databaseFactoryVi = labVIEWApp.GetVIReference(databaseFactoryPath "", false, 0);

databaseFactoryVi.Run(true);

 

// Get the database labview object from the frontpanel control called "database out"

object databaseObject = (object)viTest.GetControlValue("database out");

 

// Obtain a reference to a database method called load.vi

string databaseLoadPath = ...;

VirtualInstrument databaseload = labVIEWApp.GetVIReference(databaseFactoryPath ""false, 0);

 

string parameterName = "database in";

databaseLoad.Call( parameterName, databaseObject );  

...

 

Will that work?

 

Thanks, 

labjunky

 

 

0 Kudos
Message 1 of 2
(2,807 Views)

Well my example above doesn't work 😞

 

I get an exception thrown on the line:

 

object databaseObject = (object)viTest.GetControlValue("database out");

 

"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

 

the databaseObject comes back 'null"

 

Anyone know how to do this type of thing properly?

 

thanks,

labJunky

0 Kudos
Message 2 of 2
(2,805 Views)