本文整理汇总了C#中Opc.Ua.NamespaceTable类的典型用法代码示例。如果您正苦于以下问题:C# NamespaceTable类的具体用法?C# NamespaceTable怎么用?C# NamespaceTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceTable类属于Opc.Ua命名空间,在下文中一共展示了NamespaceTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateBrowsePaths
/// <summary>
/// Returns the node ids for a set of relative paths.
/// </summary>
/// <param name="session">An open session with the server to use.</param>
/// <param name="startNodeId">The starting node for the relative paths.</param>
/// <param name="namespacesUris">The namespace URIs referenced by the relative paths.</param>
/// <param name="relativePaths">The relative paths.</param>
/// <returns>A collection of local nodes.</returns>
public static List<NodeId> TranslateBrowsePaths(
Session session,
NodeId startNodeId,
NamespaceTable namespacesUris,
params string[] relativePaths)
{
// build the list of browse paths to follow by parsing the relative paths.
BrowsePathCollection browsePaths = new BrowsePathCollection();
if (relativePaths != null)
{
for (int ii = 0; ii < relativePaths.Length; ii++)
{
BrowsePath browsePath = new BrowsePath();
// The relative paths used indexes in the namespacesUris table. These must be
// converted to indexes used by the server. An error occurs if the relative path
// refers to a namespaceUri that the server does not recognize.
// The relative paths may refer to ReferenceType by their BrowseName. The TypeTree object
// allows the parser to look up the server's NodeId for the ReferenceType.
browsePath.RelativePath = RelativePath.Parse(
relativePaths[ii],
session.TypeTree,
namespacesUris,
session.NamespaceUris);
browsePath.StartingNode = startNodeId;
browsePaths.Add(browsePath);
}
}
// make the call to the server.
BrowsePathResultCollection results;
DiagnosticInfoCollection diagnosticInfos;
ResponseHeader responseHeader = session.TranslateBrowsePathsToNodeIds(
null,
browsePaths,
out results,
out diagnosticInfos);
// ensure that the server returned valid results.
Session.ValidateResponse(results, browsePaths);
Session.ValidateDiagnosticInfos(diagnosticInfos, browsePaths);
// collect the list of node ids found.
List<NodeId> nodes = new List<NodeId>();
for (int ii = 0; ii < results.Count; ii++)
{
// check if the start node actually exists.
if (StatusCode.IsBad(results[ii].StatusCode))
{
nodes.Add(null);
continue;
}
// an empty list is returned if no node was found.
if (results[ii].Targets.Count == 0)
{
nodes.Add(null);
continue;
}
// Multiple matches are possible, however, the node that matches the type model is the
// one we are interested in here. The rest can be ignored.
BrowsePathTarget target = results[ii].Targets[0];
if (target.RemainingPathIndex != UInt32.MaxValue)
{
nodes.Add(null);
continue;
}
// The targetId is an ExpandedNodeId because it could be node in another server.
// The ToNodeId function is used to convert a local NodeId stored in a ExpandedNodeId to a NodeId.
nodes.Add(ExpandedNodeId.ToNodeId(target.TargetId, session.NamespaceUris));
}
// return whatever was found.
return nodes;
}
示例2: TypeTable
/// <summary>
/// Initializes the object with default values.
/// </summary>
/// <param name="namespaceUris">The namespace URIs.</param>
public TypeTable(NamespaceTable namespaceUris)
{
m_namespaceUris = namespaceUris;
m_referenceTypes = new SortedDictionary<QualifiedName,TypeInfo>();
m_nodes = new NodeIdDictionary<TypeInfo>();
m_encodings = new NodeIdDictionary<TypeInfo>();
}
示例3: BindingFactory
/// <summary>
/// Creates an empty factory.
/// </summary>
/// <param name="namespaceUris">The namespace uris.</param>
/// <param name="factory">The factory.</param>
public BindingFactory(NamespaceTable namespaceUris, EncodeableFactory factory)
{
m_bindings = new Dictionary<string, Type>();
AddDefaultBindings(m_bindings);
m_namespaceUris = namespaceUris;
m_factory = factory;
}
示例4: ServiceMessageContext
private ServiceMessageContext(bool shared) : this()
{
m_maxStringLength = UInt16.MaxValue;
m_maxByteStringLength = UInt16.MaxValue*16;
m_maxArrayLength = UInt16.MaxValue;
m_maxMessageSize = UInt16.MaxValue*32;
m_namespaceUris = new NamespaceTable(shared);
m_serverUris = new StringTable(shared);
m_factory = EncodeableFactory.GlobalFactory;
}
示例5: TestDataSystem
public TestDataSystem(ITestDataSystemCallback callback, NamespaceTable namespaceUris, StringTable serverUris)
{
m_callback = callback;
m_minimumSamplingInterval = Int32.MaxValue;
m_monitoredNodes = new Dictionary<uint,BaseVariableState>();
m_generator = new Opc.Ua.Test.DataGenerator(null);
m_generator.NamespaceUris = namespaceUris;
m_generator.ServerUris = serverUris;
m_historyArchive = new HistoryArchive();
}
示例6: SetMappingTables
/// <summary>
/// Initializes the tables used to map namespace and server uris during encoding.
/// </summary>
/// <param name="namespaceUris">The namespaces URIs referenced by the data being encoded.</param>
/// <param name="serverUris">The server URIs referenced by the data being encoded.</param>
public void SetMappingTables(NamespaceTable namespaceUris, StringTable serverUris)
{
m_namespaceMappings = null;
if (namespaceUris != null && m_context.NamespaceUris != null)
{
m_namespaceMappings = namespaceUris.CreateMapping(m_context.NamespaceUris, false);
}
m_serverMappings = null;
if (serverUris != null && m_context.ServerUris != null)
{
m_serverMappings = serverUris.CreateMapping(m_context.ServerUris, false);
}
}
示例7: GetDefaultDataTypeId
/// <summary>
/// Returns the id of the default data type node for the instance.
/// </summary>
protected override NodeId GetDefaultDataTypeId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Opc.Ua.DataTypes.BaseDataType, Opc.Ua.Namespaces.OpcUa, namespaceUris);
}
示例8: GetDefaultTypeDefinitionId
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
/// <param name="namespaceUris">The namespace uris.</param>
/// <returns></returns>
protected virtual NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return null;
}
示例9: TranslateNamespaceIndexes
/// <summary>
/// Updates the path to use the indexes from the target table.
/// </summary>
/// <param name="currentTable">The NamespaceTable which the RelativePathString currently references</param>
/// <param name="targetTable">The NamespaceTable which the RelativePathString should reference</param>
public void TranslateNamespaceIndexes(NamespaceTable currentTable, NamespaceTable targetTable)
{
// build mapping table.
int[] mappings = new int[currentTable.Count];
mappings[0] = 0;
// copy mappings.
string[] uris = new string[mappings.Length];
for (int ii = 1; ii < mappings.Length; ii++)
{
uris[ii] = currentTable.GetString((uint)ii);
if (uris[ii] != null)
{
mappings[ii] = targetTable.GetIndex(uris[ii]);
}
}
// update each element.
foreach (Element element in m_elements)
{
QualifiedName qname = element.ReferenceTypeName;
if (qname != null && qname.NamespaceIndex > 0)
{
if (qname.NamespaceIndex < mappings.Length && mappings[qname.NamespaceIndex] > 0)
{
element.ReferenceTypeName = new QualifiedName(qname.Name, (ushort)mappings[qname.NamespaceIndex]);
}
}
qname = element.TargetName;
if (qname != null && qname.NamespaceIndex > 0)
{
if (qname.NamespaceIndex < mappings.Length && mappings[qname.NamespaceIndex] > 0)
{
element.TargetName = new QualifiedName(qname.Name, (ushort)mappings[qname.NamespaceIndex]);
}
}
}
}
示例10: Parse
/// <summary>
/// Parses a relative path formatted as a string.
/// </summary>
public static RelativePath Parse(
string browsePath,
ITypeTable typeTree,
NamespaceTable currentTable,
NamespaceTable targetTable)
{
// parse the string.
RelativePathFormatter formatter = RelativePathFormatter.Parse(browsePath, currentTable, targetTable);
// convert the browse names to node ids.
RelativePath relativePath = new RelativePath();
foreach (RelativePathFormatter.Element element in formatter.Elements)
{
RelativePathElement parsedElement = new RelativePathElement();
parsedElement.ReferenceTypeId = null;
parsedElement.IsInverse = false;
parsedElement.IncludeSubtypes = element.IncludeSubtypes;
parsedElement.TargetName = element.TargetName;
switch (element.ElementType)
{
case RelativePathFormatter.ElementType.AnyHierarchical:
{
parsedElement.ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences;
break;
}
case RelativePathFormatter.ElementType.AnyComponent:
{
parsedElement.ReferenceTypeId = ReferenceTypeIds.Aggregates;
break;
}
case RelativePathFormatter.ElementType.ForwardReference:
case RelativePathFormatter.ElementType.InverseReference:
{
if (typeTree == null)
{
throw new InvalidOperationException("Cannot parse path with reference names without a type table.");
}
parsedElement.ReferenceTypeId = typeTree.FindReferenceType(element.ReferenceTypeName);
parsedElement.IsInverse = element.ElementType == RelativePathFormatter.ElementType.InverseReference;
break;
}
}
if (NodeId.IsNull(parsedElement.ReferenceTypeId))
{
throw ServiceResultException.Create(
StatusCodes.BadSyntaxError,
"Could not convert BrowseName to a ReferenceTypeId: {0}",
element.ReferenceTypeName);
}
relativePath.Elements.Add(parsedElement);
}
return relativePath;
}
示例11: GetDefaultTypeDefinitionId
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Opc.Ua.Fdi7.ObjectTypes.ServerCommunicationGENERICDeviceType, Opc.Ua.Fdi7.Namespaces.OpcUaFdi7, namespaceUris);
}
示例12: FilterContext
/// <summary>
/// Initializes the context.
/// </summary>
/// <param name="namespaceUris">The namespace URIs.</param>
/// <param name="typeTree">The type tree.</param>
/// <param name="context">The context.</param>
public FilterContext(NamespaceTable namespaceUris, ITypeTable typeTree, IOperationContext context)
{
if (namespaceUris == null) throw new ArgumentNullException("namespaceUris");
if (typeTree == null) throw new ArgumentNullException("typeTree");
m_namespaceUris = namespaceUris;
m_typeTree = typeTree;
m_context = context;
}
示例13: Server_ConnectComplete
/// <summary>
/// Updates the application after connecting to or disconnecting from the server.
/// </summary>
private void Server_ConnectComplete(object sender, EventArgs e)
{
try
{
m_session = ConnectServerCTRL.Session;
if (m_session == null)
{
StartBTN.Enabled = false;
return;
}
// set a suitable initial state.
if (m_session != null && !m_connectedOnce)
{
m_connectedOnce = true;
}
// this client has built-in knowledge of the information model used by the server.
NamespaceTable wellKnownNamespaceUris = new NamespaceTable();
wellKnownNamespaceUris.Append(Namespaces.Methods);
string[] browsePaths = new string[]
{
"1:My Process/1:State",
"1:My Process",
"1:My Process/1:Start"
};
List<NodeId> nodes = ClientUtils.TranslateBrowsePaths(
m_session,
ObjectIds.ObjectsFolder,
wellKnownNamespaceUris,
browsePaths);
// subscribe to the state if available.
if (nodes.Count > 0 && !NodeId.IsNull(nodes[0]))
{
m_subscription = new Subscription();
m_subscription.PublishingEnabled = true;
m_subscription.PublishingInterval = 1000;
m_subscription.Priority = 1;
m_subscription.KeepAliveCount = 10;
m_subscription.LifetimeCount = 20;
m_subscription.MaxNotificationsPerPublish = 1000;
m_session.AddSubscription(m_subscription);
m_subscription.Create();
MonitoredItem monitoredItem = new MonitoredItem();
monitoredItem.StartNodeId = nodes[0];
monitoredItem.AttributeId = Attributes.Value;
monitoredItem.Notification += new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
m_subscription.AddItem(monitoredItem);
m_subscription.ApplyChanges();
}
// save the object/method
if (nodes.Count > 2)
{
m_objectNode = nodes[1];
m_methodNode = nodes[2];
}
InitialStateTB.Text = "1";
FinalStateTB.Text = "100";
StartBTN.Enabled = true;
}
catch (Exception exception)
{
ClientUtils.HandleException(this.Text, exception);
}
}
示例14: GetDefaultTypeDefinitionId
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(TutorialModel.ObjectTypes.GenericSensorType, TutorialModel.Namespaces.Tutorial, namespaceUris);
}
示例15: GetDefaultTypeDefinitionId
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Boiler.ObjectTypes.ValveType, Boiler.Namespaces.Boiler, namespaceUris);
}