Compare commits

...

2 Commits

Author SHA1 Message Date
Kimdiego2098
d39aa22b09 优化OPCUAServer,取消注册,提供多url写入 2023-10-20 01:19:05 +08:00
Kimdiego2098
e232a6b6ea 更新赞助名单 2023-10-19 21:15:35 +08:00
60 changed files with 333 additions and 211 deletions

View File

@@ -11,5 +11,4 @@
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes" Version="1.4.372.56" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,39 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using Opc.Ua.Configuration;
namespace ThingsGateway.Plugin.OPCUA;
public partial class OPCUAServer
{
public class ApplicationMessageDlg : IApplicationMessageDlg
{
private string message = string.Empty;
private ILog _log;
public ApplicationMessageDlg(ILog log)
{
_log = log;
}
public override void Message(string text, bool ask)
{
message = text;
}
public override async Task<bool> ShowAsync()
{
_log.Warning(message);
return await Task.FromResult(true);
}
}
}

View File

@@ -0,0 +1,59 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using Microsoft.Extensions.Logging;
namespace ThingsGateway.Plugin.OPCUA;
public partial class OPCUAServer
{
private class OPCUALogger : ILogger
{
private ILog _log;
public OPCUALogger(ILog log)
{
_log = log;
}
/// <summary>
/// Set the log level
/// </summary>
public Microsoft.Extensions.Logging.LogLevel LogLevel { get; set; } = Microsoft.Extensions.Logging.LogLevel.Trace;
/// <inheritdoc/>
public IDisposable BeginScope<TState>(TState state) => default;
/// <inheritdoc/>
public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) => logLevel >= LogLevel;
/// <inheritdoc/>
public void Log<TState>(
Microsoft.Extensions.Logging.LogLevel logLevel,
EventId eventId,
TState state,
Exception exception,
Func<TState, Exception, string> formatter)
{
if (!IsEnabled(logLevel))
{
return;
}
else
{
var message = formatter(state, exception);
_log.Log((Foundation.Core.LogLevel)(byte)logLevel, state, message, exception);
if (logLevel > Microsoft.Extensions.Logging.LogLevel.Information)
{
}
}
}
}
}

View File

@@ -63,7 +63,7 @@ public partial class OPCUAServer : UpLoadBase
public override async Task BeforStartAsync(CancellationToken cancellationToken)
{
// 启动服务器。
await m_application.CheckApplicationInstanceCertificate(true, 0, 1200);
await m_application.CheckApplicationInstanceCertificate(false, 0, 1200);
await m_application.Start(m_server);
}
/// <inheritdoc/>
@@ -90,7 +90,7 @@ public partial class OPCUAServer : UpLoadBase
}
catch (Exception ex)
{
LogMessage.LogWarning(ex);
LogMessage.LogWarning(ex);
}
}
@@ -98,7 +98,7 @@ public partial class OPCUAServer : UpLoadBase
}
catch (Exception ex)
{
LogMessage.LogWarning(ex);
LogMessage.LogWarning(ex);
}
if (driverPropertys.CycleInterval > UploadDeviceThread.CycleInterval + 50)
{
@@ -138,9 +138,13 @@ public partial class OPCUAServer : UpLoadBase
_uploadVariables = null;
CollectVariableRunTimes.Clear();
}
/// <inheritdoc/>
protected override void Init(UploadDeviceRunTime device)
{
ApplicationInstance.MessageDlg = new ApplicationMessageDlg(LogMessage);//默认返回true
//Utils.SetLogger(new OPCUALogger(LogMessage)); //调试用途
m_application = new ApplicationInstance();
m_configuration = GetDefaultConfiguration();
m_configuration.Validate(ApplicationType.Server).GetAwaiter().GetResult();
@@ -169,7 +173,7 @@ public partial class OPCUAServer : UpLoadBase
private ApplicationConfiguration GetDefaultConfiguration()
{
ApplicationConfiguration config = new();
string url = driverPropertys.OpcUaStringUrl;
var urls = driverPropertys.OpcUaStringUrl.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
// 签名及加密验证
ServerSecurityPolicyCollection policies = new();
var userTokens = new UserTokenPolicyCollection();
@@ -242,13 +246,14 @@ public partial class OPCUAServer : UpLoadBase
config.ApplicationName = "ThingsGateway OPCUAServer";
config.ApplicationType = ApplicationType.Server;
config.ApplicationUri = Utils.Format(@"urn:{0}:thingsgatewayopcuaserver", System.Net.Dns.GetHostName());
config.ApplicationUri = driverPropertys.ApplicationUri;
config.ServerConfiguration = new ServerConfiguration()
{
// 配置登录的地址
BaseAddresses = new string[] { url },
BaseAddresses = urls,
SecurityPolicies = policies,
UserTokenPolicies = userTokens,
ShutdownDelay = 1,
@@ -269,7 +274,7 @@ public partial class OPCUAServer : UpLoadBase
MaxNotificationQueueSize = 100, // 为每个被监视项目保存在队列中的最大证书数
MaxNotificationsPerPublish = 1000, // 每次发布的最大通知数
MinMetadataSamplingInterval = 1000, // 元数据的最小采样间隔
MaxRegistrationInterval = 30000, // 两次注册尝试之间的最大时间(以毫秒为单位)
MaxRegistrationInterval = -1, // 两次注册尝试之间的最大时间(以毫秒为单位)//不提供注册
};
config.SecurityConfiguration = new SecurityConfiguration()
@@ -283,7 +288,8 @@ public partial class OPCUAServer : UpLoadBase
{
StoreType = CertificateStoreType.X509Store,
StorePath = "CurrentUser\\UAServer_ThingsGateway",
SubjectName = "CN=ThingsGateway OPCUAServer, C=CN, S=GUANGZHOU, O=ThingsGateway, DC=" + System.Net.Dns.GetHostName(),
SubjectName = driverPropertys.SubjectName,
//ValidationOptions = CertificateValidationOptions.SuppressHostNameInvalid,
},
TrustedPeerCertificates = new CertificateTrustList()
@@ -323,7 +329,7 @@ public partial class OPCUAServer : UpLoadBase
config.CertificateValidator = new CertificateValidator();
config.CertificateValidator.Update(config);
config.CertificateValidator.Update(config).GetAwaiter().GetResult();
config.Extensions = new XmlElementCollection();
return config;

View File

@@ -10,6 +10,8 @@
//------------------------------------------------------------------------------
#endregion
using Opc.Ua;
namespace ThingsGateway.Plugin.OPCUA;
/// <inheritdoc/>
@@ -18,8 +20,21 @@ public class OPCUAServerProperty : UpDriverPropertyBase
/// <summary>
/// 服务地址
/// </summary>
[DeviceProperty("服务地址", "")]
[DeviceProperty("服务地址", "分号分割数组可设置多个url")]
public string OpcUaStringUrl { get; set; } = "opc.tcp://127.0.0.1:49321";
/// <summary>
/// SubjectName
/// </summary>
[DeviceProperty("SubjectName", "")]
public string SubjectName { get; set; } = "CN=ThingsGateway OPCUAServer, C=CN, S=GUANGZHOU, O=ThingsGateway, DC=" + System.Net.Dns.GetHostName();
/// <summary>
/// ApplicationUri
/// </summary>
[DeviceProperty("ApplicationUri", "")]
public string ApplicationUri { get; set; } = Utils.Format(@"urn:{0}:thingsgatewayopcuaserver", System.Net.Dns.GetHostName());
/// <summary>
/// 安全策略
/// </summary>

View File

@@ -6,7 +6,7 @@ export const language = ["en","zh"];
export const removeDefaultStopWordFilter = false;
export const removeDefaultStemmer = false;
export { default as Mark } from "E:\\Tg\\ThingsGateway\\ThingsGateway-DEV\\handbook\\node_modules\\mark.js\\dist\\mark.js"
export const searchIndexUrl = "search-index{dir}.json?_=5f24d3ee";
export const searchIndexUrl = "search-index{dir}.json?_=264c6792";
export const searchResultLimits = 8;
export const searchResultContextMaxLength = 50;
export const explicitSearchResultPath = true;

View File

@@ -227,9 +227,9 @@
"179": {
"js": [
{
"file": "assets/js/main.cf42840d.js",
"hash": "41e8aa8c7cbe401b",
"publicPath": "/thingsgateway-docs/assets/js/main.cf42840d.js"
"file": "assets/js/main.90bffab9.js",
"hash": "6774eb8ed9189628",
"publicPath": "/thingsgateway-docs/assets/js/main.90bffab9.js"
}
]
},
@@ -299,9 +299,9 @@
"1303": {
"js": [
{
"file": "assets/js/runtime~main.2b19bbf8.js",
"hash": "e48e0c0408aa1c4e",
"publicPath": "/thingsgateway-docs/assets/js/runtime~main.2b19bbf8.js"
"file": "assets/js/runtime~main.2d62406a.js",
"hash": "fc67bb23388f4a51",
"publicPath": "/thingsgateway-docs/assets/js/runtime~main.2d62406a.js"
}
]
},
@@ -398,9 +398,9 @@
"3371": {
"js": [
{
"file": "assets/js/d22033f9.6a725d32.js",
"hash": "edd7fef77b05ef57",
"publicPath": "/thingsgateway-docs/assets/js/d22033f9.6a725d32.js"
"file": "assets/js/d22033f9.838d285d.js",
"hash": "b8c8ee41012bac15",
"publicPath": "/thingsgateway-docs/assets/js/d22033f9.838d285d.js"
}
]
},
@@ -619,9 +619,9 @@
"8707": {
"js": [
{
"file": "assets/js/4c79e569.5c5c0d05.js",
"hash": "e9c712a478ed50e6",
"publicPath": "/thingsgateway-docs/assets/js/4c79e569.5c5c0d05.js"
"file": "assets/js/4c79e569.b07342bd.js",
"hash": "c0362a85c0105049",
"publicPath": "/thingsgateway-docs/assets/js/4c79e569.b07342bd.js"
}
]
},

View File

@@ -12,8 +12,8 @@
"tags": [],
"version": "current",
"lastUpdatedBy": "Kimdiego2098",
"lastUpdatedAt": 1697632930,
"formattedLastUpdatedAt": "Oct 18, 2023",
"lastUpdatedAt": 1697718988,
"formattedLastUpdatedAt": "Oct 19, 2023",
"frontMatter": {
"id": "upgrade",
"title": "历史更新"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -16,9 +16,13 @@ title: 支持作者
|序号|名称|金额|
|-----------|--------------|-----------------|
|1| 绢| 10¥|
|2| 小蚂蚁 |18.8¥+66.66¥+16.8¥+66.66¥+66.66¥|
|2| 小蚂蚁 |500+¥ + .............|
|3| *伟 |18.8¥|
|4| *碟 |20¥|
|5| *长 |6.66¥|
|6| 小黄鸭 |38.8¥|
|7| *交 |50¥|
|8| *洋 |200¥+50¥|
|9| *元 |20¥|