From 721824c2f71b11847f99d91fd702c0e70a7e065b Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 26 Dec 2023 11:06:34 +0800 Subject: [PATCH] =?UTF-8?q?iscs=20=20bas=20=20=E5=A4=A7=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fi/iscs_bas.go | 150 ----------------------------------- sys/iscs_sys/iscs_bas_fan.go | 5 +- 2 files changed, 4 insertions(+), 151 deletions(-) diff --git a/fi/iscs_bas.go b/fi/iscs_bas.go index d6bff8f..910f176 100644 --- a/fi/iscs_bas.go +++ b/fi/iscs_bas.go @@ -8,137 +8,11 @@ import ( "joylink.club/rtsssimulation/entity" ) -// CommonFanOperate 一般风机控制,如排烟风机、正压送风机、射流风机、普通风机、硬线风机 -// -// power : 风机电源,大于0接通正转相序电源,小于0接通反转相序电源,等于0关闭电源 -func CommonFanOperate(w ecs.World, deviceId string, power int) error { - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !deviceEntry.HasComponent(component.FanType) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId)) - } - // - fan := component.FanType.Get(deviceEntry) - fan.Power = power - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - -// SoftBypassFanOperate 如软启风机、隧道风机 -func SoftBypassFanOperate(w ecs.World, deviceId string, power int, softStart bool, bypass bool) error { - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !deviceEntry.HasComponent(component.FanType) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId)) - } - // - fan := component.FanType.Get(deviceEntry) - fan.Bypass = bypass - fan.SoftStart = softStart - fan.Power = power - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - -// FcBypassFanOperate (变频、旁路)回排风机 -func FcBypassFanOperate(w ecs.World, deviceId string, power int, fc bool, bypass bool) error { - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !deviceEntry.HasComponent(component.FanType) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是风机", deviceId)) - } - // - fan := component.FanType.Get(deviceEntry) - fan.Bypass = bypass - fan.Fc = fc - fan.Power = power - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - -// TwoSpeedFanOperate 双速风机,转速模式设置 -// -// highSpeedMode-true高速模式,false-低速模式 -func TwoSpeedFanOperate(w ecs.World, deviceId string, power int, highSpeedMode bool) error { - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !(deviceEntry.HasComponent(component.FanType) && deviceEntry.HasComponent(component.TwoSpeedFanTag)) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是双速风机", deviceId)) - } - // - fan := component.FanType.Get(deviceEntry) - fan.Power = power - // - deviceEntry.RemoveComponent(component.HighSpeedModeFanTag) - deviceEntry.RemoveComponent(component.LowSpeedModeFanTag) - if highSpeedMode { - deviceEntry.AddComponent(component.HighSpeedModeFanTag) - } else { - deviceEntry.AddComponent(component.LowSpeedModeFanTag) - } - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - // FanExceptionOperate 风机异常设置(故障、异常、通信中断) func FanExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOptEnum) error { return DeviceExceptionOperate(w, deviceId, opt) } -// ElectricControlValveOperate 电动调节阀操作 -// -// optOpen : true-触发开阀;false-触发关阀 -func ElectricControlValveOperate(w ecs.World, deviceId string, optOpen bool) error { - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !(deviceEntry.HasComponent(component.ElectricControlValveType) && deviceEntry.HasComponent(component.TwoPositionTransformType)) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是电动调节阀", deviceId)) - } - tps := component.TwoPositionTransformType.Get(deviceEntry) //最小表示全关,最大表示全开 - if optOpen { - tps.Speed = component.CalculateTwoPositionAvgSpeed(component.ElectricControlValveOperationTime, w.Tick()) - } else { - tps.Speed = -component.CalculateTwoPositionAvgSpeed(component.ElectricControlValveOperationTime, w.Tick()) - } - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - // PurificationDeviceOperate 净化装置操作 // // optStart : true-启动净化器;false-关停净化器 @@ -302,30 +176,6 @@ func WaterClosedContainerOperate(w ecs.World, deviceId string, optRun bool) erro return r.Err } -// BypassValveSwitchOperate 旁通阀开关操作 -// -// openRate 旁通阀开关打开百分比[0,100] -func BypassValveSwitchOperate(w ecs.World, deviceId string, openRate uint8) error { - if openRate < 0 || openRate > 100 { - return fmt.Errorf("旁通阀开关打开百分比值须在[0,100]范围内") - } - r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - deviceEntry, ok := wd.EntityMap[deviceId] - if !ok { - return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) - } - // - if !(deviceEntry.HasComponent(component.ControlValveType) && deviceEntry.HasComponent(component.BypassValveSwitchTag)) { - return ecs.NewErrResult(fmt.Errorf("设备[%s]不是旁通阀开关", deviceId)) - } - component.ControlValveType.Get(deviceEntry).OpenRate = openRate - // - return ecs.NewOkEmptyResult() - }) - return r.Err -} - // CivilDefenseDoorOperate 封闭式水容器(如冷却塔、水处理器) // // optOpen : true-开门;false-关门 diff --git a/sys/iscs_sys/iscs_bas_fan.go b/sys/iscs_sys/iscs_bas_fan.go index 0190ca3..dbe9f6d 100644 --- a/sys/iscs_sys/iscs_bas_fan.go +++ b/sys/iscs_sys/iscs_bas_fan.go @@ -26,6 +26,7 @@ func (s *FanSystem) Update(w ecs.World) { // 计算风机加速度 func (s *FanSystem) calculateAc(fan *component.FanDevice, fanEntry *ecs.Entry) float32 { + //大于0加速,小于0减速 ac := float32(0) if fan.Fs.Off() { //电源关闭 ac = -4 //4 r/ms @@ -77,8 +78,10 @@ func (s *FanSystem) calculateAc(fan *component.FanDevice, fanEntry *ecs.Entry) f if fanEntry.HasComponent(component.FcBypassFanTag) { fcUnit := component.FanFcUnitType.Get(fanEntry) if fcUnit.Fc { - //SPEED := 60 * fcUnit.F + SPEED := 60 * fcUnit.F + if fan.Speed > float32(SPEED) && ac > 0 { + } } else { }