页面逻辑调整
This commit is contained in:
@@ -47,6 +47,12 @@ namespace 头罩视野.Views
|
||||
private double _binocularTotalArea = 0; // 双目总视野面积
|
||||
double maxBottomViewAngle = 0; //记录所有姿态里的最大下方视野
|
||||
|
||||
|
||||
// 最终左眼视野(永远243个)
|
||||
private List<int> _leftFinalData = new List<int>();
|
||||
// 最终右眼视野(永远243个)
|
||||
private List<int> _rightFinalData = new List<int>();
|
||||
|
||||
// 表跟数据存储列表
|
||||
public List<dynamic> DataList = new List<dynamic>();
|
||||
|
||||
@@ -54,7 +60,6 @@ namespace 头罩视野.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
InitLightPositions();
|
||||
System.Diagnostics.Debug.WriteLine("页面加载了!111111111");
|
||||
_timer = InitDispatcherTimer();
|
||||
// 2. 初始化定时器:500毫秒 执行一次
|
||||
|
||||
@@ -116,32 +121,7 @@ namespace 头罩视野.Views
|
||||
testTimer.Stop();
|
||||
}
|
||||
|
||||
////测试btn 测试按钮:读取数据,存入共享列表
|
||||
//private async void Button_Click_Test(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
|
||||
// ma.BtnClickFunction(Function.ButtonType.复归型, 100);
|
||||
// ButtonTest.Content = "测试中....";
|
||||
// _isTesting = true;
|
||||
// testTimer.Start();
|
||||
// bool isLeftOnly = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼关";
|
||||
// bool isRightOnly = btnRight.Content.ToString() == "右眼开" && btnLeft.Content.ToString() == "左眼关";
|
||||
// bool isBinocular = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼开";
|
||||
// if (isLeftOnly)
|
||||
// {
|
||||
// _leftTotalArea = 0;
|
||||
// }
|
||||
// else if (isRightOnly)
|
||||
// {
|
||||
// _rightTotalArea = 0;
|
||||
|
||||
// }
|
||||
// else if (isBinocular)
|
||||
// {
|
||||
// _binocularTotalArea = 0;
|
||||
|
||||
// }
|
||||
//}
|
||||
private async void Button_Click_Test(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_isTesting)
|
||||
@@ -171,11 +151,17 @@ namespace 头罩视野.Views
|
||||
//_binocularTotalArea = 0;
|
||||
//maxBottomViewAngle = 0;
|
||||
|
||||
// 初始化:全部设为0(灭)
|
||||
_leftFinalData = Enumerable.Repeat(0, 243).ToList();
|
||||
_rightFinalData = Enumerable.Repeat(0, 243).ToList();
|
||||
|
||||
// 面积也清空
|
||||
|
||||
|
||||
isLeftOnly = btnLeft.Content.ToString() == "左眼关" && btnRight.Content.ToString() == "右眼开";
|
||||
isRightOnly = btnLeft.Content.ToString() == "左眼开" && btnRight.Content.ToString() == "右眼关";
|
||||
isBinocular = btnLeft.Content.ToString() == "左眼关" && btnRight.Content.ToString() == "右眼关";
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("start11111");
|
||||
await calCurrentangle();
|
||||
|
||||
_nextTargetAngle = _stepAngle;
|
||||
@@ -192,19 +178,13 @@ namespace 头罩视野.Views
|
||||
{
|
||||
zmsyarea.Text = _leftTotalArea.ToString("0"); // 左目
|
||||
ymsyarea.Text = _rightTotalArea.ToString("0"); // 右目
|
||||
smsyarea.Text = _binocularTotalArea.ToString("0"); // 双目
|
||||
|
||||
// 3. 计算空白区视野面积(双目时才有效)
|
||||
//if (double.TryParse(smsyarea.Text, out double binocularTotalArea))
|
||||
//{
|
||||
// double blankArea = GetArea.GetBlankViewArea(binocularTotalArea);
|
||||
// kbsyarea.Text = blankArea.ToString("0.00"); // 空白视野面积
|
||||
//}
|
||||
//// 4. 计算下方视野面积
|
||||
|
||||
// 计算下方视野°
|
||||
int botViAnInt = (int)Math.Round(BotViAn);
|
||||
xfsyarea.Text = botViAnInt.ToString("0"); // 下方视野
|
||||
|
||||
// 5. 计算视野保存率(双目)根据左右目视野不同算不同的值
|
||||
// 计算视野保存率(双目)根据左右目视野不同,算不同的值
|
||||
|
||||
if (isLeftOnly)
|
||||
{
|
||||
@@ -222,15 +202,17 @@ namespace 头罩视野.Views
|
||||
double blankArea = GetArea.GetBlankViewArea(_rightTotalArea);
|
||||
kbsyarea.Text = blankArea.ToString("0"); // 空白视野面积
|
||||
}
|
||||
|
||||
else if (isBinocular)
|
||||
if (_leftFinalData != null && _leftFinalData.Count > 0 &&_rightFinalData != null && _rightFinalData.Count > 0)
|
||||
{
|
||||
// ✅ 传值调用:把左右眼最终数据传给方法
|
||||
_binocularTotalArea = GetArea.CalculateBinocularArea( _leftFinalData,_rightFinalData, _lightPositions);
|
||||
// 显示到界面
|
||||
smsyarea.Text = _binocularTotalArea.ToString("0.00");
|
||||
|
||||
// 视野保存率(如果需要)
|
||||
double binocularRateD = GetArea.CalcVisionRate(_binocularTotalArea);
|
||||
sybhl.Text = binocularRateD.ToString("0"); // 视野保存率
|
||||
double blankArea = GetArea.GetBlankViewArea(_binocularTotalArea);
|
||||
kbsyarea.Text = blankArea.ToString("0"); // 空白视野面积
|
||||
sybhl.Text = binocularRateD.ToString("0.0"); // 视野保存率
|
||||
}
|
||||
|
||||
|
||||
//if (double.TryParse(smsyarea.Text, out double totalAreaForRate))
|
||||
//{
|
||||
@@ -241,6 +223,7 @@ namespace 头罩视野.Views
|
||||
ShowAreaData();
|
||||
}
|
||||
|
||||
|
||||
//读取灯泡的数据
|
||||
|
||||
private async Task ReadLightBarData()
|
||||
@@ -335,11 +318,28 @@ namespace 头罩视野.Views
|
||||
|
||||
// 5. 根据当前测试模式(左眼/右眼/双目),累加面积
|
||||
if (isLeftOnly)
|
||||
{
|
||||
_leftTotalArea += singleArea;
|
||||
// 实时合并左眼:只要亮过一次,就永久亮
|
||||
for (int i = 0; i < 243; i++)
|
||||
{
|
||||
if (lightData[i] == 1)
|
||||
_leftFinalData[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (isRightOnly)
|
||||
{
|
||||
_rightTotalArea += singleArea;
|
||||
else if (isBinocular)
|
||||
_binocularTotalArea += singleArea;
|
||||
// 实时合并右眼
|
||||
for (int i = 0; i < 243; i++)
|
||||
{
|
||||
if (lightData[i] == 1)
|
||||
_rightFinalData[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 6. 更新下方视野的最大值(取所有角度中最大的)
|
||||
if (bottomViewAngle > maxBottomViewAngle)
|
||||
@@ -698,11 +698,10 @@ namespace 头罩视野.Views
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("页面加载了!112222222");
|
||||
|
||||
_timer.Start();
|
||||
ma = new Function(_modbusMaster);
|
||||
c = new DataChange();
|
||||
|
||||
//zmsyarea.Text = "4.00"; // 左目
|
||||
//smsyarea.Text = "5.00"; // 双目
|
||||
//kbsyarea.Text = "6.00"; // 空白
|
||||
|
||||
Reference in New Issue
Block a user