LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.net example

Hi,
 
currently, I am looking for an example using .NET to call LabVIEW exe/dll (or something even better that you recommend) file... When the file is successfully called, it will pass a parameter to the LabVIEW file... When the "Save" button is pressed, the parameter will be saved to SQL together with calculations done in LabVIEW (I've managed to do this part)...
 
The main problem for me is using .NET to call the LabVIEW file out, pass the parameter to LabVIEW and store the parameter as a string... A simple example would be greatly appreciated... Smiley Very Happy
 
PS: I'm totally clueless about .NET Smiley Sad (someone else is doing it but doesnt know LabVIEW)
Best Regards,

JQ

LV 8.0 user...
0 Kudos
Message 1 of 12
(5,274 Views)
anyone can help me with an example?? Smiley Sad
Best Regards,

JQ

LV 8.0 user...
0 Kudos
Message 2 of 12
(5,237 Views)
If I understand what you want correctly, you should check out the Application>>Command Line Arguments property which allows you to read the switches (there should also be an example in the example finder). Then, the other program can simply call your executable with some command line switches (the actual implementation of how to run an executable is dependant on the other language and has nothing to do with LV.

___________________
Try to take over the world!
Message 3 of 12
(5,231 Views)
Hi there.  I think what you are looking for is located here.  That KnowledgeBase contains some related links to example code and guides to call DLLs from .NET applications.

Hope that helps!
Lorielle P.
Applications Engineer
National Instruments
Message 4 of 12
(5,212 Views)
thanks tst and Lorielle for your advices... i'll take a look at the examples you guys suggested... thanks once again Smiley Very Happy ... 
 
by the way, i cannot run the examples on labview's Find Example (i am using LV 8.0) section... i've installed framework 1.1 from microsoft's website and when i run the examples, they gave me a warning sign asking me to install at least a framework 1.1 SP1... i thought is because i didnt restart my computer, but after restarting it still prompts me the error... also for some reason, i am able to run the example recommended by Lorielle... is there something i missed out besides the framework 1.1??
Best Regards,

JQ

LV 8.0 user...
0 Kudos
Message 5 of 12
(5,197 Views)

SP1 stands for "Service Pack 1". It's an update to the version you have. My guess is that you don't have that installed. In any case, I would suggest working with .net 2.0 and not 1.1.

And another "in any case", what I refered to (including the examples) has nothing to do with .net. It is simply calling an executable you built with command line switches. You just need to learn how to parse those switches.


___________________
Try to take over the world!
Message 6 of 12
(5,183 Views)
thanks tst for your suggestion Smiley Happy ... i'll go download framework 2.0 asap...
 
sorry to ask you, where is Application>>Command Line Arguments ?? i cant seem to find where is it... is it an example or are you recommending me to search the website for Application followed by looking out for Command Line Arguments ?? sorry... quite lost here...
Best Regards,

JQ

LV 8.0 user...
0 Kudos
Message 7 of 12
(5,181 Views)

It's an Application class property. When you drop a property node on the diagram (from the Application Control palette) it defaults to the Application class, so you should just be able to select that property, which outputs a 1D array of strings.

I suggest you search the example finder for "argument" to find the example I mentioned and see how to work with it.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 8 of 12
(5,174 Views)

JQ,

Tst's solution would be a good one if you build your LabVIEW application into an EXE. If you need more flexibility, I'd recommend building your VI's into a DLL, exposing a series of C functions.

Calling this from .NET requires that the caller either use managed C++ or P/Invoke (C# and VB.NET). Managed C++ is the easiest, if you know C++. If you're using C# or VB.NET, then I'd recommend checking out the P/Invoke wiki and/or picking up Adam Nathan's excellent book on the subject of interop.

Because interop between .NET and non-.NET code can be tricky, I recommend sticking with simple and easy parameters for your DLL VI's. In fact, it's often a good idea to create VIs whose sole purpose is to be the interop layer - thus they can convert between a cluster and three primative types on the connector pane.

Message 9 of 12
(5,159 Views)

thanks tst for the example and tutorials... they were useful in helping me understand the basics better... i've also attended two seminars two months ago that taught the basics... currently i've completed the 1st part of the project which is to retrieve data from sensors, calculate and store them into SQL... now the next requirement is to use .NET to call LabVIEW and pass a parameter so that when the data is saved, the parameter passed from .NET is also saved to make the saving of data unique (the parameter passed is the source from .NET as many data may be the same and can be hard to search).. stucked at this point... haha...

and also, you are right about the framework problem i mentioned earlier... i've downloaded 1.1 and not 1.1 SP1 Smiley Mad ... thanks for pointing that out Smiley Very Happy ...

thanks lycangeek... i think i'll use DLL rather than exe as the example recommended by lorielle above used DLL rather than exe... hope to figure it out somehow... researching and reading articles like mad now Smiley Very Happy ... 

 

off topic: how come i do not see people working LabVIEW with Java?? just wondering as I'm a Java based person... that is why I'm having so much problem with this .NET thing (and also, its the company's policy to use .NET Smiley Sad )... totally alien to it...

Best Regards,

JQ

LV 8.0 user...
0 Kudos
Message 10 of 12
(5,146 Views)