2023-10-09 15:05:34 +08:00
|
|
|
|
package fi
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
|
|
|
|
)
|
|
|
|
|
|
2023-10-09 16:22:29 +08:00
|
|
|
|
// signal 3xh1 接口:点灯操作、开通列车信号、开通引导信号、开通禁止信号
|
|
|
|
|
|
2023-10-09 17:58:29 +08:00
|
|
|
|
// DriveSignal3XH1Dd 点灯操作
|
2023-10-09 15:05:34 +08:00
|
|
|
|
// dd : true-物理点灯;false-物理灭灯
|
2023-10-09 17:58:29 +08:00
|
|
|
|
func DriveSignal3XH1Dd(w ecs.World, signalId string, dd bool) {
|
2023-10-09 15:05:34 +08:00
|
|
|
|
w.Execute(func() {
|
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
|
signalEntry, ok := wd.EntityMap[signalId]
|
|
|
|
|
if ok {
|
|
|
|
|
state := component.Signal3XH1ElectronicType.Get(signalEntry)
|
|
|
|
|
driveDd := component.RelayDriveType.Get(state.Z3XH1_DDJ)
|
|
|
|
|
//点灯继电器落下时才点灯
|
|
|
|
|
driveDd.Td = !dd
|
|
|
|
|
driveDd.Xq = !dd
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 17:58:29 +08:00
|
|
|
|
// DriveSignal3XH1Lx 开通列车信号(直向通过则亮绿灯;侧向通过则亮黄灯)
|
2023-10-09 15:05:34 +08:00
|
|
|
|
// xz : true-直向通过,false-侧向通过
|
2023-10-09 17:58:29 +08:00
|
|
|
|
func DriveSignal3XH1Lx(w ecs.World, signalId string, zx bool) {
|
2023-10-09 15:05:34 +08:00
|
|
|
|
w.Execute(func() {
|
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
|
signalEntry, ok := wd.EntityMap[signalId]
|
|
|
|
|
if ok {
|
|
|
|
|
state := component.Signal3XH1ElectronicType.Get(signalEntry)
|
|
|
|
|
driveLx := component.RelayDriveType.Get(state.Z3XH1_LXJ)
|
|
|
|
|
driveLx.Td = true
|
|
|
|
|
driveLx.Xq = true
|
|
|
|
|
driveZx := component.RelayDriveType.Get(state.Z3XH1_ZXJ)
|
|
|
|
|
driveZx.Td = zx
|
|
|
|
|
driveZx.Xq = zx
|
|
|
|
|
driveYx := component.RelayDriveType.Get(state.Z3XH1_YXJ)
|
|
|
|
|
driveYx.Td = false
|
|
|
|
|
driveYx.Xq = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 17:58:29 +08:00
|
|
|
|
// DriveSignal3XH1Yx 开通引导信号(红灯亮且黄灯亮)
|
|
|
|
|
func DriveSignal3XH1Yx(w ecs.World, signalId string) {
|
2023-10-09 15:05:34 +08:00
|
|
|
|
w.Execute(func() {
|
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
|
signalEntry, ok := wd.EntityMap[signalId]
|
|
|
|
|
if ok {
|
|
|
|
|
state := component.Signal3XH1ElectronicType.Get(signalEntry)
|
|
|
|
|
driveLx := component.RelayDriveType.Get(state.Z3XH1_LXJ)
|
|
|
|
|
driveLx.Td = false
|
|
|
|
|
driveLx.Xq = false
|
|
|
|
|
driveZx := component.RelayDriveType.Get(state.Z3XH1_ZXJ)
|
|
|
|
|
driveZx.Td = false
|
|
|
|
|
driveZx.Xq = false
|
|
|
|
|
driveYx := component.RelayDriveType.Get(state.Z3XH1_YXJ)
|
|
|
|
|
driveYx.Td = true
|
|
|
|
|
driveYx.Xq = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 17:58:29 +08:00
|
|
|
|
// DriveSignal3XH1Non 开通禁止信号(红灯亮)
|
|
|
|
|
func DriveSignal3XH1Non(w ecs.World, signalId string) {
|
2023-10-09 15:05:34 +08:00
|
|
|
|
w.Execute(func() {
|
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
|
signalEntry, ok := wd.EntityMap[signalId]
|
|
|
|
|
if ok {
|
|
|
|
|
state := component.Signal3XH1ElectronicType.Get(signalEntry)
|
|
|
|
|
driveLx := component.RelayDriveType.Get(state.Z3XH1_LXJ)
|
|
|
|
|
driveLx.Td = false
|
|
|
|
|
driveLx.Xq = false
|
|
|
|
|
driveZx := component.RelayDriveType.Get(state.Z3XH1_ZXJ)
|
|
|
|
|
driveZx.Td = false
|
|
|
|
|
driveZx.Xq = false
|
|
|
|
|
driveYx := component.RelayDriveType.Get(state.Z3XH1_YXJ)
|
|
|
|
|
driveYx.Td = false
|
|
|
|
|
driveYx.Xq = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|