修改opcua客户端驱动,优化前端

This commit is contained in:
王海东 2021-12-26 14:48:28 +08:00
parent 5232d884ba
commit 60185bb34c
25 changed files with 2547 additions and 153 deletions

Binary file not shown.

View File

@ -1,35 +0,0 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 518
EXPOSE 1888
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["IoTGateway/IoTGateway.csproj", "IoTGateway/"]
COPY ["IoTGateway.ViewModel/IoTGateway.ViewModel.csproj", "IoTGateway.ViewModel/"]
COPY ["Plugins/Plugin/Plugin.csproj", "Plugins/Plugin/"]
COPY ["IoTGateway.Model/IoTGateway.Model.csproj", "IoTGateway.Model/"]
COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.Core/"]
COPY ["Plugins/PluginInterface/PluginInterface.csproj", "Plugins/PluginInterface/"]
COPY ["IoTGateway.DataAccess/IoTGateway.DataAccess.csproj", "IoTGateway.DataAccess/"]
COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/WalkingTec.Mvvm.TagHelpers.LayUI.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/"]
COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/"]
RUN dotnet restore "IoTGateway/IoTGateway.csproj"
COPY . .
WORKDIR "/src/IoTGateway"
RUN dotnet build "IoTGateway.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "IoTGateway.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV TZ=Asia/Shanghai
ENTRYPOINT ["dotnet", "IoTGateway.dll"]

View File

@ -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);
})
}

Binary file not shown.

View File

@ -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>

View File

@ -7,6 +7,7 @@ using Opc.Ua.Client;
using System.Collections.Generic;
using System.Threading.Tasks;
using Opc.Ua.Configuration;
using OpcUaHelper;
namespace DriverOPCUaClient
{
@ -14,9 +15,7 @@ namespace DriverOPCUaClient
[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")]
@ -37,18 +36,7 @@ namespace DriverOPCUaClient
{
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();
}
@ -57,7 +45,7 @@ namespace DriverOPCUaClient
get
{
return session != null && session.Connected;
return opcUaClient != null && opcUaClient.Connected;
}
}
@ -65,7 +53,7 @@ namespace DriverOPCUaClient
{
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)
{
@ -78,7 +66,7 @@ namespace DriverOPCUaClient
{
try
{
session?.Close();
opcUaClient?.Disconnect();
return !IsConnected;
}
catch (Exception)
@ -92,8 +80,7 @@ namespace DriverOPCUaClient
{
try
{
session?.Dispose();
session = null;
opcUaClient = null;
}
catch (Exception)
{
@ -111,7 +98,7 @@ namespace DriverOPCUaClient
{
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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
using Opc.Ua;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpcUaHelper
{
/// <summary>
/// OPC UA的状态更新消息
/// </summary>
public class OpcUaStatusEventArgs
{
/// <summary>
/// 是否异常
/// </summary>
public bool Error { get; set; }
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 文本
/// </summary>
public string Text { get; set; }
/// <summary>
/// 转化为字符串
/// </summary>
/// <returns></returns>
public override string ToString( )
{
return Error ? "[异常]" : "[正常]" + Time.ToString( " yyyy-MM-dd HH:mm:ss " ) + Text;
}
}
/// <summary>
/// 读取属性过程中用于描述的
/// </summary>
public class OpcNodeAttribute
{
/// <summary>
/// 属性的名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 属性的类型描述
/// </summary>
public string Type { get; set; }
/// <summary>
/// 操作结果状态描述
/// </summary>
public StatusCode StatusCode { get; set; }
/// <summary>
/// 属性的值,如果读取错误,返回文本描述
/// </summary>
public object Value { get; set; }
}
}

View File

@ -1,4 +1,6 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -11,6 +13,7 @@ namespace PluginInterface
public object Value { get; set; }
public object CookedValue { get; set; }
public string Message { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public VaribaleStatusTypeEnum StatusType { get; set; }
public Guid VarId { get; set; }
}

View File

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationConfiguration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ua="http://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd"
>
<ApplicationName>Quickstart Console Reference Client</ApplicationName>
<ApplicationUri>urn:localhost:UA:Quickstarts:ReferenceClient</ApplicationUri>
<ProductUri>uri:opcfoundation.org:Quickstarts:ReferenceClient</ProductUri>
<ApplicationType>Client_1</ApplicationType>
<SecurityConfiguration>
<!-- Where the application instance certificate is stored (MachineDefault) -->
<ApplicationCertificate>
<StoreType>Directory</StoreType>
<StorePath>%LocalApplicationData%/OPC Foundation/pki/own</StorePath>
<SubjectName>CN=Console Reference Client, C=US, S=Arizona, O=OPC Foundation, DC=localhost</SubjectName>
</ApplicationCertificate>
<!-- Where the issuer certificate are stored (certificate authorities) -->
<TrustedIssuerCertificates>
<StoreType>Directory</StoreType>
<StorePath>%LocalApplicationData%/OPC Foundation/pki/issuer</StorePath>
</TrustedIssuerCertificates>
<!-- Where the trust list is stored -->
<TrustedPeerCertificates>
<StoreType>Directory</StoreType>
<StorePath>%LocalApplicationData%/OPC Foundation/pki/trusted</StorePath>
</TrustedPeerCertificates>
<!-- The directory used to store invalid certficates for later review by the administrator. -->
<RejectedCertificateStore>
<StoreType>Directory</StoreType>
<StorePath>%LocalApplicationData%/OPC Foundation/pki/rejected</StorePath>
</RejectedCertificateStore>
<!-- WARNING: The following setting (to automatically accept untrusted certificates) should be used
for easy debugging purposes ONLY and turned off for production deployments! -->
<AutoAcceptUntrustedCertificates>false</AutoAcceptUntrustedCertificates>
</SecurityConfiguration>
<TransportConfigurations></TransportConfigurations>
<TransportQuotas>
<OperationTimeout>600000</OperationTimeout>
<MaxStringLength>1048576</MaxStringLength>
<MaxByteStringLength>1048576</MaxByteStringLength>
<MaxArrayLength>65535</MaxArrayLength>
<MaxMessageSize>4194304</MaxMessageSize>
<MaxBufferSize>65535</MaxBufferSize>
<ChannelLifetime>300000</ChannelLifetime>
<SecurityTokenLifetime>3600000</SecurityTokenLifetime>
</TransportQuotas>
<ClientConfiguration>
<DefaultSessionTimeout>60000</DefaultSessionTimeout>
<WellKnownDiscoveryUrls>
<ua:String>opc.tcp://{0}:4840</ua:String>
<ua:String>http://{0}:52601/UADiscovery</ua:String>
<ua:String>http://{0}/UADiscovery/Default.svc</ua:String>
</WellKnownDiscoveryUrls>
<DiscoveryServers></DiscoveryServers>
<MinSubscriptionLifetime>10000</MinSubscriptionLifetime>
</ClientConfiguration>
<Extensions>
</Extensions>
<TraceConfiguration>
<OutputFilePath>%LocalApplicationData%/OPC Foundation/Logs/Quickstarts.ReferenceClient.log.txt</OutputFilePath>
<DeleteOnLoad>true</DeleteOnLoad>
<!-- Show Only Errors -->
<!-- <TraceMasks>1</TraceMasks> -->
<!-- Show Only Security and Errors -->
<!-- <TraceMasks>513</TraceMasks> -->
<!-- Show Only Security, Errors and Trace -->
<!-- <TraceMasks>515</TraceMasks> -->
<!-- Show Only Security, COM Calls, Errors and Trace -->
<!-- <TraceMasks>771</TraceMasks> -->
<!-- Show Only Security, Service Calls, Errors and Trace -->
<!-- <TraceMasks>523</TraceMasks> -->
<!-- Show Only Security, ServiceResultExceptions, Errors and Trace -->
<!-- <TraceMasks>519</TraceMasks> -->
</TraceConfiguration>
</ApplicationConfiguration>

View File

@ -9,8 +9,6 @@
"DriverOPCUaClient/1.0.0": {
"dependencies": {
"OPCFoundation.NetStandard.Opc.Ua.Client": "1.4.367.75",
"OPCFoundation.NetStandard.Opc.Ua.Configuration": "1.4.367.75",
"OPCFoundation.NetStandard.Opc.Ua.Core": "1.4.367.75",
"PluginInterface": "1.0.0"
},
"runtime": {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.