本文整理匯總了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)
{
//.........這裏部分代碼省略.........