2023-10-10 18:06:30 +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 16:57:48 +08:00
|
|
|
return &SignalDebugSystem{query: ecs.NewQuery(filter.Contains(component.Signal3XH1ElectronicType))}
|
2023-10-10 18:06:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
2023-10-11 16:57:48 +08:00
|
|
|
ld := component.BitStateType.Get(state.Z3XH1_L)
|
|
|
|
hd := component.BitStateType.Get(state.Z3XH1_H)
|
|
|
|
ud := component.BitStateType.Get(state.Z3XH1_U)
|
2023-10-10 18:06:30 +08:00
|
|
|
//
|
|
|
|
log.Printf("===>> uid = %s | ddj = %t | lxj = %t zxj = %t yxj = %t | dj = %t 2dj = %t | 绿灯 = %t 红灯 = %t 黄灯 = %t,\n",
|
2023-10-11 16:57:48 +08:00
|
|
|
uid.Id, ddj.Val, lxj.Val, zxj.Val, yxj.Val, dj.Val, edj.Val, ld.Val, hd.Val, ud.Val)
|
2023-10-10 18:06:30 +08:00
|
|
|
})
|
|
|
|
}
|