页面逻辑和代码调整。
This commit is contained in:
@@ -109,108 +109,6 @@ namespace 头罩视野.Views
|
||||
System.Diagnostics.Debug.WriteLine($"灯条数据:{_lightPositions.Count}");
|
||||
}
|
||||
|
||||
// 蓝色亮(蓝色)
|
||||
private void LedOn(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightSkyBlue;
|
||||
}
|
||||
|
||||
// 灯灭(灰色)
|
||||
private void LedOff(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightGray;
|
||||
}
|
||||
|
||||
//复位btn
|
||||
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 90);
|
||||
}
|
||||
//左开眼
|
||||
private void Button_Click_left(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换文案:开是关,关是开
|
||||
if (btnLeft.Content.ToString() == "左眼开")
|
||||
{
|
||||
|
||||
|
||||
btnLeft.Content = "左眼关";
|
||||
LedOn(led0);
|
||||
if (btnRight.Content.ToString() == "右眼关")
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
//LedOn(led0);
|
||||
}
|
||||
//右开眼
|
||||
private void Button_Click_Right(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
// 切换文案:左眼开 ↔ 左眼关
|
||||
if (btnRight.Content.ToString() == "右眼开")
|
||||
{
|
||||
btnRight.Content = "右眼关";
|
||||
LedOn(led1);
|
||||
if (btnLeft.Content.ToString() == "左眼关")
|
||||
{
|
||||
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
//LedOn(led1);
|
||||
}
|
||||
|
||||
//反转
|
||||
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 10, true);
|
||||
System.Diagnostics.Debug.WriteLine("反转开始");
|
||||
}
|
||||
|
||||
private async void Button_Click_ResUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 10, false);
|
||||
System.Diagnostics.Debug.WriteLine("反转结束");
|
||||
|
||||
}
|
||||
//正转
|
||||
|
||||
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 11, true);
|
||||
}
|
||||
|
||||
private async void Button_Click_ForUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 11, false);
|
||||
//System.Diagnostics.Debug.WriteLine("正传end");
|
||||
}
|
||||
|
||||
//停止btn
|
||||
private void Button_Click_Stop(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -291,8 +189,6 @@ namespace 头罩视野.Views
|
||||
testTimer.Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//页面渲染值
|
||||
|
||||
public void UpdateVisionResults(double BotViAn)
|
||||
@@ -317,6 +213,8 @@ namespace 头罩视野.Views
|
||||
double binocularRate = GetArea.CalcVisionRate(totalAreaForRate);
|
||||
sybhl.Text = binocularRate.ToString("0.00"); // 视野保存率
|
||||
}
|
||||
//上面有值之后更新一下 共享数据
|
||||
ShowAreaData();
|
||||
}
|
||||
|
||||
//读取灯泡的数据
|
||||
@@ -431,29 +329,41 @@ namespace 头罩视野.Views
|
||||
xfsyarea.Text = maxBottomViewAngle.ToString("0.0");
|
||||
});
|
||||
}
|
||||
//打印
|
||||
|
||||
private void Button_Click_Print(object sender, RoutedEventArgs e)
|
||||
//数据共享
|
||||
private async void ShowAreaData()
|
||||
|
||||
{
|
||||
// 组装当前数据
|
||||
var data = new TestDataStore.TestRecord
|
||||
{
|
||||
Date = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
Time = DateTime.Now.ToString("HH:mm:ss"),
|
||||
LeftEyeArea = double.TryParse(zmsyarea.Text, out var l) ? l : 0,
|
||||
RightEyeArea = double.TryParse(ymsyarea.Text, out var r) ? r : 0,
|
||||
BinocularArea = double.TryParse(smsyarea.Text, out var b) ? b : 0,
|
||||
LowerVision = double.TryParse(xfsyarea.Text, out var lv) ? lv : 0,
|
||||
VisionRetentionRate = double.TryParse(sybhl.Text, out var vr) ? vr : 0
|
||||
};
|
||||
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
||||
|
||||
// ==================== 去重判断 ====================
|
||||
if (_lastRecord != null &&
|
||||
data.LeftEyeArea == _lastRecord.LeftEyeArea &&
|
||||
data.RightEyeArea == _lastRecord.RightEyeArea &&
|
||||
data.BinocularArea == _lastRecord.BinocularArea &&
|
||||
data.LowerVision == _lastRecord.LowerVision &&
|
||||
data.VisionRetentionRate == _lastRecord.VisionRetentionRate)
|
||||
{
|
||||
return; // 一样就不添加
|
||||
}
|
||||
//原来存的数据清空 切换页面会清空
|
||||
//TestDataStore.Records.Clear();
|
||||
// 不一样 → 插入表格
|
||||
TestDataStore.AddNewRecord(data);
|
||||
_lastRecord = data;
|
||||
}
|
||||
//试样测试
|
||||
|
||||
|
||||
private async void TbTest_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 选中 → 试样测试
|
||||
|
||||
|
||||
tbTest.Content = "空白测试";
|
||||
|
||||
tbTest.Background = System.Windows.Media.Brushes.LightSkyBlue;
|
||||
System.Diagnostics.Debug.WriteLine($"1232312312");
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 41, true);
|
||||
}
|
||||
|
||||
private async void TbTest_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 取消 → 空白测试
|
||||
@@ -599,6 +509,130 @@ namespace 头罩视野.Views
|
||||
}
|
||||
}
|
||||
|
||||
//打印
|
||||
|
||||
private void Button_Click_Print(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
||||
|
||||
}
|
||||
//试样测试
|
||||
|
||||
|
||||
private async void TbTest_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 选中 → 试样测试
|
||||
|
||||
|
||||
tbTest.Content = "空白测试";
|
||||
|
||||
tbTest.Background = System.Windows.Media.Brushes.LightSkyBlue;
|
||||
System.Diagnostics.Debug.WriteLine($"1232312312");
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 41, true);
|
||||
}
|
||||
|
||||
// 蓝色亮(蓝色)
|
||||
private void LedOn(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightSkyBlue;
|
||||
}
|
||||
|
||||
// 灯灭(灰色)
|
||||
private void LedOff(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightGray;
|
||||
}
|
||||
|
||||
//复位btn
|
||||
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 90);
|
||||
}
|
||||
//左开眼
|
||||
private void Button_Click_left(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换文案:开是关,关是开
|
||||
if (btnLeft.Content.ToString() == "左眼开")
|
||||
{
|
||||
|
||||
|
||||
btnLeft.Content = "左眼关";
|
||||
LedOn(led0);
|
||||
if (btnRight.Content.ToString() == "右眼关")
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
//LedOn(led0);
|
||||
}
|
||||
//右开眼
|
||||
private void Button_Click_Right(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
// 切换文案:左眼开 ↔ 左眼关
|
||||
if (btnRight.Content.ToString() == "右眼开")
|
||||
{
|
||||
btnRight.Content = "右眼关";
|
||||
LedOn(led1);
|
||||
if (btnLeft.Content.ToString() == "左眼关")
|
||||
{
|
||||
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
//LedOn(led1);
|
||||
}
|
||||
|
||||
//反转
|
||||
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 10, true);
|
||||
System.Diagnostics.Debug.WriteLine("反转开始");
|
||||
}
|
||||
|
||||
private async void Button_Click_ResUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 10, false);
|
||||
System.Diagnostics.Debug.WriteLine("反转结束");
|
||||
|
||||
}
|
||||
//正转
|
||||
|
||||
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 11, true);
|
||||
}
|
||||
|
||||
private async void Button_Click_ForUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 11, false);
|
||||
//System.Diagnostics.Debug.WriteLine("正传end");
|
||||
}
|
||||
|
||||
//写入
|
||||
private void fbspeed_GotFocus(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user