cramph.compiled_tick#
Classes#
A value per node that a pass through the statechart reads on top of the life |
|
One value per node of a statechart that a pass reads, together with the |
|
One node changing its life cycle state during a pass. |
|
Brings every node of a statechart to the state it reaches in one tick. |
Module Contents#
- class cramph.compiled_tick.PassInputKind#
Bases:
enum.StrEnumA value per node that a pass through the statechart reads on top of the life cycle, observation and last observation states.
- LIFE_CYCLE_AT_CYCLE_START = 'life_cycle_at_cycle_start'#
The life cycle state the node entered the tick with.
- HAS_TICK_OBSERVATION = 'has_tick_observation'#
Whether
on_tick()returned an observation for the node this tick.
- OWN_TRANSITION_TAKEN = 'own_transition_taken'#
Whether the node already took a transition triggered by its own conditions this tick.
- class cramph.compiled_tick.PassInput#
One value per node of a statechart that a pass reads, together with the variables standing for it in the compiled pass.
- variables: list[krrood.symbolic_math.symbolic_math.FloatVariable]#
The variable of every node, in node order.
- data: numpy.typing.NDArray[numpy.float64]#
The value of every node, in node order.
- classmethod create(kind: PassInputKind, nodes: list[cramph.node.StatechartNode]) Self#
- Parameters:
kind – What the values stand for.
nodes – The nodes to hold a value for, in node order.
- Returns:
An input holding zero for every node.
- class cramph.compiled_tick.LifeCycleChange#
One node changing its life cycle state during a pass.
- node: cramph.node.StatechartNode#
The node whose life cycle state changed.
- previous_state: cramph.data_types.LifeCycleValues#
The life cycle state before the change.
- new_state: cramph.data_types.LifeCycleValues#
The life cycle state after the change.
- class cramph.compiled_tick.CompiledTick#
Brings every node of a statechart to the state it reaches in one tick.
One compiled pass updates every node at once, reading the states the previous pass left. Passes repeat until no state changes, so how deeply nodes are nested does not change when they react to each other. Within a pass:
A node observes if it was running when the tick started and is still running or paused. Its observation expression reads the states of the previous pass. A node that was paused when the tick started and is still running or paused keeps its observation. A node that stopped running during this tick keeps the observation it stopped on until the next one. Every other node observes Unknown.
A node that has neither ended nor started the tick ended takes over its observation as its last observation.
Every node takes its next life cycle transition, reading the observations of this pass and the life cycle state its parent reaches in this pass. A node takes at most one transition triggered by its own conditions per tick; transitions its parent forces on it always happen.
Note
Life cycle callbacks run afterwards, once per change and in the order the changes happened, so no Python code runs between passes.
- statechart: cramph.statechart.Statechart#
The statechart whose nodes are updated.
- compile() None#
Builds one pass through the statechart, compiles it and binds its inputs to the state arrays it reads, and to the world and float variable data of the context of
statechart.
- settle() list[LifeCycleChange]#
Runs passes until neither a life cycle state nor an observation changes, writing the result of every pass into the statechart.
- Returns:
Every life cycle change, in the order it happened.
- Raises:
TickDoesNotSettleError – If a pass returns the statechart to a state it already had in this tick, which it would then never leave, or if more passes than
_pass_budgetchange it.