53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package fi
|
||
|
||
import (
|
||
"joylink.club/ecs"
|
||
"joylink.club/rtsssimulation/component"
|
||
"joylink.club/rtsssimulation/entity"
|
||
)
|
||
|
||
// signal 2xh1 接口:点灯操作、开通列车信号、开通禁止信号
|
||
|
||
// DriveSignal2XH1Dd 点灯操作
|
||
// dd : true-物理点灯,false-物理灭灯
|
||
func DriveSignal2XH1Dd(w ecs.World, signalId string, dd bool) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
state := component.Signal2XH1ElectronicType.Get(signalEntry)
|
||
drive := component.RelayDriveType.Get(state.Z2XH1_DDJ)
|
||
drive.Td = !dd
|
||
drive.Xq = !dd
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal2XH1Lx 开通列车信号(绿灯亮)
|
||
func DriveSignal2XH1Lx(w ecs.World, signalId string) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
state := component.Signal2XH1ElectronicType.Get(signalEntry)
|
||
drive := component.RelayDriveType.Get(state.Z2XH1_LXJ)
|
||
drive.Td = true
|
||
drive.Xq = true
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal2XH1Non 开通禁止信号(红灯亮)
|
||
func DriveSignal2XH1Non(w ecs.World, signalId string) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
state := component.Signal2XH1ElectronicType.Get(signalEntry)
|
||
drive := component.RelayDriveType.Get(state.Z2XH1_LXJ)
|
||
drive.Td = false
|
||
drive.Xq = false
|
||
}
|
||
})
|
||
}
|