ISCS火警系统ecs定义

This commit is contained in:
xzb 2023-12-14 13:33:18 +08:00
parent 914cb25599
commit 2b6b1120a5
6 changed files with 274 additions and 1 deletions

View File

@ -8,7 +8,7 @@ import (
//水泵相关
// WaterPump 水泵
// 如:冷冻水泵、冷却水循环泵、超声波型水泵、浮球型水泵
// 如:冷冻水泵、冷却水循环泵、超声波型水泵、浮球型水泵、火警相关水泵
type WaterPump struct {
Running bool //true-正常运行false-停止
Exception consts.DeviceExceptionEnum //具体异常

141
component/iscs_fas.go Normal file
View File

@ -0,0 +1,141 @@
package component
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/consts"
)
// NetworkHost 网络设备、网络主机等
type NetworkHost struct {
Normal bool //true-正常
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
}
///////////////////////////////
// SmokeDetector 烟感
//
// 隔离模块可以防止其他设备的故障或干扰对烟感系统的正常运行产生影响;
// 当消防主机外部设备(探测器、模块或火灾显示盘)发生故障时,可将它隔离掉,待修理或更换后,再利用取消隔离功能将设备恢复
//
// 输入模块可以接收其他设备(如手动火警按钮、温度探测器等)的信号输入,从而实现联动控制或触发火警报警
//
// 输出模块可以控制其他设备(如声光报警器、喷淋系统等)的操作,以及向其他系统发送报警信息
type SmokeDetector struct {
Normal bool //true-正常
Act StaAct //烟感动作
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
}
// StaAct 烟感或温感动作定义
type StaAct = uint8
const (
StaNon StaAct = iota //正常
StaFireAlarm //火警
StaIsolate //隔离
StaEarlyWarn //预警
)
/////////////////////////////////////
// TemperatureDetector 温感
type TemperatureDetector struct {
Normal bool //true-正常
Act StaAct //温感动作
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
}
/////////////////////////////////////////
// ManualFireAlarmButton 手动火灾报警按钮
type ManualFireAlarmButton struct {
Normal bool //true-正常
Act MfabAct //手动火灾报警按钮动作
Exception consts.DeviceExceptionEnum //具体异常-故障、通信中断
}
// MfabAct 手动火灾报警按钮动作定义
type MfabAct = uint8
const (
MfabNon MfabAct = iota //正常
MfabFireAlarm //火警
MfabIsolate //隔离
)
/////////////////////////////////////
// GasFireExtinguisher 气体灭火
type GasFireExtinguisher struct {
Normal bool //true-正常
Act GfeAct //气体灭火动作
Exception consts.DeviceExceptionEnum //具体异常-故障、异常、通信中断
}
// GfeAct 气体灭火动作定义
type GfeAct = uint8
const (
GfeNon GfeAct = iota //正常
GfeIsolate //隔离
GfeEarlyWarn //预警
GfeAlarm //报警
)
////////////////////////////////////////
// AlarmBell 警铃
type AlarmBell struct {
Normal bool //true-正常
Act AbAct //警铃动作
Exception consts.DeviceExceptionEnum //具体异常-模块故障、异常、通信中断
}
// AbAct 警铃动作定义
type AbAct = uint8
const (
AbaNon AbAct = iota //正常
AbaAlarm //报警
AbaIsolate //隔离
)
////////////////////////////////////////
// FireRollerShutter 防火卷帘(隔断型防火卷帘、疏散型防火卷帘)
type FireRollerShutter struct {
Normal bool //true-正常
Act FrsAct //防火卷帘动作
Exception consts.DeviceExceptionEnum //具体异常-异常、通信中断
}
// FrsAct 防火卷帘动作定义
type FrsAct = uint8
const (
FrsNon FrsAct = iota //正常
FrsAlarm //报警
FrsFullFall //全降
FrsHalfFall //半降
)
/////////////////////////////////////////
var (
PartitionTypeFireRollerShutterTag = ecs.NewTag() //隔断型防火卷帘
EvacuationTypeFireRollerShutterTag = ecs.NewTag() //疏散型防火卷帘
FirePumpTag = ecs.NewTag() //消防泵
SprayPumpTag = ecs.NewTag() //喷淋泵
StabilizedPressurePumpTag = ecs.NewTag() //稳压泵
)
var (
NetworkHostType = ecs.NewComponentType[NetworkHost]() //主机
SmokeDetectorType = ecs.NewComponentType[SmokeDetector]() //烟感
TemperatureDetectorType = ecs.NewComponentType[TemperatureDetector]() //温感
ManualFireAlarmButtonType = ecs.NewComponentType[ManualFireAlarmButton]() //手动火灾报警按钮
GasFireExtinguisherType = ecs.NewComponentType[GasFireExtinguisher]() //气体灭火
AlarmBellType = ecs.NewComponentType[AlarmBell]() //警铃
FireRollerShutterType = ecs.NewComponentType[FireRollerShutter]() //防火卷帘
)

View File

@ -165,6 +165,7 @@ var (
DeviceFaultTag = ecs.NewTag() //故障 有预告信号产生
DeviceAlarmTag = ecs.NewTag() //报警 有事故信号产生
DeviceStartTimeoutTag = ecs.NewTag() //启动超时
DeviceModuleFaultTag = ecs.NewTag() //模块故障
)
// 设备置牌标签定义

View File

@ -10,4 +10,5 @@ const (
DeviceFault //故障 有预告信号产生
DeviceAlarm //报警 有事故信号产生
DeviceStartTimeout //启动超时
DeviceModuleFault //模块故障
)

125
entity/iscs_fas.go Normal file
View File

@ -0,0 +1,125 @@
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
// NewNetworkHostEntity 创建网络设备、网络主机等实体
func NewNetworkHostEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.NetworkHostType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewSmokeDetectorEntity 创建烟感实体
func NewSmokeDetectorEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.SmokeDetectorType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewTemperatureDetectorEntity 创建温感实体
func NewTemperatureDetectorEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.TemperatureDetectorType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewManualFireAlarmButtonEntity 创建手动火灾报警按钮实体
func NewManualFireAlarmButtonEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.ManualFireAlarmButtonType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewGasFireExtinguisherEntity 创建气体灭火器实体
func NewGasFireExtinguisherEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.GasFireExtinguisherType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewAlarmBellEntity 创建警铃实体
func NewAlarmBellEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.AlarmBellType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// 创建防火卷帘
func newFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.FireRollerShutterType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewPartitionTypeFireRollerShutterEntity 创建隔断型防火卷帘
func NewPartitionTypeFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry {
entry := newFireRollerShutterEntity(w, id)
entry.AddComponent(component.PartitionTypeFireRollerShutterTag)
return entry
}
// NewEvacuationTypeFireRollerShutterEntity 创建疏散型防火卷帘
func NewEvacuationTypeFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry {
entry := newFireRollerShutterEntity(w, id)
entry.AddComponent(component.EvacuationTypeFireRollerShutterTag)
return entry
}
// NewFirePumpEntity 创建消防泵实体
func NewFirePumpEntity(w ecs.World, id string) *ecs.Entry {
entry := NewWaterPumpEntity(w, id)
entry.AddComponent(component.FirePumpTag)
return entry
}
// NewSprayPumpEntity 创建喷淋泵实体
func NewSprayPumpEntity(w ecs.World, id string) *ecs.Entry {
entry := NewWaterPumpEntity(w, id)
entry.AddComponent(component.SprayPumpTag)
return entry
}
// NewStabilizedPressurePumpEntity 创建稳压泵实体
func NewStabilizedPressurePumpEntity(w ecs.World, id string) *ecs.Entry {
entry := NewWaterPumpEntity(w, id)
entry.AddComponent(component.StabilizedPressurePumpTag)
return entry
}

View File

@ -92,6 +92,7 @@ const (
DeviceExceptionFault //故障 有预告信号产生
DeviceExceptionAlarm //报警 有事故信号产生
DeviceExceptionStartTimeout //启动超时
DeviceExceptionModuleFault //模块故障
)
// DeviceExceptionOperate 设备例外操作
@ -108,6 +109,7 @@ func DeviceExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOpt
deviceEntry.RemoveComponent(component.DeviceFaultTag)
deviceEntry.RemoveComponent(component.DeviceAlarmTag)
deviceEntry.RemoveComponent(component.DeviceStartTimeoutTag)
deviceEntry.RemoveComponent(component.DeviceModuleFaultTag)
}
//
switch opt {
@ -126,6 +128,9 @@ func DeviceExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOpt
case DeviceExceptionStartTimeout:
clearAllExceptions(deviceEntry)
deviceEntry.AddComponent(component.DeviceStartTimeoutTag)
case DeviceExceptionModuleFault:
clearAllExceptions(deviceEntry)
deviceEntry.AddComponent(component.DeviceModuleFaultTag)
default:
clearAllExceptions(deviceEntry)
}