Web server configuration

Modbus SCADA provides HTTP web server for remote access to the program. Web server supports authentication, templates, and can display screen images.

Configuring web server

In order to configure the web server select Settings->Settings from the main menu. Once the dialog opens, go to the Web server tab and check Enable Web server option. When this option is checked, the program starts along with the embedded web server. The web server binds to the port specified in the Port edit box. Please ensure, the port is not occupied by another application. The default port is 8088, and the web page is accessible at the following link http://localhost:8088 from the local computer.

The web server supports basic authentication. If you want only authenticated users view the web page, enter Username and Password in the configuration dialog. To disable authentication leave Username empty.

Web server configuration dialog

webserver-dialog.png

Creating web pages

Web server can serve any HTML page located in the "http/" directory beneath the Modbus SCADA application data directory. Create HTML files and copy them along with CSS files or image files to the "http/" directory. The default file served for "GET /" request is index.html.

To locate "http/" folder on your computer click Open web server root directory... button on Web server tab in Settings dialog.

Using templates

In order to allow users embed tags properties and values into the web page content, the web server uses template engine. Template engine converts markers (${...}) into the actual tag properties. When web browser request a web page, the web server first look for the requested resource (e.g. index.html). If the file does not exist in the http directory, the web browser searches for corresponding template. Template file must have an extension ".tpl" (e.g. template file for index.html must be named index.html.tpl). If the template is found, template engine converts all valid markers into the corresponding values. If neither requested file, nor template (file with .tpl postfix) exists the web server responses with 404 error code (Page Not Found).

There are the following markers available:

  • ${tag_name.X} - Resolves to the name of the tag of id X (indexing of tags is 1-based).
  • ${tag_value.X} - Resolves to the real value of the tag of id X.
  • ${tag_unit.X} - Resolves to the unit of the tag of id X.
  • ${tag_name_next} - Resolves to the name of the tag of current id.
  • ${tag_value_next} - Resolves to the real value of the tag of current id.
  • ${tag_unit_next} - Resolves to the unit of the tag of current id.
  • ${tag_resetcount} - Resolves to empty string. Reset counter of tag id used for markers ${tag_..._next}
  • ${tag_gotonext} - Resolves to empty string. Increments counter of the tag id used for markers ${tag_..._next} and goes to the previous line in the template file if the id is less than the maximum available tag id. Note: the control goes to previous line so empty lines are not allowed.
  • ${tag_count} - Resolves to the number of tags.
  • ${screen_name.X} - Resolves to the title of the screen of id X (indexing of screens is 0-based).
  • ${screen_img.X} - Resolves to the name of bitmap image of the screen of id X.
  • ${sceen_name_next} - Resolves to the title of screen of current id.
  • ${screen_img_next} - Resolves to the name of bitmap image of the screen of current id.
  • ${screen_resetcount} - Resolves to empty string. Reset counter of screen id used for markers ${screen_..._next}
  • ${screen_gotonext} - Resolves to empty string. Increments counter of screen id used for markers ${screen_..._next} and goes to the previous line in the template file if the id is less than the maximum available screen id. Note: the control goes to previous line so empty lines are not allowed.
  • ${screen_count} - Resolves to the number of screens.
Markers ${screen...} are available since version 2.0.0 of Modbus SCADA.

Loops in templates

The following example shows how to create a loop for each tag to build HTML table:

${tag_resetcount}
<tr><td>${tag_name_next}</td><td>${tag_value_next} ${tag_unit_next}</td></tr>
${tag_gotonext}


Exemplary webpage - loops used to create tables

webserver-page.png

Showing screen image

Web server (since version 2.0.0) can serve bitmap files showing screen images. Screen images are named "screen-image-X.bmp", where X is the screen id. You can use ${screen-img...} markers to obtain image file name.

Displaying screen image in a web browser

webserver-screen.png