csv导入和导出的问题
排量配置的问题 物性参数回差值配置的问题
This commit is contained in:
@@ -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">排量输出,单位 cc(cm³/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)
|
||||
|
||||
Reference in New Issue
Block a user