Table of Contents

Events

About events

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.

Customizing an event

Creating an Event

Setup / Events menu is for adding events into a project.

'Add event' button is located in the top-right page corner:

Event Basic settings

In the Basic tab, there are 3 items:

About parent and child events

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:

Event Condition

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)

Lasting vs. one - shot events

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.

Event Actions

The 'Action' tab of the event settings determines what, how, and when have to be recorded in the event report data structure.

Selecting registers for the event

Besides a common register selection list, there are 3 extra values in the list:

Viewing events data

When there are configured and logged events in a project, an event viewing page became accessible too:

  1. Report access menu
  2. Refresh, adjust list length and download buttons. The latter has csv | html options.
  3. Calendar to pick desired time interval for viewing
  4. Search omnibox
  5. Table header. The columns names are action titles set in Actions tab. There are sort arrows as well.
  6. This is a row with unfinished event i.e. not having end condition fulfilled and interrupted by a new start event condition.
  7. Highlighted event
  8. Row with normal data.
  9. Link to the wrapped (daughter, or nested) event
  10. Link to the event report, configured in the Report builder.

Highlighting events

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.

Calculating column totals

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:

Setting up permissions

You can set permission for the users who may access event view table.

Report constructor

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:

Graph widget

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.

Gannt widget

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

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

Values table widget is identical to that one in the screen editor except for register selector (only from event's actions).

Bar char, hystogram, pie chart

These are identical to the screen editor widgets, except for the register selector.

Text widget

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.

Other event usage options

Besides above application, there are extra options for the recorded event data:

Get event data from external applicaion via API

More on this - here.

Send event data to Level2

There is a report builder in the Level2 system as well which uses data taken from WebHMI as a source. More on this here.

Creating a timeline based on time from the event

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.

Advanced customized reports based on events, screens, lua and api

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.

Notes on event usage

Editing events in the running project

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.

One - time events

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

Lasting events with different start and end condition

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.