50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package fi
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/entity"
|
|
)
|
|
|
|
// 道岔功能接口
|
|
|
|
// 驱动道岔定操相关继电器
|
|
func DriveTurnoutDCRelay(w ecs.World, id string, on bool) {
|
|
w.Execute(func() {
|
|
wd := entity.GetWorldData(w)
|
|
entry, ok := wd.EntityMap[id]
|
|
if ok {
|
|
if entry.HasComponent(component.Zdj9TwoElectronicType) {
|
|
zdj9 := component.Zdj9TwoElectronicType.Get(entry)
|
|
ycj := component.RelayDriveType.Get(zdj9.TDC_YCJ)
|
|
dcj := component.RelayDriveType.Get(zdj9.TDC_DCJ)
|
|
ycj.Td = on
|
|
dcj.Td = on
|
|
}
|
|
} else {
|
|
fmt.Println("未找到id=", id, "的道岔")
|
|
}
|
|
})
|
|
}
|
|
|
|
// 驱动道岔反操相关继电器
|
|
func DriveTurnoutFCRelay(w ecs.World, id string, on bool) {
|
|
w.Execute(func() {
|
|
wd := entity.GetWorldData(w)
|
|
entry, ok := wd.EntityMap[id]
|
|
if ok {
|
|
if entry.HasComponent(component.Zdj9TwoElectronicType) {
|
|
zdj9 := component.Zdj9TwoElectronicType.Get(entry)
|
|
ycj := component.RelayDriveType.Get(zdj9.TDC_YCJ)
|
|
fcj := component.RelayDriveType.Get(zdj9.TDC_FCJ)
|
|
ycj.Td = on
|
|
fcj.Td = on
|
|
}
|
|
} else {
|
|
fmt.Println("未找到id=", id, "的道岔")
|
|
}
|
|
})
|
|
}
|