rts-sim-module/sys/iscs_sys/iscs_bas_chiller.go

38 lines
928 B
Go
Raw Normal View History

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
// ChillerUnitSystem 冷水机组
type ChillerUnitSystem struct {
query *ecs.Query
}
func NewChillerUnitSystem() *ChillerUnitSystem {
return &ChillerUnitSystem{
query: ecs.NewQuery(filter.Contains(component.ChillerUnitType)),
}
}
func (s *ChillerUnitSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
device := component.ChillerUnitType.Get(entry)
//
device.Exception = consts.DeviceExceptionNon
//
if entry.HasComponent(component.DeviceFaultTag) {
device.Exception = consts.DeviceFault
}
if entry.HasComponent(component.DeviceAbnormalTag) {
device.Exception = consts.DeviceAbnormal
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
device.Exception = consts.DeviceCommunicationInterrupt
}
})
}