From 90f41b558f76910e5b7c6073de246c0fcba79541 Mon Sep 17 00:00:00 2001 From: RedstoneParkour <39594309+RedstoneParkour@users.noreply.github.com> Date: Mon, 24 Aug 2026 19:53:12 +0200 Subject: [PATCH 1/2] add a simple gauge and a simple annunciator board --- server/example/simulation_module.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/example/simulation_module.py b/server/example/simulation_module.py index c2f4d7b..8dad1dd 100644 --- a/server/example/simulation_module.py +++ b/server/example/simulation_module.py @@ -25,6 +25,15 @@ class PositionType(Enum): Momentary = 0, Maintained = 1, +class Gauge(devices.DeviceBase): + def __init__(self, name: str): + super().__init__(device_type="Gauge",name=name) + self._fields = [devices.DeviceField("Value", 0, 0.0)] + +class AnnunciatorBoard(devices.DeviceBase): + def __init__(self, name: str, annunciators: [str]): + super().__init__(device_type="AnnunciatorBoard",name=name) + self._fields = [devices.DeviceField(annunciators[idx], idx, 0) for idx in range(len(annunciators))] class SBMSelector(devices.DeviceBase): def __init__(self, name: str,positions:dict): @@ -49,9 +58,13 @@ def __init__(self): self.DG_1 = SBMBreaker("DG_1") self.DG_1_Off = Indicator("DG_1_Off") self.DG_1_On = Indicator("DG_1_On") + self.DG_Speed = Gauge("DG_Speed") + self.BOARD_603200 = AnnunciatorBoard("BOARD_603200", ["TEST"]) devices.REGISTRY.add_device(self.DG_1) devices.REGISTRY.add_device(self.DG_1_Off) devices.REGISTRY.add_device(self.DG_1_On) + devices.REGISTRY.add_device(self.DG_Speed) + devices.REGISTRY.add_device(self.BOARD_603200) self.EngineState = False def OnTick(self,world:simulation.SimulationContext,ctx:simulation.TickContext): @@ -62,6 +75,13 @@ def OnTick(self,world:simulation.SimulationContext,ctx:simulation.TickContext): elif devices.REGISTRY.get_device(self.DG_1.device_id).get_field_by_id(0).value == 0: self.EngineState = False + if self.EngineState: + self.DG_Speed.set_field_value(0, 1.0) + self.BOARD_603200.set_field_value(0, 1) + else: + self.DG_Speed.set_field_value(0, 0.0) + self.BOARD_603200.set_field_value(0, 0) + self.DG_1_Off.set_field_value(0, not self.EngineState) self.DG_1_On.set_field_value(0, self.EngineState) From 43c984cf2ed54e7da621463f65e62eb640dfe01a Mon Sep 17 00:00:00 2001 From: RedstoneParkour <39594309+RedstoneParkour@users.noreply.github.com> Date: Fri, 28 Aug 2026 15:54:53 +0200 Subject: [PATCH 2/2] have AnnunciatorBoard use an enum instead of raw int values could probably have used an IntEnum but meh also removed the commas after the PositionType enum because it turns out those commas make the value a tuple (like `(0,)`) and i doubt that's right --- server/example/simulation_module.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/example/simulation_module.py b/server/example/simulation_module.py index 8dad1dd..13896cc 100644 --- a/server/example/simulation_module.py +++ b/server/example/simulation_module.py @@ -22,18 +22,27 @@ def on_interaction(self, interaction_id, interaction_type, data): return (True, "") class PositionType(Enum): - Momentary = 0, - Maintained = 1, + Momentary = 0 + Maintained = 1 class Gauge(devices.DeviceBase): def __init__(self, name: str): super().__init__(device_type="Gauge",name=name) self._fields = [devices.DeviceField("Value", 0, 0.0)] +class AnnunciatorState(Enum): + Clear = 0 + Active = 1 + Acknowledged = 2 + ActiveClear = 3 + class AnnunciatorBoard(devices.DeviceBase): def __init__(self, name: str, annunciators: [str]): super().__init__(device_type="AnnunciatorBoard",name=name) self._fields = [devices.DeviceField(annunciators[idx], idx, 0) for idx in range(len(annunciators))] + def set_field_value(self, field: int, value: AnnunciatorState): + super().set_field_value(field, value.value) + pass class SBMSelector(devices.DeviceBase): def __init__(self, name: str,positions:dict): @@ -77,10 +86,10 @@ def OnTick(self,world:simulation.SimulationContext,ctx:simulation.TickContext): if self.EngineState: self.DG_Speed.set_field_value(0, 1.0) - self.BOARD_603200.set_field_value(0, 1) + self.BOARD_603200.set_field_value(0, AnnunciatorState.Active) else: self.DG_Speed.set_field_value(0, 0.0) - self.BOARD_603200.set_field_value(0, 0) + self.BOARD_603200.set_field_value(0, AnnunciatorState.Clear) self.DG_1_Off.set_field_value(0, not self.EngineState) self.DG_1_On.set_field_value(0, self.EngineState)