Chapter 8. OPC to Web

Table of Contents

8.1. Introduction
8.2. Configuring the Web Server
8.3. Viewing the Web Demos
8.4. Viewing Your Own Data
8.4.1. DataHub Browser
8.4.2. DataHub Table View
8.5. Modifying the ASP and AJAX Demo Files
8.6. Using ASP to Query a Database and Display Results
8.7. Creating Passwords
8.8. Generating XML output from the OPC DataHub
8.8.1. Streaming XML How-To
8.8.2. Polling XML How-To

8.1. Introduction

The OPC DataHub has a built-in web server that lets you display live data in a web page in several different ways, depending on your needs. The data can come from any data source that is connected to the DataHub. A two-way data flow allows the user to view data and also write data back to the DataHub.

There are several different display technologies available:

    ASP (Active Server Pages):  DataHub scripts embedded in an HTML page are run by the DataHub each time the page is requested by the client. The DataHub scripts generate the page content dynamically before sending the page to the browser. This is also called "server-side scripting".

    AJAX (Asynchronous Javascript and XML):  Javascript code embedded in an HTML page is interpreted by the browser. The data updates automatically on the page, without the need for refresh. This is also called "client-side scripting".

      Polling AJAX:  The Javascript code periodically sends commands to the DataHub to update the data on the browser page.

      Streaming AJAX:  The Javascript code maintains an open connection to the DataHub, which transmits updates to each point individually whenever its value changes.

    Java applets from the DataHub API for Java are embedded in the HTML code make a separate TCP connection from the browser to the DataHub. Once connected, the applets receive and display updated data values as soon as they change, without the need to refresh the page. The Java applets are executed by the browser, not by the DataHub.

Here is a comparison chart for these technologies:

 ASPPolling AJAXStreaming AJAXJava applets
Web browser supportDesktop and mobileDesktop and mobileDesktop and mobileDesktop only
Plug-in/Active X requiredNoNoNoYes, Java plug-in
Update speedsNo updates - Manual refresh requiredFast updatesVery fast updatesVery fast updates
System requirements (CPU and memory)Very lowHigh compared to Streaming AJAX and JavaLow compared to Polling AJAX, similar to Java.Low compared to Polling AJAX, similar to Streaming AJAX.
Bandwidth requirements (Will depend on point count and update rate)Very lowRelatively highModerate to lowModerate to low
Security (Password / SSL protection)YesYesYesYes
Firewall friendlyYesYesYesNo, requires firewall configuration
Licensing (Licenses required in addition to the standard DataHub Node license)DataHub Web Server licenseDataHub Web Server licenseDataHub Web Server license, + TCP Link license for each connectionDataHub Web Server license, + TCP Link license for each connection
Programming RequirementsUses DataHub scripting languageUses JavaScriptUses JavaScriptUses HTML. Requires knowledge of Java to build custom applets.
Types of Application Common usesGood for displaying static or slow moving data. Used for shift reports and statistics.Good for displaying fast moving data and alarm conditions. Used in web monitoring and trouble shooting applications.Excellent for displaying fast moving data. Used in remote monitoring and diagnostics systems.Best choice for very high speed and large number of users. Used in stock trading and process control systems for monitoring and HMI displays.

These different display technologies can be used together in the same page. For example, we often use ASP code to dynamically create AJAX tables that display live data in a web browser. The ASP code does the repetitive task of writing table entries for each point in a specific data domain and the web browser interprets the resulting JavaScript and builds the AJAX display accordingly. You can also use ASP to access data from an ODBC database and display it as part of the web page, along with the live data from the DataHub.

More about ASP

    Most process data does not update very quickly, so ASP is suitable for a wide range of applications.

    ASP will typically use very few system resources and bandwidth, so it is good for low speed connections.

    ASP is the most efficient method for handling a large number of user connections.

    ASP pages are generated by a script running in the DataHub. This means you can use the script to bring in data from other sources, such as from SQL databases. The web page can then display data from both live sources and database or text file archives.

    Web pages that are generated by ASP scripts can usually be displayed on all desktop and mobile web browsers. This is because while the scripts themselves are written in Gamma (the DataHub script language), the web pages they generate are delivered as plain HTML.

    In order to see new point values in an ASP page, you need to refresh the web page manually.

More about AJAX

    AJAX automatically updates the web page whenever the data changes in the DataHub, no page refresh is required.

    AJAX can handle high speed updates to a large number of users. However, system resources on the server will increase as the number of points, the number of users and the speed of the updates increases.

    AJAX displays are created using JavaScript programming, which means they are popular with web developers who wish to control all aspects of how the data is displayed in the web page.

    AJAX can be displayed using most modern desktop and mobile web browsers, but some mobile web browsers may not support one of both types of AJAX display. We have found the Opera Mobile web browser to be one of the best for displaying AJAX on mobile devices.

    Polling AJAX and Streaming AJAX differ as follows:

      Polling AJAX web pages make requests for new data to the DataHub on a polling cycle. This means there is usually a higher load on the CPU compared with Streaming AJAX, but in many cases the update speeds are comparable.

      Streaming AJAX web pages are highly efficient at moving data, which means they use very little system resources and much less network bandwidth compared to Polling AJAX applications.

More about Java applets

    Java applets are the best choice for displaying high speed data in complex web graphics like gauges, trends and progress bars.

    Java displays can typically handle a large number data points, updating rapidly to a large number of users.

    In most cases, Java web pages use far less system and network resources than AJAX pages.

    Java pages are often used for displaying executive summary screens for management, or as an HMI to remote facilities.

    We provide a wide range of Java applets that allow you to create sophisticated web pages with no programming required. Just use a simple HTML editor to configure the applet code and you can have a working web page up and running in a few minutes.

    Java pages can be displayed using most modern desktop browsers, but they do require the free Java plug-in to be installed first. The plug-in will download and install automatically if it is not already installed on your system.

    We have found that Java is generally not supported on mobile web browsers.