ISCS火警系统ecs定义
This commit is contained in:
parent
2b1d332918
commit
c103a41f86
@ -22,102 +22,107 @@ type NetworkHost struct {
|
||||
//
|
||||
// 输出模块可以控制其他设备(如声光报警器、喷淋系统等)的操作,以及向其他系统发送报警信息
|
||||
type SmokeDetector struct {
|
||||
Normal bool //true-正常
|
||||
Act StaAct //烟感动作
|
||||
State StaState //烟感状态
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
|
||||
Density uint16 //烟感周围烟气浓度,1=0.01%;一般为0.15-0.3%时会触发警报
|
||||
}
|
||||
|
||||
// StaAct 烟感或温感动作定义
|
||||
type StaAct = uint8
|
||||
// StaState 烟感或温感状态
|
||||
type StaState = uint8
|
||||
|
||||
const (
|
||||
StaNon StaAct = iota //正常
|
||||
StaFireAlarm //火警
|
||||
StaIsolate //隔离
|
||||
StaEarlyWarn //预警
|
||||
StaNormal StaState = iota //正常
|
||||
StaFireAlarm //火警
|
||||
StaIsolate //隔离
|
||||
StaEarlyWarn //预警
|
||||
)
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
// TemperatureDetector 温感
|
||||
type TemperatureDetector struct {
|
||||
Normal bool //true-正常
|
||||
Act StaAct //温感动作
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
|
||||
State StaState //温感动作
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
|
||||
Temperature int16 //温感周围温度,1=1摄氏度
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
// ManualFireAlarmButton 手动火灾报警按钮
|
||||
// 报警按钮有红色报警确认灯,报警按钮启动零件动作,报警确认灯点亮,并保持至报警状态被复位。
|
||||
// 报警按钮形状有方形和长方形,颜色为红色(正常工作状态为闪烁状态,如果不闪烁说明设备损坏;如场所内所有设备都不亮说明消防系统被停用
|
||||
//
|
||||
// 按下手动报警按钮3-5s(最长不超过10s)后,手动报警按钮上的火警确认灯会点亮,这个状态灯表示火灾报警控制器已经收到火警信号,并且确认了现场位置。
|
||||
// 控制室值班人员应第一时间前往现场确认火情;报警按钮一般有三种形式:吸盘复位型、钥匙复位和更换有机玻璃进行复位型。须人工复位。
|
||||
//
|
||||
// 报警后,如控制器在自动工作状态,声光报警器、消防广播、防火卷帘、防排烟系统等设备会动作,非消防电梯停止运行,切断该区域非消防用电……因此,非警勿动;
|
||||
type ManualFireAlarmButton struct {
|
||||
Normal bool //true-正常
|
||||
Act MfabAct //手动火灾报警按钮动作
|
||||
State MfabState //手动火灾报警按钮状态
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
|
||||
Pressed bool //按钮按下
|
||||
}
|
||||
|
||||
// MfabAct 手动火灾报警按钮动作定义
|
||||
type MfabAct = uint8
|
||||
// MfabState 手动火灾报警按钮状态
|
||||
type MfabState = uint8
|
||||
|
||||
const (
|
||||
MfabNon MfabAct = iota //正常
|
||||
MfabFireAlarm //火警
|
||||
MfabIsolate //隔离
|
||||
MfabNormal MfabState = iota //正常
|
||||
MfabNon //未知
|
||||
MfabFireAlarm //火警
|
||||
MfabIsolate //隔离
|
||||
)
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
// GasFireExtinguisher 气体灭火
|
||||
type GasFireExtinguisher struct {
|
||||
Normal bool //true-正常
|
||||
Act GfeAct //气体灭火动作
|
||||
State GfeState //气体灭火器状态
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、异常、通信中断
|
||||
}
|
||||
|
||||
// GfeAct 气体灭火动作定义
|
||||
type GfeAct = uint8
|
||||
// GfeState 气体灭火器状态
|
||||
type GfeState = uint8
|
||||
|
||||
const (
|
||||
GfeNon GfeAct = iota //正常
|
||||
GfeIsolate //隔离
|
||||
GfeEarlyWarn //预警
|
||||
GfeAlarm //报警
|
||||
GfeNormal GfeState = iota //正常
|
||||
GfeIsolate //隔离
|
||||
GfeEarlyWarn //预警
|
||||
GfeAlarm //报警
|
||||
)
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
// AlarmBell 警铃
|
||||
type AlarmBell struct {
|
||||
Normal bool //true-正常
|
||||
Act AbAct //警铃动作
|
||||
State AbState //警铃状态
|
||||
Exception consts.DeviceExceptionEnum //具体异常-模块故障、异常、通信中断
|
||||
}
|
||||
|
||||
// AbAct 警铃动作定义
|
||||
type AbAct = uint8
|
||||
// AbState 警铃状态
|
||||
type AbState = uint8
|
||||
|
||||
const (
|
||||
AbaNon AbAct = iota //正常
|
||||
AbaAlarm //报警
|
||||
AbaIsolate //隔离
|
||||
AbaNormal AbState = iota //正常
|
||||
AbaAlarm //报警
|
||||
AbaIsolate //隔离
|
||||
)
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
// FireRollerShutter 防火卷帘(隔断型防火卷帘、疏散型防火卷帘)
|
||||
type FireRollerShutter struct {
|
||||
Normal bool //true-正常
|
||||
Act FrsAct //防火卷帘动作
|
||||
State FrsState //防火卷帘状态
|
||||
Exception consts.DeviceExceptionEnum //具体异常-异常、通信中断
|
||||
}
|
||||
|
||||
// FrsAct 防火卷帘动作定义
|
||||
type FrsAct = uint8
|
||||
// FrsState 防火卷帘状态
|
||||
type FrsState = uint8
|
||||
|
||||
const (
|
||||
FrsNon FrsAct = iota //正常
|
||||
FrsAlarm //报警
|
||||
FrsFullFall //全降
|
||||
FrsHalfFall //半降
|
||||
FrsNormal FrsState = iota //正常
|
||||
FrsAlarm //报警
|
||||
FrsFullFall //全降
|
||||
FrsHalfFall //半降
|
||||
)
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
@ -21,13 +21,75 @@ func SmokeDetectorIsolateOperate(w ecs.World, deviceId string, isolate bool) err
|
||||
}
|
||||
detector := component.SmokeDetectorType.Get(deviceEntry)
|
||||
if isolate {
|
||||
detector.Act = component.StaIsolate
|
||||
detector.State = component.StaIsolate
|
||||
} else {
|
||||
if detector.Act == component.StaIsolate {
|
||||
detector.Act = component.StaNon
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("烟感[%s]当前不处于隔离态,不能执行取消隔离操作", deviceId))
|
||||
}
|
||||
detector.State = component.StaNormal
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
// TemperatureDetectorIsolateOperate 温感隔离设置
|
||||
func TemperatureDetectorIsolateOperate(w ecs.World, deviceId string, isolate bool) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !(deviceEntry.HasComponent(component.TemperatureDetectorType)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是温感", deviceId))
|
||||
}
|
||||
detector := component.TemperatureDetectorType.Get(deviceEntry)
|
||||
if isolate {
|
||||
detector.State = component.StaIsolate
|
||||
} else {
|
||||
detector.State = component.StaNormal
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
// MfabOperate 火灾报警按钮操作定义
|
||||
type MfabOperate = uint8
|
||||
|
||||
const (
|
||||
MfabOperatePress MfabOperate = iota //按下按钮
|
||||
MfabOperateReset //按钮复位
|
||||
MfabOperateSetIsolate //按钮隔离设置
|
||||
MfabOperateCancelIsolate //按钮隔离取消
|
||||
)
|
||||
|
||||
// ManualFireAlarmButtonOperate 火灾报警按钮操作
|
||||
func ManualFireAlarmButtonOperate(w ecs.World, deviceId string, opt MfabOperate) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
deviceEntry, ok := wd.EntityMap[deviceId]
|
||||
if !ok {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId))
|
||||
}
|
||||
//
|
||||
if !(deviceEntry.HasComponent(component.ManualFireAlarmButtonType)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是火灾报警按钮", deviceId))
|
||||
}
|
||||
button := component.ManualFireAlarmButtonType.Get(deviceEntry)
|
||||
//
|
||||
switch opt {
|
||||
case MfabOperatePress:
|
||||
button.Pressed = true
|
||||
case MfabOperateReset:
|
||||
button.Pressed = false
|
||||
case MfabOperateSetIsolate:
|
||||
button.State = component.MfabIsolate
|
||||
case MfabOperateCancelIsolate:
|
||||
button.State = component.MfabNon
|
||||
}
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
|
@ -8,6 +8,14 @@ import (
|
||||
)
|
||||
|
||||
// ManualFireAlarmButtonSystem 手动火灾报警按钮
|
||||
//
|
||||
// 报警按钮有红色报警确认灯,报警按钮启动零件动作,报警确认灯点亮,并保持至报警状态被复位。
|
||||
// 报警按钮形状有方形和长方形,颜色为红色(正常工作状态为闪烁状态,如果不闪烁说明设备损坏;如场所内所有设备都不亮说明消防系统被停用
|
||||
//
|
||||
// 按下手动报警按钮3-5s(最长不超过10s)后,手动报警按钮上的火警确认灯会点亮,这个状态灯表示火灾报警控制器已经收到火警信号,并且确认了现场位置。
|
||||
// 控制室值班人员应第一时间前往现场确认火情;报警按钮一般有三种形式:吸盘复位型、钥匙复位和更换有机玻璃进行复位型。须人工复位。
|
||||
//
|
||||
// 报警后,如控制器在自动工作状态,声光报警器、消防广播、防火卷帘、防排烟系统等设备会动作,非消防电梯停止运行,切断该区域非消防用电……因此,非警勿动;
|
||||
type ManualFireAlarmButtonSystem struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
@ -20,17 +28,22 @@ func NewManualFireAlarmButtonSystem() *ManualFireAlarmButtonSystem {
|
||||
func (s *ManualFireAlarmButtonSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
button := component.ManualFireAlarmButtonType.Get(entry)
|
||||
//
|
||||
button.Exception = consts.DeviceExceptionNon
|
||||
//故障、通信中断
|
||||
exception := consts.DeviceExceptionNon
|
||||
if entry.HasComponent(component.DeviceFaultTag) {
|
||||
button.Exception = consts.DeviceFault
|
||||
exception = consts.DeviceFault
|
||||
}
|
||||
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||
button.Exception = consts.DeviceCommunicationInterrupt
|
||||
exception = consts.DeviceCommunicationInterrupt
|
||||
}
|
||||
//todo act
|
||||
|
||||
//
|
||||
button.Normal = button.Exception == consts.DeviceExceptionNon && button.Act == component.MfabNon
|
||||
button.Exception = exception
|
||||
//没有异常且没有被按下且没有被隔离,此时按钮处于正常状态
|
||||
if button.Exception == consts.DeviceExceptionNon && !button.Pressed && button.State == component.MfabNon {
|
||||
button.State = component.MfabNormal
|
||||
}
|
||||
//如果按钮处于正常工作状态且被按下,则向火灾报警控制器发送火警信号
|
||||
//todo
|
||||
//当火灾报警控制器确认收到该按钮按下信号后,按钮状态变为火警状态,表示火灾报警控制器收到该按钮报警信号
|
||||
//todo
|
||||
})
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ 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)),
|
||||
@ -20,26 +25,36 @@ func NewSmokeDetectorSystem() *SmokeDetectorSystem {
|
||||
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.Exception = consts.DeviceExceptionNon
|
||||
exception := consts.DeviceExceptionNon
|
||||
if entry.HasComponent(component.DeviceFaultTag) {
|
||||
detector.Exception = consts.DeviceFault
|
||||
exception = consts.DeviceFault
|
||||
}
|
||||
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||
detector.Exception = consts.DeviceCommunicationInterrupt
|
||||
exception = consts.DeviceCommunicationInterrupt
|
||||
}
|
||||
detector.Exception = exception
|
||||
//烟感探测所在环境
|
||||
if detector.Act != component.StaIsolate {
|
||||
detectorId := component.UidType.Get(entry).Id
|
||||
detector.Act = s.detectSmoke(w, detectorId)
|
||||
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
|
||||
}
|
||||
//
|
||||
detector.Normal = detector.Exception == consts.DeviceExceptionNon && detector.Act == component.StaNon
|
||||
})
|
||||
}
|
||||
|
||||
// 烟感探测环境,以得到环境是否正常,是否需要预警,是否需要发出火警
|
||||
func (s *SmokeDetectorSystem) detectSmoke(w ecs.World, detectorId string) component.StaAct {
|
||||
// 烟感探测环境烟雾浓度,1=0.01%
|
||||
func (s *SmokeDetectorSystem) detectSmoke(w ecs.World, detectorId string) uint16 {
|
||||
//todo
|
||||
return component.StaNon
|
||||
return 0
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ 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)),
|
||||
@ -20,26 +25,35 @@ func NewTemperatureDetectorSystem() *TemperatureDetectorSystem {
|
||||
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
|
||||
//例外处理
|
||||
detector.Exception = consts.DeviceExceptionNon
|
||||
exception := consts.DeviceExceptionNon
|
||||
if entry.HasComponent(component.DeviceFaultTag) {
|
||||
detector.Exception = consts.DeviceFault
|
||||
exception = consts.DeviceFault
|
||||
}
|
||||
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||
detector.Exception = consts.DeviceCommunicationInterrupt
|
||||
exception = consts.DeviceCommunicationInterrupt
|
||||
}
|
||||
detector.Exception = exception
|
||||
//温感探测所在环境
|
||||
if detector.Act != component.StaIsolate {
|
||||
detectorId := component.UidType.Get(entry).Id
|
||||
detector.Act = s.detectTemperature(w, detectorId)
|
||||
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
|
||||
}
|
||||
//
|
||||
detector.Normal = detector.Exception == consts.DeviceExceptionNon && detector.Act == component.StaNon
|
||||
})
|
||||
}
|
||||
|
||||
// 温感探测环境,以得到环境是否正常,是否需要预警,是否需要发出火警
|
||||
func (s *TemperatureDetectorSystem) detectTemperature(w ecs.World, detectorId string) component.StaAct {
|
||||
// 温感探测环境温度
|
||||
func (s *TemperatureDetectorSystem) detectTemperature(w ecs.World, detectorId string) int16 {
|
||||
//todo
|
||||
return component.StaNon
|
||||
return 25
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user