From OpenSCADAWiki
Jump to: navigation, search

Events, their processing and the events' maps

Given the range of tasks for which OpenSCADA may be used, it is necessary to provide a tool for control of interactive user events. This is due to the fact, that in dealing with individual tasks of embedded systems, input and control devices can greatly vary. But it is enough to look at the regular office keyboard and notebook one, that would remove any doubt about the necessity for the manager of events.

The events manager must work using the maps of events. Events map is a list of named events with indicating its origin. The origin of the events can be a keyboard, mouse, joystick, etc. At an event emerge the events manager is looking for it in the active map and compares with the name of the event. A comparison name of the event is placed in the queue for processing. Widgets in this case must process the given queue of events.

The active map of the events is specified in the profile of each user or it is set by default, in planes.

In general, four types of events are provided:

  • events of the VCA shapes-primitives (prefix: ws_), for example, the event of pressing of the screen button — "ws_BtPress";
  • keyboard events (prefix: key_) — all events from mouse and keyboard in the form of — "key_presAlt1";
  • user events (prefix: usr_) are generated by the user in the procedures of the widgets calculation;
  • mapping events (prefix: map_) — events from the events map, in planes.

The event itself does not provide enough information, especially if it is processed at the levels above. To uniquely identify the event and its source, the event in the whole is written as follows: "ws_BtPress:/curtime". Where:

ws_BtPress — event;
/curtime — path to the child element that has generated the event.

Table 3.5 provides a list of standard events, the support of which should be provided in visualizers of VCA.

Table 3.5. Standard events

Identifier Description
Keyboard events: key_[pres|rels][Ctrl|Alt|Shift]{Key}
*SC#3b Scan-code of the key.
*#2cd5 Code of the unnamed key.
*Esc "Esc".
*BackSpace Removing of the previous character — "<--".
*Return, *Enter Enter — "Enter".
*Insert Insertion — "Insert".
*Delete Deleting — "Delete".
*Pause Pause — "Pause".
*Print Print of the screen — "Print Screen".
*Home Home — "Home".
*End End — "End".
*Left To the left — "<-".
*Up To the up — '^'.
*Right To the right — "->".
*Down To the down — '\/'.
*PageUp Page up — "PageUp".
*PageDown Page down — "PageDown".
*F1 ... *F35 Function key from "F1" to "F35".
*Space Space — ' '.
*Apostrophe Apostrophe — '`'.
*Asterisk Asterisk on the additional field of the keyboard — '*'.
*Plus Plus on the additional field of the keyboard — '+'.
*Comma Comma — ','.
*Minus Minus — '-'.
*Period Period — '.'.
*Slash Slash — '\'.
*0 ... *9 Number from '0' to '9'.
*Semicolon Semicolon — ';'.
*Equal Equal — '='.
*A ... *Z Keys of Latin alphabet from 'A' to 'Z'.
*BracketLeft Left square bracket - '['.
*BackSlash Backslash — '/'.
*BracketRight Right square bracket — ']'.
*QuoteLeft Left quote — .
Keyboard focus events.
ws_FocusIn Focus is obtained by the widget.
ws_FocusOut Focus is lost by the widget.
Mouse events:
key_mouse[Pres|Rels][Left|Right|Midle] Pressed/released the mouse button.
key_mouseDblClick Double-click the left mouse button.
Events of quietance on the side of the visualizer.
ws_alarmChange Notifies about the alarm status change, the attribute "alarmSt".
ws_alarmLev Quietance of all violations by all notices methods and types.
ws_alarmNtf{N} Quietance of all violations by the type {N} (0...7).
Events of the elementary figure primitive ElFigure:
ws_Fig[Left|Right|Midle|DblClick] Activating of the figures (fills) by the mouse button.
ws_Fig{N}[Left|Right|Midle|DblClick] Activating of the figure (fill) N by the mouse button.
Events of the form element primitive FormEl:
ws_LnAccept A new value in the input line is set.
ws_TxtAccept The value of the text editor is changed.
ws_ChkChange The state of the flag is changed.
ws_BtPress The button is pressed.
ws_BtRelease The button is released.
ws_BtToggleChange The button toggle is changed.
ws_BtMenu={Item} Selection of the menu Item on the button.
ws_BtLoad The selected file loaded.
ws_CombChange The value of the combo box is changed.
ws_ListChange The current list item is changed.
ws_TreeChange The current tree item is changed.
ws_TableChangeSel The table item selection is changed.
ws_TableEdit_{colN}_{rowN} The table cell ({colN}:{rowN}) is edited.
ws_SliderChange The slider position is changed.
Events of the media content primitive Media:
ws_MapAct{N}[Left|Right|Midle] Media area with the number N is activated by the mouse button.
ws_MediaFinished Media-stream play is finished.

Events are the main notification mechanism and are actively used to interact with the user. There are two mechanisms for processing events:

  • Primary — the script of management of pages opening.
  • Secondary — the computational procedure of the widget.

The mechanism "Script for the control the opening of pages" based on the basic attribute of the widget "evProc", which can be used for opening the pages. Scenario of this attribute is stored as a list of commands with the syntax: "{event}:{evSrc}:{com}:{prm}". Where:

  • event — expected event;
  • evSrc — path of the nested widget-source of the event;
  • com — session command;
  • prm — parameter of the command.

The following commands are implemented:

  • open — opening page; page to open is specified in the parameter prm both in direct way and as a template, example: /pg_so/1/*/*;
  • next — opening of the next page; page to open is specified in the parameter prm as a template, example: /pg_so/*/*/$;
  • prev — opening of the previous page; page to open is specified in the parameter prm as a template, example: /pg_so/*/*/$.

Special characters of the template are deciphered as follows:

  • pg_so — direct name of the desired-static page (with the prefix), requires the compulsory accordance and is used to identify the last open page;
  • 1 — name of a new page in a general way (without a prefix);
  • * — the page is taken from the name of a previous opened page or the first available page is substituted, if the previous opened page is missing;
  • $ — points the place of the opened page relative to which you are to go to the next or to the previous one.

For a correct understanding of working the template mechanism, when choosing a page, we give a few real examples:

  • Changing the signal object:
Initially: /pg_so/pg_1/pg_mn/pg_1
Command: open:/pg_so/2/*/*
Result: /pg_so/pg_2/pg_mn/pg_1
  • Switching of the view type:
Initially: /pg_so/pg_1/pg_mn/pg_1
Command: open:/pg_so/*/gkadr/*
Result: /pg_so/pg_1/pg_gkadr/pg_1
  • Next/previous page of the view type:
Initially: /pg_so/pg_1/pg_mn/pg_1
Command: next:/pg_so/*/*/$
Result: /pg_so/pg_1/pg_mn/pg_2

As an example, let's give a script to provide the work of the main page of the user interface: </translate>

ws_BtPress:/prev:prev:/pg_so/*/*/$
ws_BtPress:/next:next:/pg_so/*/*/$
ws_BtPress:/go_mn:open:/pg_so/*/mn/*
ws_BtPress:/go_graph:open:/pg_so/*/ggraph/*
ws_BtPress:/go_cadr:open:/pg_so/*/gcadr/*
ws_BtPress:/go_view:open:/pg_so/*/gview/*
ws_BtPress:/go_doc:open:/pg_so/*/doc/*
ws_BtPress:/go_resg:open:/pg_so/rg/rg/*
ws_BtPress:/so1:open:/pg_so/1/*/*
ws_BtPress:/so2:open:/pg_so/2/*/*
ws_BtPress:/so3:open:/pg_so/3/*/*
ws_BtPress:/so4:open:/pg_so/4/*/*
ws_BtPress:/so5:open:/pg_so/5/*/*
ws_BtPress:/so6:open:/pg_so/6/*/*
ws_BtPress:/so7:open:/pg_so/7/*/*
ws_BtPress:/so8:open:/pg_so/8/*/*
ws_BtPress:/so9:open:/pg_so/9/*/*
ws_BtPress:*:open:/pg_control/pg_terminator

<translate> The mechanism "Processing the events with the help of computational procedure of the widget" is based on the attribute "event" and the user procedure of calculating written with the help of the programming language of OpenSCADA. The events, in process of receipt, are accumulated in the attribute "event" till the moment of call of the computational procedure. The computational procedure is called with the specified frequency of calculating the widget and receives the attribute "event" value as the list of events. In the calculation procedure the user can: analyze, process and delete the processed events from the list, and add to the list new events. The remaining, after the procedure execution, and new events are analyzed for compliance with the conditions of the call by means of script of the primary mechanism, after which the remaining events are transmitted to the upper by the hierarchy widget to be processed by it, with the appending of the events path in accordance with the hierarchy of the penetration.

The content of the attribute "event" is a list of events in the format "{event}:{evSrc}", with the event on the separate line. Here is an example of processing events in the Java-like programming language of the OpenSCADA: </translate>

for(ev_rez = "", off = 0; (sval=event.parse(0,"\n",off)).length; ) {
  if(sval == "ws_BtPress:/cvt_light") alarmSt = 0x1000001;
  else if(sval == "ws_BtPress:/cvt_alarm") alarmSt = 0x1000002;
  else if(sval == "ws_BtPress:/cvt_sound") alarmSt = 0x1000004;
  else ev_rez += sval+"\n";
}
event = ev_rez;