FSM Module#
SPDX-FileCopyrightText: 2024 DESY and the Constellation authors SPDX-License-Identifier: EUPL-1.2
- class core.fsm.SatelliteFSM#
Bases:
StateMachine
Manage the satelliteās state and its transitions.
- DEAD#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- ERROR#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- INIT#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- NEW#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- ORBIT#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- RUN#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- SAFE#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- complete#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- failure#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- final_states = [State('Dead', id='DEAD', value=<SatelliteState.DEAD: 255>, initial=False, final=True)]#
- initial_state#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- initialize#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- initialized#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- initializing#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- interrupt#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- interrupted#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- interrupting#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- land#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- landed#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- landing#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- launch#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- launched#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- launching#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- name = 'SatelliteFSM'#
- reconfigure#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- reconfigured#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- reconfiguring#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- shutdown#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- start#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- started#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- starting#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- states = [State('New', id='NEW', value=<SatelliteState.NEW: 16>, initial=True, final=False), State('Init', id='INIT', value=<SatelliteState.INIT: 32>, initial=False, final=False), State('Orbit', id='ORBIT', value=<SatelliteState.ORBIT: 48>, initial=False, final=False), State('Run', id='RUN', value=<SatelliteState.RUN: 64>, initial=False, final=False), State('Safe', id='SAFE', value=<SatelliteState.SAFE: 224>, initial=False, final=False), State('Error', id='ERROR', value=<SatelliteState.ERROR: 240>, initial=False, final=False), State('Initializing', id='initializing', value=<SatelliteState.initializing: 18>, initial=False, final=False), State('Launching', id='launching', value=<SatelliteState.launching: 35>, initial=False, final=False), State('Landing', id='landing', value=<SatelliteState.landing: 50>, initial=False, final=False), State('Reconfiguring', id='reconfiguring', value=<SatelliteState.reconfiguring: 51>, initial=False, final=False), State('Starting', id='starting', value=<SatelliteState.starting: 52>, initial=False, final=False), State('Stopping', id='stopping', value=<SatelliteState.stopping: 67>, initial=False, final=False), State('Interrupting', id='interrupting', value=<SatelliteState.interrupting: 14>, initial=False, final=False), State('Dead', id='DEAD', value=<SatelliteState.DEAD: 255>, initial=False, final=True)]#
- states_map = {SatelliteState.DEAD: State('Dead', id='DEAD', value=<SatelliteState.DEAD: 255>, initial=False, final=True), SatelliteState.ERROR: State('Error', id='ERROR', value=<SatelliteState.ERROR: 240>, initial=False, final=False), SatelliteState.INIT: State('Init', id='INIT', value=<SatelliteState.INIT: 32>, initial=False, final=False), SatelliteState.NEW: State('New', id='NEW', value=<SatelliteState.NEW: 16>, initial=True, final=False), SatelliteState.ORBIT: State('Orbit', id='ORBIT', value=<SatelliteState.ORBIT: 48>, initial=False, final=False), SatelliteState.RUN: State('Run', id='RUN', value=<SatelliteState.RUN: 64>, initial=False, final=False), SatelliteState.SAFE: State('Safe', id='SAFE', value=<SatelliteState.SAFE: 224>, initial=False, final=False), SatelliteState.initializing: State('Initializing', id='initializing', value=<SatelliteState.initializing: 18>, initial=False, final=False), SatelliteState.interrupting: State('Interrupting', id='interrupting', value=<SatelliteState.interrupting: 14>, initial=False, final=False), SatelliteState.landing: State('Landing', id='landing', value=<SatelliteState.landing: 50>, initial=False, final=False), SatelliteState.launching: State('Launching', id='launching', value=<SatelliteState.launching: 35>, initial=False, final=False), SatelliteState.reconfiguring: State('Reconfiguring', id='reconfiguring', value=<SatelliteState.reconfiguring: 51>, initial=False, final=False), SatelliteState.starting: State('Starting', id='starting', value=<SatelliteState.starting: 52>, initial=False, final=False), SatelliteState.stopping: State('Stopping', id='stopping', value=<SatelliteState.stopping: 67>, initial=False, final=False)}#
- stop#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- stopped#
An event is triggers a signal that something has happened.
They are send to a state machine and allow the state machine to react.
An event starts a Transition, which can be thought of as a ācauseā that initiates a change in the state of the system.
See also Events.
- stopping#
A State in a StateMachine describes a particular behavior of the machine. When we say that a machine is āinā a state, it means that the machine behaves in the way that state describes.
- Args:
- name: A human-readable representation of the state. Default is derived
from the name of the variable assigned to the state machine class. The name is derived from the id using this logic:
name = id.replace("_", " ").capitalize()
- value: A specific value to the storage and retrieval of states.
If specified, you can use It to map a more friendly representation to a low-level value.
- initial: Set
True
if theState
is the initial one. There must be one and only one initial state in a statemachine. Defaults to
False
.- final: Set
True
if represents a final state. A machine can have optionally many final states. Final states have no Transition starting from It. Defaults to
False
.- enter: One or more callbacks assigned to be executed when the state is entered.
See Actions.
- exit: One or more callbacks assigned to be executed when the state is exited.
See Actions.
State is a core component on how this library implements an expressive API to declare StateMachines.
>>> from statemachine import State
Given a few statesā¦
>>> draft = State("Draft", initial=True)
>>> producing = State("Producing")
>>> closed = State('Closed', final=True)
Transitions are declared using the
State.to()
orState.from_()
(reversed) methods.>>> draft.to(producing) TransitionList([Transition(State('Draft', ...
The result is a TransitionList. Donāt worry about this internal class. But the good thing is that it implements the
OR
operator to combine transitions, so you can use the|
syntax to compound a list of transitions and assign to the same event.You can declare all transitions for a state in one single line ā¦
>>> transitions = draft.to(draft) | producing.to(closed)
⦠and you can append additional transitions for a state to previous definitions.
>>> transitions |= closed.to(draft)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Producing', 'Closed'), ('Closed', 'Draft')]
There are handy shortcuts that you can use to express this same set of transitions.
The first one,
draft.to(draft)
, is also called a Self transition, and can be expressed using an alternative syntax:>>> draft.to.itself() TransitionList([Transition(State('Draft', ...
You can even pass a list of target states to declare at once all transitions starting from the same state.
>>> transitions = draft.to(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
Sometimes itās easier to use the
State.from_()
method:>>> transitions = closed.from_(draft, producing, closed)
>>> [(t.source.name, t.target.name) for t in transitions] [('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
- class core.fsm.SatelliteStateHandler(*args: Any, **kwargs: Any)#
Bases:
HeartbeatChecker
,BaseSatelliteFrame
- get_state(_request: CSCP1Message | None = None) tuple[str, Any, dict[str, Any]] #
Return the current state of the Satellite.
No payload argument.
Payload of the response contains ālast_changedā
- get_status(_request: CSCP1Message | None = None) tuple[str, Any, dict[str, Any]] #
Get a string describing the current status of the Satellite.
No payload argument.
- initialize(request: CSCP1Message) tuple[str, Any, dict[str, Any]] #
Initiate āinitializeā state transition via a CSCP request.
Takes dictionary with configuration values as argument.
If the transition is not allowed, TransitionNotAllowed will be thrown by the FSM.
- land(request: CSCP1Message) tuple[str, Any, dict[str, Any]] #
Initiate landing state transition via a CSCP request.
No payload argument.
If the transition is not allowed, TransitionNotAllowed will be thrown by the FSM.
- launch(request: CSCP1Message) tuple[str, Any, dict[str, Any]] #
Initiate launch state transition via a CSCP request.
No payload argument.
If the transition is not allowed, TransitionNotAllowed will be thrown by the FSM.
- reconfigure(request: CSCP1Message) tuple[str, Any, dict[str, Any]] #
Initiate reconfigure state transition via a CSCP request.
Takes dictionary with configuration values as argument.
If the transition is not allowed, TransitionNotAllowed will be thrown by the FSM.