Модуль | Ім'я | Версія | Ліцензія | Джерело | Мови | Платформи | Тип | Автор | Опис |
---|---|---|---|---|---|---|---|---|---|
WebUser | WWW-сторінка користувача | 1.7 | GPL2 | ui_WebUser.so | en,uk,ru,de | x86,x86_64,ARM | Користувацькі інтерфейси | Роман Савоченко | Забезпечує створення власних WWW-сторінок на внутрішній мові OpenSCADA. |
Модуль надає користувачу механізм створення WWW-сторінок, а також дозволяє обробляти інші WWW-запити на внутрішній мові OpenSCADA, зазвичай це JavaLikeCalc, не залучаючи при цьому низькорівневого програмування. У ролі обробнику сторінок, модуль дозволяє використовувати стандартні DAQ-Шаблони. Використання DAQ-Шаблонів дозволяє створювати бібліотеки WWW-сторінок і здійснювати виклик їх у цьому модулі багаторазово, як їх реалізації, а також надає контекст даних виконання шаблону із їх зв'язуванням з даними підсистеми "Збір Даних".
Окрім приналежності модуля до OpenSCADA, він також належить і є модулем модуля транспортного протоколу Protocol.HTTP. Власне, виклик модулю WebUser здійснюється із Protocol.HTTP і за посередництвом розширеного механізму комунікації — експортованою функцією HTTP() цього модуля.
Адресація сторінок починається із другого елементу URI. Що пов'язано із тим, що перший елемент URI використовується для ідентифікації самого модуля користувацького WWW-інтерфейсу. Наприклад, URL http://localhost.localdomain:10002/WebUser/UserPage можна розшифрувати як виклик користувацької сторінки "UserPage" цього модуля на хості "localhost.localdomain" через порт 10002. У випадку відсутності другого елементу URI та вказання на відображення індексу користувацьких сторінок у конфігурації — формується індекс сторінок (рис.1).
Головна вкладка конфігурації модуля (рис.2) містить стан модуля, надає можливість обрання сторінки по замовченню та дозволяє формувати перелік користувацьких сторінок.
WWW-сторінки
Модуль надає можливість створення реалізацій WWW-сторінок у об'єкті "Користувацька WWW-сторінка" (рис.3).
Головна вкладка містить основні налаштування користувацької WWW-сторінки:
- Розділ "Стан" — містить властивості, які характеризують стан сторінки: статус, "Ввімкнено", ім'я БД (яка містить конфігурацію і з відстеженням наявності даних у різних сховищах та наданням послідовного видалення дублікатів) і дату останньої модифікації.
- Ідентифікатор, ім'я і опис сторінки.
- Стан "Ввімкнено", у який переводити сторінку при завантажені.
- Мова прямої процедури або DAQ-Шаблон, пов'язаний зі сторінкою.
Всі запити до користувацьких сторінок спрямовуються до процедури обробки запитів користувацької сторінки, або до процедури DAQ-Шаблону, яка представлена на вкладці "Програма" об'єкту сторінки користувача (рис.4). У випадку з DAQ-Шаблоном також надається вкладка конфігурації шаблону (рис.5).
Вкладка процедури обробки запитів до користувацької сторінки містить:
- Таблицю контексту даних процедури. Переважно має сенс лише при роботі за шаблоном і де можна контролювати цей процес обробки, включно з можливістю втручання через зміну значень даних.
- Текст прямої процедури сторінки, відсутній у режимі роботи за шаблоном.
- Зв'язки на дані підсистеми "Збір Даних", які видимі і доступні для визначення у режимі роботи за шаблоном та у ввімкненому стані об'єкту сторінки.
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;
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!