rts-sim-module/sys/iscs_sys/iscs_fas_smoke_detector.go

51 lines
1.2 KiB
Go
Raw Normal View History

2023-12-14 16:57:44 +08:00
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// SmokeDetectorSystem 烟感
type SmokeDetectorSystem struct {
query *ecs.Query
}
2023-12-15 13:34:22 +08:00
const (
SmokeDensityFireAlarm uint16 = 15
SmokeDensityEarlyWarn uint16 = 10
)
2023-12-14 16:57:44 +08:00
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)
2023-12-15 13:34:22 +08:00
detectorId := component.UidType.Get(entry).Id
2023-12-14 16:57:44 +08:00
//烟感探测所在环境
2023-12-15 13:34:22 +08:00
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
2023-12-14 16:57:44 +08:00
}
})
}
2023-12-15 13:34:22 +08:00
// 烟感探测环境烟雾浓度1=0.01%
func (s *SmokeDetectorSystem) detectSmoke(w ecs.World, detectorId string) uint16 {
2023-12-14 16:57:44 +08:00
//todo
2023-12-15 13:34:22 +08:00
return 0
2023-12-14 16:57:44 +08:00
}