rts-sim-module/sys/iscs_sys/iscs_fas_host.go
2023-12-14 16:57:44 +08:00

35 lines
894 B
Go

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
// NetworkHostSystem 网络设备、网络主机等
type NetworkHostSystem struct {
query *ecs.Query
}
func NewNetworkHostSystem() *NetworkHostSystem {
return &NetworkHostSystem{
query: ecs.NewQuery(filter.Contains(component.NetworkHostType)),
}
}
func (s *NetworkHostSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
host := component.NetworkHostType.Get(entry)
//
host.Exception = consts.DeviceExceptionNon
if entry.HasComponent(component.DeviceFaultTag) {
host.Exception = consts.DeviceFault
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
host.Exception = consts.DeviceCommunicationInterrupt
}
//
host.Normal = host.Exception == consts.DeviceExceptionNon
})
}