|
|
@@ -204,7 +204,7 @@ namespace YSAI.Opc.ua.client
|
|
|
//处理数据
|
|
|
AddressValue addressValue = YSAI.Core.data.Dispose.Execute(addressDetails, notification.Value.ToString()); //数据
|
|
|
|
|
|
- param.AddOrUpdate(addressDetails.Address, addressValue, (k, v) => addressValue);
|
|
|
+ param.AddOrUpdate(addressDetails.AddressName, addressValue, (k, v) => addressValue);
|
|
|
|
|
|
//响应
|
|
|
OnEventParamHandler?.Invoke(this, new EventParam() { Message = $"点位数据更新", Step = Steps.订阅通知事件, State = true, Params = param });
|
|
|
@@ -219,7 +219,7 @@ namespace YSAI.Opc.ua.client
|
|
|
/// <summary>
|
|
|
/// 从服务器读取值节点
|
|
|
/// </summary>
|
|
|
- private async Task<DataValue> ReadNode(NodeId nodeId)
|
|
|
+ private DataValue ReadNode(NodeId nodeId)
|
|
|
{
|
|
|
ReadValueIdCollection nodesToRead = new ReadValueIdCollection
|
|
|
{
|
|
|
@@ -231,11 +231,11 @@ namespace YSAI.Opc.ua.client
|
|
|
};
|
|
|
|
|
|
// 读取当前值
|
|
|
- ReadResponse readResponse = await clientSession.ReadAsync(
|
|
|
+ ReadResponse readResponse = clientSession.ReadAsync(
|
|
|
null,
|
|
|
0,
|
|
|
TimestampsToReturn.Neither,
|
|
|
- nodesToRead, new CancellationToken());
|
|
|
+ nodesToRead, new CancellationToken()).Result;
|
|
|
|
|
|
return readResponse.Results[0];
|
|
|
}
|
|
|
@@ -299,11 +299,11 @@ namespace YSAI.Opc.ua.client
|
|
|
/// <summary>
|
|
|
/// 获取树节点图片类型
|
|
|
/// </summary>
|
|
|
- public async Task<string> GetNodeIconType(ReferenceDescription target, NodeId sourceId)
|
|
|
+ public string GetNodeIconType(ReferenceDescription target, NodeId sourceId)
|
|
|
{
|
|
|
if (target.NodeClass == NodeClass.Variable)
|
|
|
{
|
|
|
- DataValue dataValue = await ReadNode((NodeId)target.NodeId);
|
|
|
+ DataValue dataValue = ReadNode((NodeId)target.NodeId);
|
|
|
|
|
|
if (dataValue.WrappedValue.TypeInfo != null)
|
|
|
{
|
|
|
@@ -355,7 +355,7 @@ namespace YSAI.Opc.ua.client
|
|
|
/// </summary>
|
|
|
/// <param name="nodeIds"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<DataValue[]> DetailedReadAllNodeData(List<NodeId> nodeIds)
|
|
|
+ public DataValue[] DetailedReadAllNodeData(List<NodeId> nodeIds)
|
|
|
{
|
|
|
ReadValueIdCollection nodesToRead = new ReadValueIdCollection();
|
|
|
foreach (var nodeId in nodeIds)
|
|
|
@@ -387,11 +387,7 @@ namespace YSAI.Opc.ua.client
|
|
|
AttributeId = Attributes.Description
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- // read all values.
|
|
|
- ReadResponse readResponse = await Task.Run(() => { return clientSession?.ReadAsync(null, 0, TimestampsToReturn.Neither, nodesToRead, new CancellationToken()); });
|
|
|
-
|
|
|
- return readResponse.Results.ToArray();
|
|
|
+ return clientSession?.ReadAsync(null, 0, TimestampsToReturn.Neither, nodesToRead, new CancellationToken()).Result.Results.ToArray();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -674,10 +670,10 @@ namespace YSAI.Opc.ua.client
|
|
|
/// <summary>
|
|
|
/// 获取指定节点的数据类型
|
|
|
/// </summary>
|
|
|
- public async Task<BuiltInType> GetNodeValueType(NodeId nodeId)
|
|
|
+ public BuiltInType GetNodeValueType(NodeId nodeId)
|
|
|
{
|
|
|
///得到数据类型
|
|
|
- DataValue[] dataValues = await DetailedReadAllNodeData(new List<NodeId> { nodeId });
|
|
|
+ DataValue[] dataValues = DetailedReadAllNodeData(new List<NodeId> { nodeId });
|
|
|
if (dataValues[1].WrappedValue.TypeInfo != null)
|
|
|
{
|
|
|
return dataValues[1].WrappedValue.TypeInfo.BuiltInType;
|
|
|
@@ -698,10 +694,15 @@ namespace YSAI.Opc.ua.client
|
|
|
public override string LogHead => "[ OpcUaClientOperate 操作 ]";
|
|
|
public override string ClassName => "OpcUaClientOperate";
|
|
|
|
|
|
- public async Task<OperateResult> AddSubscribeAsync(ConcurrentDictionary<string, List<AddressDetails>> param, byte Priority = 100)
|
|
|
+ public Task<OperateResult> AddSubscribeAsync(ConcurrentDictionary<string, List<AddressDetails>> param, byte Priority = 100)
|
|
|
+ {
|
|
|
+ return Task.Run(()=> AddSubscribe(param,Priority));
|
|
|
+ }
|
|
|
+
|
|
|
+ public OperateResult AddSubscribe(ConcurrentDictionary<string, List<AddressDetails>> param, byte Priority = 100)
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.AddSubscribe").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.AddSubscribe").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
if (!IsConnected)
|
|
|
@@ -740,7 +741,7 @@ namespace YSAI.Opc.ua.client
|
|
|
//节点与键对应
|
|
|
foreach (var item in alls.Value.MonitoredItems)
|
|
|
{
|
|
|
- if (item.StartNodeId.ToString().Equals(Nodes[i].Address))
|
|
|
+ if (item.StartNodeId.ToString().Equals(Nodes[i].AddressName))
|
|
|
{
|
|
|
//存在此节点,则移除此节点
|
|
|
Nodes.Remove(Nodes[i]);
|
|
|
@@ -751,7 +752,7 @@ namespace YSAI.Opc.ua.client
|
|
|
if (Nodes.Count > 0)
|
|
|
{
|
|
|
//先在会话中,移除这个订阅
|
|
|
- if (!await clientSession?.RemoveSubscriptionAsync(allSubscriptions[Tag]))
|
|
|
+ if (!clientSession.RemoveSubscriptionAsync(allSubscriptions[Tag]).Result)
|
|
|
{
|
|
|
//如果从会话中异常订阅失败则直接跳出
|
|
|
return Break("AddSubscribe", false, "从会话中移除订阅失败");
|
|
|
@@ -767,9 +768,9 @@ namespace YSAI.Opc.ua.client
|
|
|
if (!item.IsEnable) continue;
|
|
|
|
|
|
MonitoredItem intMonitoredItem = new MonitoredItem(allSubscriptions[Tag].DefaultItem);
|
|
|
- intMonitoredItem.StartNodeId = new NodeId(item.Address); //标识要监视的节点的浏览路径的开始节点
|
|
|
+ intMonitoredItem.StartNodeId = new NodeId(item.AddressName); //标识要监视的节点的浏览路径的开始节点
|
|
|
intMonitoredItem.AttributeId = Attributes.Value; //要监视的属性
|
|
|
- intMonitoredItem.DisplayName = item.Address; //被监控项的显示名称
|
|
|
+ intMonitoredItem.DisplayName = item.AddressName; //被监控项的显示名称
|
|
|
intMonitoredItem.SamplingInterval = opcUaData.SamplingInterval; //采样间隔
|
|
|
intMonitoredItem.Notification += async delegate (MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { OnMonitoredItemNotification(monitoredItem, e, item); }; //重写事件添加一个参数
|
|
|
|
|
|
@@ -779,7 +780,7 @@ namespace YSAI.Opc.ua.client
|
|
|
if (Nodes.Count > 0)
|
|
|
{
|
|
|
//不在主线程中实现
|
|
|
- await Task.Run(async () =>
|
|
|
+ Task.Run(async () =>
|
|
|
{
|
|
|
//添加订阅
|
|
|
clientSession?.AddSubscription(allSubscriptions[Tag]);
|
|
|
@@ -787,7 +788,7 @@ namespace YSAI.Opc.ua.client
|
|
|
await allSubscriptions[Tag].CreateAsync();
|
|
|
// 在服务器端创建监控项
|
|
|
await allSubscriptions[Tag].ApplyChangesAsync();
|
|
|
- });
|
|
|
+ }).Wait();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -809,15 +810,15 @@ namespace YSAI.Opc.ua.client
|
|
|
if (!item.IsEnable) continue;
|
|
|
|
|
|
MonitoredItem intMonitoredItem = new MonitoredItem(subscription.DefaultItem);
|
|
|
- intMonitoredItem.StartNodeId = new NodeId(item.Address); //标识要监视的节点的浏览路径的开始节点
|
|
|
+ intMonitoredItem.StartNodeId = new NodeId(item.AddressName); //标识要监视的节点的浏览路径的开始节点
|
|
|
intMonitoredItem.AttributeId = Attributes.Value; //要监视的属性
|
|
|
- intMonitoredItem.DisplayName = item.Address; //被监控项的显示名称
|
|
|
+ intMonitoredItem.DisplayName = item.AddressName; //被监控项的显示名称
|
|
|
intMonitoredItem.SamplingInterval = opcUaData.SamplingInterval; //采样间隔
|
|
|
intMonitoredItem.Notification += async delegate (MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { OnMonitoredItemNotification(monitoredItem, e, item); }; //重写事件添加一个参数
|
|
|
subscription.AddItem(intMonitoredItem); //添加订阅通知项
|
|
|
}
|
|
|
//不在主线程中实现
|
|
|
- await Task.Run(async () =>
|
|
|
+ Task.Run(async () =>
|
|
|
{
|
|
|
//添加订阅
|
|
|
clientSession?.AddSubscription(subscription);
|
|
|
@@ -825,7 +826,7 @@ namespace YSAI.Opc.ua.client
|
|
|
await subscription.CreateAsync();
|
|
|
// 在服务器端创建监控项
|
|
|
await subscription.ApplyChangesAsync();
|
|
|
- });
|
|
|
+ }).Wait();
|
|
|
//把此订阅添加到集合,方便后续移除订阅(当存在此键则更新值,不存在则添加)
|
|
|
allSubscriptions?.AddOrUpdate(Tag, subscription, (k, v) => subscription);
|
|
|
}
|
|
|
@@ -845,15 +846,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult AddSubscribe(ConcurrentDictionary<string, List<AddressDetails>> param, byte Priority = 100)
|
|
|
+ public Task<OperateResult> RemoveSubscribeAsync(List<AddressDetails> Nodes)
|
|
|
{
|
|
|
- return AddSubscribeAsync(param, Priority).Result;
|
|
|
+ return Task.Run(() => RemoveSubscribe(Nodes));
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> RemoveSubscribeAsync(List<AddressDetails> Nodes)
|
|
|
+ public OperateResult RemoveSubscribe(List<AddressDetails> Nodes)
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.RemoveSubscribe").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.RemoveSubscribe").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
if (!IsConnected)
|
|
|
@@ -869,7 +870,7 @@ namespace YSAI.Opc.ua.client
|
|
|
//节点与键对应
|
|
|
foreach (var item in alls.Value.MonitoredItems)
|
|
|
{
|
|
|
- if (item.StartNodeId.ToString().Equals(node.Address))
|
|
|
+ if (item.StartNodeId.ToString().Equals(node.AddressName))
|
|
|
{
|
|
|
if (monitored == null)
|
|
|
{
|
|
|
@@ -889,7 +890,7 @@ namespace YSAI.Opc.ua.client
|
|
|
{
|
|
|
if (alls2.Key.Equals(alls.Key))
|
|
|
{
|
|
|
- await Task.Run(() => { clientSession?.RemoveSubscriptionAsync(alls.Value); });
|
|
|
+ clientSession?.RemoveSubscriptionAsync(alls.Value).Wait();
|
|
|
//移除后立马跳到上一级,防止性能消耗
|
|
|
break;
|
|
|
}
|
|
|
@@ -902,7 +903,6 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return Break("RemoveSubscribe", true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
@@ -911,15 +911,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult RemoveSubscribe(List<AddressDetails> Nodes)
|
|
|
+ public Task<OperateResult> DeleteNodeAsync(string Key)
|
|
|
{
|
|
|
- return RemoveSubscribeAsync(Nodes).Result;
|
|
|
+ return Task.Run(()=> DeleteNode(Key));
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> DeleteNodeAsync(string Key)
|
|
|
+ public OperateResult DeleteNode(string Key)
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.DeleteNode").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.DeleteNode").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
if (!IsConnected)
|
|
|
@@ -932,7 +932,7 @@ namespace YSAI.Opc.ua.client
|
|
|
NodeId = new NodeId(Key),
|
|
|
};
|
|
|
|
|
|
- DeleteNodesResponse deleteNodesResponse = await Task.Run(() => { return clientSession?.DeleteNodesAsync(null, waitDelete, new CancellationToken()); });
|
|
|
+ DeleteNodesResponse? deleteNodesResponse = clientSession?.DeleteNodesAsync(null, waitDelete, new CancellationToken()).Result;
|
|
|
|
|
|
foreach (var item in deleteNodesResponse.Results)
|
|
|
{
|
|
|
@@ -949,16 +949,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult DeleteNode(string Key)
|
|
|
+ public Task<OperateResult> InitAsync()
|
|
|
{
|
|
|
- return DeleteNodeAsync(Key).Result;
|
|
|
+ return Task.Run(()=> Init());
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> InitAsync()
|
|
|
+ public OperateResult Init()
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.Init").StartRecord();
|
|
|
-
|
|
|
+ RunTimeTool.Instance($"{ClassName}.Init").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
//实例化对象
|
|
|
@@ -984,7 +983,7 @@ namespace YSAI.Opc.ua.client
|
|
|
|
|
|
|
|
|
//用配置的当前状态更新验证器。
|
|
|
- await certificateValidator.Update(new SecurityConfiguration
|
|
|
+ certificateValidator.Update(new SecurityConfiguration
|
|
|
{
|
|
|
//获取或设置一个值,该值指示是否应自动接受不受信任的证书
|
|
|
AutoAcceptUntrustedCertificates = true,
|
|
|
@@ -992,7 +991,7 @@ namespace YSAI.Opc.ua.client
|
|
|
RejectSHA1SignedCertificates = false,
|
|
|
//获取或设置一个值,该值指示接受的最小证书密钥强度
|
|
|
MinimumCertificateKeySize = 1024
|
|
|
- });
|
|
|
+ }).Wait();
|
|
|
//实例化
|
|
|
if (AI == null)
|
|
|
{
|
|
|
@@ -1002,7 +1001,7 @@ namespace YSAI.Opc.ua.client
|
|
|
AI.ApplicationType = ApplicationType.Client;
|
|
|
AI.ConfigSectionName = "Opc.Ua.Client"; //配置文件的名称
|
|
|
//加载应用程序配置
|
|
|
- AC = await AI.LoadApplicationConfiguration(false);
|
|
|
+ AC = AI.LoadApplicationConfiguration(false).Result;
|
|
|
AC.ApplicationName = opcUaData.Name;
|
|
|
AC.ApplicationType = ApplicationType.Client;
|
|
|
AC.CertificateValidator = certificateValidator;
|
|
|
@@ -1015,15 +1014,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult Init()
|
|
|
+ public Task<OperateResult> OnAsync()
|
|
|
{
|
|
|
- return InitAsync().Result;
|
|
|
+ return Task.Run(() => On());
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> OnAsync()
|
|
|
+ public OperateResult On()
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.On").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.On").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
if (AC != null)
|
|
|
@@ -1050,7 +1049,7 @@ namespace YSAI.Opc.ua.client
|
|
|
UserIdentity = new UserIdentity(opcUaData.User, opcUaData.Password);
|
|
|
}
|
|
|
//通过调用CreateSession服务创建与服务器的新通信会话
|
|
|
- clientSession = await Task.Run(async () => { return await Session.Create(AC, endpoint, false, false, AC.ApplicationName, 60000, UserIdentity, null); });
|
|
|
+ clientSession = Session.Create(AC, endpoint, false, false, AC.ApplicationName, 60000, UserIdentity, null).Result;
|
|
|
|
|
|
//当会话关闭,则关闭订阅
|
|
|
clientSession.DeleteSubscriptionsOnClose = true;
|
|
|
@@ -1074,15 +1073,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult On()
|
|
|
+ public Task<OperateResult> OffAsync()
|
|
|
{
|
|
|
- return OnAsync().Result;
|
|
|
+ return Task.Run(()=> Off());
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> OffAsync()
|
|
|
+ public OperateResult Off()
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.Off").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.Off").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
if (!IsConnected)
|
|
|
@@ -1098,11 +1097,7 @@ namespace YSAI.Opc.ua.client
|
|
|
|
|
|
if (clientSession != null)
|
|
|
{
|
|
|
- //不在主线程里面操作
|
|
|
- await Task.Run(async () =>
|
|
|
- {
|
|
|
- await clientSession.CloseAsync(10000);
|
|
|
- });
|
|
|
+ clientSession.Close(10000);
|
|
|
clientSession = null;
|
|
|
}
|
|
|
IsConnected = false;
|
|
|
@@ -1115,15 +1110,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult Off()
|
|
|
+ public Task<OperateResult> ReadAsync(Address address)
|
|
|
{
|
|
|
- return OffAsync().Result;
|
|
|
+ return Task.Run(() => Read(address));
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> ReadAsync(Address address)
|
|
|
+ public OperateResult Read(Address address)
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.Read").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.Read").StartRecord();
|
|
|
List<AddressDetails> Nodes = address.AddressArray;
|
|
|
try
|
|
|
{
|
|
|
@@ -1152,16 +1147,16 @@ namespace YSAI.Opc.ua.client
|
|
|
AddressValue addressValue = YSAI.Core.data.Dispose.Execute(item, Value);
|
|
|
|
|
|
//数据添加
|
|
|
- param.AddOrUpdate(item.Address, addressValue, (k, v) => addressValue);
|
|
|
+ param.AddOrUpdate(item.AddressName, addressValue, (k, v) => addressValue);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- readValueIds.Add(new ReadValueId() { NodeId = new NodeId(item.Address), AttributeId = Attributes.Value });
|
|
|
+ readValueIds.Add(new ReadValueId() { NodeId = new NodeId(item.AddressName), AttributeId = Attributes.Value });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 读取当前节点的值
|
|
|
- ReadResponse read = await clientSession.ReadAsync(null, 0, TimestampsToReturn.Neither, readValueIds, token);
|
|
|
+ ReadResponse? read = clientSession?.ReadAsync(null, 0, TimestampsToReturn.Neither, readValueIds, token).Result;
|
|
|
|
|
|
|
|
|
for (int i = 0; i < read.Results.Count; i++)
|
|
|
@@ -1169,7 +1164,7 @@ namespace YSAI.Opc.ua.client
|
|
|
if (!StatusCode.IsBad(read.Results[i].StatusCode))
|
|
|
{
|
|
|
//获取对应的节点配置
|
|
|
- AddressDetails? addressDetails = Nodes.FirstOrDefault(c => c.Address.Equals(readValueIds[i].NodeId.ToString()));
|
|
|
+ AddressDetails? addressDetails = Nodes.FirstOrDefault(c => c.AddressName.Equals(readValueIds[i].NodeId.ToString()));
|
|
|
|
|
|
string? Value = read.Results[i].ToString();
|
|
|
|
|
|
@@ -1177,7 +1172,7 @@ namespace YSAI.Opc.ua.client
|
|
|
AddressValue addressValue = YSAI.Core.data.Dispose.Execute(addressDetails, Value);
|
|
|
|
|
|
//数据添加
|
|
|
- param.AddOrUpdate(addressDetails.Address, addressValue, (k, v) => addressValue);
|
|
|
+ param.AddOrUpdate(addressDetails.AddressName, addressValue, (k, v) => addressValue);
|
|
|
}
|
|
|
}
|
|
|
return Break("Read", true, RData: param, RType: Core.@enum.ResultType.KeyValue);
|
|
|
@@ -1188,15 +1183,15 @@ namespace YSAI.Opc.ua.client
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult Read(Address address)
|
|
|
+ public Task<OperateResult> WriteAsync<V>(ConcurrentDictionary<string, V> Values)
|
|
|
{
|
|
|
- return ReadAsync(address).Result;
|
|
|
+ return Task.Run(() => Write(Values));
|
|
|
}
|
|
|
|
|
|
- public async Task<OperateResult> WriteAsync<V>(ConcurrentDictionary<string, V> Values)
|
|
|
+ public OperateResult Write<V>(ConcurrentDictionary<string, V> Values)
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
- RunTimeTool.Instance("OpcUaClientOperate.Writes").StartRecord();
|
|
|
+ RunTimeTool.Instance($"{ClassName}.Writes").StartRecord();
|
|
|
try
|
|
|
{
|
|
|
OperateResult? reverseBack = null;
|
|
|
@@ -1231,7 +1226,7 @@ namespace YSAI.Opc.ua.client
|
|
|
WriteValueCollection writeValues = new WriteValueCollection { writeValue };
|
|
|
|
|
|
// 写入当前的值
|
|
|
- WriteResponse writeResponse = await Task.Run(() => { return clientSession?.WriteAsync(null, writeValues, new CancellationToken()); });
|
|
|
+ WriteResponse? writeResponse = clientSession?.WriteAsync(null, writeValues, new CancellationToken()).Result;
|
|
|
|
|
|
foreach (var scc in writeResponse.Results)
|
|
|
{
|
|
|
@@ -1249,10 +1244,5 @@ namespace YSAI.Opc.ua.client
|
|
|
return Break("Writes", false, ex.Message);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public OperateResult Write<V>(ConcurrentDictionary<string, V> Values)
|
|
|
- {
|
|
|
- return WriteAsync(Values).Result;
|
|
|
- }
|
|
|
}
|
|
|
}
|