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

Changelog

https://github.com/dls-controls/tickit/blob/master/CHANGELOG.rst

An example device which emits a random value between 0 and 255 whenever called and asks to be called again once the simulation has progressed by the callback_period. Additionally, extenal control of RandomTrampoline is afforded by a RemoteControlledAdapter which is exposed extenally through a TCPServer:

@dataclass
class RandomTrampoline(ComponentConfig):

    def __call__(self) -> Component:  # noqa: D102
        return DeviceSimulation(
            name=self.name,
            device=RandomTrampolineDevice(),
            adapters=[RemoteControlledAdapter(server=TcpServer(format="%b\r\n"))])


class RandomTrampolineDevice(Device):

    Inputs: TypedDict = TypedDict("Inputs", {})
    Outputs: TypedDict = TypedDict("Outputs", {"output": int})

    def __init__(self, callback_period: int = int(1e9)) -> None:
        self.callback_period = SimTime(callback_period)

    def update(self, time: SimTime, inputs: Inputs) -> DeviceUpdate[Outputs]:
        output = randint(0, 255)
        LOGGER.debug(
            "Boing! (delta: {}, inputs: {}, output: {})".format(time, inputs, output)
        )
        return DeviceUpdate(
            RandomTrampoline.Outputs(output=output),
            SimTime(time + self.callback_period),
        )

An example simulation defines a RemoteControlled device named tcp_contr and a Sink device named contr_sink. The observed output of tcp_contr is wired to the input input of contr_sink:

- examples.devices.remote_controlled.RemoteControlled: {}
    name: tcp_contr
    inputs: {}
- tickit.devices.sink.Sink: {}
    name: contr_sink
    inputs:
      input: tcp_contr:observed

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.1.1.tar.gz (45.6 kB view hashes)

Uploaded Source

Built Distribution

tickit-0.1.1-py3-none-any.whl (79.1 kB view hashes)

Uploaded Python 3

Supported by

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