diff --git a/fi/signal_jckxh.go b/fi/signal_jckxh.go new file mode 100644 index 0000000..22b769b --- /dev/null +++ b/fi/signal_jckxh.go @@ -0,0 +1,60 @@ +package fi + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/entity" +) + +// signal jckxh 接口:开通列车信号、开通调车信号、开通禁止信号 + +// DriveJCKXHLx 开通列车信号(黄灯亮) +func DriveJCKXHLx(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.SignalJCKXHElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ) + driveLx.Td = true + driveLx.Xq = true + driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ) + driveDx.Td = false + driveDx.Xq = false + } + }) +} + +// DriveJCKXHDx 开通调车信号(白灯亮) +func DriveJCKXHDx(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.SignalJCKXHElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ) + driveLx.Td = false + driveLx.Xq = false + driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ) + driveDx.Td = true + driveDx.Xq = true + } + }) +} + +// DriveJCKXHNon 开通禁止信号(红灯亮) +func DriveJCKXHNon(w ecs.World, signalId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + signalEntry, ok := wd.EntityMap[signalId] + if ok { + state := component.SignalJCKXHElectronicType.Get(signalEntry) + driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ) + driveLx.Td = false + driveLx.Xq = false + driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ) + driveDx.Td = false + driveDx.Xq = false + } + }) +}