判断OPCUAServer状态时增加tryCatch

This commit is contained in:
2248356998 qq.com
2023-05-19 21:27:20 +08:00
parent ee70133e47
commit 60f5702f17
2 changed files with 8 additions and 2 deletions

View File

@@ -409,13 +409,17 @@ public class CollectDeviceCore : DisposableObject
}
else if (deviceMedsVariableFailedNum != 0 || deviceSourceVariableFailedNum != 0)
{
if (_driver.IsConnected().IsSuccess)
var oper = _driver.IsConnected();
if (oper.IsSuccess)
{
Device.DeviceStatus = DeviceStatusEnum.OnLineButNoInitialValue;
}
else
{
Device.DeviceStatus = DeviceStatusEnum.OffLine;
Device.DeviceOffMsg = oper.Message;
}
}
else

View File

@@ -284,13 +284,15 @@ public class UploadDeviceCore : DisposableObject
if (StoppingToken.IsCancellationRequested)
return ThreadRunReturn.Break;
if (_driver.IsConnected().IsSuccess)
var oper = _driver.IsConnected();
if (oper.IsSuccess)
{
Device.DeviceStatus = DeviceStatusEnum.OnLine;
}
else
{
Device.DeviceStatus = (Device.DeviceStatus == DeviceStatusEnum.OnLine || Device.DeviceStatus == DeviceStatusEnum.OnLineButNoInitialValue) ? DeviceStatusEnum.OffLine : Device.DeviceStatus;
Device.DeviceOffMsg = oper.Message;
}
return ThreadRunReturn.None;