32 lines
881 B
Go
32 lines
881 B
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.Signal2XH1ElectronicType))}
|
|
}
|
|
|
|
// Update world 执行
|
|
func (s *SignalDebugSystem) Update(w ecs.World) {
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
uid := component.UidType.Get(entry)
|
|
state := component.Signal2XH1ElectronicType.Get(entry)
|
|
ld := component.BitStateType.Get(state.Z2XH1_L)
|
|
hd := component.BitStateType.Get(state.Z2XH1_H)
|
|
//
|
|
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
|
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
|
//
|
|
log.Printf("===>> uid = %s ddj = %t lxj = %t , 绿灯 = %t 红灯 = %t,\n", uid.Id, ddj.Val, lxj.Val, ld.Val, hd.Val)
|
|
})
|
|
}
|