Scripted Event Trigger

Scripted Time Instants

We also provide the possibility to script Time Instants in Python (a common scripting language). This is only used, if timing is very complicated, e.g. it depends on complex computations. The following simple statement Result=SimulationContext.Time.GotoHour(9); from the picture below tells the simulation that this event fires every day at 9 o’clock. Of course, this example is very trivial, and could be achieved more easily with Time Instants. But maybe, you want to substitute the '9' with a variable, which is the result on an individual algorithm, you programmed in Python language.

Also have a look at Simulation Context Data for an overview of the available data from the simulation context.

TimeEditor Python
Figure 1. Time Editor in Python-mode for time instants

Scripted duration

The time span of activities can also be scripted using the System.TimeSpan struct. This is only used, if timing is very complicated, e.g. it depends on complex computations. The following simple statement Result=System.TimeSpan.FromHours(8); from the picture below tells the simulation that this activity’s duration is 8 hours. Of course, this example is very trivial, and could be achieved more easily with the stochastic time span. But maybe, you want to substitute the '8' with a variable, which is the result on an individual algorithm, you programmed in Python language.

NewItem1214
Figure 2. Time Editor in Python-mode for an activity’s time span