CSV 的报错的更改

This commit is contained in:
2026-04-29 20:51:27 +08:00
parent 53ded58da3
commit 74bf47ee62
10 changed files with 497 additions and 100 deletions

View File

@@ -24,6 +24,7 @@ namespace CapMachine.Wpf.Services
public MachineRtDataService MachineRtDataService { get; }
private readonly EnthalpyDrynessCalculator _enthalpyDrynessCalculator;
private readonly ThermodynamicSixResultsCalculator _thermodynamicSixResultsCalculator;
private readonly SuperheatSubcoolCalculator _superheatSubcoolCalculator;
/// <summary>
/// 标签中心
@@ -41,6 +42,7 @@ namespace CapMachine.Wpf.Services
MachineRtDataService = machineRtDataService;
_enthalpyDrynessCalculator = new EnthalpyDrynessCalculator(_refpropLock);
_thermodynamicSixResultsCalculator = new ThermodynamicSixResultsCalculator(_refpropLock);
_superheatSubcoolCalculator = new SuperheatSubcoolCalculator(_refpropLock);
TagManager = MachineRtDataService.TagManger;
if (TagManager.TryGetShortTagByName("转速[rpm]", out ShortValueTag? speedShortTag))
@@ -130,7 +132,7 @@ namespace CapMachine.Wpf.Services
}
// 干度标签(如不存在则仅跳过写入,不抛异常)。优先使用“干度[%]”,其次“干度[-]”。
if (TagManager.TryGetShortTagByName("干度[%]", out ShortValueTag? drynessPct))
if (TagManager.TryGetShortTagByName("干度[-]", out ShortValueTag? drynessPct))
{
DrynessTag = drynessPct!;
}
@@ -139,7 +141,7 @@ namespace CapMachine.Wpf.Services
{
HeatingCapacityTag = heatingCapacityTag!;
}
if (TagManager.TryGetShortTagByName("压缩机性能系数(制热)", out ShortValueTag? copHeatTag))
if (TagManager.TryGetShortTagByName("压缩机性能系数(制热COP)", out ShortValueTag? copHeatTag))
{
COPHeatTag = copHeatTag!;
}
@@ -151,7 +153,7 @@ namespace CapMachine.Wpf.Services
{
CoolCapacityTag = coolCapacityTag!;
}
if (TagManager.TryGetShortTagByName("压缩机性能系数(制冷)", out ShortValueTag? copCoolTag))
if (TagManager.TryGetShortTagByName("压缩机性能系数(制冷COP)", out ShortValueTag? copCoolTag))
{
COPCoolTag = copCoolTag!;
}
@@ -302,15 +304,8 @@ namespace CapMachine.Wpf.Services
try
{
long iErr, kph = 1;
double te = 0.0, te1 = 0.0, p = 0.0, p1 = 0.0, d = 0.0, Dl = 0.0, Dv = 0.0, q = 0.0, h = 0.0, ee = 0.0, hh = 0.0, ss = 0.0, cp = 0.0, cv = 0.0, w = 0.0;
double[] x = new double[20], xliq = new double[20], xvap = new double[20];
double[] xlkg = new double[20], xvkg = new double[20];
double tk = 0.0, wm = 0.0, prevDeltaH = 0.0;//prevDeltaH 未使用
//textBox5.Text = "";
double[] x = new double[20];
double wm = 0.0;
// 幂等初始化:仅首次或工质/路径变化时执行 SETPATH/SETUP提高每秒循环效率
if (!EnsureRefpropInitialized(out var initErr))
@@ -324,33 +319,7 @@ namespace CapMachine.Wpf.Services
x[0] = 1.0;
IRefProp64.WMOLdll(x, ref wm);
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力kpa
p = (InhPressTag.PVModel.EngValue) * 100.0;// 保持你原有流程:将 BarA 当作 MPa? 历史代码为 *1000.0,不改变你的算法
kph = 1;
p1 = (TxvFrPressTag.PVModel.EngValue) * 100.0;// 保持你原有流程
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力Mpa
// 统一放入同一把锁中,避免并发导致的 Fortran 读文件/状态竞态
string herr = new string(' ', 255); long herrLen = 255; iErr = 0;
lock (_refpropLock)
{
IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
}
if (iErr == 0)
Superheat.PVModel.EngValue = Math.Abs(InhTempTag.PVModel.EngValue - (te - 273.15));
else
Superheat.PVModel.EngValue = 0;
herr = new string(' ', 255); herrLen = 255; iErr = 0;
lock (_refpropLock)
{
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
}
if (iErr == 0)
Subcool.PVModel.EngValue = Math.Abs(TxvFrTempTag.PVModel.EngValue - (te1 - 273.15));
else
Subcool.PVModel.EngValue = 0;
UpdateSuperheatAndSubcool_BySatp();
//这里写死干度的输入数据
@@ -363,7 +332,7 @@ namespace CapMachine.Wpf.Services
double vrvFlowKgPerH = VRVTag.PVModel.EngValue;
double liqRefFlowKgPerH = LiqRefFlowTag.PVModel.EngValue;
double lubeFlowKgPerH = 0.0;
//干度技术
@@ -383,7 +352,8 @@ namespace CapMachine.Wpf.Services
{
if (DrynessTag != null)
{
DrynessTag.PVModel.EngValue = drynessResult.Dryness1_01 * 100.0;
//DrynessTag.PVModel.EngValue = drynessResult.Dryness1_01 * 100.0;
DrynessTag.PVModel.EngValue = Math.Round(drynessResult.Dryness1_01, 4);
}
//DrynessTag2Value = drynessResult.Dryness1_01 * 100.0;
@@ -422,7 +392,7 @@ namespace CapMachine.Wpf.Services
if (drynessResult.IsDryness2Success)
{
//DrynessTag.PVModel.EngValue = drynessResult.Dryness2_01 * 100.0;
DrynessTag2Value = drynessResult.Dryness2_01 * 100.0;
DrynessTag2Value = Math.Round(drynessResult.Dryness2_01,4) ;
//if (drynessResult.Dryness2_01 <= 0)
//{
// LogDrynessSnapshotIfNeeded(
@@ -486,6 +456,20 @@ namespace CapMachine.Wpf.Services
});
}
private void UpdateSuperheatAndSubcool_BySatp()
{
_superheatSubcoolCalculator.Calculate(
inhPressBarA: InhPressTag.PVModel.EngValue,
inhTempC: InhTempTag.PVModel.EngValue,
txvFrPressBarA: TxvFrPressTag.PVModel.EngValue,
txvFrTempC: TxvFrTempTag.PVModel.EngValue,
out var superheatK,
out var subcoolK);
Superheat.PVModel.EngValue = superheatK;
Subcool.PVModel.EngValue = subcoolK;
}
// 若类中尚未定义,请添加全局互斥锁,串行化所有 REFPROP 调用
private static readonly object _refpropLock = new object();
@@ -664,7 +648,7 @@ namespace CapMachine.Wpf.Services
return false;
}
double suctionPress_BarA = InhPressTag.PVModel.EngValue;
double suctionTemp_C = InhTempTag.PVModel.EngValue;