ISCS环境与设备监控系统ecs定义
This commit is contained in:
parent
9244ec0080
commit
1d93d59518
@ -1 +1,16 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
)
|
||||
|
||||
// PlcController PLC控制器
|
||||
type PlcController struct {
|
||||
Normal bool //true-正常
|
||||
Exception consts.DeviceExceptionEnum //具体异常-通信中断、故障、异常
|
||||
}
|
||||
|
||||
var (
|
||||
PlcControllerType = ecs.NewComponentType[PlcController]()
|
||||
)
|
||||
|
@ -328,3 +328,15 @@ func NewCivilDefenseDoorEntity(w ecs.World, id string) *ecs.Entry {
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewPlcControllerEntity 创建PLC控制器实体
|
||||
func NewPlcControllerEntity(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.PlcControllerType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
36
sys/iscs_sys/iscs_bas_plc.go
Normal file
36
sys/iscs_sys/iscs_bas_plc.go
Normal file
@ -0,0 +1,36 @@
|
||||
package iscs_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
)
|
||||
|
||||
type PlcControllerSystem struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewPlcControllerSystem() *PlcControllerSystem {
|
||||
return &PlcControllerSystem{
|
||||
query: ecs.NewQuery(filter.Contains(component.PlcControllerType)),
|
||||
}
|
||||
}
|
||||
func (s *PlcControllerSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
plc := component.PlcControllerType.Get(entry)
|
||||
//
|
||||
plc.Exception = consts.DeviceExceptionNon
|
||||
if entry.HasComponent(component.DeviceFaultTag) {
|
||||
plc.Exception = consts.DeviceFault
|
||||
}
|
||||
if entry.HasComponent(component.DeviceAbnormalTag) {
|
||||
plc.Exception = consts.DeviceAbnormal
|
||||
}
|
||||
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||
plc.Exception = consts.DeviceCommunicationInterrupt
|
||||
}
|
||||
//正常
|
||||
plc.Normal = plc.Exception == consts.DeviceExceptionNon
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user