页面样式
This commit is contained in:
@@ -23,6 +23,8 @@ public static class ModbusHelper
|
||||
// 判断是否连接成功
|
||||
public static bool IsConnected => TcpClient != null && TcpClient.Connected;
|
||||
|
||||
public static ushort ValidThreshold { get; private set; }
|
||||
|
||||
|
||||
// <summary>
|
||||
/// 公共保存方法(用户自选文件夹)
|
||||
@@ -66,6 +68,36 @@ public static class ModbusHelper
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 剔除异常值,用相邻数据插值
|
||||
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 = 10;
|
||||
|
||||
private static void FilterInvalidSignals(List<ushort> data)
|
||||
{
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
if (data[i] < ValidSignalThreshold)
|
||||
data[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计算单眼视野面积
|
||||
/// </summary>
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace 头罩视野.Views
|
||||
// 长按清除用
|
||||
private bool _isClearPressed = false;
|
||||
private Thread _clearThread;
|
||||
private List<ushort> leftEyeDataList;
|
||||
|
||||
public RecordDate()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -177,6 +179,7 @@ namespace 头罩视野.Views
|
||||
/// </summary>
|
||||
private void AddPlcDataRow(ushort[] registers, List<ushort> dataList, DataGrid dg)
|
||||
{
|
||||
|
||||
// 清空旧数据,防止重复
|
||||
dataList.Clear();
|
||||
|
||||
@@ -201,19 +204,20 @@ namespace 头罩视野.Views
|
||||
// 更新DataGrid
|
||||
dg.ItemsSource = null;
|
||||
dg.ItemsSource = rows;
|
||||
//根据不的dg 值 可以算出 左/右目视野面积
|
||||
|
||||
|
||||
}
|
||||
|
||||
//private void AddPlcDataRow()
|
||||
//{
|
||||
// AddPlcDataRow(LeftEyeDataList);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//左右目面积调用方法
|
||||
private void AddPlcDataRow(List<dynamic> leftEyeDataList, List<dynamic> RightEyeDataList)
|
||||
{ //左目视野面积
|
||||
{
|
||||
leftEyeDataList = ModbusHelper.RemoveOutliers(leftEyeDataList);
|
||||
RightEyeDataList = ModbusHelper.RemoveOutliers(RightEyeDataList);
|
||||
|
||||
//左目视野面积
|
||||
GlobalData.LeftEyeArea = ModbusHelper.CalculateEyeArea(leftEyeDataList,
|
||||
80,
|
||||
120
|
||||
@@ -250,6 +254,11 @@ namespace 头罩视野.Views
|
||||
|
||||
}
|
||||
|
||||
private List<dynamic> RemoveOutliers(List<dynamic> leftEyeDataList)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private double CalcLowerAngle(double[] leftAvg, int v)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -291,7 +300,6 @@ namespace 头罩视野.Views
|
||||
{
|
||||
LeftEyeDataList.Clear();
|
||||
dataGrid1.Items.Clear();
|
||||
|
||||
RightEyeDataList.Clear();
|
||||
dataGrid2.Items.Clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user