diff --git a/头罩视野slove/头罩视野/ModbusHelper.cs b/头罩视野slove/头罩视野/ModbusHelper.cs index 31360ef..739163b 100644 --- a/头罩视野slove/头罩视野/ModbusHelper.cs +++ b/头罩视野slove/头罩视野/ModbusHelper.cs @@ -86,7 +86,7 @@ public static class ModbusHelper //// 过滤无效信号 - private const int ValidSignalThreshold = 10; + private const int ValidSignalThreshold = 12; private static void FilterInvalidSignals(List data) { @@ -97,13 +97,12 @@ public static class ModbusHelper } } - /// /// 计算单眼视野面积 /// /// 20组数据,每组72个通道 - /// 有效亮度阈值(如80) - /// 标准视野面积(如120) + /// 有效亮度阈值(如12) + /// 标准视野面积(如140) /// 计算好的面积 /// public static double CalculateEyeArea(List groupData, double threshold, double standardArea) @@ -202,7 +201,7 @@ public static class ModbusHelper /// eyeData:单眼72路平均数据数组 /// threshold:有效亮度阈值 /// - 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 RemoveOutliers(List leftEyeDataList) + { + throw new NotImplementedException(); + } + // 你算出来的实际面积 //double left = 4250; diff --git a/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs b/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs index 13a023e..5bbd588 100644 --- a/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs +++ b/头罩视野slove/头罩视野/Views/RecordDate.xaml.cs @@ -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 leftEyeDataList, List 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 RemoveOutliers(List 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(); // 停止 - //} }