2023-10-10 18:06:30 +08:00
|
|
|
package sigSys
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/ecs/filter"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
2023-10-12 13:54:53 +08:00
|
|
|
"log/slog"
|
2023-10-10 18:06:30 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
2023-10-12 13:54:53 +08:00
|
|
|
lights := component.SignalLightsType.Get(entry)
|
|
|
|
Z3XH1_L := lights.GetLightByTag(component.LdTag)
|
|
|
|
Z3XH1_H := lights.GetLightByTag(component.HdTag)
|
|
|
|
Z3XH1_U := lights.GetLightByTag(component.UdTag)
|
2023-10-10 18:06:30 +08:00
|
|
|
//
|
|
|
|
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-12 13:54:53 +08:00
|
|
|
ld := component.BitStateType.Get(Z3XH1_L)
|
|
|
|
hd := component.BitStateType.Get(Z3XH1_H)
|
|
|
|
ud := component.BitStateType.Get(Z3XH1_U)
|
|
|
|
//lsq := component.Signal3XH1LsqType.Get(entry)
|
|
|
|
//lsc := component.Signal3XH1LscType.Get(entry)
|
2023-10-10 18:06:30 +08:00
|
|
|
//
|
2023-10-12 13:54:53 +08:00
|
|
|
slog.Debug(uid.Id, "ddj", ddj.Val, "lxj", lxj.Val, "zxj", zxj.Val, "yxj", yxj.Val, "dj", dj.Val, "2dj", edj.Val, "绿灯", ld.Val, "红灯", hd.Val, "黄灯", ud.Val)
|
2023-10-10 18:06:30 +08:00
|
|
|
})
|
|
|
|
}
|