Skip to main content

Event-based device simulation framework

Project description

Code CI Docs CI Test Coverage Latest PyPI version Apache License

An event-based multi-device simulation framework providing configuration and orchestration of complex multi-device simulations.

PyPI

pip install tickit

Source code

https://github.com/dls-controls/tickit

Documentation

https://dls-controls.github.io/tickit

Releases

https://github.com/dls-controls/tickit/releases

An example simulation consists of a simple counter and a sink. The counter increments up a given value and then passes this value to a sink.

A simulation is defined using a yaml file, in which the graphing of the required components is denoted. This file defines a Counter device named counter and a Sink device named counter_sink. The output _value of counter is wired to the input of counter_sink.

- type: examples.devices.counter.Counter
  name: counter
  inputs: {}
- type: tickit.devices.sink.Sink
  name: counter_sink
  inputs:
    input:
      component: counter
      port: _value

This file is executed to run the simulation.

python -m tickit all examples/configs/counter.yaml

The simulation will output logs depicting the incrementing of the counter:

DEBUG:examples.devices.counter:Counter initialized with value => 0
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:tickit.core.management.ticker:Doing tick @ 0
DEBUG:tickit.core.components.component:counter got Input(target='counter', time=0, changes=immutables.Map({}))
DEBUG:examples.devices.counter:Counter incremented to 1
DEBUG:tickit.core.management.schedulers.base:Scheduler got Output(source='counter', time=0, changes=immutables.Map({'value': 1}), call_at=1000000000)
DEBUG:tickit.core.management.schedulers.base:Scheduling counter for wakeup at 1000000000
DEBUG:tickit.core.components.component:counter_sink got Input(target='counter_sink', time=0, changes=immutables.Map({}))
DEBUG:tickit.devices.sink:Sunk {}
DEBUG:tickit.core.management.schedulers.base:Scheduler got Output(source='counter_sink', time=0, changes=immutables.Map({}), call_at=None)
DEBUG:tickit.core.management.ticker:Doing tick @ 1000000000
DEBUG:tickit.core.components.component:counter got Input(target='counter', time=1000000000, changes=immutables.Map({}))
DEBUG:examples.devices.counter:Counter incremented to 2
DEBUG:tickit.core.management.schedulers.base:Scheduler got Output(source='counter', time=1000000000, changes=immutables.Map({'value': 2}), call_at=2000000000)

The counting device is defined as below. It increments a given value and logs as it increments.

@dataclass
class Counter(ComponentConfig):
    """Simple counting device."""

    def __call__(self) -> Component:  # noqa: D102
        return DeviceComponent(
            name=self.name,
            device=CounterDevice(),
            )

class CounterDevice(Device):
    """A simple device which increments a value."""

    class Inputs(TypedDict):
        ...

    class Outputs(TypedDict):
        value: int

    def __init__(self, initial_value: int = 0, callback_period: int = int(1e9)) -> None:
        self._value = initial_value
        self.callback_period = SimTime(callback_period)
        LOGGER.debug(f"Counter initialized with value => {self._value}")

    def update(self, time: SimTime, inputs: Inputs) -> DeviceUpdate[Outputs]:
        self._value = self._value + 1
        LOGGER.debug(f"Counter incremented to {self._value}")
        return DeviceUpdate(
            CounterDevice.Outputs(value=self._value),
            SimTime(time + self.callback_period),
        )

See https://dls-controls.github.io/tickit for more detailed documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tickit-0.4.3.tar.gz (234.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tickit-0.4.3-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

Details for the file tickit-0.4.3.tar.gz.

File metadata

  • Download URL: tickit-0.4.3.tar.gz
  • Upload date:
  • Size: 234.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for tickit-0.4.3.tar.gz
Algorithm Hash digest
SHA256 9b449e84196ace9cf7f489de3ec782c38aae09124cb2c1d45feb62649fdcbc3a
MD5 08d7d5b528c9d69a0a179ffd10278910
BLAKE2b-256 a358a6fbeccba6ad280c81a3746ed3442a7d10495f6c9f798eeccbcbd9bbbb3f

See more details on using hashes here.

File details

Details for the file tickit-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: tickit-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 59.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for tickit-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d87697f7020d89a4690a0975cad7ea175eed374eade757d61516db3ae4738b84
MD5 76d5e26be27a6f8fd32775e072803169
BLAKE2b-256 9447075ef49be0bcce5fa75edc3a48c81140e1a18a5420948a9800824a053424

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page