ISCS环境与设备监控系统ecs定义
This commit is contained in:
parent
661790e208
commit
e27ccfd184
14
component/iscs_bas_air_curtain.go
Normal file
14
component/iscs_bas_air_curtain.go
Normal file
@ -0,0 +1,14 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
)
|
||||
|
||||
// AirCurtain 空气幕
|
||||
type AirCurtain struct {
|
||||
Running bool //true-运行;false-停止
|
||||
Exception consts.DeviceExceptionEnum //具体异常-故障、报警、异常、通信中断
|
||||
}
|
||||
|
||||
var AirCurtainType = ecs.NewComponentType[AirCurtain]()
|
@ -364,3 +364,15 @@ func NewEmergencyLightingEntity(w ecs.World, id string) *ecs.Entry {
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewAirCurtainEntity 创建空气幕实体
|
||||
func NewAirCurtainEntity(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.AirCurtainType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
@ -409,3 +409,27 @@ func EmergencyLightingEmergencyOperate(w ecs.World, deviceId string) error {
|
||||
func EmergencyLightingFirefightingOperate(w ecs.World, deviceId string) error {
|
||||
return emergencyLightingOperate(w, deviceId, component.ElmFirefighting)
|
||||
}
|
||||
|
||||
// AirCurtainOperate 空气幕操作
|
||||
func AirCurtainOperate(w ecs.World, deviceId string, optRun 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.AirCurtainType)) {
|
||||
return ecs.NewErrResult(fmt.Errorf("设备[%s]不是空气幕", deviceId))
|
||||
}
|
||||
ac := component.AirCurtainType.Get(deviceEntry)
|
||||
if optRun && ac.Exception != consts.DeviceExceptionNon {
|
||||
return ecs.NewErrResult(fmt.Errorf("空气幕[%s]有故障,不能开启", deviceId))
|
||||
}
|
||||
//
|
||||
ac.Running = optRun
|
||||
//
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
42
sys/iscs_sys/iscs_bas_air_curtain.go
Normal file
42
sys/iscs_sys/iscs_bas_air_curtain.go
Normal file
@ -0,0 +1,42 @@
|
||||
package iscs_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
)
|
||||
|
||||
// AirCurtainSystem 空气幕
|
||||
type AirCurtainSystem struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewAirCurtainSystem() *AirCurtainSystem {
|
||||
return &AirCurtainSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.AirCurtainType)),
|
||||
}
|
||||
}
|
||||
func (s *AirCurtainSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
ac := component.AirCurtainType.Get(entry)
|
||||
//
|
||||
ac.Exception = consts.DeviceExceptionNon
|
||||
if entry.HasComponent(component.DeviceFaultTag) {
|
||||
ac.Exception = consts.DeviceFault
|
||||
}
|
||||
if entry.HasComponent(component.DeviceAlarmTag) {
|
||||
ac.Exception = consts.DeviceAlarm
|
||||
}
|
||||
if entry.HasComponent(component.DeviceAbnormalTag) {
|
||||
ac.Exception = consts.DeviceAbnormal
|
||||
}
|
||||
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||
ac.Exception = consts.DeviceCommunicationInterrupt
|
||||
}
|
||||
//异常停止运行
|
||||
if ac.Exception != consts.DeviceExceptionNon {
|
||||
ac.Running = false
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user