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

57 lines
1.4 KiB
Go
Raw Normal View History

package iscs_sys
2023-12-26 10:59:07 +08:00
import (
2023-12-26 17:52:28 +08:00
"fmt"
2023-12-26 10:59:07 +08:00
"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-26 17:52:28 +08:00
query: ecs.NewQuery(filter.Contains(component.UidType, component.MotorType, 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-26 17:52:28 +08:00
fanId := component.UidType.Get(entry).Id
fan := component.MotorType.Get(entry)
fmt.Printf("====>>>fanId = %s , forward = %t , speed = %f , ms = %d\n", fanId, fan.Forward, fan.Speed, fan.Ms)
fan.Ms = component.MsOnForward
if entry.HasComponent(component.MotorFcType) {
component.MotorFcType.Get(entry).F = 80
}
//一般风机(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-26 10:59:07 +08:00
})
}