工具表定模块 使用科学计数法

This commit is contained in:
XingCheng3
2026-05-12 13:28:37 +08:00
parent 36a4084d3a
commit 08b0d4e5e3
9 changed files with 261 additions and 67 deletions

View File

@@ -24,6 +24,7 @@ namespace MesWork
public decimal? StableWeight;
public int? StableStartSeq;
public int? StableEndSeq;
public DateTime LastCalibrationErrorLogTime;
}
private static readonly ConcurrentDictionary<string, CurveCollectorState> _curveCollectors
@@ -76,7 +77,7 @@ namespace MesWork
}
/// <summary>
/// 采集线程200ms读取一次实时重量缓存到内存,保存时一次性写库。
/// 采集线程200ms读取一次实时重量先按工具标定公式计算,再缓存到内存,保存时一次性写库。
/// </summary>
private void CurveCollector_Work(CurveCollectorState state)
{
@@ -84,7 +85,17 @@ namespace MesWork
{
try
{
decimal weight = Convert.ToDecimal(ReadPLC(100220, state.OpName)); // 实时重量点位
decimal rawWeight = Convert.ToDecimal(ReadPLC(100220, state.OpName)); // 实时重量点位
if (!WeightCalibrationHelper.Apply(state.OpName, rawWeight, out decimal weight, out _, out string msg))
{
if ((DateTime.Now - state.LastCalibrationErrorLogTime).TotalSeconds >= 5)
{
state.LastCalibrationErrorLogTime = DateTime.Now;
WeighingPage?.AppendLog($"[{state.OpName}] 曲线采样标定失败:{msg}");
}
Thread.Sleep(CurveCollectorSampleIntervalMs);
continue;
}
lock (state.BufferLock)
{
state.Buffer.Add(new CurveSamplePoint
@@ -139,7 +150,7 @@ namespace MesWork
}
/// <summary>
/// 优先用曲线点计算稳定重量失败时调用方继续使用PLC锁定重量。
/// 优先用已标定曲线点计算稳定重量失败时调用方继续使用PLC锁定重量。
/// </summary>
private bool CurveCollector_TryGetStableWeight(string opName, out decimal weight, out int pointCount, out string msg)
{