From OpenSCADAWiki
Jump to: navigation, search
Constr.png Forming for the DAQ part and moving from the old Wiki for VCA one ...
Name Version License Source Languages Author Description
Prescriptions 1.0, 1.0 GPLv2

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

en Roman Savochenko Library of the prescriptions.

1 Conception

2 Processing and executing side

2.1 Prescriptions manager (manager)

2.0 GPLv2 * en, uk, ru Roman Savochenko

Prescriptions manager and controller. Used in addition with user interface's cadre "Prescription: editing" and "Prescription: runtime" for which into a parameter of the controller you must pass that parameters: "mode", "prog", "startTm", "curCom", "comLs", "work".
Sponsor: Vasiliy Grigoriev from "Vacuum technologies laboratory (http://e-beam.ru)".


2.2 Timer (timer)

2.0 GPLv2 * en, uk, ru Roman Savochenko

Typical timer. Hold run up to time elapse.


2.3 Background timer (backTimer)

2.0 GPLv2 * en, uk, ru Roman Savochenko

Background timer. Updating parallel with current command.

3 Graphical representation side

3.1 Prescription:edit (prescrEdit)

1.2 GPLv2 * en, uk, ru Roman Savochenko

The element "Prescription: editing", shown in Fig. 28, is one of the group frames for working with the prescriptions, which serves for the user-editing of prescription-programs.

The prescription-program is a sequentially call of the function's blocks — commands (macros), taking up to five arguments and return string, with result code at 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 "Finished" (> 0) result and command "Pass" (2). In the case of error, the "Error" (<0) result, the execution of the prescription is terminated. Prescription's execution making through prescription controller's parameter, which support two mode of prescriptions execution:

1) direct into the prescription controller object by commands stored into table "PrescrComs";
2) by commands placed in view parameters of the logical controller account it's context, if the logical controller assigned into the prescription controller.

Macro-commands, 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 the commands table in the OpenSCADA or parameters list of selected logical controller. Table of commands is placed to the accessible in the specific OpenSCADA configuration database. As an example, this table is placed to the database of the library with the name "PrescrComs". Table of command has the following structure PrescrComs = (name, proc, arg1, arg2, arg3, arg4, arg5), where:

  • name — the name of macro-command.
  • proc — the text of the macro-command procedure. The procedure in the first line contains the name of the program language, at the moment it is only "JavaLikeCalc.JavaScript", and the program text directly after the language. In the procedure of a macro-command the following context parameters are available:
    • rez — result of the command, by default it returns "Work" ("").
    • f_start — sign of the first procedure's execution.
    • f_frq — frequency of periodic executions of the procedure.
    • arg{1...5} — argument's 1..5 value.
    • tmp{1...10} — temporary parameter's (step execution context) 1...10 value.
An example of 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:Wait elapsed for "+arg1+"s"; return; }
curTm -= 1/f_frq;
tmp1 = max(0,curTm);
rez = "0:Wait now for "+curTm+"s";
  • arg{1...5} — label of the 1..5 argument. Only arguments with the label will be displayed when editing the step of the prescription. Into the label you can set minimum and maximum borders of numeric values of the argument into format "{Label}|{min}|{max}".

The several commands with the following names are reserved for special purposes:

  • "Error" — is called after an error at the prescription's step.
  • "Stop" — is called on stopping a prescription, on successful prescription finishing and on forced shutdown by the user.

The commands-parameters of the logical controller firming as template of parameters of subsystem "Data acquisition", which next used into the logical controller of prescription include mandatory, service and internal attributes:

  • rez — command: execution result; the command should be return string view "{rezCode}:{TextMess}", where rezCode have states:
    • < 0 — error;
    • = 0 — running;
    • > 0 — running finish;
    • = 10 — running into background with indication to update the running state.
  • run — command: execution;
  • pause — command: pause the execution;
  • start — prescription: start;
  • stop — prescription: correct finish;
  • error — prescription: prescription finish by error;
  • abort — prescription: execution abort by operator;
  • arg{1...5} — arguments 1...5. Into an argument name you can set minimal and maximal borders of the numerical value as "{name}|{min}|{max}".

Feature of using the commands-parameters is independent execution and possibility left some commands into background execution, regulators for example.

In the prescription-program formation process through the frame you are working with a table of programs. As an example, this table is placed in the database of the library with the name "PrescrProgs". The table of the programs has the following structure:
PrescrProgs = (name, prgTxt), Where:

  • name — the name of the prescription-program.
  • prgTxt — program text as an XML-tree. In the step command's tags there is the command name (id) and user-specified values of the arguments (arg1 - arg5). For example, for the four-step prescription:
<prg>
  <com arg1="10" id="Timer" />
  <com arg1="20" id="Timer" />
  <com arg1="10" id="Vacuum" />
  <com arg1="34" id="Enable coils" />
</prg>

The "Prescription: editing" frame contains from left to right:

  • "Library" — library with a list of programs and library's control tools.
  • "Program" — the list of commands-steps of the selected in the library prescription-program with the control tools.
  • "Command" — the edit field of the selected step in the prescription, which contains the selection of command and set the values of the available attributes, as well as button to save the changes.

file:prescrEditD.png Fig.28. The "Prescription: editing" frame in the development mode.

Using — Development
This frame should be placed in the mnemonic schemes or panels logical container of the project's tree.

For correct working of the frame it is necessary to copy an existing tables "PrescrComs" (if the commands mode is not into logical controller) and "PrescrProgs" from the database of the library to the desired database or create a new empty tables there by SQL the commands in the desired DB, for example SQLite:

CREATE TABLE PrescrComs (name TEXT, descr TEXT, proc TEXT, arg1 TEXT, arg2 TEXT, arg3 TEXT, arg4 TEXT, arg5 TEXT, PRIMARY KEY (name));
CREATE TABLE PrescrProgs (name TEXT, prgTxt TEXT, PRIMARY KEY (name));

Blank or copied commands table must be edited and filled with necessary commands in the DB "Table" page, if used first mode of commands, or the logical controller assigned, with commands list, into object of the prescription controller for second mode.

After formation of the tables it is necessary in the links of the frame to set the values of the database with tables and the names of tables themselves, specify the name of the export/import file and set link to object of prescription controller.

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, removing or reposition the selected step. For the selected step of the prescription-program the user can set the command and enter values for the available parameters-arguments of the selected command, and then to keep changes of the step.

Fig. 29 shows an example of a frame at runtime.

file:prescrEditR.png Fig.29. The "Prescription: editing" frame in the runtime mode.

Linking attributes

ID Parameter Data type Config Config template Description
Generic configuration
dbDB DB:Database String Constant DB DB address with tables in view {DBType}.{DBName}.
dbProgs DB:Programs String Constant DB Prescriptions-programs table name.
fileExpImp Export/import file String Constant File User's prescriptions-programs file for Export/Import.
Linking to prescription controller. The prescription controller realization example you can see into DB Dynamic model "AGLKS"
prExtComLs The list of available commands of prescription Object Input link Controller|comLs

3.2 Prescription:run (prescrRun)

1.2 GPLv2 * en, uk, ru Roman Savochenko

The element "Prescription: runtime", shown in Fig. 30, is one of the group frames for working with the prescriptions, which serves to direct execution of programs-prescriptions or observe for execution into external program-prescription executor, previously formed in the Prescription: edit frame.

The "Prescription: runtime" frame contains from left to right:

  • "Start/stop/skip" — two buttons to start and stop the selected program and button for skip current step execution.
  • "Library" — library with a list of programs.
  • "Program" — the document of the list of commands-steps of the selected in the library prescription-program. During the execution in this field it is monitored the current state by the appropriate highlight of the steps.

The executable prescription-program may be suspended by pressing the "Pause" button or interrupted by pressing the "Stop" one. Also possible skip step by place to button "Skip" into step execution time.

On the any completion of the prescription-program the message with the parameters of the session is generated, and archiving of the session's document is made. Message with the parameters of a session can be used during viewing the message's archive, or to generate a list of sessions, for example, in the graphics group to go to the history for the session's time. To view the reports history of program's execution you can click on the document and browse on the appearing on the right navigation bar on archival document. By default, the archive of documents is set to the depth of 10 documents.

In addition to full-format frame of prescription execution also provided the simplified, which allow compact control and follow for the prescriptions execution as parts for other frames of a technological process (Fig.30).

file:prescrRunD.png Fig.30. The full-format and simplified "Prescription: runtime" frames in the development mode.

Using — development
This frames should be placed in the mnemonic schemes or panels logical container of the project's tree, for full-format, and to mnemo for simplified.

In the links of the frames it is necessary to set the database with the tables and the name of programs' table themselves as in the Prescription: editing, and also link to controller of prescriptions, like to Prescription: editing.

To provide the possibility of finished sessions archiving while the operator switches to another frame, it is necessary for the full-format frame in the project's tree to set the "Page: process not opened."

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

Fig. 31 shows an example of the full-format and simplified frames at runtime mode.

file:prescrRunR.png Fig.31. The full-format and simplified "Prescription: runtime" frames in the runtime mode.

Linking parameters

ID Parameter Data type Config Config template Description
Generic configuration
dbDB DB:Database String Constant DB DB address with tables in view {DBType}.{DBName}.
dbProgs DB:Programs String Constant DB Prescriptions-programs table name.
Linking to prescription controller. The prescription controller realization example you can see into DB Dynamic model "AGLKS"
prExtCurCom Controller:current command Integer Input link Controller|curCom
prExtMode Controller:mode Integer Full link Controller|mode
prExtProg Controller:program String Full link Controller|prog
prExtStartTm Controller:start Integer Input link Controller|startTm
prExtWork Controller:work Object Input link Controller|work

3.3 Prescription:run (simple) (prescrRunSimple)

1.2 GPLv2 * en, uk, ru Roman Savochenko

The element "Prescription: run simple" is simple variant of the element "Prescription: run" which designed for placing as a widget of mnemo and works only in cooperation with the primary element "Prescription: run".

Executed prescription-programm can been paused, pressing the button "Pause" in the place of the button "Start", or interrupt, pressing the button "Stop".