61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package fi
|
||
|
||
import (
|
||
"joylink.club/ecs"
|
||
"joylink.club/rtsssimulation/component"
|
||
"joylink.club/rtsssimulation/entity"
|
||
)
|
||
|
||
// signal 3xh4 接口:点灯操作、开通列车信号、开通禁止信号
|
||
|
||
// DriveSignal3XH4Dd 点灯操作
|
||
// dd : true-物理点灯;false-物理灭灯
|
||
func DriveSignal3XH4Dd(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
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal3XH4Lx 开通列车信号(直向通过亮绿灯,侧向通过亮黄灯)
|
||
// zx : true-直向通过,false-侧向通过
|
||
func DriveSignal3XH4Lx(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
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal3XH4Non 开通禁止信号(亮红灯)
|
||
func DriveSignal3XH4Non(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
|
||
}
|
||
})
|
||
}
|