2023-12-12 18:07:38 +08:00
|
|
|
package iscs_sys
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/ecs/filter"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/consts"
|
|
|
|
)
|
|
|
|
|
|
|
|
// WaterPumpSystem 水泵
|
|
|
|
// 如:冷冻水泵、冷却水循环泵、超声波型水泵、浮球型水泵
|
|
|
|
// 注:浮球型水泵通过浮球来控制水泵的开启关闭
|
|
|
|
type WaterPumpSystem struct {
|
|
|
|
query *ecs.Query
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewWaterPumpSystem() *WaterPumpSystem {
|
|
|
|
return &WaterPumpSystem{
|
2023-12-19 11:11:27 +08:00
|
|
|
query: ecs.NewQuery(filter.Contains(component.WaterPumpType, component.DeviceExceptionType)),
|
2023-12-12 18:07:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func (s *WaterPumpSystem) Update(w ecs.World) {
|
|
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
|
|
pump := component.WaterPumpType.Get(entry)
|
2023-12-13 10:21:02 +08:00
|
|
|
//浮球型水泵,水箱水位控制浮球开关从而控制水泵开关
|
2023-12-12 18:07:38 +08:00
|
|
|
if entry.HasComponent(component.FloatBallSwitchType) {
|
|
|
|
fbs := component.FloatBallSwitchType.Get(entry)
|
|
|
|
pump.Running = fbs.On
|
|
|
|
}
|
|
|
|
//
|
2023-12-19 11:11:27 +08:00
|
|
|
de := component.DeviceExceptionType.Get(entry)
|
2023-12-13 18:03:00 +08:00
|
|
|
//异常停止运行
|
2023-12-19 11:11:27 +08:00
|
|
|
if de.Exception != consts.DeviceExceptionNon {
|
2023-12-13 18:03:00 +08:00
|
|
|
pump.Running = false
|
|
|
|
}
|
2023-12-12 18:07:38 +08:00
|
|
|
})
|
|
|
|
}
|