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 to the WebUser module functions: HttpGet() and HttpSet().
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 the Web module WebUser 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 page 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:
Enable - the page status "Enabled".
DB - DB that stores configuration.
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;
URLprms - URL parameters in the Object;
cnts - content items for POST in the Array<XMLNodeObj>.
The overall scenario of the user's page request:
Внешняя сетевая станция формирует HTTP запрос с URI вида "/WebUser/<UserPage>" который попадает на транспорт OpenSCADA с значением поля конфигурации "Протокол" равного "HTTP".
Транспорт направляет запрос на модуль транспортного протокола Protocol.HTTP.
Модуль транспортного протокола, в соответствии с первым элементом URI, направляет запрос данному модуль.
Данный модуль выбирает объект страницы пользователя, которая указана во втором элементе URI.
Выполняется инициализация переменных HTTP-протокола для процедуры страницы:
HTTPreq - устанавливается в значение строки "GET" или "POST", в зависимости от типа запроса;
url - адрес запрашиваемого ресурса (URI);
page - содержимое передаваемой страницы для метода "POST";
sender - адрес отправителя запроса;
user - адрес аутентифицированного пользователя, если аутентификация имела место;
HTTPvars - разобранный перечень переменных протокола HTTP в виде свойств объекта;
URLprms - разобранный перечень параметров URL в виде свойств объекта;
cnts - разобранные элементы содержимого для POST в Array<XMLNodeObj>, с содержимым элементов в тексте и свойствами в атрибутах XMLNodeObj.
Вызов процедуры на исполнение, которая обработав запрос формирует содержимое страницы в "page" и результат запроса в "rez".
В завершении формируется ответ с кодом возврата HTTP из "rez" и содержимым из "page".