ISCS环境与设备监控系统ecs定义
This commit is contained in:
parent
1d93d59518
commit
8fe8fa76cb
16
component/iscs_bas_network.go
Normal file
16
component/iscs_bas_network.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package component
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NetworkSwitch 交换机
|
||||||
|
type NetworkSwitch struct {
|
||||||
|
Normal bool //true-正常
|
||||||
|
Exception consts.DeviceExceptionEnum //具体异常-通信中断、异常
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
NetworkSwitchType = ecs.NewComponentType[NetworkSwitch]()
|
||||||
|
)
|
@ -340,3 +340,15 @@ func NewPlcControllerEntity(w ecs.World, id string) *ecs.Entry {
|
|||||||
}
|
}
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewNetworkSwitchEntity 创建网络交换机实体
|
||||||
|
func NewNetworkSwitchEntity(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.NetworkSwitchType))
|
||||||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||||
|
wd.EntityMap[id] = e
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
34
sys/iscs_sys/iscs_bas_network.go
Normal file
34
sys/iscs_sys/iscs_bas_network.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package iscs_sys
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NetworkSystem struct {
|
||||||
|
queryNetworkSwitch *ecs.Query
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNetworkSystem() *NetworkSystem {
|
||||||
|
|
||||||
|
return &NetworkSystem{
|
||||||
|
queryNetworkSwitch: ecs.NewQuery(filter.Contains(component.NetworkSwitchType)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (s *NetworkSystem) Update(w ecs.World) {
|
||||||
|
s.queryNetworkSwitch.Each(w, func(entry *ecs.Entry) {
|
||||||
|
ns := component.NetworkSwitchType.Get(entry)
|
||||||
|
//
|
||||||
|
ns.Exception = consts.DeviceExceptionNon
|
||||||
|
if entry.HasComponent(component.DeviceAbnormalTag) {
|
||||||
|
ns.Exception = consts.DeviceAbnormal
|
||||||
|
}
|
||||||
|
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||||||
|
ns.Exception = consts.DeviceCommunicationInterrupt
|
||||||
|
}
|
||||||
|
//正常
|
||||||
|
ns.Normal = ns.Exception == consts.DeviceExceptionNon
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user