Skip to content

Commit

Permalink
修改opcua客户端驱动,优化前端
Browse files Browse the repository at this point in the history
  • Loading branch information
iioter committed Dec 26, 2021
1 parent 5232d88 commit 60185bb
Show file tree
Hide file tree
Showing 25 changed files with 2,547 additions and 153 deletions.
Binary file modified .vs/IoTGateway/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/IoTGateway/v16/.suo
Binary file not shown.
35 changes: 0 additions & 35 deletions Dockerfile-win

This file was deleted.

6 changes: 3 additions & 3 deletions IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
}, 1500);
//状态
$('#id' + objmsg.VarId + '_StatusType').text(objmsg.StatusType);
$('#id' + objmsg.VarId + '_StatusType').addClass('animated bounceIn');
$('#id' + objmsg.VarId + '_State').text(objmsg.StatusType);
$('#id' + objmsg.VarId + '_State').addClass('animated bounceIn');
setTimeout(function(){
$('#id' + objmsg.VarId + '_StatusType').removeClass('bounceIn');
$('#id' + objmsg.VarId + '_State').removeClass('bounceIn');
}, 1500);
})
}
Expand Down
Binary file modified IoTGateway/iotgateway.db
Binary file not shown.
2 changes: 0 additions & 2 deletions Plugins/Drivers/DriverOPCUaClient/DriverOPCUaClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.4.367.75" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.4.367.75" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Core" Version="1.4.367.75" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 8 additions & 21 deletions Plugins/Drivers/DriverOPCUaClient/OPCUaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Opc.Ua.Configuration;
using OpcUaHelper;

namespace DriverOPCUaClient
{
[DriverSupported("OPC UA")]
[DriverInfoAttribute("OPCUaClient", "V1.0.0", "Copyright WHD© 2021-12-19")]
public class OPCUaClient : IDriver
{
Session session = null;
ApplicationConfiguration config = null;
ConfiguredEndpoint endpoint = null;
OpcUaClientHelper opcUaClient = null;
#region 配置参数

[ConfigParameter("设备Id")]
Expand All @@ -37,18 +36,7 @@ public OPCUaClient(Guid deviceId)
{
DeviceId = deviceId;

ApplicationInstance application = new ApplicationInstance
{
ApplicationName = "ConsoleReferenceClient",
ApplicationType = ApplicationType.Client,
ConfigSectionName = "Quickstarts.ReferenceClient",
CertificatePasswordProvider = new CertificatePasswordProvider(null)
};
config = application.LoadApplicationConfiguration(silent: false).Result;

EndpointDescription endpointDescription = CoreClientUtils.SelectEndpoint(application.ApplicationConfiguration, Uri, false);
EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(application.ApplicationConfiguration);
endpoint = new ConfiguredEndpoint(null, endpointDescription, endpointConfiguration);
opcUaClient = new OpcUaClientHelper();
}


Expand All @@ -57,15 +45,15 @@ public bool IsConnected
get
{

return session != null && session.Connected;
return opcUaClient != null && opcUaClient.Connected;
}
}

public bool Connect()
{
try
{
session = Session.Create(config, endpoint, false, false, config.ApplicationName, 30 * 60 * 1000, new UserIdentity(), null).Result;
opcUaClient.ConnectServer(Uri).Wait((int)Timeout);
}
catch (Exception)
{
Expand All @@ -78,7 +66,7 @@ public bool Close()
{
try
{
session?.Close();
opcUaClient?.Disconnect();
return !IsConnected;
}
catch (Exception)
Expand All @@ -92,8 +80,7 @@ public void Dispose()
{
try
{
session?.Dispose();
session = null;
opcUaClient = null;
}
catch (Exception)
{
Expand All @@ -111,7 +98,7 @@ public DriverReturnValueModel ReadNode(DriverAddressIoArgModel ioarg)
{
try
{
var dataValue = session.ReadValue(new NodeId(ioarg.Address));
var dataValue = opcUaClient.ReadNode(new NodeId(ioarg.Address));
if (DataValue.IsGood(dataValue))
ret.Value = dataValue.Value;
}
Expand Down
Loading

0 comments on commit 60185bb

Please sign in to comment.