Event

Event is the simplest way to schedule some action in the model. Thus, events are commonly used to model delays and timeouts. Sometimes you do the same using timed transitions in statecharts, but events might be more efficient. 

There are three types of events:

There is another type of event defined with another model element -  dynamic event. Dynamic events are used to schedule any number of concurrent and independent events. For example, a communication channel which is able to transmit an arbitrary number of messages concurrently can be modeled with the help of dynamic events that are created for each message. 

This document gives you the general information about event and its properties. More specific information can be found in the help topics relevant to particular event types.

  To create an event
  1. Drag the Event element from the  Agent palette onto the agent's graphical diagram.
  2. Once the event is created, you can specify its name in the text line editor opened on the right of the element in the graphical editor. When finished, press Enter and go to the Properties view.  
  3. Specify the event’s action in the Action section. There you can write Java code to be executed on the event occurrence. Probably it would be more convenient to define this code as a function or as an action chart and place the function call here.
  4. Using the Trigger type drop-down list, choose the type of event and configure the event using the specific properties of this particular event type.
General properties

Name – The name of the event. The name is used to identify and access the event.

Show name – If selected, the name of the event is displayed on a presentation diagram.

Ignore – If selected, the event is excluded from the model.

Visible – If selected, the event is visible on a presentation at runtime.

Trigger type – The event's trigger type:

Timeout – The event is timeout triggered. The event occurs according to the chosen Mode.

Rate – The event is rate triggered. The event occurs with the specified Rate.

Condition – The event is condition triggered. The event occurs when the specified boolean Condition evaluates to true.

Mode – [Visible if Trigger type is Timeout] Choose here the mode of the timeout triggered event:

User control – The event will work in manual mode. It will occur only when the user calls the event’s restart function passing the timeout as the argument, for instance myEvent.restart(15).
 If the timeout is fixed, you can define it once in the Timeout property and simply call myEvent.restart() without specifying the timeout as a function parameter.

Occurs once – The event will occur only once exactly in the specified  (absolute) or Occurence date. You can define the occurrence time as a calendar date (choose Use calendar dates) or as a number of model time units to be passed from the model start (choose Use model time).
Please note that here you define the absolute time and in the case the event will be created after the specified time, it will never occur.

Cyclic – The event will occur cyclically. You define the First occurrence time (absolute) or Occurrence date and the Recurrence time for an event. The first occurrence time can be defined either as a calendar date (choose Use calendar dates), or as a number of model time units to be passed from the model start (choose Use model time).
Please note that you define absolute times. If you want to use relative times (i.e. count the first occurrence time from the moment this event will be created), use time() function in the First occurrence time (absolute) property. time() will refer to the moment this event was created at.

Timeout – [Visible if Trigger type is Timeout and Mode is User control] The expression evaluating the timeout that should pass from the moment when the user starts the event by calling its restart() function.

Use model time - [Visible if Trigger type is Timeout and Mode is Occurs once or Cyclic] If selected, the event will occur at the specified model time. 

Use calendar dates - [Visible if Trigger type is Timeout and Mode is Occurs once or Cyclic] If selected, the event will occur at the specified calendar date.

Occurrence time (absolute) – [Visible if Trigger type is Timeout, Mode is Occurs once and Use model time is selected] The absolute time of event occurrence defined as a number of model time units to be passed from the model start.

Occurence date - [Visible if Trigger type is Timeout, Mode is Occurs once or Cyclic and Use calendar dates is selected] The calendar date and time of the event.

First occurrence time (absolute) – [Visible if Trigger type is Timeout, Mode is Cyclic and Use model time is selected] The absolute time of the first occurrence of the cyclic event, defined as a number of model time units to be passed from the model start.

Recurrence time – [Visible if Trigger type is Timeout and Mode is Cyclic] The recurrence time of the cyclic event.

Rate – [Visible if Trigger type is Rate] The rate triggering the event. Event will occur with the timeout distributed exponentially with the parameter rate, e.g. if the rate is 5, event will occur on average 5 times per time unit.

Condition – [Visible if Trigger type is Condition] The condition triggering the event. Event will occur when the specified Boolean expression is true. 

Action

Java code to be executed on event occurrence.


Related topics

 Timeout triggered event

Condition triggered event

 Rate triggered event

 Dynamic event