diff --git a/头罩视野slove/头罩视野/MainWindow.xaml b/头罩视野slove/头罩视野/MainWindow.xaml index 7fb69aa..e30a9fb 100644 --- a/头罩视野slove/头罩视野/MainWindow.xaml +++ b/头罩视野slove/头罩视野/MainWindow.xaml @@ -46,7 +46,7 @@ Fill="White" Opacity="0.15" Stroke="White" StrokeThickness="1" Grid.ColumnSpan="2"/> - + TcpClient != null && TcpClient.Connected; - public static ushort ValidThreshold { get; private set; } - // /// 公共保存方法(用户自选文件夹) @@ -67,376 +66,4 @@ public static class ModbusHelper MessageBox.Show("保存成功!\n" + filePath); } - - - - - // 剔除异常值,用相邻数据插值 - private static List RemoveOutliers(List 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 data) - { - for (int i = 0; i < data.Count; i++) - { - if (data[i] < ValidSignalThreshold) - data[i] = 0; - } - } - - /// - /// 计算单眼视野面积 - /// - /// 20组数据,每组72个通道 - /// 有效亮度阈值(如12) - /// 标准视野面积(如140) - /// 计算好的面积 - /// - public static double CalculateEyeArea(List 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 // 标准面积 - //); - - - - //计算双目视野面积 - /// - /// 计算双目视野面积(左右眼同时可见) - /// - public static double CalcBinocularArea( - List leftGroups, - List 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 left20Groups = ...; - //List 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; - - - //下方视野角度 - /// - /// GB2890-2022 计算 单眼下方视野角度 - /// eyeData:单眼72路平均数据数组 - /// threshold:有效亮度阈值 - /// - 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; - } - - - /// - /// 计算单眼72点通道平均值数组 - /// - /// 多组采样数据集合 - /// 72点通道平均值数组 - private static double[] GetEyeAvgArray(List 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 - { - /// - /// 计算视野保存率 - /// - /// 实测面积 - /// 标准面积 - /// 保存率 % - 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); - } - - /// - /// GB2890-2022 自动获取 总视野/双目视野 校正系数γ - /// - /// 实测面积/标准面积 比值(0~1) - /// 校正系数 γ - 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 leftEyeDataList, int v1, int v2) - { - throw new NotImplementedException(); - } - - internal static double CalcBinocularArea(List leftEyeDataList, List rightEyeDataList, int v1, int v2) - { - throw new NotImplementedException(); - } - - internal static double[] GetEyeAvgArray(List leftEyeDataList) - { - throw new NotImplementedException(); - } - - internal static List RemoveOutliers(List 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° -//} \ No newline at end of file +} \ No newline at end of file diff --git a/头罩视野slove/头罩视野/Services/GetArea.cs b/头罩视野slove/头罩视野/Services/GetArea.cs new file mode 100644 index 0000000..32a4926 --- /dev/null +++ b/头罩视野slove/头罩视野/Services/GetArea.cs @@ -0,0 +1,249 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace 头罩视野.Services +{ + class GetArea + { + //public const double standardArea = 140; + + /// 有效亮度阈值:区分有效视野和噪声/遮挡的门槛设备标定经验值,≥12判定为有效视野 + public const int threshold = 12; + + /// 异常值差值阈值:过滤孤立尖峰噪声当前点与前后点差值均>30时,判定为异常值并插值修正 + public const int OutlierDiffThreshold = 30; + + /// 灯条通道总数:360°圆周采样点数量对应每点5°(360° ÷ 72 = 5°/点),符合国标GB2890-2022要求 + public const int lightNum = 72; + + /// 设备最大检测半径:理论上的最大视野半径单位:mm,用来计算理论圆面积 这个是我们自己的设备值 + public const int maxRadius_mm = 330; + + /// 单眼标准标定面积:无面罩空标准头模的单眼实测面积 国标视野保存率计算的基准值,单位:cm² + public const double SingleEyeStandardArea = 5180; + + /// 双目标准标定总面积:无面罩空标准头模的双目总实测面积国标总视野保存率计算的基准值,单位:cm² + 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 RemoveOutliers(List 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; + } + + + /// + /// 计算单眼视野面积 + /// + /// 20组数据,每组lightNum个通道 + /// 有效亮度阈值(如12) + /// (如140) + /// 计算好的面积 + /// + public static double CalculateEyeArea(List 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; + } + + + + + //计算双目视野面积 + /// + /// 计算双目视野面积(左右眼同时可见) + /// + public static double CalcBinocularArea( + List leftGroups, + List 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; + } + + //下方视野角度 + /// + /// GB2890-2022 计算 单眼下方视野角度 + /// eyeData:单眼lightNum路平均数据数组 + /// threshold:有效亮度阈值 + /// + 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; + } + + + /// + /// 计算单眼lightNum点通道平均值数组 + /// + /// 多组采样数据集合 + /// lightNum点通道平均值数组 + public static double[] GetEyeAvgArray(List 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 + { + /// + /// 计算视野保存率 + /// + /// 实测面积 + /// 标准面积 + /// 保存率 % + 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); + } + + /// + /// GB2890-2022 自动获取 总视野/双目视野 校正系数γ + /// + /// 实测面积/标准面积 比值(0~1) + /// 校正系数 γ + 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; + } + } +} diff --git a/头罩视野slove/头罩视野/Views/PageTest.xaml.cs b/头罩视野slove/头罩视野/Views/PageTest.xaml.cs index aa41fa0..e8358da 100644 --- a/头罩视野slove/头罩视野/Views/PageTest.xaml.cs +++ b/头罩视野slove/头罩视野/Views/PageTest.xaml.cs @@ -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"); // 双目 diff --git a/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs b/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs index e423628..e64dea7 100644 --- a/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs +++ b/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs @@ -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 LeftEyeDataList = new List(); - public List RightEyeDataList = new List(); + public List LeftEyeDataList = new List(); + public List RightEyeDataList = new List(); // 配置:和你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 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 dataList, DataGrid dataGrid) - { - throw new NotImplementedException(); - } + /// @@ -143,7 +139,7 @@ namespace 头罩视野.Views byte slaveAddress, ushort startAddress, ushort count, - List dataList, + List dataList, DataGrid dataGrid) { if (_modbusMaster == null || !ModbusHelper.TcpClient.Connected) @@ -177,7 +173,7 @@ namespace 头罩视野.Views /// /// 把PLC数据添加到动态表格 /// - public void AddPlcDataRow(ushort[] registers, List dataList, DataGrid dg) + private void AddPlcDataRow(ushort[] registers, List dataList, DataGrid dg) { // 清空旧数据,防止重复 @@ -208,47 +204,44 @@ namespace 头罩视野.Views } + //面积的计算方法 + public void getAllData(List leftEyeDataList, List RightEyeDataList, double perAngle) - //左右目面积调用方法 - public void AddPlcDataRow(List leftEyeDataList, List 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); diff --git a/头罩视野slove/头罩视野/Views/VisiData.xaml b/头罩视野slove/头罩视野/Views/VisiData.xaml index 4f7a528..e3ea79d 100644 --- a/头罩视野slove/头罩视野/Views/VisiData.xaml +++ b/头罩视野slove/头罩视野/Views/VisiData.xaml @@ -124,17 +124,12 @@ - - - - - -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -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 头罩视野 { - - - /// - /// MainWindow - /// - 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; - - /// - /// InitializeComponent - /// - [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; - } - } -} - diff --git a/头罩视野slove/头罩视野/obj/Debug/net10.0-windows/MainWindow.g.i.cs b/头罩视野slove/头罩视野/obj/Debug/net10.0-windows/MainWindow.g.i.cs deleted file mode 100644 index af58a5b..0000000 --- a/头罩视野slove/头罩视野/obj/Debug/net10.0-windows/MainWindow.g.i.cs +++ /dev/null @@ -1,140 +0,0 @@ -#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B3AA18B6D2D35505085C1250F6B7671386BCB992" -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -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 头罩视野 { - - - /// - /// MainWindow - /// - 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; - - /// - /// InitializeComponent - /// - [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; - } - } -} -