2.2. Working with Java Applets

The DataHub offers a mechanism for displaying live data in a web browser through Sun's Java plug-in. The DataHub API defines a number of Java applets, each of which can display one or more data points. An applet can be as simple as a text field, or as complex as a data table. Web pages typically contain more than one applet, each displaying a specific item of information.

2.2.1. Connecting

Java applets connect to the DataHub via a private TCP connection. This connection uses the the Tunnel/Mirror functionality of the Cascade DataHub or OPC DataHub. So you must configure your DataHub as a Tunnelling/Mirror Master for a Java applet to connect. The Java applet must be configured to use the same port number that the DataHub is configured to use in the mirroring or tunnelling master configuration.

There are two types of applets supplied with the DataHub API. The first is a DataHubBaseApplet, which is an applet that opens the TCP socket to the DataHub and manages the data flow between the browser and the DataHub. The second type is a DataHubListener, which is a screen element that communicates with a DataHubBaseApplet for its live data. This arrangement means that even though there may be several applets on a single web page, they can share a single connection to the DataHub. This is significant since the DataHub requires a TCP Link License for each concurrent connection.

2.2.2. Applet Configuration

Java applets are configured through parameters in the HTML source for the web page. Different applets can accept different arguments. No argument may appear more than once per applet. Please refer to Section 2.5.2, “Example HTML coding” for examples.

2.2.3. Specifying Colors

Some applet parameters require a color specification. Colors are specified in hexadecimal as RGB values. Colors may optionally contain an alpha blending parameter. The color may optionally start with a # character. This is helpful to mark a string as a color for easier readability. A complete color specification would be: #AARRGGBB where AA is two hexadecimal digits specifying an alpha value from 00 (transparent) to FF (opaque). RR, GG and BB specify red, green and blue values from 00 (none) to FF (full) brightness. A fully opaque color may be truncated to as few as 1 character. For example, #ff would indicate pure blue, and #ff00 would be pure green. If the color requires an alpha value other than FF (opaque) then all 8 characters of the color must be specified. Thus, #800000ff would be 50% transparent blue. #00000000 would be fully transparent black, which would be invisible.

2.2.4. Customization

This DataHub API contains the complete Java source code for the Java applets and TCP connection classes. You can create your own applets to display data in any form that you like, using this DataHub API source as a starting point.

2.2.5. Browser Limitations

Internet Explorer versions 6 and 7 cannot display a large number of Java applets on a single page. The limit is variable, but is in the vicinity of 15 applets per page. Mozilla Firefox can reliably display around 200 applets per page, but it may crash with larger numbers of applets on a page.

You can work around browser limitations by using the DataHubTable applet, or by designing your own applets to display more information per applet, thereby reducing the total number of applets on a page.