You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/wiki/concepts/Execution-Modes.md
+68-1
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,15 @@ All inputs in simulation are driven off the provided timestamped data of its inp
6
6
In realtime mode, the engine runs in wallclock time as of "now".
7
7
Realtime engines can get data from realtime adapters which source data on separate threads and pass them through to the engine (ie think of activeMQ events happening on an activeMQ thread and being passed along to the engine in "realtime").
8
8
9
-
Since engines can run in both simulated and realtime mode, users should **always** use **`csp.now()`** to get the current time in `csp.node`s.
9
+
Since engines can run in both simulated and realtime mode, users should **always** use **`csp.now()`** to get the current time in a `csp.node`.
-[Realtime Group Event Synchronization](#realtime-group-event-synchronization)
18
19
19
20
## Simulation Mode
@@ -50,6 +51,72 @@ When consuming data from input adapters there are three choices on how one can c
50
51
|**BURST**| Simulation | all ticks from input source with duplicate timestamps (on the same timeseries) will tick once with a list of all values |
51
52
|| Realtime | all ticks that occurred since previous engine cycle will tick once with a list of all the values |
52
53
54
+
## Handling duplicate timestamps
55
+
56
+
In `csp`, there can be multiple engine cycles that occur at the same engine time. This is often the case when using nodes with internal alarms (e.g. [`csp.unroll`](Base-Nodes-API#cspunroll)) or using feedback edges ([`csp.feedback`](Feedback-and-Delayed-Edge#cspfeedback)).
57
+
If multiple events are scheduled at the same timestamp on a single time-series edge, they will be executed on separate cycles *in the order* they were scheduled. For example, consider the code snippet below:
58
+
59
+
```python
60
+
import csp
61
+
from csp import ts
62
+
from datetime import datetime, timedelta
63
+
64
+
@csp.node
65
+
defticks_n_times(x: ts[int], n: int) -> ts[int]:
66
+
# Ticks out a value n times, incrementing it each time
A real life example is when using `csp.unroll` to tick out a list of values on separate engine cycles. If we were to use `csp.sample` on the output, we would get the *first* value that is unrolled at each timestamp. Why?
99
+
The event that is scheduled on the sampling timer is its first (and only) event at that time; thus, it is executed on the first engine cycle, and samples the first unrolled value.
100
+
101
+
```python
102
+
defsampling_unroll():
103
+
u = csp.unroll(csp.const.using(T=[int])([1, 2, 3]))
0 commit comments