public bool DoBrowse() { try { OPCNAMESPACETYPE opcorgi = theSrv.QueryOrganization(); // fill TreeView with all treeOpcItems.Nodes.Clear(); TreeNode tnRoot = new TreeNode(rootname, 0, 1); if (opcorgi == OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL) { theSrv.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, ""); // to root RecurBrowse(tnRoot, 1); } treeOpcItems.Nodes.Add(tnRoot); tnRoot.ExpandAll(); // expand all nodes ([+] -> [-]) tnRoot.EnsureVisible(); // make the root visible // preselect root (dummy) treeOpcItems.SelectedNode = tnRoot; // force treeOpcItems_AfterSelect } catch (COMException /* eX */) { MessageBox.Show(this, "browse error!", "DoBrowse", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }
public void BrowseServerAndAddItems() { _itemAccessMutex.WaitOne(); try { List <string> l_ItemIds = new List <string>(); OpcNamespaceType l_ServerOrganization = _server.QueryOrganization(); // Browse to root _server.ChangeBrowsePosition(OpcBrowseDirection.OPC_BROWSE_TO, ""); if (l_ServerOrganization == OpcNamespaceType.OPC_NS_HIERARCHIAL) { RecursiveServerHierarchialBrowse(ref l_ItemIds); } else { RecursiveServerFlatBrowse(ref l_ItemIds); } ValidateItemIds(ref l_ItemIds); AddItems(l_ItemIds); } catch (Exception l_Ex) { Disconnect(); throw l_Ex; } finally { _itemAccessMutex.ReleaseMutex(); } }
public void TestQueryOrganization01() { //testing -- OpcServer opcServer = new OpcServer(); Accessor opcServerAccessor = ReflectionAccessor.Wrap(opcServer); opcServerAccessor.SetField("ifServer", new OPCServerComClass()); opcServerAccessor.SetField("ifBrowse", ((IOPCBrowseServerAddressSpace)opcServerAccessor.GetField("ifServer"))); //Test Procedure Call OPCNAMESPACETYPE spaceType = opcServer.QueryOrganization(); //Post Condition Check }
private bool DoBrowse() { try { OPCNAMESPACETYPE opcorgi = _theSrv.QueryOrganization(); // fill Tree with all OpcNamespacesTree.Clear(); if (opcorgi == OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL) { _theSrv.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, ""); // to root RecurBrowse(OpcNamespacesTree, 1); } } catch (COMException ex) { throw ex; } return(true); }