LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to turn my VI from a "web server" into a "web file server"

I have a VI that samples and saves data in xml format to the local drive whenever the user presses a virtual button in the from panel. 

The same VI is now working as web server, it samples a waveform for 2 seconds and saves tha data into a local file.  I need to save the waveform data not in the local drive but in the terminal where the remote connection was started.   How can I publish files in my web server to be downloaded on request by remote clients?

Any advice will be appreciated.

Erik Vargas



Message Edited by Erik-QCT on 03-17-2008 12:21 PM
0 Kudos
Message 1 of 8
(3,760 Views)

Hey Erik,

Funky question!

Are we assuming that your 'terminal' PC can't have direct network access to, for example, shared Windows folders on the machine where the 'main VI' runs? Then the VIs could access that shared folder as if it was on the local machine.

Is it possible to set up an ftp server on the main VI's machine and have the remote client VIs automatically grab any files available from the ftp server? There are several ftp VIs available in the Internet Toolkit.

Those are 2 ways, but if neither are possible there must be loads of others. Have you thought of e-mailing the files off the main PC?

Cheers,

Mark Lee

Certified LabVIEW Architect
0 Kudos
Message 2 of 8
(3,754 Views)
Hi Mark,

Thanks for you suggestion, however the station where my web server VI is running has not access to "network drives" or any Windows shared folders that the remote clients can reach.
The web server should run as a stand alone application without imposing any requirements on the clients but a web server to download the sampled data.  Do you know how to include "links" in the front panel that point to local files or other http/ftp sites? 
0 Kudos
Message 3 of 8
(3,747 Views)

Hey Erik,

Thanks for the clarification. As I understand it, when the web server is turned on in LabVIEW, any file that is saved under the web server root directory, which in the default case is:

C:\Program Files\National Instruments\LabVIEW 8.5\www

Will be 'served' up by the web server upon request on whichever port the web server is working on (by default port 80).

Therefore, if you save your files on the 'main' machine to this directory, you should be able to see them when you browse to your main machine on another PC (using say Internet Explorer). For example, on a local network if the web server is running on 'main' PC with the IP address 192.168.0.1, you should be able to see a directory listing of the folder (above) and download the files within if you browse to:

http://192.168.0.1/

(although your browser may keep picking up the index.html automatically!)

If you want your remote VI to be able to download and/or view these files, you can use the Datasocket Read VI, pass it the URL to the file you want, tell the Datasocket Read VI to retrieve a string and retrieve the xml file(s) that way.

BEWARE that if you're downloading a text file in this way (and I assume this is the same for .xml) - you may need to add [text] to the end of the URL.

Please see the attached screenshot for how I did this on my PC here (with the web server on the same PC 'localhost' - the same should work across your network if you substitute your main PC's name where I've put localhost:8080). The file I was aiming to download is called rest.html. Once the string is in your 'remote' VI obviously you can save it, display it on the front panel, do anything you want with it!

There is loads more info on which file formats the Datasocket VIs can download (and how) at this board:

http://forums.ni.com/ni/board/message?board.id=180&message.id=33766&query.id=149985#M33766


Hope that gives you something to get going with!

Good Luck!

Mark

Certified LabVIEW Architect
0 Kudos
Message 4 of 8
(3,738 Views)
Hi Mark,

Sorry for the misunderstanding... at the "client" site the only tool available is a web browser (i.e. firefox) not a web server. 

What I want to do from the "server side" is to enable a link or a button in the front panel when the excel file is ready to be downloaded by the client.  When the "remote client" clicks on the button, the browser should prompt the user to choose the location where to save the file (as shown in the picture).  I'm not interested in showing the content of the xls file in the front panel but rather to trigger the "save as" window at the client's browser so the transfer can begin.


Any hints?







0 Kudos
Message 5 of 8
(3,724 Views)

Hey Erik,

Ah I see what you mean Smiley Surprised

I think what you're suggesting is pretty difficult - if not impossible. The embedded Front Panel is its own ActiveX object, so doesn't expose anything 'clickable' to the remote browser that would trigger the save dialogue.

There are 2 ideas I have - neither are that easy.

1) Is if you can get your application to open an ActiveX reference to the remote browser (ie the application viewing it on the remote machine) you could potentially use ActiveX methods to trigger a save dialogue that way. This is tricky (you would have to find the remote browser's IP address and ensure the correct port(s) are open), and you may have to cope with viewing in different browsers.

2) You could get LabVIEW to add an HTML tag into the file which servers up the application's front panel (the one which LabVIEW normally generates including the ActiveX for the Front panel) which the user can then click on to download the file. The problem with this is you would then have to refresh the remote browser's page (probably manually) to be able to see that link. Not ideal and, technically, not a link on the VI Front panel!

I would seriously consider getting the app to e-mail out the file or push it up to some web space for you to download it at this point.

Sorry I can't think of a better solution!

Best wishes,

Mark

Certified LabVIEW Architect
0 Kudos
Message 6 of 8
(3,711 Views)
Hi Mark,

I think I'm going to change my developing plattaform to something more suitable for web applications. Probablly I'll make the user interface in PHP using Apache as a web server and use LabView as a side process to get the samples and save the excel file in a known location where the web server can reach it.

Thanks for your time and suggestions anyways.

Erik


0 Kudos
Message 7 of 8
(3,703 Views)

Hey Erik,

That sounds like a good plan, I hope I remember where to find this thread if I ever need the same functionality!

Good Luck with it!

Mark

Certified LabVIEW Architect
0 Kudos
Message 8 of 8
(3,699 Views)