With events you can save some set of process related data in a separate log, an event log and then analize these sets or data. For events you define trigger conditions and actions, i.e. what data to save. Then you get records which can be used further in many ways:
Unlike building the necessary protocols by 'mining' information in the database (logs), event reports are generated 'on the fly' ie. at a pace with the monitoring process.
Setup / Events menu is for adding events into a project.
'Add event' button is located in the top-right page corner:
In the Basic tab, there are 3 items:
If there is some process that could happen “inside” a parent event and is a part of the whole event you can declare it as “child” event. Child events have some features:
After a 3.3 version, WebHMI has simpler condition setting - if some register's value equal or not equal to another value. There could be several conditions acting by logical 'AND' operation.
Of course, the event conditions sometimes may be very complex, but with Lua scripts you can describe any imaginable condition:
-- complex event start condition local tmr_state, count_down = Timer(var1 > 60, ON_DELAY, OFF_DELAY, "myTimer_1") local eventEnableCondition = var2 and var3 or (var4 and count_down >= 30)
The events may have or do not have duration in time. For lasting events (that is more common application) you set special checkbox Has some duration in time. Lasting events are good solution when you have some regular batching process lasting several minutes. For long lasting processes (with durations of days, weeks or more) they not always can be appropriate (see note on events below).
For day, week etc. totals you can latch neccessary data in an one-shot event. For such an event condition must be true for ONLY one scan. Otherwise the records will be added in every scan while event condtion is true. See the note below.
The 'Action' tab of the event settings determines what, how, and when have to be recorded in the event report data structure.
Besides a common register selection list, there are 3 extra values in the list:
When there are configured and logged events in a project, an event viewing page became accessible too:
You can mark some row in the table (having error, alert etc.). There is a 'Highlight' tab in the event configuration, where you can set the condition:
Then the rows will be highlighted like #7 in the list above.
For the columns of the event view table, you can add totals in the table's bottom. They are set up in the “Totals” tab:
There is a report constructor similar to the screen constructor right in the event configuration. It can show that kind of a report:
Like in screen editor, you pick widgets and arrange them on the canvas.
Below notes on the widgets for the report constructor are given:
The graph widget is drawn based on the graph already existing in the project. You just pick one of the graph from a list:
For the time range, event start / end times are used.
It's similar to that of the screen widget. You can select only child event as data source for the diagram.
The summary shows duration of all events:
Please refer to the demo project gannt diagram in events example. Rename the file to .bak after download.
Register value widget is similar to that in the screen editor, except for register selection: you can only pick up one of the event's (or nested sub-events) actions.
You can add options to add text label, change font size for both value text and text label, display measurement units and scale:
For a scale, you set start, end point and its color:
If you want the value be centered with the scale, choose windows centered option in the Appearance tab:
Please note that in the edit mode the value is refered to as “Ey.x”, where E - means event, y - event id, x - action number.
Values table widget is identical to that one in the screen editor except for register selector (only from event's actions).
These are identical to the screen editor widgets, except for the register selector.
It is simple html editor, please refer to the video below. For the actions - you can type action address in the form of Ey.x or use action picker.
Besides above application, there are extra options for the recorded event data:
There is a report builder in the Level2 system as well which uses data taken from WebHMI as a source. More on this here.
When you set Show on timeline checkbox for events, the timeline view become available in the Report sub-menu where you can analize how the events has been logged.
The Report constructor for events may not be convinient in some cases:
In this cases, still a desired report can be obtained from particular events, lua, api and screen/dashboard editor. You can use the following approach:
Please refer to the following application note.
Due to 'on the fly' method of recordig events, WebHMI project restart will cause an event being recorded to “split”. If you have some important report or critical data in your project and edit or comission the project remotely, apply changes when the event unlikely to happen or won't cause data distortion.
With one-time event, i.e. those not having 'event has duration' checkbox set, remember that while the event condition is true WebHMI will generate excess records in the DB on every scan. Use lua script which provides one scan duration of the event enabling condition.
The script which gives a right condtion for an one-shot event (running every hour) could be like this:
function main (userId) -- vars local prev_cur_hour = R("cur_hour") -- read current stored value local cur_hour = os.date("%H", os.time()) -- read RTC -- logic if (cur_hour ~= prev_cur_hour) then W("one_time_event_condition", 1) W("cur_hour", cur_hour) else W("one_time_event_condition", 0) -- prevents further calls end end
Be carefull with different start and end condition for lasting events. Becuase when they intersect, i.e. end conditino happens while start condition is true, you will get multiple events at once.