package iscs_sys import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/consts" ) // ChillerUnitSystem 冷水机组 type ChillerUnitSystem struct { query *ecs.Query } func NewChillerUnitSystem() *ChillerUnitSystem { return &ChillerUnitSystem{ query: ecs.NewQuery(filter.Contains(component.ChillerUnitType)), } } func (s *ChillerUnitSystem) Update(w ecs.World) { s.query.Each(w, func(entry *ecs.Entry) { device := component.ChillerUnitType.Get(entry) // device.Exception = consts.DeviceExceptionNon // if entry.HasComponent(component.DeviceFaultTag) { device.Exception = consts.DeviceFault } if entry.HasComponent(component.DeviceAbnormalTag) { device.Exception = consts.DeviceAbnormal } if entry.HasComponent(component.DeviceCommunicationInterruptTag) { device.Exception = consts.DeviceCommunicationInterrupt } //异常停止运行 if device.Exception != consts.DeviceExceptionNon { device.Running = false } }) }