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

50 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"
)
// TemperatureDetectorSystem 温感
type TemperatureDetectorSystem struct {
query *ecs.Query
}
2023-12-15 13:34:22 +08:00
const (
TemperatureFireAlarm int16 = 65
TemperatureEarlyWarn int16 = 54
)
2023-12-14 16:57:44 +08:00
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)
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
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
2023-12-14 16:57:44 +08:00
}
})
}
2023-12-15 13:34:22 +08:00
// 温感探测环境温度
func (s *TemperatureDetectorSystem) detectTemperature(w ecs.World, detectorId string) int16 {
2023-12-14 16:57:44 +08:00
//todo
2023-12-15 13:34:22 +08:00
return 25
2023-12-14 16:57:44 +08:00
}