测试页面

This commit is contained in:
2026-04-27 16:45:06 +08:00
parent 37ce218e22
commit c5920022e8
8 changed files with 280 additions and 700 deletions

View File

@@ -46,7 +46,7 @@
Fill="White" Opacity="0.15" Stroke="White" StrokeThickness="1" Grid.ColumnSpan="2"/>
<!-- 主标题区 -->
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Margin="234,0,0,0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<!-- 中文标题 -->
<TextBlock x:Name="TX_1" Text="头罩视野测试仪"
FontSize="48" FontWeight="Bold"

View File

@@ -1,5 +1,5 @@
using Modbus.Device;
using Microsoft.Win32;
using Microsoft.Win32;
using Modbus.Device;
using System;
using System.Collections.Generic;
using System.IO;
@@ -7,6 +7,7 @@ using System.Net.Sockets;
using System.Text;
using System.Windows;
using .Services.Data;
using static .TestDataStore;
public static class ModbusHelper
{
@@ -23,8 +24,6 @@ public static class ModbusHelper
// 判断是否连接成功
public static bool IsConnected => TcpClient != null && TcpClient.Connected;
public static ushort ValidThreshold { get; private set; }
// <summary>
/// 公共保存方法(用户自选文件夹)
@@ -67,376 +66,4 @@ public static class ModbusHelper
MessageBox.Show("保存成功!\n" + filePath);
}
// 剔除异常值,用相邻数据插值
private static List<ushort> RemoveOutliers(List<ushort> data)
{
for (int i = 1; i < data.Count - 1; i++)
{
if (Math.Abs(data[i] - data[i - 1]) > 30 && Math.Abs(data[i] - data[i + 1]) > 30)
{
data[i] = (ushort)((data[i - 1] + data[i + 1]) / 2);
}
}
return data;
}
//// 过滤无效信号
private const int ValidSignalThreshold = 12;
private static void FilterInvalidSignals(List<ushort> data)
{
for (int i = 0; i < data.Count; i++)
{
if (data[i] < ValidSignalThreshold)
data[i] = 0;
}
}
/// <summary>
/// 计算单眼视野面积
/// </summary>
/// <param name="groupData">20组数据每组72个通道</param>
/// <param name="threshold">有效亮度阈值如12</param>
/// <param name="standardTotalArea">标准视野面积如140</param>
/// <returns>计算好的面积</returns>
///
public static double CalculateEyeArea(List<double[]> groupData, double threshold, double standardArea)
{
double[] avg = new double[72];
for (int c = 0; c < 72; c++)
{
double sum = 0;
foreach (var g in groupData) sum += g[c];
avg[c] = sum / groupData.Count;
}
int valid = avg.Count(v => v >= threshold);
return (valid / 72.0) * standardArea;
}
//计算单眼面积调用的方法
//double leftArea = CalculateEyeArea(
// leftEye20Groups, // 左眼20组数据
// 80, // 阈值
// 120 // 标准面积
//);
//double rightArea = .CalculateEyeArea(
// rightEye20Groups, // 右眼20组数据
// 80, // 阈值
// 120 // 标准面积
//);
//计算双目视野面积
/// <summary>
/// 计算双目视野面积(左右眼同时可见)
/// </summary>
public static double CalcBinocularArea(
List<double[]> leftGroups,
List<double[]> rightGroups,
double threshold,
double standardArea)
{
// 1. 左眼平均数据
double[] leftAvg = new double[72];
for (int i = 0; i < 72; i++)
{
double sum = 0;
foreach (var g in leftGroups) sum += g[i];
leftAvg[i] = sum / leftGroups.Count;
}
// 2. 右眼平均数据
double[] rightAvg = new double[72];
for (int i = 0; i < 72; i++)
{
double sum = 0;
foreach (var g in rightGroups) sum += g[i];
rightAvg[i] = sum / rightGroups.Count;
}
// 3. 双目同时有效点数(左右都亮才算)
int biValid = 0;
for (int i = 0; i < 72; i++)
{
if (leftAvg[i] >= threshold && rightAvg[i] >= threshold)
biValid++;
}
// 4. 双目视野面积
return (biValid / 72.0) * standardArea;
}
//调用公式
// 你从Modbus拿到的20组数据
//List<double[]> left20Groups = ...;
//List<double[]> right20Groups = ...;
//double threshold = 80;
//double standardArea = 120;
//// 左眼
//double left = VisionCalculator.CalcEyeArea(left20Groups, threshold, standardArea);
//// 右眼
//double right = VisionCalculator.CalcEyeArea(right20Groups, threshold, standardArea);
//// 双目视野面积
//double binocular = VisionCalculator.CalcBinocularArea(left20Groups, right20Groups, threshold, standardArea);
//// 总视野面积
//double total = left + right - binocular;
//下方视野角度
/// <summary>
/// GB2890-2022 计算 单眼下方视野角度
/// eyeData单眼72路平均数据数组
/// threshold有效亮度阈值
/// </summary>
public static double CalcLowerAngle(double[] eyeData, double threshold = 12)
{
// 总72点 每点5°
int totalPoint = 72;
double perAngle = 5;
// 国标最下方起始点位第54号开始为正下方
int startDownIndex = 54;
int validCount = 0;
// 从最下方向上 连续检测有效点
for (int i = 0; i < 36; i++)
{
int idx = (startDownIndex + i) % totalPoint;
if (eyeData[idx] >= threshold)
{
validCount++;
}
else
{
// 断开直接停止
break;
}
}
// 下方视野角度 = 有效点数 × 单步角度
return validCount * perAngle;
}
/// <summary>
/// 计算单眼72点通道平均值数组
/// </summary>
/// <param name="eyeGroups">多组采样数据集合</param>
/// <returns>72点通道平均值数组</returns>
private static double[] GetEyeAvgArray(List<double[]> eyeGroups)
{
if (eyeGroups == null || eyeGroups.Count == 0)
return new double[72]; // 无数据时返回全0数组
double[] avg = new double[72];
for (int i = 0; i < 72; i++)
{
double sum = 0;
foreach (var group in eyeGroups)
{
sum += group[i];
}
avg[i] = sum / eyeGroups.Count;
}
return avg;
}
//下方视野计算方法
////1. 先拿到左右眼 72点平均数组
//double[] leftAvg = GetLeftEyeAvgArray();
//double[] rightAvg = GetRightEyeAvgArray();
////2. 分别算下方角度
//double leftLowerAngle = CalcLowerAngle(leftAvg, 10);
//double rightLowerAngle = CalcLowerAngle(rightAvg, 10);
////3. 最终报告取值(国标取双眼较小值)
//double finalLowerAngle = Math.Min(leftLowerAngle, rightLowerAngle);
//bool lowerAngleOk = finalLowerAngle >= 35;
//空白视野面积计算
//空白视野面积 = 标准视野总面积 实测总视野面积
//总视野面积 = 左眼面积 + 右眼面积 双目重叠面积
// 前面已经算出来的
//double leftArea = ...;
//double rightArea = ...;
//double binocularArea = ...;
//// 总视野
//double totalVisionArea = leftArea + rightArea - binocularArea;
//// 标准总面积(设备固定值,比如 120
//double standardTotalArea = 120;
//// 空白视野面积
//double blankArea = standardTotalArea - totalVisionArea;
//视野保存率
//double totalSaveRate = (总视野面积 / 标准总视野面积) * 100;
public static class VisionCalculator
{
/// <summary>
/// 计算视野保存率
/// </summary>
/// <param name="actualArea">实测面积</param>
/// <param name="standardArea">标准面积</param>
/// <returns>保存率 %</returns>
public static double CalculateVisionSaveRate(double actualArea, double standardArea)
{
if (standardArea == 0) return 0;
return (actualArea / standardArea) * 100;
}
}
// 空头模无面罩标定的标准面积GB2890-2022
//public static double StandardSingleEye = 5200;
//// 双眼总标准面积(左+右)
//public static double StandardTotalEye = 10400;
//// 双目重叠标准面积
////public static double StandardBinocular = 4200;
//// 下方视野标准角度
//public static double StandardLowerAngle = 75;
//===== 1. 你预先标定的 空模标准面积 =====
// 单眼标准、总标准(左+右)、双目重叠标准
public static double StandardLeftEye = 5180;
public static double StandardRightEye = 5180;
public static double StandardTotal = 10360;
public static double StandardBinocular = 4150;
//===== 2. 传入你采集的实测面积 =====
// leftArea左眼实测 rightArea右眼实测 binArea双目重叠实测
public static double CalcVisionRate(double leftArea, double rightArea)
{
// 总视野实测 = 左+右
double totalSi = leftArea + rightArea;
// 1. 总视野保存率
double ratioTotal = totalSi / StandardTotal;
double gammaTotal = GetVisionGamma(ratioTotal);
double totalRate = gammaTotal * ratioTotal * 100;
return (totalRate);
}
/// <summary>
/// GB2890-2022 自动获取 总视野/双目视野 校正系数γ
/// </summary>
/// <param name="ratio">实测面积/标准面积 比值(0~1)</param>
/// <returns>校正系数 γ</returns>
public static double GetVisionGamma(double ratio)
{
// X视野残存率 Si/S0
double[] xData = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
// 总视野 γ 对应值
double[] gammaTotal = { 1.22, 1.18, 1.14, 1.10, 1.06, 1.03, 1.02, 1.01, 1.00 };
double[] yData = gammaTotal;
// 边界限制
if (ratio <= xData[0]) return yData[0];
if (ratio >= xData.Last()) return 1.0;
// 线性插值
for (int i = 0; i < xData.Length - 1; i++)
{
if (ratio >= xData[i] && ratio <= xData[i + 1])
{
double t = (ratio - xData[i]) / (xData[i + 1] - xData[i]);
return yData[i] + t * (yData[i + 1] - yData[i]);
}
}
return 1.0;
}
internal static double CalculateEyeArea(List<dynamic> leftEyeDataList, int v1, int v2)
{
throw new NotImplementedException();
}
internal static double CalcBinocularArea(List<dynamic> leftEyeDataList, List<dynamic> rightEyeDataList, int v1, int v2)
{
throw new NotImplementedException();
}
internal static double[] GetEyeAvgArray(List<dynamic> leftEyeDataList)
{
throw new NotImplementedException();
}
internal static List<dynamic> RemoveOutliers(List<dynamic> leftEyeDataList)
{
throw new NotImplementedException();
}
// 你算出来的实际面积
//double left = 4250;
//double right = 4320;
//double bin = 2860;
//// 一键算出 国标保存率
//var result = CalcVisionRate(left, right, bin);
//double 总视野保存率 = result.totalRate;
//double 双目视野保存率 = result.binRate;
}
//// 1. 总视野保存率
//double gammaTotal = 查国标图D.4的总视野γ;
//double totalRate = gammaTotal * totalArea / GlobalData.StandardTotalEye * 100;
// // 2. 双目视野保存率
// double gammaBinoc = 查国标图D.4的双目视野γ;
//double binocRate = gammaBinoc * binocArea / GlobalData.StandardBinocular * 100;
//// 3. 下方视野(直接比角度,不用面积)
//bool lowerPass = lowerAngle >= 35;
// 四、关键澄清(你之前问的)
//下方视野:国标是角度(°),不是面积
//按左右眼视野曲线下方交点位置直接读出角度
//合格≥35°
//总视野 = 左眼 + 右眼(国标明确)
//双目视野 = 左右眼重叠部分(单独算面积)
//五、最简总结(国标一句话)
//总视野保存率 =γ ×(左 + 右实测面积))/ 标准总面积 ×100%
//双目视野保存率 =γ × 重叠实测面积)/ 标准重叠面积 ×100%
//下方视野:直接看角度 ≥35°
//}
}

View File

@@ -0,0 +1,249 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace .Services
{
class GetArea
{
//public const double standardArea = 140;
/// <summary>有效亮度阈值:区分有效视野和噪声/遮挡的门槛设备标定经验值≥12判定为有效视野</summary>
public const int threshold = 12;
/// <summary>异常值差值阈值:过滤孤立尖峰噪声当前点与前后点差值均>30时判定为异常值并插值修正</summary>
public const int OutlierDiffThreshold = 30;
/// <summary>灯条通道总数360°圆周采样点数量对应每点5°360° ÷ 72 = 5°/点符合国标GB2890-2022要求</summary>
public const int lightNum = 72;
/// <summary>设备最大检测半径理论上的最大视野半径单位mm用来计算理论圆面积</summary> 这个是我们自己的设备值
public const int maxRadius_mm = 330;
/// <summary>单眼标准标定面积:无面罩空标准头模的单眼实测面积 国标视野保存率计算的基准值单位cm²</summary>
public const double SingleEyeStandardArea = 5180;
/// <summary>双目标准标定总面积无面罩空标准头模的双目总实测面积国标总视野保存率计算的基准值单位cm²</summary>
public const double StandardTotal = 10360;
// 补充:用半径计算的单眼理论圆面积(供参考) 公式:π × 半径²单位cm²
public static readonly double standardArea = Math.PI * maxRadius_mm * maxRadius_mm / 100;
//双目重叠标准
public static double StandardBinocular = 4150;
// 剔除异常值,用相邻数据插值
public static List<ushort> RemoveOutliers(List<ushort> data)
{
for (int i = 1; i < data.Count - 1; i++)
{
if (Math.Abs(data[i] - data[i - 1]) > OutlierDiffThreshold && Math.Abs(data[i] - data[i + 1]) > OutlierDiffThreshold)
{
data[i] = (ushort)((data[i - 1] + data[i + 1]) / 2);
}
//过滤无效信号
if (data[i] < threshold)
{
data[i] = 0;
}
}
return data;
}
/// <summary>
/// 计算单眼视野面积
/// </summary>
/// <param name="groupData">20组数据每组lightNum个通道</param>
/// <param name="threshold">有效亮度阈值如12</param>
/// <param name="standardArea">如140</param>
/// <returns>计算好的面积</returns>
///
public static double CalculateEyeArea(List<double[]> groupData)
{
double[] avg = new double[lightNum];
for (int c = 0; c < lightNum; c++)
{
double sum = 0;
foreach (var g in groupData) sum += g[c];
avg[c] = sum / groupData.Count;
}
int valid = avg.Count(v => v >= threshold);
return (valid / lightNum) * standardArea;
}
//计算双目视野面积
/// <summary>
/// 计算双目视野面积(左右眼同时可见)
/// </summary>
public static double CalcBinocularArea(
List<double[]> leftGroups,
List<double[]> rightGroups
)
{
// 1. 左眼平均数据
double[] leftAvg = new double[lightNum];
for (int i = 0; i < lightNum; i++)
{
double sum = 0;
foreach (var g in leftGroups) sum += g[i];
leftAvg[i] = sum / leftGroups.Count;
}
// 2. 右眼平均数据
double[] rightAvg = new double[lightNum];
for (int i = 0; i < lightNum; i++)
{
double sum = 0;
foreach (var g in rightGroups) sum += g[i];
rightAvg[i] = sum / rightGroups.Count;
}
// 3. 双目同时有效点数(左右都亮才算)
int biValid = 0;
for (int i = 0; i < lightNum; i++)
{
if (leftAvg[i] >= threshold && rightAvg[i] >= threshold)
biValid++;
}
// 4. 双目视野面积
return (biValid / lightNum) * standardArea;
}
//下方视野角度
/// <summary>
/// GB2890-2022 计算 单眼下方视野角度
/// eyeData单眼lightNum路平均数据数组
/// threshold有效亮度阈值
/// </summary>
public static double CalcLowerAngle(double[] eyeData, double perAngle)
{
// 总lightNum点 每点5°
int totalPoint = lightNum;
// 国标最下方起始点位第54号开始为正下方
int startDownIndex = 54;
int validCount = 0;
// 从最下方向上 连续检测有效点
for (int i = 0; i < lightNum / 2; i++)
{
int idx = (startDownIndex + i) % totalPoint;
if (eyeData[idx] >= threshold)
{
validCount++;
}
else
{
// 断开直接停止
break;
}
}
// 下方视野角度 = 有效点数 × 单步角度
return validCount * perAngle;
}
/// <summary>
/// 计算单眼lightNum点通道平均值数组
/// </summary>
/// <param name="eyeGroups">多组采样数据集合</param>
/// <returns>lightNum点通道平均值数组</returns>
public static double[] GetEyeAvgArray(List<double[]> eyeGroups)
{
if (eyeGroups == null || eyeGroups.Count == 0)
return new double[lightNum]; // 无数据时返回全0数组
double[] avg = new double[lightNum];
for (int i = 0; i < lightNum; i++)
{
double sum = 0;
foreach (var group in eyeGroups)
{
sum += group[i];
}
avg[i] = sum / eyeGroups.Count;
}
return avg;
}
//视野保存率
//double totalSaveRate = (总视野面积 / 标准总视野面积) * 100;
public static class VisionCalculator
{
/// <summary>
/// 计算视野保存率
/// </summary>
/// <param name="actualArea">实测面积</param>
/// <param name="standardArea">标准面积</param>
/// <returns>保存率 %</returns>
public static double CalculateVisionSaveRate(double actualArea)
{
return (actualArea / standardArea) * 100;
}
}
//===== 2. 传入你采集的实测面积 =====
// leftArea左眼实测 rightArea右眼实测 binArea双目重叠实测
public static double CalcVisionRate(double leftArea, double rightArea)
{
// 总视野实测 = 左+右
double totalSi = leftArea + rightArea;
// 1. 总视野保存率
double ratioTotal = totalSi / StandardTotal;
double gammaTotal = GetVisionGamma(ratioTotal);
double totalRate = gammaTotal * ratioTotal * 100;
return (totalRate);
}
/// <summary>
/// GB2890-2022 自动获取 总视野/双目视野 校正系数γ
/// </summary>
/// <param name="ratio">实测面积/标准面积 比值(0~1)</param>
/// <returns>校正系数 γ</returns>
public static double GetVisionGamma(double ratio)
{
// X视野残存率 Si/S0
double[] xData = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
// 总视野 γ 对应值
double[] gammaTotal = { 1.22, 1.18, 1.14, 1.10, 1.06, 1.03, 1.02, 1.01, 1.00 };
double[] yData = gammaTotal;
// 边界限制
if (ratio <= xData[0]) return yData[0];
if (ratio >= xData.Last()) return 1.0;
// 线性插值
for (int i = 0; i < xData.Length - 1; i++)
{
if (ratio >= xData[i] && ratio <= xData[i + 1])
{
double t = (ratio - xData[i]) / (xData[i + 1] - xData[i]);
return yData[i] + t * (yData[i + 1] - yData[i]);
}
}
return 1.0;
}
}
}

View File

@@ -46,7 +46,6 @@ namespace 头罩视野.Views
public PageTest()
{
InitializeComponent();
System.Diagnostics.Debug.WriteLine("页面加载了111111111");
_timer = InitDispatcherTimer();
// 2. 初始化定时器500毫秒 执行一次
@@ -55,7 +54,6 @@ namespace 头罩视野.Views
testTimer.Interval = TimeSpan.FromMilliseconds(500); // 500ms = 0.5秒
testTimer.Tick += Timer_Tick;
//// 判断连接
if (!ModbusHelper.IsConnected)
{
@@ -64,8 +62,6 @@ namespace 头罩视野.Views
}
}
//
// 蓝色亮(蓝色)
private void LedOn(Ellipse led)
@@ -320,7 +316,7 @@ namespace 头罩视野.Views
{
// 还不确定?
var recordPage = GetRecordDatePage();
recordPage?.AddPlcDataRow(LeftEyeDataList, RightEyeDataList);
recordPage?.getAllData(LeftEyeDataList, RightEyeDataList);
//值显示在页面,
zmsyarea.Text = GlobalData.LeftEyeArea.ToString("0.00"); // 左目
smsyarea.Text = GlobalData.BinocularArea.ToString("0.00"); // 双目

View File

@@ -15,6 +15,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using .Services;
using .Services.Data;
using static .TestDataStore;
namespace .Views
@@ -30,8 +31,8 @@ namespace 头罩视野.Views
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
private System.Timers.Timer? _plcReadTimer;
// 表跟数据存储列表
public List<dynamic> LeftEyeDataList = new List<dynamic>();
public List<dynamic> RightEyeDataList = new List<dynamic>();
public List<double> LeftEyeDataList = new List<double>();
public List<double> RightEyeDataList = new List<double>();
// 配置和你PLC地址完全对应 左目
private const int LeftEyeStartAddress = 1362; // D1362
@@ -41,10 +42,9 @@ namespace 头罩视野.Views
//右目
private const int RightEyeStartAddress = 1218; // D1218
// 长按清除用
//// 长按清除用
private bool _isClearPressed = false;
private Thread _clearThread;
private List<ushort> leftEyeDataList;
public RecordDate()
{
@@ -64,7 +64,7 @@ namespace 头罩视野.Views
//动态生成表头
void DynamicHeader()
{
// 2. 循环生成 64 个 ch 列
// 2. 循环生成 72 个 ch 列
for (int i = 1; i <= ChannelCount; i++)
{
dataGrid1.Columns.Add(new DataGridTextColumn
@@ -86,8 +86,7 @@ namespace 头罩视野.Views
_plcReadTimer.Stop();
_plcReadTimer.Dispose();
_plcReadTimer = null;
//这个时候开始计算
AddPlcDataRow(LeftEyeDataList, RightEyeDataList);
}
}
//定时读取 PLC 数据
@@ -121,10 +120,7 @@ namespace 头罩视野.Views
dataGrid: dataGrid2);
}
private void ReadPlcDataGeneric(int slaveAddress, int startAddress, ushort count, List<dynamic> dataList, DataGrid dataGrid)
{
throw new NotImplementedException();
}
/// <summary>
@@ -143,7 +139,7 @@ namespace 头罩视野.Views
byte slaveAddress,
ushort startAddress,
ushort count,
List<ushort> dataList,
List<double> dataList,
DataGrid dataGrid)
{
if (_modbusMaster == null || !ModbusHelper.TcpClient.Connected)
@@ -177,7 +173,7 @@ namespace 头罩视野.Views
/// <summary>
/// 把PLC数据添加到动态表格
/// </summary>
public void AddPlcDataRow(ushort[] registers, List<ushort> dataList, DataGrid dg)
private void AddPlcDataRow(ushort[] registers, List<ushort> dataList, DataGrid dg)
{
// 清空旧数据,防止重复
@@ -208,47 +204,44 @@ namespace 头罩视野.Views
}
//面积的计算方法
public void getAllData(List<double> leftEyeDataList, List<double> RightEyeDataList, double perAngle)
//左右目面积调用方法
public void AddPlcDataRow(List<dynamic> leftEyeDataList, List<dynamic> RightEyeDataList)
{
leftEyeDataList = ModbusHelper.RemoveOutliers(leftEyeDataList);
RightEyeDataList = ModbusHelper.RemoveOutliers(RightEyeDataList);
// 1. 先去除异常值,生成新列表(不修改原列表)
var filteredLeft = GetArea.RemoveOutliers(leftEyeDataList);
var filteredRight = GetArea.RemoveOutliers(RightEyeDataList);
//左目视野面积
GlobalData.LeftEyeArea = ModbusHelper.CalculateEyeArea(leftEyeDataList,
12,
140
);
GlobalData.LeftEyeArea = GetArea.CalculateEyeArea(leftEyeDataList);
//右目视野面积
GlobalData.RightEyeArea = ModbusHelper.CalculateEyeArea(RightEyeDataList,
12,
140
);
GlobalData.RightEyeArea = GetArea.CalculateEyeArea(RightEyeDataList);
//双目视野面积
GlobalData.BinocularArea = ModbusHelper.CalcBinocularArea(leftEyeDataList, RightEyeDataList, 12, 140);
GlobalData.BinocularArea = GetArea.CalcBinocularArea(leftEyeDataList, RightEyeDataList);
//// 总视野面积
GlobalData.TotalEyeArea = GlobalData.LeftEyeArea + GlobalData.RightEyeArea - GlobalData.BinocularArea;
//// 空白视野面积
GlobalData.BlankArea = 140 - GlobalData.TotalEyeArea;
GlobalData.BlankArea = GetArea.StandardTotal - GlobalData.TotalEyeArea;
//视野保存率
// 左眼平均值数组
double[] leftAvg = ModbusHelper.GetEyeAvgArray(leftEyeDataList);
double[] leftAvg = GetArea.GetEyeAvgArray(leftEyeDataList);
// 右眼平均值数组
double[] rightAvg = ModbusHelper.GetEyeAvgArray(RightEyeDataList);
double[] rightAvg = GetArea.GetEyeAvgArray(RightEyeDataList);
double leftLowerAngle = ModbusHelper.CalcLowerAngle(leftAvg, 12);
double rightLowerAngle = ModbusHelper.CalcLowerAngle(rightAvg, 12);
double leftLowerAngle = GetArea.CalcLowerAngle(leftAvg, perAngle);
double rightLowerAngle = GetArea.CalcLowerAngle(rightAvg, perAngle);
//下方视野
GlobalData.LowerVision = Math.Min(leftLowerAngle, rightLowerAngle);
//视野保存率
GlobalData.VisionRetentionRate = ModbusHelper.CalcVisionRate(GlobalData.LeftEyeArea, GlobalData.RightEyeArea);
GlobalData.VisionRetentionRate = GetArea.CalcVisionRate(GlobalData.LeftEyeArea, GlobalData.RightEyeArea);
//打印数值显示在系统上面
System.Diagnostics.Debug.WriteLine("左目视野面积" + GlobalData.LeftEyeArea);

View File

@@ -124,17 +124,12 @@
<StackPanel Orientation="Horizontal" Margin="0,15,0,15">
<TextBlock Text="上灯条数据4" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj4" Text="" Style="{StaticResource TextBoxStyle}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="上灯条数据5" Style="{StaticResource LabelStyle}"/>
<TextBox Name="sdtsj5" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"

View File

@@ -1,140 +0,0 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B3AA18B6D2D35505085C1250F6B7671386BCB992"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using HandyControl.Controls;
using HandyControl.Data;
using HandyControl.Expression.Media;
using HandyControl.Expression.Shapes;
using HandyControl.Interactivity;
using HandyControl.Media.Animation;
using HandyControl.Media.Effects;
using HandyControl.Properties.Langs;
using HandyControl.Themes;
using HandyControl.Tools;
using HandyControl.Tools.Converter;
using HandyControl.Tools.Extension;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using ;
namespace {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 51 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_1;
#line default
#line hidden
#line 59 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_0;
#line default
#line hidden
#line 75 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Frame MainFrame;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.TX_1 = ((System.Windows.Controls.TextBlock)(target));
return;
case 2:
this.TX_0 = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
#line 68 "..\..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.GoRecord);
#line default
#line hidden
return;
case 4:
#line 73 "..\..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.GoVisiPage);
#line default
#line hidden
return;
case 5:
this.MainFrame = ((System.Windows.Controls.Frame)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@@ -1,140 +0,0 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B3AA18B6D2D35505085C1250F6B7671386BCB992"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using HandyControl.Controls;
using HandyControl.Data;
using HandyControl.Expression.Media;
using HandyControl.Expression.Shapes;
using HandyControl.Interactivity;
using HandyControl.Media.Animation;
using HandyControl.Media.Effects;
using HandyControl.Properties.Langs;
using HandyControl.Themes;
using HandyControl.Tools;
using HandyControl.Tools.Converter;
using HandyControl.Tools.Extension;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using ;
namespace {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 51 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_1;
#line default
#line hidden
#line 59 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_0;
#line default
#line hidden
#line 75 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Frame MainFrame;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.TX_1 = ((System.Windows.Controls.TextBlock)(target));
return;
case 2:
this.TX_0 = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
#line 68 "..\..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.GoRecord);
#line default
#line hidden
return;
case 4:
#line 73 "..\..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.GoVisiPage);
#line default
#line hidden
return;
case 5:
this.MainFrame = ((System.Windows.Controls.Frame)(target));
return;
}
this._contentLoaded = true;
}
}
}