页面测试
This commit is contained in:
@@ -37,7 +37,12 @@ namespace 头罩视野.Views
|
|||||||
private DispatcherTimer testTimer;
|
private DispatcherTimer testTimer;
|
||||||
// 保存上一条数据(用于去重)
|
// 保存上一条数据(用于去重)
|
||||||
private TestDataStore.TestRecord? _lastRecord;
|
private TestDataStore.TestRecord? _lastRecord;
|
||||||
private object btnLeftEye;
|
|
||||||
|
|
||||||
|
private double _leftTotalArea = 0; // 左目总视野面积
|
||||||
|
private double _rightTotalArea = 0; // 右目总视野面积
|
||||||
|
private double _binocularTotalArea = 0; // 双目总视野面积
|
||||||
|
|
||||||
// 表跟数据存储列表
|
// 表跟数据存储列表
|
||||||
public List<dynamic> DataList = new List<dynamic>();
|
public List<dynamic> DataList = new List<dynamic>();
|
||||||
|
|
||||||
@@ -220,20 +225,49 @@ namespace 头罩视野.Views
|
|||||||
|
|
||||||
// 1. 读取输入框
|
// 1. 读取输入框
|
||||||
double stepAngle = double.Parse(fbspeed.Text); // 分辨角度 例:10
|
double stepAngle = double.Parse(fbspeed.Text); // 分辨角度 例:10
|
||||||
|
|
||||||
//double speed = double.Parse(zdangle.Text); // 转动速度
|
bool isLeftOnly = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼关";
|
||||||
int[] lightData = DataList.Cast<int>().ToArray(); // 1. 把DataList(List<dynamic>)转成方法需要的int[]
|
bool isRightOnly = btnRight.Content.ToString() == "右眼开" && btnLeft.Content.ToString() == "左眼关";
|
||||||
// 1. 定义总和变量,初始为0
|
bool isBinocular = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼开";
|
||||||
double totalArea = 0;//总面积
|
if (isLeftOnly)
|
||||||
double maxBottomViewAngle = 0; ;//记录所有姿态里的最大下方视野
|
{ _leftTotalArea = 0;
|
||||||
|
}
|
||||||
|
else if (isRightOnly)
|
||||||
|
{
|
||||||
|
_rightTotalArea = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBinocular)
|
||||||
|
{
|
||||||
|
_binocularTotalArea = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
double maxBottomViewAngle = 0; ;//记录所有姿态里的最大下方视野
|
||||||
// 2. 从0转到180,每 stepAngle 执行一次
|
// 2. 从0转到180,每 stepAngle 执行一次
|
||||||
for (double current = stepAngle; current <= 180; current += stepAngle)
|
for (double current = stepAngle; current <= 180; current += stepAngle)
|
||||||
{
|
{
|
||||||
|
int[] lightData = DataList.Cast<int>().ToArray();
|
||||||
_ = ReadLightBarData();
|
_ = ReadLightBarData();
|
||||||
|
|
||||||
//开始计算视野面积
|
//开始计算视野面积
|
||||||
double area = GetArea.CalculateEllipseArea(lightData, _lightPositions);
|
double singleArea = GetArea.CalculateEllipseArea(lightData, _lightPositions);
|
||||||
totalArea += area;
|
|
||||||
|
if (isLeftOnly)
|
||||||
|
{
|
||||||
|
_leftTotalArea += singleArea;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isRightOnly)
|
||||||
|
{
|
||||||
|
_rightTotalArea += singleArea;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBinocular)
|
||||||
|
{
|
||||||
|
_binocularTotalArea += singleArea;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 单次计算下方视野角度
|
// 单次计算下方视野角度
|
||||||
double bottomViewAngle = GetArea.CalculateBottomViewAngle(lightData, _lightPositions);
|
double bottomViewAngle = GetArea.CalculateBottomViewAngle(lightData, _lightPositions);
|
||||||
|
|
||||||
@@ -252,26 +286,16 @@ namespace 头罩视野.Views
|
|||||||
if (isFinished)
|
if (isFinished)
|
||||||
{
|
{
|
||||||
Button_Click_Stop(null, null);
|
Button_Click_Stop(null, null);
|
||||||
UpdateVisionResults(totalArea, maxBottomViewAngle);
|
UpdateVisionResults( maxBottomViewAngle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//页面渲染值
|
//页面渲染值
|
||||||
|
|
||||||
public void UpdateVisionResults(double area, double BotViAn)
|
public void UpdateVisionResults( double BotViAn)
|
||||||
{
|
{
|
||||||
// 2. 根据按钮状态,把当前面积更新到对应的文本框
|
zmsyarea.Text = _leftTotalArea.ToString("0.00"); // 左目
|
||||||
if (btnRight.Content.ToString() == "右眼开" && btnLeft.Content.ToString() == "左眼关")
|
ymsyarea.Text = _rightTotalArea.ToString("0.00"); // 右目
|
||||||
{
|
smsyarea.Text = _binocularTotalArea.ToString("0.00"); // 双目
|
||||||
zmsyarea.Text = area.ToString("0.00"); // 左目
|
|
||||||
}
|
|
||||||
else if (btnRight.Content.ToString() == "右眼关" && btnLeft.Content.ToString() == "左眼开")
|
|
||||||
{
|
|
||||||
ymsyarea.Text = area.ToString("0.00"); // 右目
|
|
||||||
}
|
|
||||||
else if (btnRight.Content.ToString() == "右眼关" && btnLeft.Content.ToString() == "左眼关")
|
|
||||||
{
|
|
||||||
smsyarea.Text = area.ToString("0.00"); // 双目
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 计算空白区视野面积(双目时才有效)
|
// 3. 计算空白区视野面积(双目时才有效)
|
||||||
if (double.TryParse(smsyarea.Text, out double binocularTotalArea))
|
if (double.TryParse(smsyarea.Text, out double binocularTotalArea))
|
||||||
|
|||||||
Reference in New Issue
Block a user