From 92c1f38ff1dac35fd7aa24e4e2435a7946cc6ca5 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 9 Oct 2023 16:42:16 +0800 Subject: [PATCH] fi signal 3xh4 --- fi/signal_3xh4.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 fi/signal_3xh4.go diff --git a/fi/signal_3xh4.go b/fi/signal_3xh4.go new file mode 100644 index 0000000..0f536d5 --- /dev/null +++ b/fi/signal_3xh4.go @@ -0,0 +1,60 @@ +package fi + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/entity" +) + +// signal 3xh4 接口:点灯操作、开通列车信号、开通禁止信号 + +// Drive3XH4Dd 点灯操作 +// dd : true-物理点灯;false-物理灭灯 +func Drive3XH4Dd(w ecs.World, signalId string, dd bool) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH4ElectronicType.Get(signalEntry) + driveDd := component.RelayDriveType.Get(state.Z3XH4_DDJ) + //点灯继电器落下时才点灯 + driveDd.Td = !dd + driveDd.Xq = !dd + } + }) +} + +// Drive3XH4Lx 开通列车信号(直向通过亮绿灯,侧向通过亮黄灯) +// zx : true-直向通过,false-侧向通过 +func Drive3XH4Lx(w ecs.World, signalId string, zx bool) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH4ElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.Z3XH4_LXJ) + driveLx.Td = true + driveLx.Xq = true + driveZx := component.RelayDriveType.Get(state.Z3XH4_ZXJ) + driveZx.Td = zx + driveZx.Xq = zx + } + }) +} + +// Drive3XH4Non 开通禁止信号(亮红灯) +func Drive3XH4Non(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH4ElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.Z3XH4_LXJ) + driveLx.Td = false + driveLx.Xq = false + driveZx := component.RelayDriveType.Get(state.Z3XH4_ZXJ) + driveZx.Td = false + driveZx.Xq = false + } + }) +}