csv导入和导出的问题

排量配置的问题
物性参数回差值配置的问题
This commit is contained in:
2026-04-30 11:35:27 +08:00
parent 74bf47ee62
commit 802348a743
15 changed files with 457 additions and 229 deletions

View File

@@ -62,6 +62,9 @@ namespace CapMachine.Wpf.Services
case "过热度/过冷度配置":
ShowSuperHeatCool(msg.Par);
break;
case "COP物性参数回差":
ShowTherdyConfig(msg.Par);
break;
case "规则转换":
if (SysRunServer.MachineRunState1.IsRunState)
{
@@ -104,6 +107,17 @@ namespace CapMachine.Wpf.Services
});
}
private void ShowTherdyConfig(object par)
{
DialogService.ShowDialog("DialogTherdyConfigView", new DialogParameters() { { "Name", par } }, (dialogResult) =>
{
if (dialogResult.Result == ButtonResult.OK)
{
PPCService.ReloadTherdyH3TempOffset();
}
});
}
/// <summary>

View File

@@ -37,8 +37,8 @@ namespace CapMachine.Wpf.Services
//}),
new NavigationItem("", "计算信息","",new ObservableCollection<NavigationItem>()
{
new NavigationItem("SuperHeatCool","过热度/过冷度配置","DialogSuperHeatCoolConfigView"),
//new NavigationItem("Palette","过冷度",""),
new NavigationItem("","过热度/过冷度配置","DialogSuperHeatCoolConfigView"),
new NavigationItem("","COP物性参数回差","DialogTherdyConfigView"),
}),
new NavigationItem("", "规则设置","",new ObservableCollection<NavigationItem>()
{

View File

@@ -165,6 +165,20 @@ namespace CapMachine.Wpf.Services
SuperHeatCoolConfig.FluidsPath = ConfigHelper.GetValue("FluidsPath");
SuperHeatCoolConfig.Cryogen = ConfigHelper.GetValue("Cryogen");
ReloadTherdyH3TempOffset();
// 订阅 ConfigService.CurExpInfo 属性变化,实验切换时自动刷新排量缓存
ConfigService.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == nameof(ConfigService.CurExpInfo))
{
RefreshDisplacementCache();
}
};
// 首次初始化排量缓存(在订阅事件前初始化,避免首次触发不必要的刷新)
RefreshDisplacementCache();
RtScanDeviceStart();
}
@@ -173,6 +187,19 @@ namespace CapMachine.Wpf.Services
/// </summary>
public SuperHeatCoolConfigModel SuperHeatCoolConfig { get; set; } = new SuperHeatCoolConfigModel();
private const string TherdyH3TempOffsetConfigKey = "Therdy_H3TempOffset_C";
private double _therdyH3TempOffset_C = -10.0;
public double TherdyH3TempOffset_C
{
get { return _therdyH3TempOffset_C; }
private set
{
_therdyH3TempOffset_C = value;
RaisePropertyChanged();
}
}
/// <summary>
/// 保存配置信息
/// </summary>
@@ -182,6 +209,25 @@ namespace CapMachine.Wpf.Services
ConfigHelper.SetValue("Cryogen", SuperHeatCoolConfig.Cryogen ?? string.Empty);
}
public void ReloadTherdyH3TempOffset()
{
double offsetC = -10.0;
try
{
string raw = ConfigHelper.GetValue(TherdyH3TempOffsetConfigKey);
if (!string.IsNullOrWhiteSpace(raw) && double.TryParse(raw, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsed))
{
offsetC = parsed;
}
}
catch
{
}
TherdyH3TempOffset_C = offsetC;
_thermodynamicSixResultsCalculator.SetH3TempOffset_C(offsetC);
}
/// <summary>
/// 吸气压力
/// </summary>
@@ -545,6 +591,27 @@ namespace CapMachine.Wpf.Services
///制热量、压缩机性能系数COP制热、等熵效率、制冷量、压缩机性能系数COP(制冷)、容积效率 计算
#region
/// <summary>
/// 缓存的压缩机排量值cc在实验切换时自动刷新
/// </summary>
private double _cachedDisplacement_cc = double.NaN;
/// <summary>
/// 缓存数据来源标识用于调试ExpInfo=实验信息, Config=配置文件, Default=默认值
/// </summary>
private string _cachedSource = string.Empty;
private int _CurDisplacementCc;
/// <summary>
/// 当前的排量信息(供 UI 展示)
/// </summary>
public int CurDisplacementCc
{
get { return _CurDisplacementCc; }
set { _CurDisplacementCc = value; RaisePropertyChanged(); }
}
private double _HeatingCapacityQh_kW;
/// <summary>
/// 制热量 Qh [kW]
@@ -781,34 +848,68 @@ namespace CapMachine.Wpf.Services
}
/// <summary>
/// 获取压缩机排量
/// 获取压缩机排量(使用缓存机制,避免每次计算周期实时读取)
/// </summary>
/// <param name="displacement_cc">排量输出,单位 cccm³/rev。</param>
/// <param name="error">失败原因(未配置、解析失败、数值不合法)。</param>
/// <returns>是否获取成功。</returns>
/// <param name="error">失败原因(仅在缓存异常时返回)。</param>
/// <returns>始终返回 true因为默认回退 35cc 保证缓存始终有效)。</returns>
private bool TryGetCompressorDisplacement_cc(out double displacement_cc, out string error)
{
displacement_cc = double.NaN;
displacement_cc = _cachedDisplacement_cc;
error = string.Empty;
return true;
}
/// <summary>
/// 刷新压缩机排量缓存,按优先级读取:实验信息 → 配置文件 → 默认值
/// 在实验切换时自动调用,保证缓存与当前实验信息一致
/// </summary>
private void RefreshDisplacementCache()
{
const double defaultDisplacementCc = 35d;
double displacementCc = defaultDisplacementCc;
string source = "Default";
// 优先级1从当前实验信息读取
if (ConfigService?.CurExpInfo != null &&
TryParseCompressorDisplacementTextToCc(ConfigService.CurExpInfo.CapDisplacement, out var expCc) &&
expCc > 0)
{
displacement_cc = expCc;
return true;
displacementCc = expCc;
source = "ExpInfo";
}
const string key = "CompressorDisplacementCc";
if (ConfigHelper.IsExist(key) && TryParseCompressorDisplacementTextToCc(ConfigHelper.GetValue(key), out var cfgCc) && cfgCc > 0)
// 优先级2从 App.config 配置读取
else if (ConfigHelper.IsExist("CompressorDisplacementCc") &&
TryParseCompressorDisplacementTextToCc(ConfigHelper.GetValue("CompressorDisplacementCc"), out var cfgCc) &&
cfgCc > 0)
{
displacement_cc = cfgCc;
return true;
displacementCc = cfgCc;
source = "Config";
}
// 优先级3使用默认值
else
{
displacementCc = defaultDisplacementCc;
source = "Default";
}
displacement_cc = defaultDisplacementCc;
return true;
// 更新缓存字段
_cachedDisplacement_cc = displacementCc;
_cachedSource = source;
// 同步更新 UI 展示属性
CurDisplacementCc = (int)displacementCc;
// 记录日志(便于调试)
Logger?.Info($"压缩机排量缓存已刷新: {displacementCc}cc (来源: {source})");
}
/// <summary>
/// 强制刷新压缩机排量缓存(供外部主动调用,用于调试或特殊情况如 App.config 配置修改后)
/// </summary>
public void ForceRefreshDisplacementCache()
{
RefreshDisplacementCache();
}
private static bool TryParseCompressorDisplacementTextToCc(string? text, out double displacementCc)