From OpenSCADAWiki
Jump to: navigation, search
(Updating to match new version of source page)
Line 6: Line 6:
 
<section begin=info />
 
<section begin=info />
 
| [[Special:MyLanguage/Modules/WebUser|WebUser]] || WWW-страница пользователя
 
| [[Special:MyLanguage/Modules/WebUser|WebUser]] || WWW-страница пользователя
| 1.6 || GPL2 || ui_WebUser.so || en,uk,ru,de || x86,x86_64,ARM
+
| 1.7 || GPL2 || ui_WebUser.so || en,uk,ru,de || x86,x86_64,ARM
 
<section end=info />
 
<section end=info />
 
| Пользовательские интерфейсы || Роман Савоченко || Обеспечивает создание собственных WWW-страниц на внутреннем языке OpenSCADA.
 
| Пользовательские интерфейсы || Роман Савоченко || Обеспечивает создание собственных WWW-страниц на внутреннем языке OpenSCADA.
 
|}
 
|}
  
Модуль предоставляет пользователю механизм создания WWW-страниц, а также позволяет обрабатывать иные WWW-запросы на внутреннем языке OpenSCADA, обычно [[Special:MyLanguage/Modules/JavaLikeCalc|JavaLikeCalc]], не прибегая к низкоуровневому программированию. В роли обработчика страниц модуль позволяет использовать [[Special:MyLanguage/Documents/Program_manual#DAQTmpl|стандартные шаблоны DAQ]]. Использование шаблонов DAQ позволяет создавать библиотеки WWW-страниц и вызов их в этом модуле многократно, как их реализации, а также предоставляет контекст данных исполнения шаблона с их связыванием с данными подсистемы "Сбор Данных".
+
The module provides the user with a mechanism to create WWW-pages, and can process other WWW-requests in internal OpenSCADA language, usually [[Special:MyLanguage/Modules/JavaLikeCalc|JavaLikeCalc]], without involving low level programming. As a page processor, the module allows you to use [[Special:MyLanguage/Documents/Program_manual#DAQTmpl|standard DAQ-Templates]]. Using DAQ-Templates allows you to create WWW-page libraries and call them in this module multiple times as their implementations, as well as provide the data context of the template with their connection to the data of the subsystem "Data Acquisition".
  
Кроме принадлежности модуля к OpenSCADA он также принадлежит и является модулем модуля транспортного протокола [[Special:MyLanguage/Modules/HTTP|Protocol.HTTP]]. Собственно вызов модуля WebUser осуществляется из Protocol.HTTP и посредством расширенного механизма коммуникации, экспортированными в этом модуле функциями: HTTP_GET(), HTTP_POST().
+
Except of the module's belonging to OpenSCADA it also belongs and is the module of the [[Special:MyLanguage/Modules/HTTP|Protocol.HTTP]] transport protocol module. Actually, the module WebUser call is made from Protocol.HTTP and through the enhanced communication mechanism — by the exported function HTTP() of the module.
  
 
Адресация страниц начинается со второго элемента URI. Это связанно с тем, что первый элемент URI используется для идентификации самого модуля пользовательского WWW-интерфейса. Например, URL ''<nowiki>http://localhost.localdomain:10002/WebUser/UserPage</nowiki>'' можно расшифровать как вызов пользовательской страницы "UserPage" этого модуля "WebUser" на хосте "localhost.localdomain" через порт 10002. В случае отсутствия второго элемента URI и указания отображать индекс пользовательских страниц в конфигурации — формируется индекс страниц (рис.1).
 
Адресация страниц начинается со второго элемента URI. Это связанно с тем, что первый элемент URI используется для идентификации самого модуля пользовательского WWW-интерфейса. Например, URL ''<nowiki>http://localhost.localdomain:10002/WebUser/UserPage</nowiki>'' можно расшифровать как вызов пользовательской страницы "UserPage" этого модуля "WebUser" на хосте "localhost.localdomain" через порт 10002. В случае отсутствия второго элемента URI и указания отображать индекс пользовательских страниц в конфигурации — формируется индекс страниц (рис.1).
Line 28: Line 28:
 
[[file:WebUser_up_main_ru.png|center|frame|Рис.3. Главная вкладка конфигурации пользовательской страницы.]]
 
[[file:WebUser_up_main_ru.png|center|frame|Рис.3. Главная вкладка конфигурации пользовательской страницы.]]
  
Главная вкладка содержит основные настройки WWW-страницы:
+
The main tab contains the basic settings of the WWW-page:
* Раздел "Состояние" — содержит свойства, характеризующие состояние страницы: статус, "Включен", имя БД (содержащей конфигурацию и с отслеживанием наличия данных в различных хранилищах и предоставлением последовательного удаления дубликатов) и дату последней модификации.
+
* Section "State" — contains properties that characterize the state of the page: Status, "Enabled", the name of the database containing the configuration (with tracking the availability of the data in different storages and providing the sequentially removing duplicates) and date of the last modification.
* Идентификатор, имя и описание страницы.
+
* Identifier, name and description of the page.
* Состояние "Включен", в которое переводить страницу при загрузке.
+
* The state "Enabled", in which the page must be translated at boot.
* Язык прямой процедуры или [[Special:MyLanguage/Documents/Program_manual#DAQTmpl|DAQ-шаблон]], связанный со страницей.
+
* Language of the direct procedure or [[Special:MyLanguage/Documents/Program_manual#DAQTmpl|DAQ-Template]] associated with the page.
  
Все запросы к пользовательским страницам направляются в прямую процедуру обработки запросов пользовательской страницы, или процедуру DAQ-шаблона, которая представлена на вкладке "Программа" объекта страницы пользователя (рис.4). В случае с DAQ-шаблоном также предоставляется вкладка конфигурации шаблона (рис.5).
+
All requests to the user pages are sent to the direct procedure of the processing of the requests of the user page, or to the DAQ-Template procedure, which is represented on the "Program" tab of the user page object (Fig.4). In the case of the DAQ-Template, the template configuration tab is also provided (Fig.5).
  
 
[[file:WebUser_up_prog_ru.png|center|frame|Рис.4. Вкладка "Процедура" объекта пользовательской WWW-страницы.]]
 
[[file:WebUser_up_prog_ru.png|center|frame|Рис.4. Вкладка "Процедура" объекта пользовательской WWW-страницы.]]
Line 44: Line 44:
  
 
For the direct processing procedure, and the required or optional ones to create in the template, the following exchange attributes with the HTTP-protocol are predetermined:
 
For the direct processing procedure, and the required or optional ones to create in the template, the following exchange attributes with the HTTP-protocol are predetermined:
* '''''Result (rez)''''' <String> — processing result, by defaults — "200 OK"; in the DAQ-template mode you must write thither directly, not by the operator "return";
+
* '''''Result (rez)''''' <String> — processing result, by defaults — "200 OK"; in the DAQ-Template mode you must write thither directly, not by the operator "return"; to prevent sending a HTTP-wrapped response, put an empty string here, that is, send the response directly via [[Special:MyLanguage/Documents/User_API#SYSTransport|SYS.Transport["Modul"]["in_Transp"].writeTo()]];
* '''''HTTP request (HTTPreq)''''' <String> — the HTTP request method: GET, POST;
+
* '''''HTTP request (HTTPreq)''''' <String> — the HTTP request method like to GET, POST, ...;
 
* '''''URL (url)''''' <String> — URI of the request;
 
* '''''URL (url)''''' <String> — URI of the request;
 
* '''''WWW-page (page)''''' <String> — content of the Get/Post page for the request and respond as well;
 
* '''''WWW-page (page)''''' <String> — content of the Get/Post page for the request and respond as well;
Line 55: Line 55:
 
* ''This object (this)'' <Object> — pointer to this page's object;
 
* ''This object (this)'' <Object> — pointer to this page's object;
 
* ''Protocol's object (prt)'' <Object> — pointer to the input part object of the HTTP protocol;
 
* ''Protocol's object (prt)'' <Object> — pointer to the input part object of the HTTP protocol;
 +
* ''Transport's object (tr)'' <Object> — pointer to the input transport to the input part object of the HTTP protocol;
 
* ''Scheduling the next service call (schedCall)'' <Integer> — write here the time value in seconds for scheduling the procedure context execution in a service call; [[file:at.png]] the service calls are performed in the periodicity 10 seconds usually, so you can schedule the calls not often than at 10 seconds.
 
* ''Scheduling the next service call (schedCall)'' <Integer> — write here the time value in seconds for scheduling the procedure context execution in a service call; [[file:at.png]] the service calls are performed in the periodicity 10 seconds usually, so you can schedule the calls not often than at 10 seconds.
  
Общий сценарий запроса пользовательской страницы:
+
The overall scenario of the user's page request:
* Внешняя сетевая станция формирует HTTP запрос с URI вида "/WebUser/{UserPage}", который попадает на транспорт OpenSCADA с значением поля конфигурации "Протокол", равного "HTTP".
+
* External network station generates an HTTP request with the following form of URI "/WebUser/{UserPage}" which falls on the OpenSCADA transport with the value of the configuration field "Protocol" equal to "HTTP".
* Транспорт направляет запрос на модуль транспортного протокола "Protocol.HTTP".
+
* Transport sends the request to the module of the transport protocol "Protocol.HTTP".
* Модуль транспортного протокола, согласно первого элемента URI, направляет запрос данному модулю.
+
* The transport protocol module, in accordance with the first element of the URI, sends the request to this module.
* Данный модуль выбирает объект страницы пользователя, которая указана во втором элементе URI.
+
* This module selects the object of the user's page which is specified in the second element of the URI.
* Выполняется инициализация переменных HTTP-протокола для процедуры страницы:
+
* Initialization of the HTTP-protocol variables for the page procedure is made:
** '''''HTTPreq''''' — устанавливается в значение строки "GET" или "POST", в зависимости от типа запроса;
+
** '''''HTTPreq''''' — is set to value of the HTTP-Method (like to "GET", "POST"), depending on the request type;
** '''''url''''' — адрес запрашиваемого ресурса (URI);
+
** '''''url''''' — address of the requested resource (URI);
** '''''page''''' — входное одиночное содержимое и передаваемая страница, для метода "POST";
+
** '''''page''''' — the input single content and the sending page for the method "POST";
** ''sender'' — адрес отправителя запроса;
+
** ''sender'' — address of sender of the request;
** ''user'' — идентификатор аутентифицированного пользователя, если аутентификация имела место;
+
** ''user'' — identifier of the authenticated user, if the authentication has occurred;
** '''''HTTPvars''''' — разобранный перечень переменных протокола HTTP в виде свойств объекта;
+
** '''''HTTPvars''''' — parsed list of variables of the HTTP-protocol in the form of object's properties;
** ''URLprms'' — разобранный перечень параметров URL в виде свойств объекта;
+
** ''URLprms'' — parsed list of the URL parameters in the form of object's properties;
** ''cnts'' — разобранные элементы содержимого для POST, в Array<XMLNodeObj>, с содержимым элементов в тексте и свойствами, в атрибутах XMLNodeObj.
+
** ''cnts'' — parsed content's items for POST, in the Array <XMLNodeObj>, with the elements content in the text and properties, in the XMLNodeObj attributes.
* Вызов процедуры на исполнение, которая, обработав запрос, формирует содержимое страницы в "page" и результат запроса в "rez".
+
* Calling the procedure for execution, which, having processed the request, forms the page content in the "page" and the request result in the "rez".
* В завершение формируется ответ с кодом возврата HTTP из "rez" и содержимым из "page", а также изменёнными и добавленными переменными протокола HTTP из "HTTPvars".
+
* At the end, the answer is formed with the return code of the HTTP from "rez" and with the content from the "page", and also with changed and appended variables of the HTTP-protocol from "HTTPvars". For empty "rez" the answer is not generated!

Revision as of 09:11, 10 October 2024

Other languages:
English • ‎mRussian • ‎Українська
Модуль Имя Версия Лицензия Источник Языки Платформы Тип Автор Описание
WebUser WWW-страница пользователя 1.7 GPL2 ui_WebUser.so en,uk,ru,de x86,x86_64,ARM Пользовательские интерфейсы Роман Савоченко Обеспечивает создание собственных WWW-страниц на внутреннем языке OpenSCADA.

The module provides the user with a mechanism to create WWW-pages, and can process other WWW-requests in internal OpenSCADA language, usually JavaLikeCalc, without involving low level programming. As a page processor, the module allows you to use standard DAQ-Templates. Using DAQ-Templates allows you to create WWW-page libraries and call them in this module multiple times as their implementations, as well as provide the data context of the template with their connection to the data of the subsystem "Data Acquisition".

Except of the module's belonging to OpenSCADA it also belongs and is the module of the Protocol.HTTP transport protocol module. Actually, the module WebUser call is made from Protocol.HTTP and through the enhanced communication mechanism — by the exported function HTTP() of the module.

Адресация страниц начинается со второго элемента URI. Это связанно с тем, что первый элемент URI используется для идентификации самого модуля пользовательского WWW-интерфейса. Например, URL http://localhost.localdomain:10002/WebUser/UserPage можно расшифровать как вызов пользовательской страницы "UserPage" этого модуля "WebUser" на хосте "localhost.localdomain" через порт 10002. В случае отсутствия второго элемента URI и указания отображать индекс пользовательских страниц в конфигурации — формируется индекс страниц (рис.1).

Рис.1. Индекс пользовательских страниц.

Главная вкладка конфигурации модуля (рис.2) содержит состояние модуля, предоставляет возможность выбора страницы по умолчанию и позволяет сформировать перечень пользовательских страниц.

Рис.2. Основная вкладка конфигурации модуля.

WWW-страницы

Модуль предоставляет возможность создания реализаций множества WWW-страниц в объекте "Пользовательская WWW-страница" (рис.3).

Рис.3. Главная вкладка конфигурации пользовательской страницы.

The main tab contains the basic settings of the WWW-page:

  • Section "State" — contains properties that characterize the state of the page: Status, "Enabled", the name of the database containing the configuration (with tracking the availability of the data in different storages and providing the sequentially removing duplicates) and date of the last modification.
  • Identifier, name and description of the page.
  • The state "Enabled", in which the page must be translated at boot.
  • Language of the direct procedure or DAQ-Template associated with the page.

All requests to the user pages are sent to the direct procedure of the processing of the requests of the user page, or to the DAQ-Template procedure, which is represented on the "Program" tab of the user page object (Fig.4). In the case of the DAQ-Template, the template configuration tab is also provided (Fig.5).

Рис.4. Вкладка "Процедура" объекта пользовательской WWW-страницы.

Вкладка процедуры обработки запросов к пользовательской странице содержит:

  • Таблицу контекста данных процедуры. В основном имеет смысл только при работе по шаблону и где можно контролировать этот процесс обработки, включая возможность вмешательства через изменение значений данных.
  • Текст прямой процедуры страницы, отсутствует в режиме работы по шаблону.
  • Связи на данные подсистемы "Сбор Данных", которые видимы и доступны для определения в режиме работы по шаблону и во включенном состоянии объекта страницы.

For the direct processing procedure, and the required or optional ones to create in the template, the following exchange attributes with the HTTP-protocol are predetermined:

  • Result (rez) <String> — processing result, by defaults — "200 OK"; in the DAQ-Template mode you must write thither directly, not by the operator "return"; to prevent sending a HTTP-wrapped response, put an empty string here, that is, send the response directly via SYS.Transport["Modul"]["in_Transp"].writeTo();
  • HTTP request (HTTPreq) <String> — the HTTP request method like to GET, POST, ...;
  • URL (url) <String> — URI of the request;
  • WWW-page (page) <String> — content of the Get/Post page for the request and respond as well;
  • Sender (sender) <String> — request sender;
  • User (user) <String> — authenticated user;
  • HTTP variables (HTTPvars) <Object> — HTTP variables; changed and appended variables (besides "Date", "Server", "Accept-Ranges" and "Content-Length") will be placed to the response package;
  • URL's parameters (URLprms) <Object> — URL parameters;
  • Content items (cnts) <Object::Array<XMLNodeObj>> — content items for POST;
  • This object (this) <Object> — pointer to this page's object;
  • Protocol's object (prt) <Object> — pointer to the input part object of the HTTP protocol;
  • Transport's object (tr) <Object> — pointer to the input transport to the input part object of the HTTP protocol;
  • Scheduling the next service call (schedCall) <Integer> — write here the time value in seconds for scheduling the procedure context execution in a service call; At.png the service calls are performed in the periodicity 10 seconds usually, so you can schedule the calls not often than at 10 seconds.

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 the OpenSCADA transport with the value of the configuration field "Protocol" equal to "HTTP".
  • Transport sends the request to the module of the transport protocol "Protocol.HTTP".
  • The transport protocol module, in accordance with the first element of the URI, sends the 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 HTTP-protocol variables for the page procedure is made:
    • HTTPreq — is set to value of the HTTP-Method (like to "GET", "POST"), depending on the request type;
    • url — address of the requested resource (URI);
    • page — the input single content and the sending page for the method "POST";
    • sender — address of sender of the request;
    • user — identifier of the authenticated user, if the authentication has occurred;
    • HTTPvars — parsed list of variables of the HTTP-protocol in the form of object's properties;
    • URLprms — parsed list of the URL parameters in the form of object's properties;
    • cnts — parsed content's items for POST, in the Array <XMLNodeObj>, with the elements content in the text and properties, in the XMLNodeObj attributes.
  • Calling the procedure for execution, which, having processed the request, forms the page content in the "page" and the request result in the "rez".
  • At the end, the answer is formed with the return code of the HTTP from "rez" and with the content from the "page", and also with changed and appended variables of the HTTP-protocol from "HTTPvars". For empty "rez" the answer is not generated!