diff --git a/fi/signal_3xh2.go b/fi/signal_3xh2.go new file mode 100644 index 0000000..cc5c20e --- /dev/null +++ b/fi/signal_3xh2.go @@ -0,0 +1,74 @@ +package fi + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/entity" +) + +// Drive3XH2Dd 点灯操作 +// dd : true-物理点灯;false-物理灭灯 +func Drive3XH2Dd(w ecs.World, signalId string, dd bool) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH2ElectronicType.Get(signalEntry) + driveDd := component.RelayDriveType.Get(state.Z3XH2_DDJ) + //点灯继电器落下时才点灯 + driveDd.Td = !dd + driveDd.Xq = !dd + } + }) +} + +// Drive3XH2Lx 开通列车信号(绿灯亮) +func Drive3XH2Lx(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH2ElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ) + driveLx.Td = true + driveLx.Xq = true + driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ) + driveYx.Td = false + driveYx.Xq = false + } + }) +} + +// Drive3XH2Yx 开通引导信号(黄灯亮且红灯亮) +func Drive3XH2Yx(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH2ElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ) + driveLx.Td = false + driveLx.Xq = false + driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ) + driveYx.Td = true + driveYx.Xq = true + } + }) +} + +// Drive3XH2Non 开通禁止信号(红灯亮) +func Drive3XH2Non(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.Signal3XH2ElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ) + driveLx.Td = false + driveLx.Xq = false + driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ) + driveYx.Td = false + driveYx.Xq = false + } + }) +}