rts-sim-module/sys/iscs_sys/iscs_fas_smoke_detector.go
2023-12-19 11:11:27 +08:00

51 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// SmokeDetectorSystem 烟感
type SmokeDetectorSystem struct {
query *ecs.Query
}
const (
SmokeDensityFireAlarm uint16 = 15
SmokeDensityEarlyWarn uint16 = 10
)
func NewSmokeDetectorSystem() *SmokeDetectorSystem {
return &SmokeDetectorSystem{
query: ecs.NewQuery(filter.Contains(component.UidType, component.SmokeDetectorType)),
}
}
func (s *SmokeDetectorSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
detector := component.SmokeDetectorType.Get(entry)
detectorId := component.UidType.Get(entry).Id
//烟感探测所在环境
detector.Density = s.detectSmoke(w, detectorId)
if detector.State != component.StaIsolate {
state := component.StaNormal
//产生烟雾预警信号
if detector.Density >= SmokeDensityEarlyWarn {
state = component.StaEarlyWarn
}
//产生烟雾报警即火警信号
if detector.Density >= SmokeDensityFireAlarm {
state = component.StaFireAlarm
}
//
detector.State = state
}
})
}
// 烟感探测环境烟雾浓度1=0.01%
func (s *SmokeDetectorSystem) detectSmoke(w ecs.World, detectorId string) uint16 {
//todo
return 0
}