本文整理汇总了C#中UInt32Collection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# UInt32Collection.Add方法的具体用法?C# UInt32Collection.Add怎么用?C# UInt32Collection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UInt32Collection
的用法示例。
在下文中一共展示了UInt32Collection.Add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadUInt32Array
/// <summary>
/// Reads a uint array from the stream.
/// </summary>
public UInt32Collection ReadUInt32Array(string fieldName)
{
bool isNil = false;
UInt32Collection values = new UInt32Collection();
if (BeginField(fieldName, true, out isNil))
{
PushNamespace(Namespaces.OpcUaXsd);
while (MoveToElement("UInt32"))
{
values.Add(ReadUInt32("UInt32"));
}
// check the length.
if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
{
throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
}
PopNamespace();
EndField(fieldName);
return values;
}
if (isNil)
{
return null;
}
return values;
}
示例2: InnerPublish
/// <summary>
/// Returns all available notifications.
/// </summary>
private NotificationMessage InnerPublish(
OperationContext context,
out UInt32Collection availableSequenceNumbers,
out bool moreNotifications)
{
// check session.
VerifySession(context);
// TraceState("PUBLISH");
// check if a keep alive should be sent if there is no data.
bool keepAliveIfNoData = (m_keepAliveCounter >= m_maxKeepAliveCount);
availableSequenceNumbers = new UInt32Collection();
moreNotifications = false;
if (m_lastSentMessage < m_sentMessages.Count)
{
// return the available sequence numbers.
for (int ii = 0; ii <= m_lastSentMessage && ii < m_sentMessages.Count; ii++)
{
availableSequenceNumbers.Add(m_sentMessages[ii].SequenceNumber);
}
moreNotifications = m_waitingForPublish = m_lastSentMessage < m_sentMessages.Count-1;
// TraceState("PUBLISH QUEUED MESSAGE");
return m_sentMessages[m_lastSentMessage++];
}
List<NotificationMessage> messages = new List<NotificationMessage>();
if (m_publishingEnabled)
{
DateTime start1 = DateTime.UtcNow;
// collect notifications to publish.
Queue<EventFieldList> events = new Queue<EventFieldList>();
Queue<MonitoredItemNotification> datachanges = new Queue<MonitoredItemNotification>();
Queue<DiagnosticInfo> datachangeDiagnostics = new Queue<DiagnosticInfo>();
// check for monitored items that are ready to publish.
LinkedListNode<IMonitoredItem> current = m_itemsToPublish.First;
while (current != null)
{
LinkedListNode<IMonitoredItem> next = current.Next;
IMonitoredItem monitoredItem = current.Value;
if ((monitoredItem.MonitoredItemType & MonitoredItemTypeMask.DataChange) != 0)
{
((IDataChangeMonitoredItem)monitoredItem).Publish(context, datachanges, datachangeDiagnostics);
}
else
{
((IEventMonitoredItem)monitoredItem).Publish(context, events);
}
// add back to list to check.
m_itemsToPublish.Remove(current);
m_itemsToCheck.AddLast(current);
// check there are enough notifications for a message.
if (m_maxNotificationsPerPublish > 0 && events.Count + datachanges.Count > m_maxNotificationsPerPublish)
{
// construct message.
int notificationCount;
int eventCount = events.Count;
int dataChangeCount = datachanges.Count;
NotificationMessage message = ConstructMessage(
events,
datachanges,
datachangeDiagnostics,
out notificationCount);
// add to list of messages to send.
messages.Add(message);
lock (m_diagnostics)
{
m_diagnostics.DataChangeNotificationsCount += (uint)(dataChangeCount - datachanges.Count);
m_diagnostics.EventNotificationsCount += (uint)(eventCount - events.Count);
m_diagnostics.NotificationsCount += (uint)notificationCount;
}
}
current = next;
}
// pubish the remaining notifications.
while (events.Count + datachanges.Count > 0)
{
// construct message.
int notificationCount;
int eventCount = events.Count;
//.........这里部分代码省略.........
示例3: SetPublishingEnabled
/// <summary>
/// Sets the publishing enable state for the subscriptions.
/// </summary>
private bool SetPublishingEnabled(bool enabled)
{
try
{
UInt32Collection subscriptionIds = new UInt32Collection();
lock (m_subscriptions)
{
for (int ii = 0; ii < m_subscriptions.Count; ii++)
{
subscriptionIds.Add(m_subscriptions[ii].SubscriptionId);
m_subscriptions[ii].PublishingEnabled = enabled;
}
}
RequestHeader requestHeader = new RequestHeader();
requestHeader.ReturnDiagnostics = 0;
StatusCodeCollection results;
DiagnosticInfoCollection diagnosticInfos;
Session.SetPublishingMode(
requestHeader,
enabled,
subscriptionIds,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, subscriptionIds);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, subscriptionIds);
if (diagnosticInfos != null && diagnosticInfos.Count > 0)
{
Log("Returned non-empty DiagnosticInfos array during SetPublishingMode.");
return false;
}
bool success = true;
for (int ii = 0; ii < results.Count; ii++)
{
if (StatusCode.IsBad(results[ii]))
{
Log(
"Unexpected error setting publish enable state for subscription {0}. StatusCode = {1}",
subscriptionIds[ii],
subscriptionIds);
success = false;
}
}
return success;
}
catch (Exception e)
{
Log(e, "SetPublishingMode Failed.");
return false;
}
}
示例4: ToogleDisabledState
/// <summary>
/// Toggles the monitoring mode for the items.
/// </summary>
private bool ToogleDisabledState(Subscription subscription, List<MonitoredItem> monitoredItems)
{
UInt32Collection monitoredItemIds = new UInt32Collection();
lock (subscription)
{
subscription.NotificationMessages.Clear();
subscription.ReceiveTimes.Clear();
for (int ii = 0; ii < monitoredItems.Count; ii++)
{
monitoredItemIds.Add(monitoredItems[ii].MonitoredItemId);
monitoredItems[ii].Value = null;
}
}
StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
Session.SetMonitoringMode(
null,
subscription.SubscriptionId,
MonitoringMode.Disabled,
monitoredItemIds,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, monitoredItemIds);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, monitoredItemIds);
lock (subscription)
{
for (int ii = 0; ii < results.Count; ii++)
{
if (StatusCode.IsBad(results[ii]))
{
Log(
"Error disabling MonitoredItem. ClientHandle = {0}, Node = {1}, Attribute = {2}, StatusCode = {3}",
monitoredItems[ii].MonitoredItemId,
monitoredItems[ii].Node,
Attributes.GetBrowseName(monitoredItems[ii].AttributeId),
results[ii]);
return false;
}
}
}
ResponseHeader responseHeader = Session.SetMonitoringMode(
null,
subscription.SubscriptionId,
MonitoringMode.Reporting,
monitoredItemIds,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, monitoredItemIds);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, monitoredItemIds);
lock (subscription)
{
for (int ii = 0; ii < results.Count; ii++)
{
if (StatusCode.IsBad(results[ii]))
{
Log(
"Error enabling MonitoredItem. ClientHandle = {0}, Node = {1}, Attribute = {2}, StatusCode = {3}",
monitoredItems[ii].MonitoredItemId,
monitoredItems[ii].Node,
Attributes.GetBrowseName(monitoredItems[ii].AttributeId),
results[ii]);
return false;
}
monitoredItems[ii].UpdateTime = responseHeader.Timestamp;
}
}
return true;
}
示例5: DeleteSubscriptions
/// <summary>
/// Deletes all of the active subscriptions.
/// </summary>
private bool DeleteSubscriptions()
{
try
{
UInt32Collection subscriptionIds = new UInt32Collection();
lock (m_subscriptions)
{
for (int ii = 0; ii < m_subscriptions.Count; ii++)
{
Subscription subscription = m_subscriptions[ii];
lock (subscription)
{
subscriptionIds.Add(subscription.SubscriptionId);
subscription.Deleted = true;
}
}
}
RequestHeader requestHeader = new RequestHeader();
requestHeader.ReturnDiagnostics = 0;
StatusCodeCollection results;
DiagnosticInfoCollection diagnosticInfos;
ResponseHeader responseHeader = Session.DeleteSubscriptions(
requestHeader,
subscriptionIds,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, subscriptionIds);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, subscriptionIds);
if (diagnosticInfos != null && diagnosticInfos.Count > 0)
{
Log("Returned non-empty DiagnosticInfos array during DeleteSubscriptions.");
return false;
}
bool success = true;
lock (m_subscriptions)
{
for (int ii = 0; ii < m_subscriptions.Count; ii++)
{
if (StatusCode.IsBad(results[ii]))
{
Log(
"Unexpected error deleting subscription {0}. StatusCode = {1}",
subscriptionIds[ii],
subscriptionIds);
success = false;
}
Subscription subscription = m_subscriptions[ii];
lock (subscription)
{
subscription.States[subscription.States.Count - 1].End = responseHeader.Timestamp;
}
}
}
// let the queue empty.
Thread.Sleep(1000);
return success;
}
catch (Exception e)
{
Log(e, "DeleteSubscriptions Failed.");
return false;
}
}
示例6: DeleteMonitoredItems
/// <summary>
/// Deletes the monitored items.
/// </summary>
private bool DeleteMonitoredItems(
Subscription subscription,
List<MonitoredItem> monitoredItems)
{
try
{
RequestHeader requestHeader = new RequestHeader();
requestHeader.ReturnDiagnostics = 0;
UInt32Collection monitoredItemIds = new UInt32Collection();
for (int ii = 0; ii < monitoredItems.Count; ii++)
{
monitoredItemIds.Add(monitoredItems[ii].MonitoredItemId);
}
StatusCodeCollection results;
DiagnosticInfoCollection diagnosticInfos;
Session.DeleteMonitoredItems(
requestHeader,
subscription.SubscriptionId,
monitoredItemIds,
out results,
out diagnosticInfos);
ClientBase.ValidateResponse(results, monitoredItemIds);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, monitoredItemIds);
if (diagnosticInfos != null && diagnosticInfos.Count > 0)
{
Log("Returned non-empty DiagnosticInfos array during DeleteMonitoredItems.");
return false;
}
bool success = true;
for (int ii = 0; ii < monitoredItems.Count; ii++)
{
if (StatusCode.IsBad(results[ii]))
{
Log(
"Delete monitored item failed for Node '{0}', NodeId = {1}, AttributeId = {2}, StatusCode = {3}",
monitoredItems[ii].Node,
monitoredItems[ii].Node.NodeId,
Attributes.GetBrowseName(monitoredItems[ii].AttributeId),
results[ii]);
success = false;
continue;
}
}
return success;
}
catch (Exception e)
{
Log(e, "DeleteMonitoredItems Failed.");
return false;
}
}
示例7: ReadUInt32Array
/// <summary>
/// Reads a uint array from the stream.
/// </summary>
public UInt32Collection ReadUInt32Array(string fieldName)
{
int length = ReadArrayLength();
if (length == -1)
{
return null;
}
UInt32Collection values = new UInt32Collection(length);
for (int ii = 0; ii < length; ii++)
{
values.Add(ReadUInt32(null));
}
return values;
}
示例8: GetIdentifiers
/// <summary>
/// Returns the ids for all attributes which are valid for the at least one of the node classes specified by the mask.
/// </summary>
public static UInt32Collection GetIdentifiers(NodeClass nodeClass)
{
FieldInfo[] fields = typeof(Attributes).GetFields(BindingFlags.Public | BindingFlags.Static);
UInt32Collection ids = new UInt32Collection(fields.Length);
foreach (FieldInfo field in fields)
{
uint id = (uint)field.GetValue(typeof(Attributes));
if (IsValid(nodeClass, id))
{
ids.Add(id);
}
}
return ids;
}
示例9: ReadUInt32Array
/// <summary>
/// Reads a uint array from the stream.
/// </summary>
public UInt32Collection ReadUInt32Array(string fieldName)
{
var values = new UInt32Collection();
List<object> token = null;
if (!ReadArrayField(fieldName, out token))
{
return values;
}
for (int ii = 0; ii < token.Count; ii++)
{
try
{
m_stack.Push(token[ii]);
values.Add(ReadUInt32(null));
}
finally
{
m_stack.Pop();
}
}
return values;
}