OpenSCADA

Libs/Prescriptions

English • ‎mRussian • ‎Українська
Name Version License Source Languages Author Icon Description
Prescriptions 1.1, 1.1 GPLv2

OscadaLibs.db (SQL, GZip) > DAQ.tmplb_PrescrTempl
vcaBase.db (SQL, GZip) > VCA.wlb_prescr

en, uk, ru Roman Savochenko LibPrescriptions.png Library of elements of scenarios of the technological operations — prescriptions.
- move the graphical part items to all work through the prescription manager, for the possibility to distribute the parts remotely.

The library is created to provide an environment of execution of scenarios of the technological operations — prescriptions, and frames of the user interface about them, including the frame of creation/edition the prescriptions and two frames of the execution control and reporting — "Prescription — run" and "Prescription — run, simple". The library is built on the basis primitives of the widgets and the internal programming language JavaLikeCalc, including templates and commands.

The element's names and their parameters are available in languages: English, Ukrainian and mRussian. Their source code wrote in human-language independent mode with calls for the translations by the function tr() and the message's translation also allowed for English, Ukrainian and mRussian.

Contents

1 Conception

The scenario of technological operations — prescription, is a sequentially call of the function's blocks — commands, which taking up to five arguments and return string with the result code at the begin: "Working (0)", "Finished (>0)" and "Error (<0)". Calling the step command is made in a loop until the "Working (0)" result is returned. Jump to the next step is made in the case of the "Finished (>0)" result and the command "Pass (2)". In the case of an error, the "Error (<0)" result, the prescription execution is terminated.

The commands sequence, by the user of the final interface, are formed on the frame of creation/editing and are controlled for their execution on the frame "Prescription — run" and "Prescription — run, simple", when, the prescriptions data is stored in the programs-prescriptions DB table. The prescriptions-programs table is placed into the accessible OpenSCADA specific configuration database, as an example, currently such table is placed in the library database as "PrescrProgs = (name, prgTxt)", where:

The prescriptions-programs XML-tree starts with the "prg" tag that contains the command end tags "com" with attributes:

For example, for a four-step prescription we will have:

<prg>
  <com arg1="10" id="Timer" />
  <com arg1="10" id="Vacuum" />
  <com arg1="20" id="Timer" />
  <com arg1="34" id="Enable coils" />
</prg>

The prescription execution making through the prescription manager's parameter, which support two modes of the prescription commands execution:

The execution mode "command-parameter"
The commands-parameters of the logical level are formed by the programmer of SCADA-system under the specific application area as templates of parameters of the subsystem "Data acquisition", which next used into the logical controller of the prescriptions, include series of mandatory, service and internal attributes:

A specific of using commands-parameters is their independent execution and the ability to leave the execution of a number of commands in the background, such as regulators. These commands can also be directly connected to a data source through links, or even implemented in the same template-parameter.

At.png This mode is now the main one, and it has implemented many mechanisms of interaction with visualization and control frames, which may not work or work erroneously with the old "command-macro" mode!

The execution mode "command-macro" (old)
The commands-macros, which user can choose during the formation of a prescription-program, are formed by the programmer of SCADA-system under the specific application area by editing a commands table in OpenSCADA. The commands table is placed into the accessible OpenSCADA specific configuration database, as an example, currently such table is placed in the library database as "PrescrComs = (name, proc, arg1, arg2, arg3, arg4, arg5)", where:

An example of the program code for the "Timer" command, which does not depend on the application area:
JavaLikeCalc.JavaScript
if(f_start) tmp1 = arg1;
var curTm = tmp1.toReal();
if(curTm <= 0) { rez = "1:Waiting is elapsed for "+arg1+"s"; return; }
curTm -= 1/f_frq;
tmp1 = max(0, curTm);
rez = "0:Waiting now for "+curTm+"s";

The several command names are reserved for the special purposes:

2 Part of processing and executing

The section contains DAQ-templates of the prescription manager and commands of the "command-template" mode, which are intended to be connected to the logic level controller, by creating related parameters of the prescription manager and commands, which available for the user to choose from, and which will carry out all the work with the prescriptions-programs for their processing and execution.

For connection the library part to a project of the OpenSCADA station you can obtain the database file as:

wget http://oscada.org/svn/trunk/OpenSCADA/data/LibsDB/OscadaLibs.sql
sqlite3 -init OscadaLibs.sql OscadaLibs.db .exit

This obtained file next you can place into the project directory of the station and create the database object for the DB module "SQLite", registering the database file in the configuration.


2.1 Prescriptions manager (manager)

2.2 GPLv2 * en, uk, ru Roman Savochenko
Result and the operative setup.

Basic, representative and unified template of a manager and a controller of the prescriptions, of their processing and direct execution in the "command-macro" mode. The template forms a structure of the prescription manager parameter which can be easily connected to all frames of this library.

The representative structure of the prescription manager is:

Functions

CATEGORY: defines the user prescription-program ID ProgNM in the form "uprg{ProgNM}", where:
  • "uprg*" — the typical template-sign of a user prescription-program, that can be directly used in the category filter to determine in the messages only the user prescriptions-programs;
  • ProgNM — the prescription-program name.
TEXT: the action description in the form "{ActDescr} "{ProgNM}" : {StartTm} : {ActTm}", where:
  • ActDescr — the action description:
  • "No current node present";
  • "Terminated program session by the user";
  • "Terminated program session by the error";
  • "Successful session of the program".
  • ProgNM — the prescription-program name;
  • StartTm — start time of the prescription-program, in the form "2020-03-14 16:05:01";
  • ActTm — action time of the prescription-program, in the form "2020-03-14 16:05:52".

Template IOs

Identifier Name Type Mode Attribute Configuration Value
dbDB DB: DB name with the tables String Input Read only Constant
dbComs DB: Table with commands String Input Not attribute Constant PrescrComs
dbProgs DB: Table with programs String Input Read only Constant PrescrProgs
comsCntr Commands controller,

<empty> - for commands into the table,
'*' - this parameter's controller

String Input Not attribute Constant *
mode Mode Integer numbers selection Input Full access Variable -2

-2;-1;0;1;2;3 Finish;Error;Stop;Run;Pause;Pass com

curMode Current mode Integer numbers selection Input Read only Variable -2

-2;-1;0;1;2;3 Finish;Error;Stop;Run;Pause;Pass com

prog Name of the selected program String Input Full access Variable
startTm Start time, seconds Integer Input Read only Variable
curCom Current command-step String Input Read only Variable
work Work program Object Input Read only Variable
comLs Commands list Object Input Read only Variable
clcCnt Cycles counter Integer Input Not attribute Variable
this The object Object Input Not attribute Variable
f_err Function error String Input Not attribute Variable 0
f_frq Frequency of calculation of the function, Hz Real Input Not attribute Variable 1000
f_start Function start flag Boolean Input Not attribute Variable 0
f_stop Function stop flag Boolean Input Not attribute Variable 0
Configuration.

Configuring and using

1. Create and start a logical controller object with the needed scheduling properties.
2. Create a logical parameter object, for the case of using the logical controller, and select this template for it. Enable the parameter.
  • [JavaLikeCalc] or select this template for the JavaLikeCalc controller; enable the controller; create a parameter "manager" of reflection the representative attributes:
dbDB
dbProgs
comLs
prog
mode
curMode
startTm
curCom
work
3. Into the tab "Template configuration" of the object of the logical parameter, or the controller for [JavaLikeCalc], you need to set:
  • DB: DB name with the tables — to DB, like to "SQLite.vcaBase", where stored or must be stored the prescription-program tables. The empty value is not allowed and will cause an error!
  • DB: Table with programs — to name of the prescriptions-programs table, by default it is "PrescrProgs".
  • Commands controller — left it in the default value "*", to use this parameter's controller for the commands also. You must change this field if you run the manager controller object in a separate logical controller for the commands!
  • [JavaLikeCalc] or and additionally:
  • Commands controller — change this field in a separate logical controller for the commands!
  • [Command-macro] or and additionally:
  • DB: Table with commands — to name of the commands table, by default it is "PrescrComs";
  • Commands controller — set to <empty>.
4. Place the required parameters of the commands together to the manager parameter.
  • [Command-macro] or prepare the required commands in "DB: Table with commands" according to the conception; the empty commands table must be created automatically after starting the object of the logical parameter, or the controller for [JavaLikeCalc]!
5. RESULT: Launching the controller object (where this parameter is created), we must get the operational data in the tab "Attributes" for the: allowed commands list, current mode, work program, current command-step and start time.
  • [JavaLikeCalc] or the JavaLikeCalc controller object directly.
6. In the process of the working, through the tab "Attributes" of operational data, in addition to obtaining the result, it is possible to perform operative setup and control on:
  • Name of the selected program — to set of the selected program name in processing by the manager;
  • Mode — to set the manager mode of the selected prescription-program execution: Finish(-2), Error(-1), Stop(0), Run(1), Pause(2), Pass command(3).

2.2 Templates of the commands

2.2.1 Command — Timer (timer)

2.0 GPLv2 * en, uk, ru Roman Savochenko
Result and the operative setup.

Template of a command of the prescription typical timer. The timer is only designed to hold time between other action steps and for example, so it only has one attribute, "Time" in seconds.

Template IOs

Identifier Name Type Mode Attribute Configuration Value
start Prescription: start Boolean Input Full access Variable 0
stop Prescription: stop Boolean Input Full access Variable 0
error Prescription: error Boolean Input Full access Variable 0
abort Prescription: abort Boolean Input Full access Variable 0
run Command: run Boolean Input Full access Variable 0
pause Command: pause Boolean Input Full access Variable 0
rez Command: result String Input Full access Variable 1
arg1 Time, seconds Real Input Full access Variable
tmp1 Temporary 1 Real Output Not attribute Variable 0
f_stop Function stop flag Boolean Input Not attribute Variable 0
f_frq Frequency of calculation of the function, Hz Real Input Not attribute Variable 1000
f_err Function error String Input Not attribute Variable 0
f_start Function start flag Boolean Input Not attribute Variable 0

Configuring and using

1. Create and start a logical controller object with the needed scheduling properties, or use created one for the prescription engine.
2. Create a logical parameter object and select this template for it. Enable the parameter.
3. RESULT: Launching, we must get the operational data in the tab "Attributes" for the command result.
4. In the process of the working, through the tab "Attributes" of operational data, in addition to obtaining the result, it is possible to perform operative setup and control on the representative attributes of the prescription commands and the additional ones:
  • Time — to set time of the timer in seconds.


2.2.2 Command — Background timer (backTimer)

2.0 GPLv2 * en, uk, ru Roman Savochenko
Result and the operative setup.

Template of a command of the prescription background timer. The timer designed only for hold a time in the background to an example, then it contains only one attribute, it is "Time" in seconds.

Template IOs

Identifier Name Type Mode Attribute Configuration Value
start Prescription: start Boolean Input Full access Variable 0
stop Prescription: stop Boolean Input Full access Variable 0
error Prescription: error Boolean Input Full access Variable 0
abort Prescription: abort Boolean Input Full access Variable 0
run Command: run Boolean Input Full access Variable 0
pause Command: pause Boolean Input Full access Variable 0
rez Command: result String Input Full access Variable 1
arg1 Time, seconds Real Input Full access Variable
tmp1 Temporary 1 Real Output Not attribute Variable 0
f_stop Function stop flag Boolean Input Not attribute Variable 0
f_frq Frequency of calculation of the function, Hz Real Input Not attribute Variable 1000
f_err Function error String Input Not attribute Variable 0
f_start Function start flag Boolean Input Not attribute Variable 0

Configuring and using

1. Create and start a logical controller object with the needed scheduling properties, or use created one for the prescription engine.
2. Create a logical parameter object and select this template for it. Enable the parameter.
3. RESULT: Launching, we must get the operational data in the tab "Attributes" for the command result.
4. In the process of the working, through the tab "Attributes" of operational data, in addition to obtaining the result, it is possible to perform operative setup and control on the representative attributes of the prescription commands and the additional ones:
  • Time — to set time of the timer in seconds.

3 Graphical part

Contains elements-frames of the prescription of the end type and elements-widgets, what intended to be placed in the mnemonic schemes part (the type of view) of the project tree of the pages, built on the concept of the signal objects of the root page "RootPgSo" and to be placed on the other complex frames. However, elements-frames may be located as separate entities or as part of your own concept of the page management, but it should be take in account that frames often refer and call certain control panels of the common usage and related elements!

For connection the library part to a project of the OpenSCADA station you can obtain the database file as:

wget http://oscada.org/svn/trunk/OpenSCADA/data/LibsDB/vcaBase.sql
sqlite3 -init vcaBase.sql vcaBase.db .exit

This obtained file next you can place into the project directory of the station and create the database object for the DB module "SQLite", registering the database file in the configuration.


3.1 Prescription — edit (prescrEdit)

1.3 GPLv2 * en, uk, ru Roman Savochenko

The frame, shown in Figure 3.1, is one of the group frames for working with the prescriptions, which serves for the user-editing of the prescriptions-programs. The frame commonly uses and represents the representative structure of the prescription manager.

The frame contains from left to right:

Fig.3.1a. The "Prescription — edit" frame in the development mode.

Using — development
The frame is designed to perform the role of page, and should therefore be placed directly in the project's tree. To the frame can be connected one parameter of the prescription manager, by setting the links.

Using — runtime
In the runtime mode, the user can add new prescription-programs, delete, copy and export the existing ones as well as to import prescriptions from other OpenSCADA stations. In the selected prescription-program user can do: add or insert a new step, remove or move the selected step. For the selected steps of the prescription-program the user can set the command and enter the name, description, background execution flag and values for the available arguments of the selected command, and then to save changes of the step.

Removal operations are accompanied by the confirmation dialog.

Fig.3.1b. The "Prescription — edit" frame in the runtime mode.

{Linking and configuring the attributes

Identifier Name Type Configuration Configuration template
dbDB DB: Data base String Input link Controller|dbDB
dbProgs DB: Programs table String Input link Controller|dbProgs
prExtComLs Available commands list Object Input link Controller|comLs


3.2 Prescription — run (prescrRun)

1.3 GPLv2 * en, uk, ru Roman Savochenko

The frame, shown in Figure 3.2, is one of the group frames for working with the prescriptions, which serves for control and observing of executing the programs-prescriptions, previously formed in the Prescription — edit frame. The frame commonly uses and represents the representative structure of the prescription manager. In addition to this full-format prescription frame, there is a simplified one — "Prescription — run, simple, that allows you to manage and to track compactly the prescriptions execution in other frames of the technological process.

The frame contains from the left to the right:

Fig.3.2a. The "Prescription — run" frame in the development mode.

Using — development
The frame is designed to perform the role of page, and should therefore be placed directly in the project's tree. To the frame can be connected one parameter of the prescription manager, by setting the links.

At.png To archive completed sessions while the operator is switching between frames, this full-format frame in the project tree must be set for the parameter "Page: process not opened".

At the end of the prescription-program, messages with session parameters are generated by the prescription manager, as well as archiving of the session document. The messages with the session parameters can be used either simply to view the sessions history or to create a session list, for example, in the graphics group to go to the history at the session time. The reports archive is set to the depth of 10 documents by default, what you can change by setting the "Archive length (n)" attribute of the document widget.

Using — runtime
In the runtime mode, the user can select the desired prescription-program and run-on the execution, and then track the execution progress or switch to other frames. The running program user can pause by pressing the "Pause" button or terminate by pressing "Stop". In addition, the user can skip the current step by clicking the "Skip" button. Also the user can review or print reports of the previously executed prescriptions of this full-format frame, for what it is necessary to press the left mouse button on the document and browse on the navigation bar through the archive of the executed prescriptions.

Fig.3.2b. The "Prescription — run" frame in the runtime mode.

{Linking and configuring the attributes

Identifier Name Type Configuration Configuration template
dbDB DB: Data base String Input link Controller|dbDB
dbProgs DB: Programs table String Input link Controller|dbProgs
prExtCurCom Controller: current command String Input link Controller|curCom
prExtMode Controller: mode Integer Full link Controller|mode
prExtProg Controller: program String Full link Controller|prog
prExtStartTm Controller: start time Integer Input link Controller|startTm
prExtWork Controller: work Object Input link Controller|work


3.3 Prescription — run, simple (prescrRunSimple)

1.3 GPLv2 * en, uk, ru Roman Savochenko

The widget, shown in Figure 3.3, is a simple variant of the frame "Prescription — run", which designed for placing as a widget of the mnemonic schemes and it mostly works together the frame "Prescription — run". The frame commonly uses and represents the representative structure of the prescription manager.

The widget contains from the left to the right and to the bottom:

Fig.3.3. The "Prescription — run, simple" frame in the development and runtime modes.

Using — development
This widget can be used by the developer to create mnemonic schemes with displaying the prescriptions execution activity and to fast control them. To use it you need to add this widget to a mnemonic scheme, adjust for the horizontal, vertical size, by scaling, and connect to the prescription manager, by setting the links.

Using — runtime
In the runtime mode, the user can select the desired prescription-program, in the dialog of selecting item into tree that appears at the prescription button click, and run-on the execution, and then track the execution progress or switch to other frames. The running program user can pause by pressing the "Pause" button or terminate by pressing "Stop". In addition, the user can skip the current step by clicking the "Skip" button.

{Linking and configuring the attributes

Identifier Name Type Configuration Configuration template
dbDB DB: Data base String Input link Controller|dbDB
dbProgs DB: Programs table String Input link Controller|dbProgs
prExtCurCom Controller: current command String Input link Controller|curCom
prExtMode Controller: mode Integer Full link Controller|mode
prExtProg Controller: program String Full link Controller|prog
prExtStartTm Controller: start time Integer Input link Controller|startTm
prExtWork Controller: work Object Input link Controller|work
Libs/Prescriptions/en - GFDLMay 2024OpenSCADA 0.9.7