优化设备断线判断逻辑
This commit is contained in:
parent
996b96df82
commit
15c33ed8f1
@ -8,16 +8,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>x86</LastUsedPlatform>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ProjectGuid>68abbdf2-1485-4756-9a94-6afa874d69a3</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<SelfContained>false</SelfContained>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -5,6 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>D:\000000-IIoTGateway\00000-iotgateway\IoTGateway\bin\Release\net6.0\publish\</_PublishTargetUrl>
|
||||
<History>True|2022-07-15T14:49:16.0563176Z;True|2022-07-15T22:48:07.3189129+08:00;True|2022-07-15T22:44:35.7670375+08:00;True|2022-07-15T22:40:17.0184184+08:00;True|2022-06-09T15:43:47.6180879+08:00;True|2022-06-09T15:42:06.6021355+08:00;False|2022-06-09T15:41:10.3444145+08:00;False|2022-06-09T15:39:22.0048230+08:00;False|2022-06-09T15:37:35.5049088+08:00;True|2022-06-09T15:34:27.8095097+08:00;True|2022-06-09T15:33:30.9577399+08:00;False|2022-06-09T15:29:58.9432537+08:00;False|2022-06-09T15:29:15.9735490+08:00;True|2022-06-09T15:27:02.3333134+08:00;True|2022-06-09T15:18:02.0623963+08:00;True|2022-01-24T23:31:28.3620602+08:00;True|2022-01-24T23:30:03.8991942+08:00;True|2022-01-24T23:23:16.4288882+08:00;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00;</History>
|
||||
<History>True|2022-08-30T12:02:03.8144013Z;True|2022-08-30T19:59:49.6042620+08:00;True|2022-08-30T19:52:02.8823029+08:00;True|2022-08-30T19:36:54.3646619+08:00;True|2022-07-15T22:49:16.0563176+08:00;True|2022-07-15T22:48:07.3189129+08:00;True|2022-07-15T22:44:35.7670375+08:00;True|2022-07-15T22:40:17.0184184+08:00;True|2022-06-09T15:43:47.6180879+08:00;True|2022-06-09T15:42:06.6021355+08:00;False|2022-06-09T15:41:10.3444145+08:00;False|2022-06-09T15:39:22.0048230+08:00;False|2022-06-09T15:37:35.5049088+08:00;True|2022-06-09T15:34:27.8095097+08:00;True|2022-06-09T15:33:30.9577399+08:00;False|2022-06-09T15:29:58.9432537+08:00;False|2022-06-09T15:29:15.9735490+08:00;True|2022-06-09T15:27:02.3333134+08:00;True|2022-06-09T15:18:02.0623963+08:00;True|2022-01-24T23:31:28.3620602+08:00;True|2022-01-24T23:30:03.8991942+08:00;True|2022-01-24T23:23:16.4288882+08:00;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -25,7 +25,6 @@ namespace Plugin
|
||||
private readonly DateTime _tsStartDt = new(1970, 1, 1);
|
||||
private readonly CancellationTokenSource _tokenSource = new CancellationTokenSource();
|
||||
private readonly object _lock = new();
|
||||
private bool _lastConnected;
|
||||
|
||||
public DeviceThread(Device device, IDriver driver, string projectId, MyMqttClient myMqttClient,
|
||||
MqttServer mqttServer, ILogger logger)
|
||||
@ -139,6 +138,7 @@ namespace Plugin
|
||||
Payload = Encoding.UTF8.GetBytes(
|
||||
JsonConvert.SerializeObject(ret.CookedValue))
|
||||
});
|
||||
mqttServer.InjectApplicationMessage(msg);
|
||||
}
|
||||
|
||||
DeviceValues[item.ID] = ret;
|
||||
@ -170,16 +170,9 @@ namespace Plugin
|
||||
}
|
||||
else
|
||||
{
|
||||
_myMqttClient?.DeviceDisconnected(Device);
|
||||
if (driver.Connect())
|
||||
{
|
||||
_lastConnected = true;
|
||||
_myMqttClient?.DeviceConnected(Device);
|
||||
}
|
||||
else if (_lastConnected)
|
||||
{
|
||||
_lastConnected = false;
|
||||
_myMqttClient?.DeviceDisconnected(Device);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user