Absolute time

Patterns using time and duration in DCR graphs

We’ve identified a set of patterns for how to use time and duration in DCR graphs.

  • Put a deadline on hold in building case permits
    • We’ve worked with Genoa and Copenhagen Municipalities on building permit process and have found a pattern where a deadline is put on hold while awaiting information from the applicant
  • Start an activity when a child reaches a certain age
    • Working with Syddjurs Municipality we’ve seen examples where certain activities must start when a child reaches the age of 16 or 18
  • Set a deadline based on data

ISO 8601 Durations in DCR 4.5

In previous versions of the engine we used C# Timestamp to specify durations. As ISO 8601 provide a standard for durations, https://en.wikipedia.org/wiki/ISO_8601#Durations, we decided to use this format instead. The 4.5 version will still support C# Timestamp.

A duration of 5 days, 3 hours, 4 minutes and 2 seconds can be specified as outlined below.

# C# TimeSpan             ISO 8601 Duration
5.03:04:02                P5DT3H4M2S

Delays and deadlines as expressions

Previously, the time value for a deadline (response) or a delay (condition) could only be a relative time. We now allow arbitrary expressions, and the expression language has been extended with (a) dates, (b) relative times, (c) arithmetic between (a) and (b), and (d) an expression now which returns the graph current time.

Example use:

Input is a data event. If you input the duration P3D into Input and then execute A, the
deadline for B will be Input + P2D = P3D + P2D = P5D, that is, 5 in days.

Record is an auto-computation event; executing it will automatically set its value to now, which evaluates always to the graph’s current time. If you execute Input, wait 3 days, then execute A, then the deadline for B will be now - Input + P2D = now - (three days ago) + P2D = -P3D + P2D. We use here that the engine allows subtraction of absolute dates now and Input. You can use this to make a graph where you input a date value and immediately use that input to set a deadline:

Absolute time in DCR 3.0

We introduced Time in DCR 2.0 and in DCR 3.0 we introduce absolute time. DCR 2.0 only supported time as time ticks which was integer values.

DCR 3.0 supports absolute time where a delay or deadline can be specified as a time span.

A timespan has the format:

[ws][-]{ d | d.hh:mm[:ss[.ff]] | hh:mm[:ss[.ff]] }[ws]

with these examples:

  • 1 – meaning 1 day
  • 1.2:0:0 – meaning 1 day and 2 hours, 0 minutes and 0 seconds
  • 0.2:30 – meaning 2 hours and 30 minutes

Elements in square brackets ([ and ]) are optional. One selection from the list of alternatives enclosed in braces ({ and }) and separated by vertical bars (|) is required. The following table describes each element.

Element Description
ws Optional white space.
An optional minus sign, which indicates a negative TimeSpan.
d Days, ranging from 0 to 10675199.
. A culture-sensitive symbol that separates days from hours. The invariant format uses a period (“.”) character.
hh Hours, ranging from 0 to 23.
: The culture-sensitive time separator symbol. The invariant format uses a colon (“:”) character.
mm Minutes, ranging from 0 to 59.
ss Optional seconds, ranging from 0 to 59.
. A culture-sensitive symbol that separates seconds from fractions of a second. The invariant format uses a period (“.”) character.
ff Optional fractional seconds, consisting of one to seven decimal digits.

Please refer to TimeSpan class for details.

Simulation with time

When you start simulation you can set the current time. The default value is right now but you can change the value forward and backwards as you like.

Start simulation with time

When the simulation is started you can always see the current time of the simulation, as well as the next deadline and next delay. You can easily advance time by 1 day, 3 days and 1 week (7 days).

Time panel in simulation

Example graph

This graph outlines an example of how to use absolute time in DCR graphs.

Supporting working days

Different countries have different working days. In order to support this the engine can be extended with a special DLL which calculates the number of working days. For more information please consult the API documentation for TimeManager class.

DCR Active Repository

In DCR Active Repository we also support time. GetEnabledOrPending now returns next deadline and next delay as absolute time.

You can advance time in the graph by invoking settime.

Sidebar



Bitnami