Programmer`s Guide

Transcription

Programmer`s Guide
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
No front panel should be a hostage!
Version: 0.61.2
Programmer’s Guide
August 2014
Programmer’s Guide
1
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Overview
WebPager is a LabVIEW add-on that allows accessing LabVIEW front panel
from a browser without any modifications in the LabVIEW block diagram and
without installing any plugins in user’s browser. It doesn’t require LabVIEW RunTime Engine on client machines. The user interface created by WebPager uses
only standard web-technologies – HTML5, CSS3, JavaScript.
WebPager maintains quasi real-time control over front panel via Internet
from any browser-enabled device and operating system – Windows, Mac, Linux,
Android, iPad, etc. Moreover, WebPager also provides API for programmatic
access of its functionality.
WebPager is suitable for all types of developers. First, it can be used for
putting LabVIEW application online in one click via Wizard - without any
modifications in the LabVIEW source code. Second, it can be used in a more
flexible ways by programmatically controlling WebPager (and not using Wizard).
And third, WebPager can be used for merging LabVIEW front panel and external
HTML code together for those with a good knowledge of web technologies, thus
allowing having user interfaces and effects that are impossible to achieve on
LabVIEW front panel itself.
WebPager features:
- Accessing LabVIEW front panel from a browser without any
modifications in the LabVIEW block diagram (via Wizard).
- Solid API for programmatic control of front panel in the browser.
- Users don’t need to install neither plugins nor LabVIEW Run-Time
Engine.
- Cross-platform access through HTML5 capable browsers.
Programmer’s Guide
2
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
- Ability to merge together LabVIEW front panel and external HTML and
CSS.
- One-to-one correspondence of front panel and generated HTML-page.
- “Value Change” events are fired in LabVIEW program when a remote
user interacts with a web-page.
- UTF-8 support (you can use Russian or Chinese characters on the front
panel and in transmitted data).
- There is no need to install any servers or open any ports for your clients
in the Internet.
Now let’s talk about underlying technology. While we invest our time and
our best efforts, that’s clearly not the only magical part in our recipe. What you’ll
be using is possible due to the new Internet communication protocol – the web
sockets. In the pre-HTML5 era one sure way to update the web page (without
using plugins like Adobe Flash Player or Microsoft Silverlight) was to use polling
techniques (polling, long-polling, streaming). What it means for us, LabVIEW
developers? Suppose you have a very simple front panel with the only UI element
on in – Boolean Push Button. When user clicks that button on the web page,
LabVIEW application has to know somehow that it happened (remember, in
HTML world server can’t send any information to the client – only client can
request it and server respond). So, in order to know, both clients would poll the
server on regular basis, let’s say once per second. With this polling each request
would contain our information (state of the Boolean in the body section of the
request, 8 bytes) and an ‘overhead’ (all the information in the header section, up
to 1.5 kb). In this situation we would have constant traffic on both sides and big
latencies for zero useful information (if there are no updates). With web sockets
protocol all this has changed – main problems solved, and it’s a high time to bring
this change to the LabVIEW world.
Programmer’s Guide
3
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Usage Notes
LabVIEW WebPager transforms LabVIEW front panel layout (with
supported UI elements) into HTML5 page and organizes the communication
between a target VI and a newly created web page in the modern browser.
Notes:
- For consistent appearance application font should be changed to any
named font (for example, to “Courier New”). Any encountered
“Application Font” will be treated as “Arial”.
- Currently only one pane per VI is supported.
- Only HTML5-capable browsers will be able to display generated webpage. Browsers that fail adhere to WWW standards will also fail to draw
front panel correctly. It is currently recommended to use following
browsers (in descending order of preference): Google Chrome, Mozilla
Firefox, Opera, and Internet Explorer.
Programmer’s Guide
4
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Using WebPager Publishing Wizard.
WebPager Wizard is available from LabVIEW menu Tools >> WebPager >>
Publishing Wizard. It can be launched at any time during program operation.
When target VI is stopped WebPager Wizard also stops. Read WebPager Wizard
Reference to know more.
Programmer’s Guide
5
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Using WebPager API.
WebPager API VIs are accessible from LabVIEW Functions ‘Data Communication’
palette:
In the simplest case you can use Express API VI like this (from WebPager examples
folder <LabVIEW>\examples\vfpsoft.com\WebPager\Examples\API
Usage\Express API usage (WebPager Demo).vi):
Read WebPager API Reference to know more.
Programmer’s Guide
6
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Supported Programmatic properties of the Front Panel Elements
Waveform Graph:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Autoscale X
Autoscale Y
Min X, Max X
Min Y, Max Y
Plot interpolation
Plot point styles
15
16
17
Plot point fill color
Fill base line
Bar Plots
18
19
20
21
Plot Line Width
Plot Color
Plot tooltip text
Plot Legend
Comments
Plain, bold, italic, underline or strikeout
If autoscale of axis X is turned off
If autoscale of axis Y is turned off
None, Linear, Stepwise
None, circles, filled circles, squares, filled squares, triangles,
filled triangles, crosses, diamonds, filled diamonds
None, zero. When used, defaults to plot line color.
Only plain text (no XML tags)
On, Off
Example:
WebPager
Programmer’s Guide
7
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Waveform Chart:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Autoscale X
Autoscale Y
Min X, Max X
Min Y, Max Y
Plot interpolation
Plot point styles
15
16
17
Plot point fill color
Fill base line
Bar Plots
18
19
20
21
Plot Line Width
Plot Color
Plot tooltip text
Plot Legend
Comments
Plain, bold, italic, underline or strikeout
If autoscale of axis X is turned off
If autoscale of axis Y is turned off
None, Linear, Stepwise
None, circles, filled circles, squares, filled squares, triangles,
filled triangles, crosses, diamonds, filled diamonds
None, zero. When used, defaults to plot line color.
Only plain text (no XML tags)
On, Off
Example:
WebPager
Programmer’s Guide
8
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
String Control:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Display Style
Text Justification
Text value
Text size
Text color
Text font
Text style
Tooltip text
Comments
Plain, bold, italic, underline or strikeout
Enabled, disabled, disabled and grayed out
Normal, Password
Left, Center, Right
Plain, bold, italic, underline or strikeout
Only plain text (no XML tags)
Example:
WebPager
Programmer’s Guide
9
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
String Indicator:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Display Style
Text Justification
Text value
Text size
Text color
Text font
Text style
Tooltip text
Comments
Plain, bold, italic, underline or strikeout
Enabled, disabled, disabled and grayed out
Normal, Password
Left, Center, Right
Plain, bold, italic, underline or strikeout
Only plain text (no XML tags)
Example:
WebPager
Programmer’s Guide
10
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Text Decorations:
№
1
2
3
4
5
6
7
Property
Position
Text value
Text Justification
Text size
Text color
Text font
Text style
Comments
Left, Center, Right
Plain, bold, italic, underline or strikeout
Example:
WebPager
Programmer’s Guide
11
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Front Panel:
№
1
2
3
4
5
Property
Size (width x height)
Background color
Background image
Background image position
Front Panel Title
Comments
Corresponds to minimum width and height of the web-page
PNG, JPG, GIF, BMP
Tile (default), Stretch, Center
Window Title in the VI Properties >> Window Appearance if
“Same as VI name” unchecked, or VI name otherwise
Example:
WebPager
Programmer’s Guide
12
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Numeric Control:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Display Style
Text Justification
Text value
Text size
Text color
Text font
Text style
Tooltip text
Comments
Plain, bold, italic, underline or strikeout
Enabled, disabled, disabled and grayed out
Normal, Password
Left, Center, Right
Plain, bold, italic, underline or strikeout
Only plain text (no XML tags)
Example:
WebPager
Programmer’s Guide
13
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Slider Control:
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Property
Position
Size of the range bar
(width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Orientation
Scale styles
Comments
Plain, bold, italic, underline or strikeout
Enabled
Horizontal/Vertical
Slider styles
Range Bar fill color
Modern, Silver (via style definition)
Tooltip text
Only plain text (no XML tags)
Example:
WebPager
Programmer’s Guide
14
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Boolean Controls and Indicators:
№
1
2
3
4
5
6
7
8
9
10
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Mechanical Action
Comments
Plain, bold, italic, underline or strikeout
Enabled, disabled, disabled and grayed out
Only Booleans with “Switch” Mechanical Action can be controlled
via web interface. Latched Booleans appear disabled and grayed out
with a following tooltip: “To make this button accessible via web
interface, change its mechanical action from 'latch' to 'switch'
(button context menu->Mechanical Action)”.
11
12
13
14
15
16
17
Multiple strings
Colors
Boolean text value
Boolean text color
Icons (decals)
On text, off text
On, Off states colors for Round LED, Square LED, …
Tooltip text
Only plain text (no XML tags)
Supported for “Silver” theme
Example:
WebPager
Programmer’s Guide
15
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Table (partially supported):
№
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Property
Position
Size (width x height)
Caption or Label text value
Caption or Label text position
Caption or Label text size
Caption or Label text color
Caption or Label text font
Caption or Label text style
Enabled State
Visible Items: Row Headers
Visible Items: Column Headers
Visible Items: Vertical Lines
Visible Items: Horizontal Lines
Value
17
Tooltip text
Comments
Plain, bold, italic, underline or strikeout
Enabled, disabled, disabled and grayed out
All lines are visible when both Vertical Lines and Horizontal
Lines are set to ‘True’, otherwise all lines are invisible
At present the value is the cells is not updated dynamically –
only once upon page upload.
Only plain text (no XML tags)
Example:
WebPager
Programmer’s Guide
16
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Web-Page customization.
WebPager allows adding custom HTML and CSS blocks to generated web-page. This
feature gives the developer an opportunity to add purely HTML elements such as animations,
pictures and other external to LabVIEW elements into the GUI.
Programmer’s Guide
17
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Appendix A. WebPager demos.
Appendix A presents LabVIEW GUIs generated by WebPager automatically, i.e. without
any development efforts and code modifications. This is done by calling Tools >> WebPager >>
Wizard similar to “Web Publishing Tool” as far as user experience is concerned. On the left you
can see LabVIEW GUIs during operation, on the right – fully interactive web-pages generated by
WebPager.
Programmer’s Guide
18
LabVIEW WebPager 0.61.2
Programmer’s Guide
webpager@vfpsoft.com
19
LabVIEW WebPager 0.61.2
Programmer’s Guide
webpager@vfpsoft.com
20
LabVIEW WebPager 0.61.2
webpager@vfpsoft.com
Appendix B. WebPager error codes.
Errors.
Error Code
500000
500001
500002
500003
500004
500005
500006
500007
500008
500009
500010
500011
500012
500013
500014
500015
500016
Error Description
GUI upload to the server failed
There is no info about this target VI. Probably it hasn't been uploaded yet.
You are trying to use invalid or empty reference. Before calling any WebPager
API VIs make sure first that you uploaded the GUI and initialized the VI
reference.
The plan has already expired. You can activate it from 'Account' tab in the
WebPager Wizard.
License key is not valid.
Your current WebPager plan is 'Basic'. You can use Express API only with
'Economy', 'Pro' and 'Deluxe' accounts. To enable this functionality please
upgrade to one of these plans from the WebPager Wizard ('Account' tab).
You can use Basic API VIs ('Upload', 'Start' and 'Stop') only with 'Pro' and
'Deluxe' accounts. To enable this functionality please upgrade to one of these
plans from the WebPager Wizard ('Account' tab).
Such account doesn't exist. Register the account at WebPager first.
License key for local network is not found.
License key for the Internet is not found.
This VI cannot access the referenced item. Use only public API VIs presented on
the WebPager palette. You shouldn't use any of the private scope WebPager VIs
- they are for internal use only, not supported and their interface may change at
any moment.
Server side error happened during activating new license. Check your
registration data and account balance. If error persists, contact support.
WebPager instance with the same license is already running on another
computer.
WebPager cannot access local network from this computer.
WebPager cannot access the Internet from this computer.
Upload to LAN failed. Port is already in use.
Upload to LAN failed.
Warnings.
Error Code
500101
500102
Warning Description
You are trying to start FP-WP synchronization for the VI that is already
synchronized.
Synchronization VI hasn't been started yet. Call 'Start FP-WP Synchronization' VI
or 'WP Express' first.
Programmer’s Guide
21
LabVIEW WebPager 0.61.2
Programmer’s Guide
webpager@vfpsoft.com
22