Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

This library is part of Hat Open project - open-source framework of tools and libraries for developing applications used for remote monitoring, control and management of intelligent electronic devices such as IoT devices, PLCs, industrial automation or home automation systems.

Development of Hat Open and associated repositories is sponsored by Končar - Power Plant and Electric Traction Engineering Inc. (Končar KET - https://www.koncar-ket.hr).

For more information see:

About

Hierarchical state machine library with support for SCXML and Graphviz visualization:

EventName = str
"""Event name"""

StateName = str
"""State name"""

ActionName = str
"""Action name"""

ConditionName = str
"""Condition name"""

class Event(typing.NamedTuple):
    name: EventName
    payload: typing.Any = None

class Transition(typing.NamedTuple):
    event: EventName
    target: typing.Optional[StateName]
    actions: typing.List[ActionName] = []
    conditions: typing.List[ConditionName] = []
    internal: bool = False

class State(typing.NamedTuple):
    name: StateName
    children: typing.List['State'] = []
    transitions: typing.List[Transition] = []
    entries: typing.List[ActionName] = []
    exits: typing.List[ActionName] = []
    final: bool = False

Action = typing.Callable[['Statechart', typing.Optional[Event]], None]
"""Action function"""

Condition = typing.Callable[['Statechart', typing.Optional[Event]], bool]
"""Condition function"""

class Statechart:
    """Statechart engine"""

    def __init__(self,
                 states: typing.Iterable[State],
                 actions: typing.Dict[str, Action],
                 conditions: typing.Dict[str, Condition] = {}): ...

    @property
    def state(self) -> typing.Optional[StateName]:
        """Current state"""

    def register(self, event: Event):
        """Add event to queue"""

    async def run(self):
        """Run statechart"""

def parse_scxml(scxml: typing.Union[typing.TextIO, pathlib.Path]
                ) -> typing.List[State]:
    """Parse SCXML"""


def create_dot_graph(states: typing.Iterable[State]) -> str:
    """Create DOT representation of statechart"""

Metadata

Release files for hat-stc 0.4.1.dev20210601

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hat-stc 0.4.1.dev20210601
File Interpreter ABI Platform
hat_stc-0.4.1.dev20210601-cp38.cp39-none-any.whl CPython 3.9, CPython 3.8 none any Details

Release files / hat_stc-0.4.1.dev20210601-cp38.cp39-none-any.whl

Download URL hat_stc-0.4.1.dev20210601-cp38.cp39-none-any.whl
Size 6.7 kB
Tags CPython 3.8 CPython 3.9
SHA-256 checksum
How to use checksums
8db15ab854b3dc8b5d7a3deddae23283182f1eebde9012f06798a3440a31f25a
BLAKE2b-256 checksum
How to use checksums
9aa34a964700eeff7745a72195029037ef85141558ef9b4beea7797a9117dfa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page