本文整理汇总了C#中Opc.Ua.Client.Session.Call方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Call方法的具体用法?C# Session.Call怎么用?C# Session.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opc.Ua.Client.Session
的用法示例。
在下文中一共展示了Session.Call方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcknowledgeEvents
/// <summary>
/// Acknowledges one or more events.
/// </summary>
public int[] AcknowledgeEvents(
Session session,
string comment,
string acknowledgerId,
AeAcknowledgeRequest[] requests)
{
if (session == null || !session.Connected)
{
throw ComUtils.CreateComException(ResultIds.E_FAIL);
}
StringBuilder buffer = new StringBuilder();
buffer.Append('[');
buffer.Append(acknowledgerId);
buffer.Append(']');
if (!String.IsNullOrEmpty(comment))
{
buffer.Append(comment);
}
// wrap the comment once.
Variant commentToWrite = new Variant(new LocalizedText(buffer.ToString()));
int[] errors = new int[requests.Length];
CallMethodRequestCollection methodsToCall = new CallMethodRequestCollection();
for (int ii = 0; ii < requests.Length; ii++)
{
int cookie = requests[ii].Cookie;
AeEvent e = null;
lock (m_lock)
{
// look up the event.
if (!m_events.TryGetValue(cookie, out e))
{
errors[ii] = ResultIds.E_INVALIDARG;
if (cookie < m_counter)
{
errors[ii] = ResultIds.S_ALREADYACKED;
}
continue;
}
if (e.SourceName != requests[ii].SourceName)
{
errors[ii] = ResultIds.E_INVALIDARG;
continue;
}
if (e.ConditionName != requests[ii].ConditionName)
{
errors[ii] = ResultIds.E_INVALIDARG;
continue;
}
if (e.ActiveTime != requests[ii].ActiveTime)
{
errors[ii] = ResultIds.E_INVALIDTIME;
continue;
}
// check that the cookie is still valid.
string conditionId = GetConditionId(e);
int expectedCookie = 0;
if (!m_cookies.TryGetValue(conditionId, out expectedCookie))
{
errors[ii] = ResultIds.S_ALREADYACKED;
continue;
}
// check cookie.
if (expectedCookie != cookie)
{
errors[ii] = ResultIds.E_INVALIDARG;
continue;
}
m_events.Remove(cookie);
}
CallMethodRequest request = new CallMethodRequest();
request.MethodId = Opc.Ua.MethodIds.AcknowledgeableConditionType_Acknowledge;
request.ObjectId = e.ConditionId;
request.InputArguments.Add(new Variant(e.EventId));
request.InputArguments.Add(commentToWrite);
request.Handle = ii;
methodsToCall.Add(request);
}
if (methodsToCall.Count > 0)
{
//.........这里部分代码省略.........