The module <WebUser> of the subsystem "User Interfaces"
Module:
WebUser
Name:
Web-interface from the user
Type:
User Interfaces
Source:
ui_WebUser.so
Version:
0.8
Author:
Roman Savochenko, Maxim Lysenko(2010)
Description:
Allows you to create your own user web-interfaces in any language of OpenSCADA.
License:
GPL
Introduction
WebUser module provides the user with a mechanism to create Web-pages, and can process other Web-requests with the help of the internal language of OpenSCADA, usually JavaLikeCalc, without necessity of low-level programming of OpenSCADA.
Except of the module's belonging to the system OpenSCADA it also belongs and is the module of the HTTP transport protocol module. Actually, the WebUser call is made from Protocol.HTTP. The call is made through enhanced communication mechanism through the exported into the module functions: HTTP_GET(), HTTP_POST().
Addressing of the pages begins with the second element of the URI. It is connected with the fact that the first element of the URI is used to identify the module of user Web-interface. For example URL: http://localhost.localdomain:10002/WebUser/UserPage can be deciphered as a call of the user page "UserPage" of this module on the host "localhost.localdomain" on port 10002. In the case of absence of the second element of URI and instruction to display an index of user pages in the configuration the index of the page is generated (Figure 1).
Fig.1. Index of user pages.
The main tab of the module configuration (Fig. 2) contains the state of the module, provides the ability to select the default page and allows you to make the list of user pages.
Fig.2. Main tab of the module's configuration.
1. WEB — pages
The module provides the ability to create multiple implementations of Web-pages in the object "User page" (Fig. 3).
Fig.3. The main configuration tab of the user page.
The main tab contains the basic settings of the user protocol:
Section "Status" — contains properties that characterize the status of the user page:
Status — current mode and statistic.
Enable — the page status "Enabled".
DB — DB that stores configuration.
Date of modification — date and time for the object last modification.
Section "Config" — directly contains the configuration fields:
ID — information on the page's identifier.
Name — specifies the name of the page.
Description — brief description of the page and its purpose.
To enable — indicates the status "Enable", in which to transfer the page at startup.
All requests to the user pages are sent to the procedure of the processing of the requests of the user page, which is represented on the "Program" tab of the user page object (Figure 4).
Fig.4. "Program" tab of the user page object.
Tab procedure's tab for processing the requests to the user's page contains the field for selecting the internal programming language of OpenSCADA and the text entry field for the processing procedure typing.
For the processing procedure the following exchange variables are predetermined:
rez — Processing result (by defaults — "200 OK").
HTTPreq — The HTTP request method (GET,POST).
url — URI of the request.
page — Contents of the Get/Post page for the request and respond as well.
sender — Request sender.
user — Authenticated user.
HTTPvars — HTTP variables in the Object. Changed and appended variables (besides "Date", "Server", "Accept-Ranges" and "Content-Length") will placed to respond packet.
URLprms — URL parameters in the Object.
cnts — Content items for POST in the Array<XMLNodeObj>.
this — Pointer to this page's object.
prt — Pointer to object of the input part of the HTTP protocol.
The overall scenario of the user's page request:
External network station generates an HTTP request with the following form of URI "/WebUser/{UserPage}" which falls on transport of OpenSCADA with the value of the configuration field "Protocol" equal to the "HTTP".
Transport sends a request to the module of transport protocol Protocol.HTTP.
Module of the transport protocol, in accordance with the first element of the URI, sends a request to this module.
This module selects the object of the user's page which is specified in the second element of the URI.
Initialization of the variables of HTTP-protocol for the procedure of the page is made:
HTTPreq — the value of the string "GET" or "POST", depending on the type of request, is set;
url — address of the requested resource (URI);
page — the content of sending page for method "POST";
sender — address of the request sender;
user — identifier of an authenticated user, if the authentication has occurred;
HTTPvars — the parsed list of variables of the HTTP protocol in the form of object's properties;
URLprms — the parsed list of URL parameters in the form of object's properties;
cnts — parsed contents items for POST in Array <XMLNodeObj>, with the contents of elements in the text and properties in the attributes XMLNodeObj.
Calling the procedure for execution, which, having processed the request, forms the contents of the page in the "page" and the result of the request in the "rez".
At the end the answer is formed with the return code of the HTTP from "rez" and with the contents from the "page", and also changed and appended variables of HTTP protocol from HTTPvars.