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 labview objects into my subvi's. 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 viTest = 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(databaseLoadPath "", false, 0);
string parameterName = "database in";
databaseLoad.Call( parameterName, databaseObject );
...
This doesn't work because an exception is thrown at viTest.GetControlValue("database out"): "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
Anyone know if it is possible to do such things? (I'm trying to get out of labview programming, but I don't want to render all my code as useless in the process.)
Thanks, labjunky
LabVIEW has an option to generate a .NET assembly itself that wraps your VIs and is callable from your .NET application. I think, this is one of the options that's often neglected by G developers when trying to use G code in .NET apps.This is the ".NET Interop Assembly" option in your BuildSpecification in the LV Project.
You can select the VIs from your project that you want to be exposed for calling in your .NET application (I think, it can generate for LVOOP vis also); generate the .NET wrapper assembly; and then use this wrapper assembly to interface with the LabVIEW code from your .NET app.
Of course, if the types are basic, then while selecting the VIs, it automatically configures the function signature. I'm not sure, if the references/handles can be passed around seamlessly between the .NET/LabVIEW boundary. But, I'm sure its faster for you to write a integer/string-to-LVObject-map in LabVIEW side, and then use the common type to refer to them across the boundaries, than to re-write all the code in a .NET language.