rts-sim-module/fi/signal_3xh3.go
2023-10-09 17:58:29 +08:00

77 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// signal 3xh3 接口:点灯操作、开通列车信号、开通引导信号、开通禁止信号
// DriveSignal3XH3Dd 点灯操作
// dd : true-物理点灯false-物理灭灯
func DriveSignal3XH3Dd(w ecs.World, signalId string, dd bool) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH3ElectronicType.Get(signalEntry)
driveDd := component.RelayDriveType.Get(state.Z3XH3_DDJ)
//点灯继电器落下时才点灯
driveDd.Td = !dd
driveDd.Xq = !dd
}
})
}
// DriveSignal3XH3Lx 开通列车信号(黄灯亮)
func DriveSignal3XH3Lx(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH3ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
driveLx.Td = true
driveLx.Xq = true
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
driveYx.Td = false
driveYx.Xq = false
}
})
}
// DriveSignal3XH3Yx 开通引导信号(黄灯亮且红灯亮)
func DriveSignal3XH3Yx(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH3ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
driveLx.Td = false
driveLx.Xq = false
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
driveYx.Td = true
driveYx.Xq = true
}
})
}
// DriveSignal3XH3Non 开通禁止信号(红灯亮)
func DriveSignal3XH3Non(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH3ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
driveLx.Td = false
driveLx.Xq = false
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
driveYx.Td = false
driveYx.Xq = false
}
})
}