This commit is contained in:
2026-05-12 16:12:31 +08:00
parent ca7658e52e
commit f099f348cc

View File

@@ -36,7 +36,7 @@ namespace 头罩视野.Views
//// 定时采集用
private DispatcherTimer testTimer;
private DispatcherTimer testTimerForLight;
//private DispatcherTimer testTimerForLight;
// 保存上一条数据(用于去重)
private TestDataStore.TestRecord? _lastRecord;
@@ -69,9 +69,9 @@ namespace 头罩视野.Views
testTimer.Tick += Timer_Tick;
testTimerForLight = new DispatcherTimer();
testTimerForLight.Interval = TimeSpan.FromMilliseconds(1000); // 500ms = 0.5秒
testTimerForLight.Tick += testTimerForLightTick;
//testTimerForLight = new DispatcherTimer();
//testTimerForLight.Interval = TimeSpan.FromMilliseconds(1000); // 500ms = 0.5秒
//testTimerForLight.Tick += testTimerForLightTick;
//// 判断连接
if (!ModbusHelper.IsConnected)
@@ -334,27 +334,32 @@ namespace 头罩视野.Views
}
}
}
private async void testTimerForLightTick(object sender, EventArgs e)
{
if (_modbusMaster == null)
return;
ma.BtnClickFunction(Function.ButtonType., 1);
//private async void testTimerForLightTick(object sender, EventArgs e)
//{
// if (_modbusMaster == null)
// return;
// await _modbusMaster.ReadCoilsAsync(1, 1, 1);
var ret = await _modbusMaster.ReadCoilsAsync(1, 1, 1);
if (ret != null && ret.Length > 0)
{
if (ret[0])
{
LedOn(led0);
LedOff(led1);
}
else
{
LedOn(led1);
LedOff(led0);
}
}
}
// var ret = await _modbusMaster.ReadCoilsAsync(1, 1, 1);
// if (ret != null && ret.Length > 0)
// {
// if (ret[0])
// {
// LedOn(led0);
// LedOff(led1);
// btnLeft.Content = "左眼关";
// btnRight.Content = "右眼开";
// }
// else
// {
// LedOn(led1);
// LedOff(led0);
// btnLeft.Content = "左眼开";
// btnRight.Content = "右眼关";
// }
// }
//}
//计算
private async Task calCurrentangle()
{
@@ -802,7 +807,7 @@ namespace 头罩视野.Views
_timer.Start();
ma = new Function(_modbusMaster);
c = new DataChange();
testTimerForLight.Start();
//testTimerForLight.Start();
//zmsyarea.Text = "4.00"; // 左目
//smsyarea.Text = "5.00"; // 双目
//kbsyarea.Text = "6.00"; // 空白