iscs bas 大系统

This commit is contained in:
xzb 2023-12-26 11:06:34 +08:00
parent 94d06677e7
commit 721824c2f7
2 changed files with 4 additions and 151 deletions

View File

@ -8,137 +8,11 @@ import (
"joylink.club/rtsssimulation/entity" "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 风机异常设置(故障、异常、通信中断) // FanExceptionOperate 风机异常设置(故障、异常、通信中断)
func FanExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOptEnum) error { func FanExceptionOperate(w ecs.World, deviceId string, opt DeviceExceptionOptEnum) error {
return DeviceExceptionOperate(w, deviceId, opt) 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 净化装置操作 // PurificationDeviceOperate 净化装置操作
// //
// optStart : true-启动净化器false-关停净化器 // optStart : true-启动净化器false-关停净化器
@ -302,30 +176,6 @@ func WaterClosedContainerOperate(w ecs.World, deviceId string, optRun bool) erro
return r.Err 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 封闭式水容器(如冷却塔、水处理器) // CivilDefenseDoorOperate 封闭式水容器(如冷却塔、水处理器)
// //
// optOpen : true-开门false-关门 // optOpen : true-开门false-关门

View File

@ -26,6 +26,7 @@ func (s *FanSystem) Update(w ecs.World) {
// 计算风机加速度 // 计算风机加速度
func (s *FanSystem) calculateAc(fan *component.FanDevice, fanEntry *ecs.Entry) float32 { func (s *FanSystem) calculateAc(fan *component.FanDevice, fanEntry *ecs.Entry) float32 {
//大于0加速小于0减速
ac := float32(0) ac := float32(0)
if fan.Fs.Off() { //电源关闭 if fan.Fs.Off() { //电源关闭
ac = -4 //4 r/ms 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) { if fanEntry.HasComponent(component.FcBypassFanTag) {
fcUnit := component.FanFcUnitType.Get(fanEntry) fcUnit := component.FanFcUnitType.Get(fanEntry)
if fcUnit.Fc { if fcUnit.Fc {
//SPEED := 60 * fcUnit.F SPEED := 60 * fcUnit.F
if fan.Speed > float32(SPEED) && ac > 0 {
}
} else { } else {
} }