2023-10-10 16:51:07 +08:00
|
|
|
package sigSys
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/ecs/filter"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
2023-10-12 10:07:40 +08:00
|
|
|
"log/slog"
|
2023-10-10 16:51:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
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-12 11:00:56 +08:00
|
|
|
lights := component.SignalLightsType.Get(entry)
|
|
|
|
Z2XH1_L := lights.GetLightByTag(component.LdTag)
|
|
|
|
Z2XH1_H := lights.GetLightByTag(component.HdTag)
|
|
|
|
ld := component.BitStateType.Get(Z2XH1_L)
|
|
|
|
hd := component.BitStateType.Get(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-12 10:07:40 +08:00
|
|
|
lsq := component.Signal2XH1LsqType.Get(entry)
|
|
|
|
lsc := component.Signal2XH1LscType.Get(entry)
|
2023-10-10 17:26:09 +08:00
|
|
|
//
|
2023-10-12 10:07:40 +08:00
|
|
|
slog.Debug(uid.Id,
|
|
|
|
"ddjQ", lsq.Z2XH1_DDJ_Q, "lxjQ", lsq.Z2XH1_LXJ_Q,
|
|
|
|
"ddjLx", lsc.Z2XH1_DDJ_Lx, "djXq", lsc.Z2XH1_DJ_Xq, "lxjXq", lsc.Z2XH1_LXJ_Xq,
|
|
|
|
"ddj", ddj.Val, "lxj", lxj.Val,
|
|
|
|
"绿灯", ld.Val, "红灯", hd.Val)
|
2023-10-10 16:51:07 +08:00
|
|
|
})
|
|
|
|
}
|