The level triggered object may be used to introduce triggers on a changing level. "Levels" are mostly periodically varying quantities, but can be quite general, for example: water height (tidal level), darkness events (dark / light), wind speed or direction, etc.
The level data may either consist of a large data set with data for all relevant model times, or it may be a shorter dataset which is repeated periodically.
It is possible to add triggers on the level, allowing you to execute some custom logic whenever, for example, the water level drops below 1.0m, the wind speed rises above 3 m/s, or when the darkness level switches from dark (0) to light (1) or vice versa.
On the data tab, you enter the source data set that the level triggered event will interpolate. You then add triggers to the Triggers tab, that determine at which point in this data set an event should happen.
The interpolation option determines how data values will be calculated for model times that do not exactly correspond to a row in the table, based on the given data.
Graphically, the difference between the interpolation options is shown below, assuming you have entered a data row at time 0 and a data row at time 10, with wind speed values of 3 m/s and 5 m/s respectively.
The offset can be used shift the whole Data table by a certain amount. For example, if the first entry in the table has time 0 and the times in the table increase by 60 with every time step, you can skip the first 60 rows of the table by setting the offset to 3600. This will consider the row with time 3600 to correspond to model time 0 for this run, the row with time value 3660 to model time 60, etc. This option is useful if you have multiple years of data in the table, and you wish to set up your model (for example using the Experimenter) such that different scenarios or replications use different years from the dataset.
Can be used to repeat the dataset after a certain time interval. For example, if you have a daily repeating sequence, set this value to 24 hours (converted to the time units in your model). This means that the table will wrap around after 24 hours, using the value for time 0 instead of 24 hours, time 1 hour instead of 25 hours, etc. When the dataset has enough data for the whole model run, leave this value at zero.
These fields allow you to quickly change the size of the table, so that you can copy / paste in your dataset.
The Triggers tab allows you to enter the trigger levels at which you want your custom logic to be executed. To add a trigger, click the Add button at the top of the tab. This will add a new trigger at the bottom of the window.
All triggers have a name, which must follow the FlexSim conventions for naming objects. The name is not used during modelling, it is only so that you can easily identify different triggers while editing the triggers on this page.
The level at which the trigger should fire. As the model time runs, FloWorks will interpolate between the points of your dataset as entered on the Data tab, and potentially execute the trigger code each time the (interpolated) level reaches or crosses the level specified in this field.
This condition field allows you to execute the trigger only when a certain requirement is met. By default, the trigger will fire any time the (interpolated) level is reached. The default drop down options are as follows:
In addition, you can write your own custom logic. For the parameters, see the Trigger parameters section below. The requirement code should return a value of true (trigger can be scheduled) or false (ignore the trigger).
This code field specifies the logic you want to run when the trigger level is reached and the "When" requirement is fulfilled.
You can use the "grips" (the gray dots at the left hand side of the trigger) to drag the trigger up or down. Release the mouse button and press Apply to effectuate the new order.
For both the "When" requirement and the "Run logic" trigger code, the following parameters are available:
|level||The current level, at which the trigger is considered for evaluation or is being evaluated.|
|inmode||The direction of change immediately before reaching the trigger level (see below).|
|outmode||The direction of change immediately after reaching the trigger level (see below).|
The inmode and outmode parameters will have one of the following values:
|Value||Meaning for inmode||Meaning for outmode|
|MODE_RISING (1)||The trigger level is reached from below||The trigger level rises after the trigger moment|
|MODE_FALLING (2)||The trigger level is reached from above||The trigger level falls after the trigger moment|
|MODE_STATIONARY (3)||The trigger level is reached from the same value||The trigger level stays at the same value after the trigger moment|
When "no interpolation" is used, the level is considered to remain at the same value throughout each interval and will instantaneously jump to the next value at the end of the interval.
In this case, trigger events can only occur at a level value specified in the table (e.g. if the level is 0 for time 0 through 100, and 1 for time 100 through 200, a trigger at level 0.5 will not fire).
The "outmode" parameter will always be set to MODE_STATIONARY, and the "inmode" parameter will never be MODE_STATIONARY but always MODE_RISING or MODE_FALLING.