LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

automatically lauching vi.exe to view files.

Hi!

Here is my problem:
I would like to build a kind of MDI application using Labview. I want this application (let's call it 1DView)
to be abble to open Data files "doubled clicked" by the user in the Windows File manager.
So far, I've been abble to create an exe that opens a selected file (using file extension associations and command line arguments).
The problem is that I want this application to open other files if the user selects other ones after the first one.
Once the first file has been opened, the application is
not re-launched, nor the command line re-sent by the Labview runtime engine.

So my idea is to use a "file opener" (Open1DView.exe) which updates an environment variable with the name of the fil
e to be opened then starts the 1DView.exe (dynamically loaded) then ends.
The 1DView.exe only opens Files with path found in the environment variable.
If the user double-clicks a new file, the Open1Dview.exe is re-launched, it re-updates the environment variable,the 1DView.exe sees a new file to open...

THE PROBLEM: Even if the Open1DView.exe program has ended, it is not unloaded from memory, so if the user clicks a second file, nothing happens, the run time engine does not even restart the Open1DView.exe

Is there a way to control the run time engine behavior?

How can I unload/close/kill an ended VI.exe from memory?

How can I start several occurences of the same VI.exe?

Any idea?
Thanks!

😉
0 Kudos
Message 1 of 10
(3,393 Views)
You need two apps. Associate the file extension to Open1DView.exe. When it is launched on double clicks, Open1DView transmits the file path to 1DView and exits using the 'Quit LabVIEW' function on the Application Control palette.

Transmitting path with an env. variable is a little old fashioned since you have the VI Server builtin the executable. When Open1DView is launched, it attempts a connection to 1DView own VI Server. If 1DView is running, call or Run a VI (say FileManager.vi) to transmit the path. If 1DView is not running, the VI Server connection fails then use System Exec.vi to launch it and reattemps a VI Server connection.

When in 1DView FileManager is called, it dynamically runs a FileViewer.vi for the file. To run several files, name th
e file viewer VI as a template VI (.vit extension). Every time you open a reference to FileViewer.vit, a new instance is created, named 'FileViewer 1.vi', 'FileViewer 2.vi' and so on. It is a nice touch to rename the Panel window name with the displayed file name.

I have written an artivle on this topic. See my LabVIEW Bestiary.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 10
(3,391 Views)
Hi Jean-Pierre!

It does not work, but maybe I haven't understood your explainations?
Anyway:
1- If I use a System Exec.vi to launche 1DView, it does not read my environment variables but Open1DView is well ended and unloaded.

2- If I use the Vi server, I understand you mean
a- open vi reference
b- call by reference node to directly update a control of 1DView.
then Open1DView waits for the end of 1DView and does not close.

3- If I use vi server to:
a- open vi reference to 1DView
b- run the vi without waiting for its completion
then Open1DView is not unloaded even if ended.

I currently use solution 3-: only the first file is
opened if the vi are built because Open1DView is not unloaded by the run-time engine.
I've tr
ied it ( 3- ) without building the vis, it works fine.
The run-time engine does not unload the ended vi.

Do you know an other way to pass "orders" between vi without using big stuff like datasocket.

For the "MDI" part of your answer using vit, it's ok,
but in fact my goal would rather be data merging.

Thanks for your answer, and if you have more time to spare, I would enjoy it!
😉
0 Kudos
Message 3 of 10
(3,391 Views)
When Open1DView is launched it:

1. Attemps to connect to 1DView VI Server using "Open Application Reference" set the machine name to "localhost" or "127.0.0.1"; do not leave empty. Set the port number to 1DView VI Server value. It defaults to 3363 but since LabVIEW already uses it on your machine, pick up another.
2. If connection fails, it launchs 1DView using "System Exec.vi" and reattemps a VI Server connection. Launching 1DView when it is running causes no harm and brings it panel on front so you can always do it anyway without checking the connection.
3. Opens a VI reference to FileManager.vi. With the call by reference method, FileManager.vi notify its main application that there is a file to open an exits immediately after, not
to hog Open1DView. With the Run method, set a control value on its panel and run it without waiting.
4. quits with "Quit LabVIEW". It terminates and unloaded from memory.
5. It is now ready for next double-click.

On the 1DView side:
If FileManager.vi is called, it must notify (by occurence, queue, notifier, etc.) the application that there is a file to open and exits as soon as possible. If it is run, it can run a little loger since Open1DView does not wait. But as long as it is running, it is not available to receive a new file. When the application is notified, act on the file as you wish (append to existing data, view in a new window running a .VIT, etc).

>Do you know an other way to pass "orders" between vi
>without using big stuff like datasocket.

There are:
Files: obsolete and inefficient
DDE: obsolete (Win16)
TCP/UDP: you will ha ve to write a server that waits on TCP/UPD connnections, receive file string from the client in Open1DView.
VI Server: uses TCP anyw
ay but you don't have to write server/client VIs.
ActiveX VI Server: similar functionality to Call and Run VIs to TCP VI Server, but using ActiveX

I assure you that it works. Post again if you still have problems.

Good Luck.


LabVIEW, C'est LabVIEW

0 Kudos
Message 4 of 10
(3,390 Views)
Hi Jean-Pierre.
Seems I'm more and more confused. so a few "more" questions.

1- How many independant VIs do you use (I mean not statically linked).
2- What do I do with the Application reference that I get in your 1- step?
3- How do you set 1DView.exe to use a port number befor e trying to connect to this port in your 1- step.
4-How does Filemanager.vi notify 1DView if it's not a child of 1DView? And if it is a child, how does its not running with it's father?
5- Which VI transmits the file name to be opened and how?


Thanks for your time.
Would you speak french by chance?
😉
0 Kudos
Message 5 of 10
(3,390 Views)
Thorgal,

I strongly suggest to download my sample code from my Web page at http://cybertechs.qc.ca/~jpdrolet/labview. It is almost all done here except that the file extension is not linked to an executable but to a vbscript calling ActiveX VI Server..
On the application side(1DView), all is the same. LabVIEW don't matter if a VI is called by ActiveX or VI Server.

I do speak French.


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 10
(3,390 Views)

Hi Jean-Pierre,

I'm really interested by this topic. I know it is an old one, but could it be possible to find your LabView Bestiary somewhere else ? The link above is broken.

Or do you have a new solution to solve this ?

Man thanks in advance and best regards !
Gerry

0 Kudos
Message 7 of 10
(3,128 Views)
You can find more info here.


LabVIEW, C'est LabVIEW

0 Kudos
Message 8 of 10
(3,121 Views)

Hi Jean-Pierre,

Thanks to respond so fast, but the link for the example specified in this new document is also broken.
I had already seen this document that helps me a lot.

Do you have this example somewhere else ?

Many thanks,
Gerry

--
I use LabView 7.1 on Windows 2K

0 Kudos
Message 9 of 10
(3,116 Views)
here attached. It has been a long time since I didn't run that code so continue posting if there are problems.


LabVIEW, C'est LabVIEW

0 Kudos
Message 10 of 10
(3,106 Views)