fi signal 3xh2

This commit is contained in:
xzb 2023-10-09 15:48:58 +08:00
parent f514c1efdd
commit 52478b0955

74
fi/signal_3xh2.go Normal file
View File

@ -0,0 +1,74 @@
package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// Drive3XH2Dd 点灯操作
// dd : true-物理点灯false-物理灭灯
func Drive3XH2Dd(w ecs.World, signalId string, dd bool) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH2ElectronicType.Get(signalEntry)
driveDd := component.RelayDriveType.Get(state.Z3XH2_DDJ)
//点灯继电器落下时才点灯
driveDd.Td = !dd
driveDd.Xq = !dd
}
})
}
// Drive3XH2Lx 开通列车信号(绿灯亮)
func Drive3XH2Lx(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH2ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ)
driveLx.Td = true
driveLx.Xq = true
driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ)
driveYx.Td = false
driveYx.Xq = false
}
})
}
// Drive3XH2Yx 开通引导信号(黄灯亮且红灯亮)
func Drive3XH2Yx(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH2ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ)
driveLx.Td = false
driveLx.Xq = false
driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ)
driveYx.Td = true
driveYx.Xq = true
}
})
}
// Drive3XH2Non 开通禁止信号(红灯亮)
func Drive3XH2Non(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
state := component.Signal3XH2ElectronicType.Get(signalEntry)
driveLx := component.RelayDriveType.Get(state.Z3XH2_LXJ)
driveLx.Td = false
driveLx.Xq = false
driveYx := component.RelayDriveType.Get(state.Z3XH2_YXJ)
driveYx.Td = false
driveYx.Xq = false
}
})
}