46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package system
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/yohamta/donburi/filter"
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/components"
|
|
)
|
|
|
|
// 调试时显示一些信息
|
|
type DebugSystem struct {
|
|
}
|
|
|
|
func NewDebugSystem() *DebugSystem {
|
|
return &DebugSystem{}
|
|
}
|
|
|
|
// world 执行
|
|
func (me *DebugSystem) Update(w ecs.World) {
|
|
debugSwitch(w)
|
|
}
|
|
|
|
// 显示道岔状态
|
|
func debugSwitch(w ecs.World) {
|
|
switchesQuery := ecs.NewQuery(filter.Contains(components.ComDeviceIdentity, components.ComSwitchState))
|
|
switchesQuery.Each(w, func(e *ecs.Entry) {
|
|
id := components.ComDeviceIdentity.Get(e).Id
|
|
state := components.ComSwitchState.Get(e)
|
|
fmt.Printf("道岔[%s] ,定操Relay=%t ,反操Relay=%t ,定表Relay=%t ,反表Relay=%t ,", id, state.NormalRelay, state.ReverseRelay, state.NormalTable, state.ReverseTable)
|
|
if e.HasComponent(components.ComSwitchNRRelayOperating) {
|
|
nrOperation := components.ComSwitchNRRelayOperating.Get(e)
|
|
if nrOperation.Normal {
|
|
fmt.Printf("定操动作Start=%t ,剩余时间=%d ,吸合动作=%t ,", nrOperation.Start, nrOperation.OperateTime, nrOperation.Close)
|
|
} else {
|
|
fmt.Printf("反操动作Start=%t ,剩余时间=%d ,吸合动作=%t ,", nrOperation.Start, nrOperation.OperateTime, nrOperation.Close)
|
|
}
|
|
}
|
|
if e.HasComponent(components.ComSwitchTurnOperating) {
|
|
turnOperation := components.ComSwitchTurnOperating.Get(e)
|
|
fmt.Printf("转动操作Start=%t ,转动到定位=%t ,剩余时间=%d", turnOperation.Start, turnOperation.TurnNormal, turnOperation.OperateTime)
|
|
}
|
|
fmt.Println()
|
|
})
|
|
}
|