基本值调整

This commit is contained in:
2026-04-24 18:07:58 +08:00
parent 613153e664
commit 2d91a579a9
2 changed files with 28 additions and 61 deletions

View File

@@ -86,7 +86,7 @@ public static class ModbusHelper
//// 过滤无效信号
private const int ValidSignalThreshold = 10;
private const int ValidSignalThreshold = 12;
private static void FilterInvalidSignals(List<ushort> data)
{
@@ -97,13 +97,12 @@ public static class ModbusHelper
}
}
/// <summary>
/// 计算单眼视野面积
/// </summary>
/// <param name="groupData">20组数据每组72个通道</param>
/// <param name="threshold">有效亮度阈值(如80</param>
/// <param name="standardTotalArea">标准视野面积如120</param>
/// <param name="threshold">有效亮度阈值(如12</param>
/// <param name="standardTotalArea">标准视野面积如140</param>
/// <returns>计算好的面积</returns>
///
public static double CalculateEyeArea(List<double[]> groupData, double threshold, double standardArea)
@@ -202,7 +201,7 @@ public static class ModbusHelper
/// eyeData单眼72路平均数据数组
/// threshold有效亮度阈值
/// </summary>
public static double CalcLowerAngle(double[] eyeData, double threshold = 10)
public static double CalcLowerAngle(double[] eyeData, double threshold = 12)
{
// 总72点 每点5°
int totalPoint = 72;
@@ -390,6 +389,11 @@ public static class ModbusHelper
throw new NotImplementedException();
}
internal static List<dynamic> RemoveOutliers(List<dynamic> leftEyeDataList)
{
throw new NotImplementedException();
}
// 你算出来的实际面积
//double left = 4250;

View File

@@ -88,6 +88,8 @@ namespace 头罩视野.Views
_plcReadTimer.Stop();
_plcReadTimer.Dispose();
_plcReadTimer = null;
//这个时候开始计算
AddPlcDataRow(LeftEyeDataList, RightEyeDataList)
}
}
//定时读取 PLC 数据
@@ -209,8 +211,6 @@ namespace 头罩视野.Views
}
//左右目面积调用方法
private void AddPlcDataRow(List<dynamic> leftEyeDataList, List<dynamic> RightEyeDataList)
{
@@ -219,22 +219,22 @@ namespace 头罩视野.Views
//左目视野面积
GlobalData.LeftEyeArea = ModbusHelper.CalculateEyeArea(leftEyeDataList,
80,
120
12,
140
);
//右目视野面积
GlobalData.RightEyeArea = ModbusHelper.CalculateEyeArea(RightEyeDataList,
80,
120
12,
140
);
//双目视野面积
GlobalData.BinocularArea = ModbusHelper.CalcBinocularArea(leftEyeDataList, RightEyeDataList, 80, 120);
GlobalData.BinocularArea = ModbusHelper.CalcBinocularArea(leftEyeDataList, RightEyeDataList, 12, 140);
//// 总视野面积
GlobalData.TotalEyeArea = GlobalData.LeftEyeArea + GlobalData.RightEyeArea - GlobalData.BinocularArea;
//// 空白视野面积
GlobalData.BlankArea = 120 - GlobalData.TotalEyeArea;
GlobalData.BlankArea = 140 - GlobalData.TotalEyeArea;
//视野保存率
@@ -244,14 +244,22 @@ namespace 头罩视野.Views
// 右眼平均值数组
double[] rightAvg = ModbusHelper.GetEyeAvgArray(RightEyeDataList);
double leftLowerAngle = ModbusHelper.CalcLowerAngle(leftAvg, 10);
double rightLowerAngle = ModbusHelper.CalcLowerAngle(rightAvg, 10);
double leftLowerAngle = ModbusHelper.CalcLowerAngle(leftAvg, 12);
double rightLowerAngle = ModbusHelper.CalcLowerAngle(rightAvg, 12);
//下方视野
GlobalData.LowerVision = Math.Min(leftLowerAngle, rightLowerAngle);
//视野保存率
GlobalData.VisionRetentionRate = ModbusHelper.CalcVisionRate(GlobalData.LeftEyeArea, GlobalData.RightEyeArea);
//打印数值显示在系统上面
System.Diagnostics.Debug.WriteLine("左目视野面积" + GlobalData.LeftEyeArea);
System.Diagnostics.Debug.WriteLine("右目视野面积" + GlobalData.RightEyeArea);
System.Diagnostics.Debug.WriteLine("双目视野面积" + GlobalData.BinocularArea);
System.Diagnostics.Debug.WriteLine("总视野面积" + GlobalData.TotalEyeArea);
System.Diagnostics.Debug.WriteLine("下方视野" + GlobalData.LowerVision);
System.Diagnostics.Debug.WriteLine("视野保存率" + GlobalData.VisionRetentionRate);
}
private List<dynamic> RemoveOutliers(List<dynamic> leftEyeDataList)
@@ -263,8 +271,6 @@ namespace 头罩视野.Views
{
throw new NotImplementedException();
}
//#endregion
// 保存左眼
@@ -340,47 +346,4 @@ namespace 头罩视野.Views
//// 公开定时器(让别的页面能访问)
//public System.Timers.Timer PlcReadTimer;
// // 公开:启动定时器
// public void StartRecordTimer()
// {
// if (PlcReadTimer == null)
// {
// PlcReadTimer = new System.Timers.Timer(100);
// PlcReadTimer.Elapsed += ReadPlcData; // 你的PLC读取方法
// PlcReadTimer.Start();
// }
// }
// // 公开:停止定时器
// public void StopRecordTimer()
// {
// if (PlcReadTimer != null)
// {
// PlcReadTimer.Stop();
// PlcReadTimer.Dispose();
// PlcReadTimer = null;
// }
// }
// // 你的PLC读取方法
// private void ReadPlcData(object sender, System.Timers.ElapsedEventArgs e)
// {
// // 你原来的逻辑
// }
// 找到 RecordDate 页面实例 页面调用和停止
//var recordPage = Application.Current.MainWindow
// .FindName("MainFrame") as Frame
// ?.Content as RecordDate;
//// 找到了就调用
//if (recordPage != null)
//{
// recordPage.StartRecordTimer(); // 启动
// // recordPage.StopRecordTimer(); // 停止
//}
}