This commit is contained in:
xyy
2026-05-12 15:57:45 +08:00
parent 91f01ecb89
commit 1608469812

View File

@@ -35,6 +35,8 @@ namespace 头罩视野.Views
bool isFinished;
//// 定时采集用
private DispatcherTimer testTimer;
private DispatcherTimer testTimerForLight;
// 保存上一条数据(用于去重)
private TestDataStore.TestRecord? _lastRecord;
@@ -66,6 +68,11 @@ namespace 头罩视野.Views
testTimer.Interval = TimeSpan.FromMilliseconds(500); // 500ms = 0.5秒
testTimer.Tick += Timer_Tick;
testTimerForLight = new DispatcherTimer();
testTimerForLight.Interval = TimeSpan.FromMilliseconds(1000); // 500ms = 0.5秒
testTimerForLight.Tick += testTimerForLight;
//// 判断连接
if (!ModbusHelper.IsConnected)
{
@@ -327,7 +334,27 @@ namespace 头罩视野.Views
}
}
}
private async void testTimerForLightTick(object sender, EventArgs e)
{
if (_modbusMaster == null)
return;
ma.BtnClickFunction(Function.ButtonType., 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);
}
}
}
//计算
private async Task calCurrentangle()
{