Comments (3)
上面粘贴可能有点问题:
`public Task<List> WriteNodeAsync(string[] tags, object[] values)
{
WriteValueCollection valuesToWrite = new WriteValueCollection();
for (int i = 0; i < tags.Length; i++)
{
if (i < values.Length)
{
WriteValue valueToWrite = new WriteValue()
{
NodeId = new NodeId(tags[i]),
AttributeId = Attributes.Value
};
valueToWrite.Value.Value = values[i];
valueToWrite.Value.StatusCode = StatusCodes.Good;
valueToWrite.Value.ServerTimestamp = DateTime.MinValue;
valueToWrite.Value.SourceTimestamp = DateTime.MinValue;
valuesToWrite.Add(valueToWrite);
}
}
// Wrap the WriteAsync logic in a TaskCompletionSource, so we can use C# async/await syntax to call it:
var taskCompletionSource = new TaskCompletionSource<List<bool>>();
m_session.BeginWrite(
requestHeader: null,
nodesToWrite: valuesToWrite,
callback: ar =>
{
var response = m_session.EndWrite(
result: ar,
results: out StatusCodeCollection results,
diagnosticInfos: out DiagnosticInfoCollection diag);
try
{
ClientBase.ValidateResponse(results, valuesToWrite);
ClientBase.ValidateDiagnosticInfos(diag, valuesToWrite);
List<bool> retList = new List<bool>();
foreach(var item in results)
{
retList.Add(StatusCode.IsGood(item));
}
taskCompletionSource.SetResult(retList);
}
catch (Exception ex)
{
taskCompletionSource.TrySetException(ex);
}
},
asyncState: null);
return taskCompletionSource.Task;
}`
from opcuahelper.
没办法:
Task<List>应该是Task<List<bool>>
from opcuahelper.
嗯,是个好的方式。
from opcuahelper.
Related Issues (20)
- 可否增加ReadNodeAsync的非泛型方法
- 订阅问题 HOT 1
- 连接Kepserver OPCUA匿名登录时,提示未能加载文件或程序集“BouncyCastle.Crypto, Version=1.8.10.0, Culture=neutral, PublicKeyToken=0e99375e54769942”或它的某一个依赖项。系统找不到指定的文件。 HOT 1
- 商业使用opc基金会UA DLL需要商业授权,那么使用基金会的传动opcdaauto.dll是不是也需要商业授权,还是免费的,我搞不清楚,有人知道吗? HOT 1
- OPCUAhelper 是否不支持加密模式的登陆方式?在APPCONFIG也没找到
- OpcUaHelper是否支持OPC DA的server?手上的设备太老,只有OPC DA2.xx。
- NodeId的中ns是如何查询到的? HOT 1
- BadSecureChannelClosed HOT 6
- 当批量写入时,存在部分值未写进PLC的变量中,但是API却反馈了写入成功 HOT 1
- 在连接OPCUAServer时候怎么能后使用下边图片信息,来设置客户端
- 服务器订阅节点后偶发获取信号值为空
- 子节点过多,陷入死循环的问题
- 连接报错toomanysessions问题 HOT 2
- 连接时不能找到方法 HOT 1
- 有用这个库在项目中长时间运行的案例吗?我程序中存在崩溃问题 HOT 1
- 关于BadRequestTimeout的处理
- Force reconnect reason=BadConnectionClosed 'Remote side closed connection'
- 未能正确的读节点值
- 没有添加节点的方法吗
- 证书生成的问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opcuahelper.