rts-sim-module/examples/signal_3xh1/sigSys/debug_sys.go
2023-10-11 16:57:48 +08:00

38 lines
1.2 KiB
Go

package sigSys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"log"
)
type SignalDebugSystem struct {
query *ecs.Query
}
func NewSignalDebugSystem() *SignalDebugSystem {
return &SignalDebugSystem{query: ecs.NewQuery(filter.Contains(component.Signal3XH1ElectronicType))}
}
// Update world 执行
func (s *SignalDebugSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
uid := component.UidType.Get(entry)
state := component.Signal3XH1ElectronicType.Get(entry)
//
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
dj := component.BitStateType.Get(state.Z3XH1_DJ)
edj := component.BitStateType.Get(state.Z3XH1_2DJ)
yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
ld := component.BitStateType.Get(state.Z3XH1_L)
hd := component.BitStateType.Get(state.Z3XH1_H)
ud := component.BitStateType.Get(state.Z3XH1_U)
//
log.Printf("===>> uid = %s | ddj = %t | lxj = %t zxj = %t yxj = %t | dj = %t 2dj = %t | 绿灯 = %t 红灯 = %t 黄灯 = %t,\n",
uid.Id, ddj.Val, lxj.Val, zxj.Val, yxj.Val, dj.Val, edj.Val, ld.Val, hd.Val, ud.Val)
})
}