2023-12-11 17:16:51 +08:00
|
|
|
package iscs_sys
|
2023-12-26 10:59:07 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/ecs/filter"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FanSystem 风机
|
|
|
|
type FanSystem struct {
|
|
|
|
query *ecs.Query
|
|
|
|
}
|
|
|
|
|
2023-12-26 13:36:15 +08:00
|
|
|
// NewFanSystem 风机系统
|
2023-12-26 10:59:07 +08:00
|
|
|
func NewFanSystem() *FanSystem {
|
|
|
|
return &FanSystem{
|
2023-12-27 18:11:27 +08:00
|
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.MotorType, component.FluidDriverType, component.DeviceExceptionType)),
|
2023-12-26 10:59:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func (s *FanSystem) Update(w ecs.World) {
|
|
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
2023-12-27 09:57:56 +08:00
|
|
|
//fanId := component.UidType.Get(entry).Id
|
2023-12-26 17:52:28 +08:00
|
|
|
fan := component.MotorType.Get(entry)
|
2023-12-27 18:11:27 +08:00
|
|
|
fluidDriver := component.FluidDriverType.Get(entry)
|
2023-12-27 09:57:56 +08:00
|
|
|
//fmt.Printf("====>>>fanId = %s , forward = %t , speed = %f , ms = %d\n", fanId, fan.Forward, fan.Speed, fan.Ms)
|
2023-12-26 17:52:28 +08:00
|
|
|
//一般风机(3000 r/min)
|
|
|
|
if entry.HasComponent(component.CommonFanTag) {
|
|
|
|
if fan.Speed > 3000 {
|
|
|
|
fan.Speed = 3000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//软启风机(100 r/min)
|
|
|
|
if entry.HasComponent(component.SoftStartFanTag) {
|
|
|
|
if fan.Speed > 100 {
|
|
|
|
fan.Speed = 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//双速风机(Low 2000 r/min ; High 7000 r/min)
|
|
|
|
if entry.HasComponent(component.HighLowSpeedFanTag) {
|
|
|
|
highMode := component.FanHighLowSpeedModeType.Get(entry).HighMode
|
|
|
|
if highMode { //高速模式
|
|
|
|
if fan.Speed > 6000 {
|
|
|
|
fan.Speed = 6000
|
2023-12-26 13:13:30 +08:00
|
|
|
}
|
2023-12-26 17:52:28 +08:00
|
|
|
} else { //低速模式
|
|
|
|
if fan.Speed > 2000 {
|
|
|
|
fan.Speed = 2000
|
2023-12-26 13:13:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-27 18:11:27 +08:00
|
|
|
//
|
|
|
|
fluidDriver.On = fan.Speed > 0
|
2023-12-26 10:59:07 +08:00
|
|
|
})
|
|
|
|
}
|