package iscs_sys import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/consts" ) // ElevatorSystem 电梯(自动扶梯、垂直电梯) type ElevatorSystem struct { queryElevator *ecs.Query //垂直电梯 queryEscalator *ecs.Query //自动扶梯 } func NewElevatorSystem() *ElevatorSystem { return &ElevatorSystem{ queryElevator: ecs.NewQuery(filter.Contains(component.ElevatorType)), queryEscalator: ecs.NewQuery(filter.Contains(component.EscalatorType)), } } func (s *ElevatorSystem) Update(w ecs.World) { s.queryElevator.Each(w, func(entry *ecs.Entry) { elevator := component.ElevatorType.Get(entry) elevator.Exception = consts.DeviceExceptionNon if entry.HasComponent(component.DeviceFaultTag) { elevator.Exception = consts.DeviceFault } if entry.HasComponent(component.DeviceAbnormalTag) { elevator.Exception = consts.DeviceAbnormal } if entry.HasComponent(component.DeviceCommunicationInterruptTag) { elevator.Exception = consts.DeviceCommunicationInterrupt } }) // s.queryElevator.Each(w, func(entry *ecs.Entry) { escalator := component.EscalatorType.Get(entry) if escalator.EmergencyStop { //急停 escalator.Running = 0 } escalator.Exception = consts.DeviceExceptionNon if entry.HasComponent(component.DeviceFaultTag) { escalator.Exception = consts.DeviceFault } if entry.HasComponent(component.DeviceAbnormalTag) { escalator.Exception = consts.DeviceAbnormal } if entry.HasComponent(component.DeviceCommunicationInterruptTag) { escalator.Exception = consts.DeviceCommunicationInterrupt } }) }