rts-sim-module/examples/signal_2xh1/sigSys/debug_sys.go

32 lines
881 B
Go
Raw Normal View History

2023-10-10 16:51:07 +08:00
package sigSys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"log"
)
type SignalDebugSystem struct {
query *ecs.Query
}
func NewSignalDebugSystem() *SignalDebugSystem {
2023-10-11 14:12:51 +08:00
return &SignalDebugSystem{query: ecs.NewQuery(filter.Contains(component.Signal2XH1ElectronicType))}
2023-10-10 16:51:07 +08:00
}
// Update world 执行
func (s *SignalDebugSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
uid := component.UidType.Get(entry)
2023-10-10 17:26:09 +08:00
state := component.Signal2XH1ElectronicType.Get(entry)
2023-10-11 14:12:51 +08:00
ld := component.BitStateType.Get(state.Z2XH1_L)
hd := component.BitStateType.Get(state.Z2XH1_H)
2023-10-10 17:26:09 +08:00
//
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
//
2023-10-11 14:12:51 +08:00
log.Printf("===>> uid = %s ddj = %t lxj = %t , 绿灯 = %t 红灯 = %t,\n", uid.Id, ddj.Val, lxj.Val, ld.Val, hd.Val)
2023-10-10 16:51:07 +08:00
})
}