添加新的测温功能
This commit is contained in:
+82
-23
@@ -1,7 +1,10 @@
|
||||
using Aitex.Core.RT.IOCore;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
||||
{
|
||||
@@ -19,20 +22,31 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
||||
|
||||
private string DeviceName { get; set; }
|
||||
|
||||
private float[] tempChangeCache;
|
||||
private double[] _chTempChangeCache;
|
||||
|
||||
private double[] _allChTempChangeCache;
|
||||
|
||||
//硬件通道数
|
||||
private int NumberOfChannels;
|
||||
private int _numberOfChannels;
|
||||
|
||||
private const double Epsilon = 0.001;
|
||||
|
||||
/// <summary>
|
||||
/// 统计温度相同次数
|
||||
/// 统计单路温度相同次数
|
||||
/// </summary>
|
||||
private int noChangeNum;
|
||||
private int _chNoChangeNum;
|
||||
|
||||
/// <summary>
|
||||
/// 统计单路温度相同次数
|
||||
/// </summary>
|
||||
private int _allChNoChangeNum;
|
||||
|
||||
/// <summary>
|
||||
/// 记录温度不变时数据,最多记录10次
|
||||
/// </summary>
|
||||
private StringBuilder strNoChangeMeg = new();
|
||||
private readonly StringBuilder _strChNoChangeMeg = new();
|
||||
|
||||
private readonly StringBuilder _strAllChNoChangeMeg = new();
|
||||
|
||||
/// <summary>
|
||||
/// 测温硬件最低测试温度,传入温度为此数值,不进行温度数据变化对比
|
||||
@@ -44,16 +58,24 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
||||
/// </summary>
|
||||
/// <param name="deviceName">测温硬件名称</param>
|
||||
/// <param name="tempMin">最低温度显示,AE和昂坤都是600</param>
|
||||
public TempBasFunction(string deviceName , double tempMin,int numberOfChannels)
|
||||
public TempBasFunction(string deviceName, double tempMin, int numberOfChannels)
|
||||
{
|
||||
DeviceName = deviceName;
|
||||
TempMin = tempMin;
|
||||
NumberOfChannels = numberOfChannels;
|
||||
tempChangeCache = new float[NumberOfChannels];
|
||||
_numberOfChannels = numberOfChannels;
|
||||
_chTempChangeCache = new double[numberOfChannels];
|
||||
_allChTempChangeCache = new double[numberOfChannels];
|
||||
IsPM1Installed = SC.GetValue<bool>($"System.SetUp.IsPM1Installed");
|
||||
IsPM2Installed = SC.GetValue<bool>($"System.SetUp.IsPM2Installed");
|
||||
}
|
||||
|
||||
public void SetTempCh(int numberOfChannels)
|
||||
{
|
||||
_numberOfChannels = numberOfChannels;
|
||||
_chTempChangeCache = new double[numberOfChannels];
|
||||
_allChTempChangeCache = new double[numberOfChannels];
|
||||
}
|
||||
|
||||
public void PM1PM2PostLog(string str, Action<string, string, int> action)
|
||||
{
|
||||
if (IsPM1Installed)
|
||||
@@ -84,7 +106,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
||||
{
|
||||
string PM = pm.ToUpper();
|
||||
if (IsMP(PM))
|
||||
IO.DO[$"PM1.DO_PyroCommunicationError"].SetValue(isReset, out _);
|
||||
IO.DO[$"{PM}.DO_PyroCommunicationError"].SetValue(isReset, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,38 +124,75 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
||||
|
||||
private bool IsMP(string pm)
|
||||
{
|
||||
return (pm == "PM1" || pm == "PM2")? true : false;
|
||||
return (pm == "PM1" || pm == "PM2") ? true : false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 温度是否发生改变,返回数据不发生改变次数
|
||||
/// 温度是否发生改变(单路温度不变记录),返回数据不发生改变次数
|
||||
/// </summary>
|
||||
/// <param name="outputTemp"></param>
|
||||
/// <returns></returns>
|
||||
public int TempInvariantCount(float[] outputTemp, out string errorInf)
|
||||
public int TempNoChangeCount(float[] outputTemp, out string errorInf)
|
||||
{
|
||||
errorInf = "";
|
||||
if (noChangeNum > 999999)//防止数据溢出
|
||||
noChangeNum = 0;
|
||||
if (_chNoChangeNum > 999999)//防止数据溢出
|
||||
_chNoChangeNum = 0;
|
||||
for (int i = 0; i < outputTemp.Length; i++)
|
||||
{
|
||||
if (outputTemp[i] <= TempMin)//低于温度下限,数据不做对比
|
||||
continue;
|
||||
|
||||
if (outputTemp[i] == tempChangeCache[i])
|
||||
if (Math.Abs(outputTemp[i] - _chTempChangeCache[i]) < Epsilon)
|
||||
{
|
||||
if (noChangeNum < 10)//记录前10次的数据
|
||||
strNoChangeMeg.Append($"#{i + 1}:{outputTemp[i]:0.00} ");
|
||||
if (_chNoChangeNum < 10)//记录前10次的数据
|
||||
_strChNoChangeMeg.Append($"#{i + 1}:{outputTemp[i]:0.00} ");
|
||||
|
||||
errorInf = strNoChangeMeg.ToString();
|
||||
return noChangeNum++;
|
||||
errorInf = _strChNoChangeMeg.ToString();
|
||||
return _chNoChangeNum++;
|
||||
}
|
||||
tempChangeCache[i] = outputTemp[i];
|
||||
_chTempChangeCache[i] = outputTemp[i];
|
||||
}
|
||||
|
||||
//只要数据不同,就可以复位计数和缓存
|
||||
strNoChangeMeg.Clear();
|
||||
noChangeNum = 0;
|
||||
_strChNoChangeMeg.Clear();
|
||||
_chNoChangeNum = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 温度是否发生改变(所有温度不变记录),返回数据不发生改变次数
|
||||
/// </summary>
|
||||
/// <param name="outputTemp"></param>
|
||||
/// <returns></returns>
|
||||
public int AllTempNoChangeCount(double[] outputTemp, out string errorInf)
|
||||
{
|
||||
errorInf = "";
|
||||
if (_allChNoChangeNum > 999999)//防止数据溢出
|
||||
_allChNoChangeNum = 0;
|
||||
|
||||
int noChangeCount = 0;
|
||||
for (int i = 0; i < outputTemp.Length; i++)
|
||||
{
|
||||
if (outputTemp[i] <= TempMin)//低于温度下限,数据不做对比
|
||||
continue;
|
||||
if (Math.Abs(outputTemp[i] - _allChTempChangeCache[i]) < Epsilon)
|
||||
{
|
||||
if (_allChNoChangeNum < 10) //记录前10次的数据
|
||||
_strAllChNoChangeMeg.Append($"#{i + 1}: {outputTemp[i]:0.00}; ");
|
||||
|
||||
errorInf = _strAllChNoChangeMeg.ToString();
|
||||
noChangeCount += 1;
|
||||
}
|
||||
_allChTempChangeCache[i] = outputTemp[i];
|
||||
}
|
||||
|
||||
if (noChangeCount == outputTemp.Length)//不变次数等于数组长度时,断定所有数据均无变化
|
||||
{
|
||||
_strAllChNoChangeMeg.Append("\r\n");
|
||||
return _allChNoChangeNum++;
|
||||
}
|
||||
//只要数据不同,就可以复位计数和缓存
|
||||
_strAllChNoChangeMeg.Clear();
|
||||
_allChNoChangeNum = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user