package iscs_sys import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" ) // TemperatureDetectorSystem 温感 type TemperatureDetectorSystem struct { query *ecs.Query } const ( TemperatureFireAlarm int16 = 65 TemperatureEarlyWarn int16 = 54 ) func NewTemperatureDetectorSystem() *TemperatureDetectorSystem { return &TemperatureDetectorSystem{ query: ecs.NewQuery(filter.Contains(component.UidType, component.TemperatureDetectorType)), } } func (s *TemperatureDetectorSystem) Update(w ecs.World) { s.query.Each(w, func(entry *ecs.Entry) { detector := component.TemperatureDetectorType.Get(entry) detectorId := component.UidType.Get(entry).Id //温感探测所在环境 temperature := s.detectTemperature(w, detectorId) if detector.State != component.StaIsolate { state := component.StaNormal //产生火警预警信号 if temperature >= TemperatureEarlyWarn { state = component.StaEarlyWarn } //产生火警报警信号 if temperature >= TemperatureFireAlarm { state = component.StaFireAlarm } detector.State = state } }) } // 温感探测环境温度 func (s *TemperatureDetectorSystem) detectTemperature(w ecs.World, detectorId string) int16 { //todo return 25 }