Overview

The basic flow of data from EPICS to the WWW site is described in the following diagram:

_images/overview.jpg

flow of data from EPICS to WWW site

The pvWebMonitor service is run on a computer in the same subnet as the EPICS system to be monitored. All configuration files and other resources are placed in a single project directory. pvWebMonitor places an EPICS Channel Access monitor on each PV in the pvlist.xml file and stores updates in-memory. Periodically, as specified in config.xml, pvWebMonitor writes the PV values from memory to an XML file (named rawdata.xml) in the project directory. Once that XML file is written, pvWebMonitor uses rawdata.xml [1] with each of the XSLT files [2] in the project directory to create a corresponding HTML file in the project directory. The complete list of HTML files is written into an index.html file in the project directory. Finally, all content in the project directory (except for the config.xml file) is copied to the WWW site directory. (Only new content is copied, files that do not change are not re-copied.)

It is important to note the WWW site is written as a static web site so that it provides no opportunity to change values in the EPICS system being monitored.

Also, since some browsers do not have XML parsers and thus cannot render XSLT [3], all HTML files are created by pvWebMonitor.

[1]The rawdata.xml file contains all the EPICS PV values, as well as some additional metadata useful in building the WWW site.
[2]Each XSLT files (*.xsl) contains the layout of a single HTML page, with additional markup to display the current EPICS PV values (and metadata). The EPICS PV data is provided in rawdata.xml.
[3]https://www.w3schools.com/xml/xsl_intro.asp

Examples

Example (very brief [4]) rawdata.xml file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="short.xsl"?>
<pvWebMonitor version="1">
  <written_by>pvWebMonitor/PvWatch</written_by>
  <datetime>2015-01-15 16:48:36</datetime>
  <pv id="VDM_Stripe" name="prj:m1.RBV">
    <name>prj:m1.RBV</name>
    <id>VDM_Stripe</id>
    <description>VDM_Stripe motor</description>
    <timestamp>2015-01-15 15:30:16.837633</timestamp>
    <counter>2</counter>
    <units>deg</units>
    <value>-1.510</value>
    <raw_value>-1.51</raw_value>
    <format>%.3f</format>
  </pv>
</pvWebMonitor>

Each XSLT file describes the format of an HTML page. The XSLT file uses XSL markup to pick EPICS PV values from the XML file. Here’s an example that shows the value of the PV prj:m1.RBV. (The id VDM_Stripe is used here as a symbolic reference.):

<xsl:value-of select="//pv[@id='VDM_Stripe']/value"/>

Here’s how to show when that PV value was last updated:

<xsl:value-of select="//pv[@id='VDM_Stripe']/timestamp"/>

Here’s how to show when the EPICS PV data was last posted to the WWW site:

<xsl:value-of select="/pvWebMonitor/datetime"/>

The XSLT language has many additional functions available to help as your page designs get more complex. Look at the supplied livedata.xsl file for additional examples. There are good tutorial web sites available, such as: http://www.w3schools.com/xsl

Here’s an example XSLT file using these example lines above (line breaks, <br />, were added for clarity):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    version="1.0"
    description="simple example XSLT to EPICS PV value">

    <xsl:template match="/">
        <html>
            <body>
                EPICS PV: <xsl:value-of select="//pv[@id='VDM_Stripe']/name"/><br />
                
                PV value: <xsl:value-of select="//pv[@id='VDM_Stripe']/value"/><br />
                
                PV last updated: <xsl:value-of select="//pv[@id='VDM_Stripe']/timestamp"/><br />
                
                HTML file written: <xsl:value-of select="/pvWebMonitor/datetime"/>
            </body>
        </html>
    </xsl:template>

</xsl:stylesheet>

The XSLT transformation using the XML file above looks like:

1
2
3
4
5
6
7
8
<html><body>
                EPICS PV: prj:m1.RBV<br>
                
                PV value: -1.510<br>
                
                PV last updated: 2015-01-15 15:30:16.837633<br>
                
                HTML file written: 2015-01-15 16:48:36</body></html>

Which shows in a browser:

_images/short.jpg

Example HTML web page from above.

[4]A more complete example is provided in the Example section.