更新TemperatureData.cs文件

This commit is contained in:
zqm
2025-11-06 09:28:50 +08:00
parent 81c65a35a6
commit e2025f1ced

View File

@@ -127,7 +127,9 @@ namespace JoyD.Windows.CS.Toprie
{
throw new ArgumentException("数据长度不足,无法解析");
}
String key = $"{Width}_{Height}";
bool hasMap = _temperatureMap.TryGetValue(key, out ConcurrentDictionary<String, List<int>> map);
// 计算温度数据长度和像素总数
int dataLength = rawData.Length - HEADER_SIZE;
int pixelCount = dataLength / 2; // 每个像素2字节
@@ -161,11 +163,13 @@ namespace JoyD.Windows.CS.Toprie
// 应用温度补偿值
float compensatedTemperature = rawTemperature + compensationValue;
// 原始温度存入TemperatureMatrix(未温补)
TemperatureMatrix[row, col] = rawTemperature;
// 温补后的温度存入RealTemperatureMatrix映射到512×384矩阵
MapToRealTemperatureMatrix(row, col, compensatedTemperature);
// 原始温度存入TemperatureMatrix
TemperatureMatrix[row, col] = compensatedTemperature;
if (hasMap)
{
// 温补后的温度存入RealTemperatureMatrix映射到512×384矩阵
MapToRealTemperatureMatrix($"{col}_{row}", map, compensatedTemperature);
}
}
}
}
@@ -174,25 +178,17 @@ namespace JoyD.Windows.CS.Toprie
/// <summary>
/// 将原始温度数据映射到512×384的实际温度矩阵
/// </summary>
/// <param name="sourceRow">源数据行索引</param>
/// <param name="sourceCol">源数据列索引</param>
/// <param name="key">映射键</param>
/// <param name="map">映射表</param>
/// <param name="temperature">温度值</param>
private void MapToRealTemperatureMatrix(int sourceRow, int sourceCol, float temperature)
private void MapToRealTemperatureMatrix(String key, ConcurrentDictionary<String, List<int>> map, float temperature)
{
// 计算映射比例从原始分辨率映射到512×384
float rowRatio = 384.0f / Height;
float colRatio = 512.0f / Width;
// 计算目标位置
int targetRow = (int)(sourceRow * rowRatio);
int targetCol = (int)(sourceCol * colRatio);
// 确保目标位置在有效范围内
targetRow = Math.Min(383, Math.Max(0, targetRow));
targetCol = Math.Min(511, Math.Max(0, targetCol));
// 设置实际温度值
RealTemperatureMatrix[targetRow, targetCol] = temperature;
if (!map.TryGetValue(key, out List<int> xy)) return;
for (int idx = 0; idx < xy.Count; idx += 2)
{
// 设置实际温度值
RealTemperatureMatrix[xy[idx], xy[idx+1]] = temperature;
}
}
/// <summary>