- class sismic.model.ActionStateMixin(on_entry=None, on_exit=None)¶
State that can define actions on entry and on exit.
- class sismic.model.BasicState(name, on_entry=None, on_exit=None)¶
A basic state, with a name, transitions, actions, etc. but no child state.
- class sismic.model.CompoundState(name, initial=None, on_entry=None, on_exit=None)¶
Compound states must have children states.
- class sismic.model.ContractMixin¶
Mixin with a contract: preconditions, postconditions and invariants.
- class sismic.model.DeepHistoryState(name, on_entry=None, on_exit=None, memory=None)¶
A deep history state resumes the execution of its parent, and of every nested active states in its parent.
- class sismic.model.Event(name, **additional_parameters)¶
An event with a name and (optionally) some data passed as named parameters.
The list of parameters can be obtained using dir(event). Notice that name and data are reserved names. If a delay parameter is provided, then this event will be considered as a delayed event (and won’t be executed until given delay has elapsed).
When two events are compared, they are considered equal if their names and their data are equal.
str) – name of the event.
data – additional data passed as named parameters.
- class sismic.model.FinalState(name, on_entry=None, on_exit=None)¶
Final state has NO transition and is used to detect state machine termination.
- class sismic.model.HistoryStateMixin(memory=None)¶
History state has a memory that can be resumed.
str]) – name of the initial state
- class sismic.model.InternalEvent(name, **additional_parameters)¶
Subclass of Event that represents an internal event.
- class sismic.model.MacroStep(time, steps)¶
A macro step is a list of micro steps.
- property transitions: List[Transition]¶
A (possibly empty) list of transitions that were triggered.
- Return type
- property entered_states: List[str]¶
List of the states names that were entered.
- Return type
- class sismic.model.MetaEvent(name, **additional_parameters)¶
Subclass of Event that represents a MetaEvent, as used in property statecharts.
- class sismic.model.MicroStep(event=None, transition=None, entered_states=None, exited_states=None, sent_events=None)¶
Create a micro step.
A step consider event, takes a transition and results in a list of entered_states and a list of exited_states. Order in the two lists is REALLY important!
Event]) – Event or None in case of eventless transition
Transition]) – a Transition or None if no processed transition
str]]) – possibly empty list of entered states
str]]) – possibly empty list of exited states
Event]]) – a possibly empty list of events that are sent during the step
- class sismic.model.OrthogonalState(name, on_entry=None, on_exit=None)¶
Orthogonal states run their children simultaneously.
- class sismic.model.ShallowHistoryState(name, on_entry=None, on_exit=None, memory=None)¶
A shallow history state resumes the execution of its parent. It activates the latest visited state of its parent.
- class sismic.model.StateMixin(name)¶
State element with a name.
str) – name of the state
- class sismic.model.Statechart(name, description=None, preamble=None)¶
Python structure for a statechart
- property preamble¶
- property states¶
List of state names in lexicographic order.
Return the state instance that has given name.
Return the name of the parent of given state name.
Return the names of the children of the given state.
Return an ordered list of ancestors for the given state. Ancestors are ordered by decreasing depth.
Return an ordered list of descendants for the given state. Descendants are ordered by increasing depth.
Return the depth of given state (1-indexed).
- least_common_ancestor(name_first, name_second)¶
Return the deepest common ancestor for s1 and s2, or None if there is no common ancestor except root (top-level) state.
Return the leaves of names.
Considering the list of states names in names, return a list containing each element of names such that this element has no descendant in names.
- property transitions¶
List of available transitions
Register given transition and register it on the source state
Remove given transitions.
- rotate_transition(transition, new_source='', new_target='')¶
Rotate given transition.
You MUST specify either new_source (a valid state name) or new_target (a valid state name or None) or both.
Return the list of transitions whose source is given name.
Return the list of transitions whose target is given name. Internal transitions are returned too.
Return the list of transitions that can be triggered by given event name.
Return a list containing the name of every event that guards a transition in this statechart.
If name_or_names is specified, it must be the name of a state (or a list of such names). Only transitions that have a source state from this list will be considered. By default, the list contains all the states.
- add_state(state, parent)¶
Add given state (a StateMixin instance) on given parent (its name as an str). If given state should be use as a root state, set parent to None.
Remove given state.
The transitions that involve this state will also be removed. If the state is the target of an initial or memory property, their value will be set to None. If the state has children, they will be removed too.
- rename_state(old_name, new_name)¶
Change state name, and adapt transitions, initial state, memory, etc.
- move_state(name, new_parent)¶
Move given state (and its children) such that its new parent is new_parent.
Notice that a state cannot be moved inside itself or inside one of its descendants. If the state to move is the target of an initial or memory property of its parent, this property will be set to None. The same occurs if given state is an history state.
- copy_from_statechart(statechart, *, source, replace, renaming_func=<function Statechart.<lambda>>)¶
Copy (a part of) given statechart into current one.
Copy source state, all its descendants and all involved transitions from statechart into current statechart. The source state will override replace state (but will be renamed to replace), and all its descendants in statechart will be copied into current statechart.
All the transitions that are involved in the process must be fully contained in source state (ie. for all transition T: S->T, if S (resp. T) is a descendant-or-self of source, then T (resp. S) must be a descendant-or-self of source).
If necessary, callable renaming_func can be provided. This function should accept a (state) name and return a (new state) name. Use renaming_func to avoid conflicting names in target statechart.
- Return type
- class sismic.model.Transition(source, target=None, event=None, guard=None, action=None, priority=None)¶
Represent a transition from a source state to a target state.
A transition can be eventless (no event) or internal (no target). A condition (code as string) can be specified as a guard.
str) – name of the source state
str]) – name of the target state (if transition is not internal)
str]) – event name (if any)
str]) – condition as code (if any)
str]) – action as code (if any)
priority – priority (default to 0)
- property internal¶
Boolean indicating whether this transition is an internal transition.
- property eventless¶
Boolean indicating whether this transition is an eventless transition.