Multiple Instances of LabVIEW

From LabVIEW Wiki
Jump to: navigation, search

The preferred approach is to add the following ini key into the labview.ini file:

allowmultipleinstances=True

In a custom executable ini file this would be:

[MyApp]
allowmultipleinstances = TRUE

Keep in mind, multiple instances of an application may require some special considerations, like deciding if you need them to read/write to different data files and talking to different hardware.

Synchronization issues

When communicating between VI's that are running in the LabVIEW development environment, they both belong to the same process. When you build the VIs into executables, each executable becomes its own process. So for example, any Queue or Semaphore references created inside one executable is meaningless inside the other executable. In the case that you only build one VI into an executable and run the other VI in the LabVIEW development environment, the same holds true, you are still dealing with two separate processes.

Other Methods

Windows:

You have to do this little trick. Create a new drive letter that maps the LabVIEW installation directory as a drive letter. From a command prompt, use the SUBST command to create a new drive letter ("L" in this case):

C:\> SUBST L: "C:\Program Files\National Instruments\LabVIEW 7.0"

You can now launch your new "instance" of the LabVIEW Development Environment by running the command:

C:\> L:\LabVIEW.exe

Or, you can launch the new instance of LabVIEW by double clicking on the LabVIEW.exe application icon inside the F:\ drive in Windows File Explorer.

When you are finished using your new instance of the development environment, delete the new drive mapping by entering the SUBST command with the /D switch:

C:\> SUBST L: /D

Note that you can run as many instances of LabVIEW as you can create drive letters.

[quote=Help printout for the SUBST command]Associates a path with a drive letter.

SUBST [drive1: [drive2:]path] SUBST drive1: /D

drive1: Specifies a virtual drive to which you want to assign a path. [drive2:]path Specifies a physical drive and path you want to assign a virtual drive. /D Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.[/quote]

Linux:

In Linux you get a new instance of the LabVIEW development environment each time you run the LabVIEW executable , unless you pass the "-launch" command line argument. For example:

$ /usr/local/lv70/labview -launch

[quote=Help for the -launch command-line argument on UNIX/Linux plaforms]LabVIEW launches and checks for an existing instance of LabVIEW already running on the same display. If an existing instance is running, the existing instance opens the VIs passed in the command line, and the new instance of LabVIEW quits silently. If an existing instance is not running, LabVIEW opens the VIs passed in the command line in the new instance.[/quote]

One problem when running instances from mapped directories is that the same labview.ini file is used for all instances so that can cause conflicts. It is better to specify a different ini file using the -pref command line switch. The method is best implemented when launching LabVIEW with a batch file, with commands that maps the directory/drive, launch LabVIEW with ini file and eventually unmap directory after LabVIEW exits.

Also

Under Windows (and I assume other OSes as well) you can map a new network folder with a target of LabVIEW.exe in that attached to an icon on your desktop. I use this all the time to run two or three instances of LabVIEW for debugging and also to compare versions of a code tree without danger of mixing the paths to VIs.

Example:

  1. Open Windows Explorer.
  2. Menu: Tools >> Map Network drive...
  3. In Map Network Drive Dialog: Select a new drive letter (something hight like j:
  4. Browse Button -> to your .\LabVIEW\ folder
  5. Check Reconnect at Login
  6. Press Finish
  7. Go to the new J: folder in Windows Explorer, right click on LabVIEW.exe and create a shortcut for your desktop. Label it "LabVIEW x.x Instance N"

Now each time you start up your machine you have multiple instances available. You can even copy-Paste code snippets in between, by saving a Copy-Paste VI.vi in your temp directory and copy to it, save (in Instance 1), then close and open in Instance 2. Otherwise the memory spaces are completely separate.

See also