Main Content

getnamespace

(To be removed) OPC DA server name space

Support for the OPC Data Access (DA) standard will be removed in a future release. Instead use OPC Unified Architecture (UA). See Version History.

Description

S = getnamespace(DAObj) returns the entire name space of the server associated with the data access (opcda) object specified by DAObj. S is a recursive structure array representing the name space of the server. Each element of S is a node in the name space. S contains the fields:

  • Name — a descriptive name

  • FullyQualifiedID — the fully qualified ItemID of that node

  • NodeType — defines the node as a 'branch' node (containing other nodes) or 'leaf' node (containing no other nodes)

  • Nodes — a structure array with the same fields as S, representing the nodes contained in this branch of the name space.

Use flatnamespace to flatten the hierarchical name space.

S = getnamespace(DAObj,'Filter1',Val1,'Filter2',Val2, ...) allows you to filter the retrieved name space based on a number of available browse filters. Available filters are described in the table in Browse Filters.

example

Examples

collapse all

  1. Get the entire name space for the Matrikon™ Simulation Server on the local host:

    da = opcda('localhost','Matrikon.OPC.Simulation');
    connect(da);
    nsFull = getnamespace(da)
  2. Get only the first level of the name space:

    nsPart = getnamespace(da,'Depth',1)
  3. Add the nodes contained in the first branch of the name space to the existing structure:

    nsPart(1).Nodes = getnamespace(da, ...
       'StartItemID', nsPart(1).FullyQualifiedID, ...
       'Depth',1);

Tips

BrowseFilter

Description

'StartItemID'

Specify the FullyQualifiedID of a branch node, as a character vector or string. Only nodes contained in that branch node will be returned. Some OPC servers do not support partial name space retrieval based on this option: An error is generated if you attempt to use the 'StartItemID' browse filter on such a server.

'Depth'

Specify the depth of the name space that you want returned. A 'Depth' value of 1 returns only the nodes contained in the starting position. A 'Depth' value of 2 returns the nodes contained in the starting position and all of their nodes. A 'Depth' value of Inf returns all nodes. When combined with the 'StartItemID' filter, the 'Depth' filter provides a useful way to investigate a name server hierarchy one layer at a time.

'AccessRights'

Restricts the search to leaf nodes with particular access right characteristics. Specify 'read' to return nodes that include the read access right, and 'write' to return nodes that include the write access right. An empty character vector ('') returns nodes with any access rights. Note that branch nodes will still be returned in the name space, in order to contain the leaf nodes that have the requested access rights.

'DataType'

Restricts the search to nodes with a particular canonical data type. Valid data types are 'double', 'single', 'int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32', 'logical', 'currency', and 'date'. Use the 'DataType' filter to find server items with a specific data type, such as 'double' or 'date'. Note that branch nodes will still be returned in the name space, in order to contain the leaf nodes that have the required data type.

Version History

Introduced before R2006a

expand all

See Also

Functions