test
This commit is contained in:
@@ -165,7 +165,8 @@ namespace 头罩视野.Services
|
||||
{
|
||||
int n = points.Count;
|
||||
if (n < 5)
|
||||
throw new Exception("至少需要5个点来拟合椭圆");
|
||||
//throw new Exception("至少需要5个点来拟合椭圆");
|
||||
return new (0,0,0,0,0) ;
|
||||
|
||||
// 这里是正确写法
|
||||
var M = MathNetMatrix.Build.Dense(n, 5);
|
||||
|
||||
@@ -38,10 +38,15 @@ namespace 头罩视野.Views
|
||||
// 保存上一条数据(用于去重)
|
||||
private TestDataStore.TestRecord? _lastRecord;
|
||||
|
||||
#region 当前角度
|
||||
private double currentAngle;
|
||||
#endregion
|
||||
|
||||
|
||||
private double _leftTotalArea = 0; // 左目总视野面积
|
||||
private double _rightTotalArea = 0; // 右目总视野面积
|
||||
private double _binocularTotalArea = 0; // 双目总视野面积
|
||||
double maxBottomViewAngle = 0; //记录所有姿态里的最大下方视野
|
||||
|
||||
// 表跟数据存储列表
|
||||
public List<dynamic> DataList = new List<dynamic>();
|
||||
@@ -210,6 +215,8 @@ namespace 头罩视野.Views
|
||||
private async void Button_Click_Test(object sender, RoutedEventArgs e)
|
||||
|
||||
{
|
||||
|
||||
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 100);
|
||||
ButtonTest.Content = "测试中....";
|
||||
testTimer.Start();
|
||||
@@ -234,7 +241,8 @@ namespace 头罩视野.Views
|
||||
bool isRightOnly = btnRight.Content.ToString() == "右眼开" && btnLeft.Content.ToString() == "左眼关";
|
||||
bool isBinocular = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼开";
|
||||
if (isLeftOnly)
|
||||
{ _leftTotalArea = 0;
|
||||
{
|
||||
_leftTotalArea = 0;
|
||||
}
|
||||
else if (isRightOnly)
|
||||
{
|
||||
@@ -246,7 +254,7 @@ namespace 头罩视野.Views
|
||||
_binocularTotalArea = 0;
|
||||
|
||||
}
|
||||
double maxBottomViewAngle = 0; ;//记录所有姿态里的最大下方视野
|
||||
|
||||
// 2. 从0转到180,每 stepAngle 执行一次
|
||||
for (double current = stepAngle; current <= 180; current += stepAngle)
|
||||
{
|
||||
@@ -283,22 +291,18 @@ namespace 头罩视野.Views
|
||||
{
|
||||
maxBottomViewAngle = bottomViewAngle;
|
||||
}
|
||||
|
||||
// 如果你要取最小值,用下面这段
|
||||
// if (bottomViewAngle < minBottomViewAngle && bottomViewAngle > 0)
|
||||
// {
|
||||
// minBottomViewAngle = bottomViewAngle;
|
||||
// }
|
||||
}
|
||||
isFinished = _modbusMaster.ReadCoils(1, 102, 1)[0];
|
||||
if (isFinished)
|
||||
{
|
||||
Button_Click_Stop(null, null);
|
||||
UpdateVisionResults( maxBottomViewAngle);
|
||||
}
|
||||
|
||||
}
|
||||
//页面渲染值
|
||||
|
||||
public void UpdateVisionResults( double BotViAn)
|
||||
public void UpdateVisionResults(double BotViAn)
|
||||
{
|
||||
zmsyarea.Text = _leftTotalArea.ToString("0.00"); // 左目
|
||||
ymsyarea.Text = _rightTotalArea.ToString("0.00"); // 右目
|
||||
@@ -360,7 +364,7 @@ namespace 头罩视野.Views
|
||||
private async void Timer_Tick(object sender, EventArgs e)
|
||||
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("定时器触发了!" + DateTime.Now);
|
||||
//System.Diagnostics.Debug.WriteLine("定时器触发了!" + DateTime.Now);
|
||||
// 调用你原来的读取方
|
||||
//await ReadAddr262DataAsync();
|
||||
|
||||
@@ -473,6 +477,16 @@ namespace 头罩视野.Views
|
||||
|
||||
|
||||
};
|
||||
isFinished = _modbusMaster.ReadCoils(1, 102, 1)[0];
|
||||
if (isFinished)
|
||||
{
|
||||
Button_Click_Stop(null, null);
|
||||
UpdateVisionResults(maxBottomViewAngle);
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 102, false);
|
||||
isFinished = false;
|
||||
System.Diagnostics.Debug.WriteLine("start11111");
|
||||
|
||||
}
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
@@ -529,7 +543,7 @@ namespace 头罩视野.Views
|
||||
//float value4 = c.UshortToFloat(registers[7], registers[6]);
|
||||
//float value5 = c.UshortToFloat(registers[9], registers[8]);
|
||||
//float value6 = c.UshortToFloat(registers[11], registers[10]);
|
||||
|
||||
currentAngle = value2;
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user