rts-sim-module/fi/signal_3xh4.go

61 lines
1.7 KiB
Go
Raw Normal View History

2023-10-09 16:42:16 +08:00
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
}
})
}