基于事件的设备仿真框架
项目描述
一个基于事件的、多设备仿真框架,提供复杂多设备仿真的配置和编排。
PyPI |
pip install tickit |
源代码 |
|
文档 |
|
版本 |
一个示例仿真包括一个简单的计数器和接收器。计数器增加一个给定值,然后将这个值传递给接收器。
仿真使用yaml文件定义,其中指定了所需组件的图示。该文件定义了一个名为 counter 的 Counter 设备和一个名为 counter_sink 的 Sink 设备。 counter 的输出 _value 连接到 counter_sink 的输入。
- type: examples.devices.counter.Counter
name: counter
inputs: {}
- type: tickit.devices.sink.Sink
name: counter_sink
inputs:
input:
component: counter
port: _value
执行此文件以运行仿真。
python -m tickit all examples/configs/counter.yaml
仿真将输出描述计数器增加的日志。
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)
计数器设备如下定义。它增加一个给定值,并在增加时记录。
@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),
)
有关更详细的文档,请参阅 https://dls-controls.github.io/tickit。
项目详细信息
下载文件
下载适合您平台文件的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
tickit-0.4.3.tar.gz (234.9 kB 查看哈希值)
构建分发
tickit-0.4.3-py3-none-any.whl (59.7 kB 查看哈希值)
关闭
tickit-0.4.3.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9b449e84196ace9cf7f489de3ec782c38aae09124cb2c1d45feb62649fdcbc3a |
|
MD5 | 08d7d5b528c9d69a0a179ffd10278910 |
|
BLAKE2b-256 | a358a6fbeccba6ad280c81a3746ed3442a7d10495f6c9f798eeccbcbd9bbbb3f |
关闭
tickit-0.4.3-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d87697f7020d89a4690a0975cad7ea175eed374eade757d61516db3ae4738b84 |
|
MD5 | 76d5e26be27a6f8fd32775e072803169 |
|
BLAKE2b-256 | 9447075ef49be0bcce5fa75edc3a48c81140e1a18a5420948a9800824a053424 |