Simulation Context Data

We provide some specific data access from the simulation context to allow you to enhance your simulation configuration.

  • The data provided is accessible in Python scripts only

  • Use the Namespace SimulationContext followed by a dot and the data qualifier, which you want to access

  • See the table below for a list of data that is accessible in Python scripts

SimulationContext.Time

Represents the simulation time as System.DateTime (.NET type). Can be used as getter in all python scripts.

You can use the following methods:

  • SimulationContext.Time.Year

  • SimulationContext.Time.Month

  • SimulationContext.Time.Day

  • SimulationContext.Time.Hour

  • SimulationContext.Time.Minute

  • SimulationContext.Time.Second

  • SimulationContext.Time.Millisecond

  • SimulationContext.Time.DayOfWeek

  • SimulationContext.Time.DayOfYear

Example usage 1 as gateway condition

SimulationContext.Time.Hour>12

will check, whether current time is 13:00 or later.

Example usage 2 as gateway condition

SimulationContext.Time.DayOfWeek=='Friday'

will check, whether current day is Friday.

At time-based events with scripted inter-arrival time, you can use operations like:

GotoHour(x)

jump to hour x (with x being an integer between 0 and 23)

GotoMinute(x)

jump to minute x (with x being an integer between 0 and 59)

SimulationContext.Resources

Provides access to the current state of resources. Can only be used as getter.

You can use the following methods:

  • SimulationContext.Resources.IsIdle(ROLE_STRING)

  • SimulationContext.Resources.Count(ROLE_STRING)

  • SimulationContext.Resources.CountIdle(ROLE_STRING)

  • SimulationContext.Resources.CountBusy(ROLE_STRING)

  • SimulationContext.Resources.AcquireForElementLifetime(ROLE_STRING)

Example usage 1 as gateway condition

SimulationContext.Resources.IsIdle('executive officer')

will check, whether at least one 'executive officer' is free.

Example usage 2 as gateway condition

SimulationContext.Resources.CountIdle('executive officer')>=3

will check, whether at least three 'executive officer' are free.

Example usage as subprocess activity expression

SimulationContext.Resources.AcquireForElementLifetime('executive officer')

is set in the expression of a subprocess activity and thus occupies the resource 'executive officer' for the duration of the subprocess.

SimulationContext.Product

Represents and provides access to the current product. Can be used as getter or setter.

You can use the following:

  • SimulationContext.Product.Name

  • SimulationContext.Product.Unit = "piece(s)"

  • SimulationContext.Product.Amount = 1

  • SimulationContext.Product.Transform(NAME_STRING, AMOUNTCONVERTER_FUNCTION = NULL, UNIT_STRING = NULL)

  • SimulationContext.Product.Take(AMOUNT)

Example usage as gateway condition

SimulationContext.Product=='standard product'

will check, whether the current product is called 'standard product'.

Example usage 1 as activity expression

SimulationContext.Product = 'standard product'

will set the current product to 'standard product'.

No product history.

Example usage 2 as activity expression

SimulationContext.Product = SimulationContext.Product.Transform('special product', lambda n: n * 3)

will transform the current product to 'special product' with tripple the amount of the former product. (The unit doesn’t change.)

Retains product history.

Example usage 3 as activity expression

SimulationContext.Product = SimulationContext.Product.Take(4)

takes 4 of the unit from the product quantity in order to do something separately with it. For example, you could have 10 water canisters and want to store 4 of them for later use.

Retains product history.

SimulationContext.Costing

Provides access to the driver-dependent cost centers.

You can use the following method:

  • SimulationContext.Costing.Amount(COSTCENTER_STRING)

Example usage as activity expression

amount = SimulationContext.Costing.Amount('FEK')

will get the cost amount of the cost center 'FEK' at the time of the call and assign it to the variable 'amount'.

SimulationContext.Globals

Represents a collection of keys and values, aka a dictionary. It allows you to make variables and their values available across multiple instances.

Example usage as activity expression

SimulationContext.Globals["x"] = 3

will make the variable x globally available and set its value to 3.

SimulationContext.Debug

The method SimulationContext.Debug(MESSAGE_STRING) can be used for debugging your script. The message is displayed in the debug report of the simulation report.