Building an HTML Document with an Embedded VI Panel
Sending Static Front Panel Images
The .snap directive instructs the LabVIEW HTTP server to display a static image of the front panel of the specified VI. .snap works like a CGI script: it requires an argument that is the name of the VI whose front panel should be snapped, and it returns the image data. However, as far as the client is concerned, it is no different than any other image the client downloads.
Example:
Suppose that there is a VI named FP.vi, and we would like to embed the image of this VI in an HTML document. The code for the document might look like this:
- <HTML>
...
<IMG SRC=".snap?FP.vi">
...
</HTML>
There are two additional arguments that may be added to the .snap command. These areguments specify the image type (PNG or JPEG) and color depth (1, 2, 4, or 24 bits).
- .snap?FP.vi&type=jpeg&depth=24
LabVIEW can also send images that update dynamically if the client supports server push technology. Once again, all it requires is a simple command to the LabVIEW server in the same place that we would normally put the image source. For updating images, we use the .monitor command. For example:
- <HTML>
...
<IMG SRC=".monitor?FP.vi">
...
</HTML>
In addition to the .snap parameters, .monitor has two more optional parameters to specify a refresh rate and duration of animation: the refresh and lifespan arguments, respectively. Each parameter's arguments are in seconds:
- .monitor?FP.vi&refresh=2&lifespan=180
Reader Comments | Submit a comment »
.snap? requires / char
The example code snip
implies that a slash before the period
(e.g. /.snap) is not required.
I don't believe this is the case. LabVIEW's
Web Publishing Tool always includes a '/'.
I've tested with and without the slash and
it appears that the image rendering fails
when the slash is omitted.
- Rich Detering, R D Technologies, LLC. rldetering@ieee.org - Sep 23, 2004
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
