LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling a labview executable from vb.net

I would like to control a labview executable from vb.net. I have seen some examples but they are outdated code or do not apply directly.

I would like to launch a labview executable from vb.net. The executable will establish communications with an instrument via tcp/ip and then wait for instructions from the vb.net program. I could use activex or whatever is appropriate. I am unfamiliar with saving the labview vi as an activeX server or .dll. I believe it needs to be an executable in order to launch and establish communications with the instrument but I could be wrong.

Does anyone know of some sample code that I could look at?

I am running Labview 6.0.2 and Ms .net framework 1.0

Thanks!
0 Kudos
Message 1 of 9
(4,363 Views)
There are a few solutions I can think of.

1. Use the LV ActiveX Server interface to load and run individual VI's as you need them. This allows you to pass data to the VIs and get the output data back.

2. In a similar form, but easier to integrate with VB.NET is to use the LV AppBuilder to turn the VIs into a DLL rather than an EXE. You can then use the DllImport command in .NET to call this "C" style DLL.

3. If the LV code must be turned into an EXE, you will need to create a TCP protocol. The LV application would come up and open a port to listen to. Your VB.NET would then send custom commands to it over TCP/IP.
0 Kudos
Message 2 of 9
(4,340 Views)
I am unfamiliar with calling DLL's or ActiveX servers so I have some questions. I need my labVIEW program to open communictions with the instrument and stay open. Can this be accomplished with dll's or ActiveX server? My understanding is that they almost work like functions that you execute once. I need the program to open, establish communications with an instrument, remain open and communicate with VB.net. Clarification would be greatly appreciated.

I have determined that I can run an executable from VB.net with the shell command. My plan is to use the shell command and run the executable. In labview I would set up an ActiveX control and then try to communicate with it via vb.net. I have not given this a try yet.

I thought about the tcp/ip communication but it seems that there should be an easier way since both programs are running in windows on the same machine.

Thanks for your reply. Any further info would be appreciated.
0 Kudos
Message 3 of 9
(4,325 Views)
*WARNING* - I'm a developer "in" LabVIEW, I don't develop with LV, so there are probably better examples or suggestions out there. You might want to post another question under the heading like "simple tcp server example" to catch the eye of the non-.NET LV programmers.

----

There are often easy ways to communicate between two programs IF the programs have been written in the same language (for example, Java, COM and .NET all have remoting technology, but they don't work across the languages - only within the language).

Also, you can't set up an ActiveX control inside LV that the VB.NET app can get to. The ActiveX controls in LV are created inside of LV and not accessable through the network. They are also usually meant for displaying addition pieces in the VI's front panel (like an IE browser window).

It also sounds like you are going to issuing control statements from the VB.NET application to the LV app, and data from LV to VB.NET. In this case I would recommend going with the TCP/IP protocol as it is the most common denominator between VB.NET and LabVIEW. LV would open up a port and sit and listen for incoming requests. When it gets a request, it would then go off and process the "command", returning the data back through TCP. Take a look at the simple LV TCP examples to get the idea - focus on the simple ones as complex examples are a lot more than you need to get started.

A word of warning: beware of using LV routines to "flatten" data as the flatted data is a special LV encoding and VB.NET won't know what to do with it. Just use the standard "Numeric to String" or "String to Numeric" type of formatting nodes.
0 Kudos
Message 4 of 9
(4,317 Views)
Thanks Brian. I was just about to try the activeX control so you saved me some time. I will try the tcp/ip communication. I have some familiarity with it and it seems relatively simple.

The other option that I thought of is to have a common text file that the two programs can access. Each would read the info in the text file that was placed there by the other program. I could have tcp/ip to trigger the two programs so that each will know when to read the file. The file could contain lots of data and the tcp/ip communications would simply be a trigger to read/write the data from the two programs.

Thanks for your help.
0 Kudos
Message 5 of 9
(4,309 Views)
If indeed the two apps are on the same machine (or can access the same file on a network share) and there are only just the two of them, using a file for data transfer is a good approach. Depending on the data, you might want to think about writing to a spreadsheet or CSV file. Both LV and .NET have routines to make reading those easier.
0 Kudos
Message 6 of 9
(4,300 Views)
FYI, The one time I needed to have a VB executable communicate with a LV executable, I used Data Sockets to pass data between the two. This worked out well. If this sounds like something you need more info on, please let me know & I can provide more details.
0 Kudos
Message 7 of 9
(4,297 Views)
BEHajder:

I am interested in using data socket. I have used it before between two labview programs and it works quite well. I'm not sure how to access data sockets with VB.net.

Any help would be appreciated.
0 Kudos
Message 8 of 9
(4,279 Views)
Hi mjcibulk,

If you want to use DataSocket from VB.NET or other environments, you should access the DataSocket Server using ActiveX. I will recommend you to refer to the "DataSocket Help" found in "Start >> All Programs >> National Instruments >> DataSocket" directory. In this documentation, you can get an overview of the ActiveX API of DataSocket. Here's a screenshot of the DataSocket API:



Have fun!

Message Edited by Philip C. on 06-21-2005 12:36 AM

- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 9 of 9
(4,274 Views)