6个物性公式的更改
This commit is contained in:
@@ -10,8 +10,10 @@ using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Services.Dialogs;
|
||||
using SixLabors.ImageSharp.ColorSpaces;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
@@ -23,7 +25,7 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 计算扫描 Task
|
||||
/// </summary>
|
||||
private static Task CalcTask { get; set; }
|
||||
private static Task CalcTask { get; set; } = Task.CompletedTask;
|
||||
public ConfigService ConfigService { get; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
@@ -93,7 +95,8 @@ namespace CapMachine.Wpf.Services
|
||||
//TxvFrTempTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前温度[℃]")!;
|
||||
//TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]")!;
|
||||
|
||||
if (TagManager.TryGetShortTagByName("SUBCOOL出口温度[℃]", out ShortValueTag? TxvFrTempShortTag))
|
||||
if (TagManager.TryGetShortTagByName("膨胀阀前温度[℃]", out ShortValueTag? TxvFrTempShortTag) ||
|
||||
TagManager.TryGetShortTagByName("SUBCOOL出口温度[℃]", out TxvFrTempShortTag))
|
||||
{
|
||||
TxvFrTempTag = TxvFrTempShortTag!;
|
||||
}
|
||||
@@ -150,6 +153,31 @@ namespace CapMachine.Wpf.Services
|
||||
DrynessTag = drynessPct!;
|
||||
}
|
||||
|
||||
if (TagManager.TryGetShortTagByName("制热量Qh[W]", out ShortValueTag? heatingCapacityTag))
|
||||
{
|
||||
HeatingCapacityTag = heatingCapacityTag!;
|
||||
}
|
||||
if (TagManager.TryGetShortTagByName("压缩机性能系数(制热)", out ShortValueTag? copHeatTag))
|
||||
{
|
||||
COPHeatTag = copHeatTag!;
|
||||
}
|
||||
if (TagManager.TryGetShortTagByName("等熵效率ns[%]", out ShortValueTag? isentrpEffTag))
|
||||
{
|
||||
IsentrpEffTag = isentrpEffTag!;
|
||||
}
|
||||
if (TagManager.TryGetShortTagByName("制冷量Qc[W]", out ShortValueTag? coolCapacityTag))
|
||||
{
|
||||
CoolCapacityTag = coolCapacityTag!;
|
||||
}
|
||||
if (TagManager.TryGetShortTagByName("压缩机性能系数(制冷)", out ShortValueTag? copCoolTag))
|
||||
{
|
||||
COPCoolTag = copCoolTag!;
|
||||
}
|
||||
if (TagManager.TryGetShortTagByName("容积效率nv[%]", out ShortValueTag? voltricEffTag))
|
||||
{
|
||||
VoltricEffTag = voltricEffTag!;
|
||||
}
|
||||
|
||||
SuperHeatCoolConfig.FluidsPath = ConfigHelper.GetValue("FluidsPath");
|
||||
SuperHeatCoolConfig.Cryogen = ConfigHelper.GetValue("Cryogen");
|
||||
|
||||
@@ -166,14 +194,14 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
public void SaveSuperHeatCoolConfig()
|
||||
{
|
||||
ConfigHelper.SetValue("FluidsPath", SuperHeatCoolConfig.FluidsPath);
|
||||
ConfigHelper.SetValue("Cryogen", SuperHeatCoolConfig.Cryogen);
|
||||
ConfigHelper.SetValue("FluidsPath", SuperHeatCoolConfig.FluidsPath ?? string.Empty);
|
||||
ConfigHelper.SetValue("Cryogen", SuperHeatCoolConfig.Cryogen ?? string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 吸气压力
|
||||
/// </summary>
|
||||
public ShortValueTag InhPressTag { get; set; }
|
||||
public ShortValueTag InhPressTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 转速标签
|
||||
@@ -198,32 +226,44 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 吸气温度
|
||||
/// </summary>
|
||||
public ShortValueTag InhTempTag { get; set; }
|
||||
public ShortValueTag InhTempTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 液体阀前温度
|
||||
/// </summary>
|
||||
public ShortValueTag TxvFrTempTag { get; set; }
|
||||
public ShortValueTag TxvFrTempTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 液体阀前压力
|
||||
/// </summary>
|
||||
public ShortValueTag TxvFrPressTag { get; set; }
|
||||
public ShortValueTag TxvFrPressTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 过热度
|
||||
/// </summary>
|
||||
public ShortValueTag Superheat { get; set; }
|
||||
public ShortValueTag Superheat { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 过冷度
|
||||
/// </summary>
|
||||
public ShortValueTag Subcool { get; set; }
|
||||
public ShortValueTag Subcool { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 干度(无量纲 [-])
|
||||
/// </summary>
|
||||
public ShortValueTag DrynessTag { get; set; }
|
||||
public ShortValueTag DrynessTag { get; set; } = null!;
|
||||
|
||||
public ShortValueTag? HeatingCapacityTag { get; set; }
|
||||
|
||||
public ShortValueTag? COPHeatTag { get; set; }
|
||||
|
||||
public ShortValueTag? IsentrpEffTag { get; set; }
|
||||
|
||||
public ShortValueTag? CoolCapacityTag { get; set; }
|
||||
|
||||
public ShortValueTag? COPCoolTag { get; set; }
|
||||
|
||||
public ShortValueTag? VoltricEffTag { get; set; }
|
||||
|
||||
private double _DrynessTag2Value;
|
||||
/// <summary>
|
||||
@@ -238,28 +278,28 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 气路阀前压力(BarA)
|
||||
/// </summary>
|
||||
public ShortValueTag GasPreValvePressTag { get; set; }
|
||||
public ShortValueTag GasPreValvePressTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 气路阀前温度(℃)
|
||||
/// </summary>
|
||||
public ShortValueTag GasPreValveTempTag { get; set; }
|
||||
public ShortValueTag GasPreValveTempTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 冷媒流量kg/h
|
||||
/// </summary>
|
||||
public ShortValueTag VRVTag { get; set; }
|
||||
public ShortValueTag VRVTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 液体流量(kg/h)
|
||||
/// 液冷媒流量kg/h=液体流量kg/h
|
||||
/// </summary>
|
||||
public ShortValueTag LiqRefFlowTag { get; set; }
|
||||
public ShortValueTag LiqRefFlowTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 润滑油流量(kg/h)
|
||||
/// </summary>
|
||||
public ShortValueTag LubeFlowTag { get; set; }
|
||||
public ShortValueTag LubeFlowTag { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 风量数据-乘以系数的后的最终结果
|
||||
@@ -448,25 +488,25 @@ namespace CapMachine.Wpf.Services
|
||||
// 处理 err2
|
||||
}
|
||||
|
||||
//if (TryUpdateThermodynamicSixResults(out var thermoErr))
|
||||
//{
|
||||
// if (!string.IsNullOrWhiteSpace(thermoErr))
|
||||
// {
|
||||
// Logger?.Error($"六个物性结果计算警告: {thermoErr}");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (!string.IsNullOrWhiteSpace(thermoErr))
|
||||
// {
|
||||
// Logger?.Error($"六个物性结果计算失败: {thermoErr}");
|
||||
// }
|
||||
//}
|
||||
if (TryUpdateThermodynamicSixResults(out var thermoErr))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(thermoErr))
|
||||
{
|
||||
Logger?.Error($"六个物性结果计算警告: {thermoErr}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(thermoErr))
|
||||
{
|
||||
Logger?.Error($"六个物性结果计算失败: {thermoErr}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
Logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace ?? string.Empty, ex.Message));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1159,6 +1199,17 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
error = string.Empty;
|
||||
|
||||
if (InhPressTag == null || InhTempTag == null)
|
||||
{
|
||||
error = "缺少吸气压力/吸气温度标签";
|
||||
return false;
|
||||
}
|
||||
if (TxvFrPressTag == null || TxvFrTempTag == null)
|
||||
{
|
||||
error = "缺少膨胀阀前压力/膨胀阀前温度标签";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryGetCompressorPower_kW(out var w_kW, out var wErr))
|
||||
{
|
||||
error = wErr;
|
||||
@@ -1217,6 +1268,27 @@ namespace CapMachine.Wpf.Services
|
||||
COPCooling = copC;
|
||||
IsentropicEfficiencyPct = etaS_pct;
|
||||
|
||||
if (HeatingCapacityTag != null)
|
||||
{
|
||||
HeatingCapacityTag.PVModel.EngValue = HeatingCapacityQh_kW * 1000.0;
|
||||
}
|
||||
if (COPHeatTag != null)
|
||||
{
|
||||
COPHeatTag.PVModel.EngValue = COPHeating;
|
||||
}
|
||||
if (IsentrpEffTag != null)
|
||||
{
|
||||
IsentrpEffTag.PVModel.EngValue = IsentropicEfficiencyPct;
|
||||
}
|
||||
if (CoolCapacityTag != null)
|
||||
{
|
||||
CoolCapacityTag.PVModel.EngValue = CoolingCapacityQc_kW * 1000.0;
|
||||
}
|
||||
if (COPCoolTag != null)
|
||||
{
|
||||
COPCoolTag.PVModel.EngValue = COPCooling;
|
||||
}
|
||||
|
||||
if (!TryComputeVolumetricEfficiencyPct(mRef_kg_s, v1_m3kg, out var etaV_pct, out var etaVErr))
|
||||
{
|
||||
VolumetricEfficiencyPct = double.NaN;
|
||||
@@ -1225,6 +1297,11 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
|
||||
VolumetricEfficiencyPct = etaV_pct;
|
||||
|
||||
if (VoltricEffTag != null)
|
||||
{
|
||||
VoltricEffTag.PVModel.EngValue = VolumetricEfficiencyPct;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1269,6 +1346,17 @@ namespace CapMachine.Wpf.Services
|
||||
mRef_kg_s = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
if (VRVTag == null)
|
||||
{
|
||||
error = "缺少总流量(冷媒流量)标签";
|
||||
return false;
|
||||
}
|
||||
if (LubeFlowTag == null)
|
||||
{
|
||||
error = "缺少油流量标签";
|
||||
return false;
|
||||
}
|
||||
|
||||
double mTotal_kg_h = VRVTag.PVModel.EngValue;
|
||||
double mOil_kg_h = LubeFlowTag.PVModel.EngValue;
|
||||
|
||||
@@ -1634,26 +1722,49 @@ namespace CapMachine.Wpf.Services
|
||||
displacement_cc = double.NaN;
|
||||
error = string.Empty;
|
||||
|
||||
const double defaultDisplacementCc = 35d;
|
||||
if (ConfigService?.CurExpInfo != null &&
|
||||
TryParseCompressorDisplacementTextToCc(ConfigService.CurExpInfo.CapDisplacement, out var expCc) &&
|
||||
expCc > 0)
|
||||
{
|
||||
displacement_cc = expCc;
|
||||
return true;
|
||||
}
|
||||
|
||||
const string key = "CompressorDisplacementCc";
|
||||
if (!ConfigHelper.IsExist(key))
|
||||
if (ConfigHelper.IsExist(key) && TryParseCompressorDisplacementTextToCc(ConfigHelper.GetValue(key), out var cfgCc) && cfgCc > 0)
|
||||
{
|
||||
displacement_cc = cfgCc;
|
||||
return true;
|
||||
}
|
||||
|
||||
displacement_cc = defaultDisplacementCc;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool TryParseCompressorDisplacementTextToCc(string? text, out double displacementCc)
|
||||
{
|
||||
displacementCc = double.NaN;
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
error = $"未配置压缩机排量,请在 App.config/appSettings 增加 {key}(单位 cc)";
|
||||
return false;
|
||||
}
|
||||
|
||||
string v = ConfigHelper.GetValue(key);
|
||||
if (!double.TryParse(v, out displacement_cc))
|
||||
var normalized = text.Trim().ToLowerInvariant();
|
||||
normalized = normalized.Replace(',', '.');
|
||||
|
||||
var match = Regex.Match(normalized, @"[-+]?\d+(\.\d+)?");
|
||||
if (!match.Success)
|
||||
{
|
||||
error = $"压缩机排量配置无法解析: {v}";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (displacement_cc <= 0)
|
||||
if (!double.TryParse(match.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var v))
|
||||
{
|
||||
error = $"压缩机排量<=0: {displacement_cc}";
|
||||
return false;
|
||||
}
|
||||
|
||||
displacementCc = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user