Skip to content

Managing Timestamps

Andrea Burattin edited this page Mar 7, 2016 · 3 revisions

Managing Timestamps

This page describes how to specify timing information in PLG. You can access these settings by right-clicking on an activity:

Once you clicked on the Activity time menu, this dialog will open:

Alternatively, if you are modeling the process using Signavio, you can enter the scripts in the documentation field of the activity

Activity Duration

It is possible to specify the duration of an activity by adding a Python. This script is requires to contain a function called time_lasted that must accept a string as only parameter. This function will be called, with the case id as parameter, every time the given activity has to be simulated. This function must return a long value, that represents the number of seconds of the given instance of the activity. An example of valid script is:

def time_lasted(caseid):
   return 60

In this case, all instances of the activity will last exactly one minute. If we want to add some randomization it is possible, for example to write:

from random import randint

def time_lasted(caseid):
   return randint(60*5, 60*15)

In this case, activities will have a random duration that goes from 5 to 15 minutes.

Time After Activity

Each activity, after its execution, may require some time, before the beginning of the next one. To specify this time, it is possible to add a Python function into its documentation tag. This function must be called time_after and must accept one parameter (exactly as in the previous case). This function must return a long value, that represents the number of seconds that must be waited after the execution of the activity. An example of valid script is:

def time_after(caseid):
   return 60*2

In this case, the following activity will start two minutes after the completion of the current one.