更新TemperatureData.cs文件
This commit is contained in:
@@ -127,7 +127,9 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("数据长度不足,无法解析");
|
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 dataLength = rawData.Length - HEADER_SIZE;
|
||||||
int pixelCount = dataLength / 2; // 每个像素2字节
|
int pixelCount = dataLength / 2; // 每个像素2字节
|
||||||
@@ -161,11 +163,13 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
// 应用温度补偿值
|
// 应用温度补偿值
|
||||||
float compensatedTemperature = rawTemperature + compensationValue;
|
float compensatedTemperature = rawTemperature + compensationValue;
|
||||||
|
|
||||||
// 原始温度存入TemperatureMatrix(未温补)
|
// 原始温度存入TemperatureMatrix
|
||||||
TemperatureMatrix[row, col] = rawTemperature;
|
TemperatureMatrix[row, col] = compensatedTemperature;
|
||||||
|
if (hasMap)
|
||||||
// 温补后的温度存入RealTemperatureMatrix(映射到512×384矩阵)
|
{
|
||||||
MapToRealTemperatureMatrix(row, col, compensatedTemperature);
|
// 温补后的温度存入RealTemperatureMatrix(映射到512×384矩阵)
|
||||||
|
MapToRealTemperatureMatrix($"{col}_{row}", map, compensatedTemperature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,25 +178,17 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将原始温度数据映射到512×384的实际温度矩阵
|
/// 将原始温度数据映射到512×384的实际温度矩阵
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sourceRow">源数据行索引</param>
|
/// <param name="key">映射键</param>
|
||||||
/// <param name="sourceCol">源数据列索引</param>
|
/// <param name="map">映射表</param>
|
||||||
/// <param name="temperature">温度值</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)
|
if (!map.TryGetValue(key, out List<int> xy)) return;
|
||||||
float rowRatio = 384.0f / Height;
|
for (int idx = 0; idx < xy.Count; idx += 2)
|
||||||
float colRatio = 512.0f / Width;
|
{
|
||||||
|
// 设置实际温度值
|
||||||
// 计算目标位置
|
RealTemperatureMatrix[xy[idx], xy[idx+1]] = temperature;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user