示例#1
0
        /// <summary>
        /// Displays all servers that support the specified specification.
        /// </summary>
        /// <param name="discovery">The discovery.</param>
        /// <param name="specification">The specification.</param>
        /// <param name="filters">The filters.</param>
        /// <param name="SelectContextMenuIsEnabled">if set to <c>true</c> context menu: select is enabled.</param>
        public void ShowAllServers(Opc.IDiscovery discovery, Opc.Specification specification, OpcDa::BrowseFilters filters, bool SelectContextMenuIsEnabled)
        {
            if (discovery == null)
            {
                throw new ArgumentNullException("Discovery cannot be null");
            }
            this.Cursor = Cursors.AppStarting;
            Clear();
            this.m_SelectContextMenuIsEnabled = SelectContextMenuIsEnabled;
            m_discovery = discovery;
            OpcDa::BrowseFilters m_filters = (filters == null) ? new OpcDa::BrowseFilters() : filters;
            //My computer
            ComputerTreeNodes m_localServers = new Computer(this, "localhost", m_filters, specification);

            m_BrowseTV.Nodes.Add(m_localServers);
            m_BrowseTV.SelectedNode = m_localServers;
            m_localServers.Browse(true);
            m_localServers.Expand();
            //Network
            NetworkTreeNode m_localNetwork = new Network(this, "Local Network", m_filters, specification);

            m_BrowseTV.Nodes.Add(m_localNetwork);
            m_BrowseTV.SelectedNode = m_localNetwork;
            m_localNetwork.Browse(true);
            m_localNetwork.Expand();
            this.Cursor = Cursors.Default;
        }
 internal OPCSessionServer(OPCCliConfiguration.ServersRow server, OpcDa::BrowseFilters filters, OPCEnvironment node) :
     base(server.Name, null, node)
 {
     LastEception = null;
     try
     {
         m_Menu = new ContextMenuServer(this);
         Opc.URL url = new Opc.URL(server.URL);
         if (server.GetConnectDataRows().Length > 0)
         {
             m_ConnectData = server.GetConnectDataRows()[0].GetConnectData();
         }
         m_Spcification = new Opc.Specification()
         {
             ID = server.PreferedSpecyficationID, Description = server.PreferedSpecyficationDsc
         };
         Tag = (Server)Factory.GetServerForURL(url, m_Spcification);
         server.GetOptions(this);
         foreach (OPCCliConfiguration.SubscriptionsRow rw in server.GetSubscriptionsRows())
         {
             new SubscriptionTreeNodeSession(rw, this);
         }
         State = state.disconnectd;
     }
     catch (Exception ex) { ReportException(ex); }
 }
        /// <summary>
        /// Displays the browse filters in a non-model dialog.
        /// </summary>
        public void Show(
            Form owner,
            OpcDa::BrowseFilters filters,
            BrowseFiltersChangedCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            Owner      = owner;
            m_callback = callback;

            BrowseFilterCTRL.Value        = filters.BrowseFilter;
            MaxElementsReturnedCTRL.Value = (decimal)filters.MaxElementsReturned;
            ElementNameFilterTB.Text      = filters.ElementNameFilter;
            VendorFilterTB.Text           = filters.VendorFilter;
            ReturnPropertiesCB.Checked    = (filters.PropertyIDs != null || filters.ReturnAllProperties);

            PropertyFiltersCTRL.ReturnAllProperties  = filters.ReturnAllProperties;
            PropertyFiltersCTRL.ReturnPropertyValues = filters.ReturnPropertyValues;
            PropertyFiltersCTRL.PropertyIDs          = filters.PropertyIDs;

            ShowDialog();
        }
        /// <summary>
        /// Invokes the callback an passes the new browse filters.
        /// </summary>
        private void ApplyChanges()
        {
            OpcDa::BrowseFilters filters = new OpcDa::BrowseFilters();

            filters.BrowseFilter        = (OpcDa::browseFilter)BrowseFilterCTRL.Value;
            filters.MaxElementsReturned = (int)MaxElementsReturnedCTRL.Value;
            filters.ElementNameFilter   = ElementNameFilterTB.Text;
            filters.VendorFilter        = VendorFilterTB.Text;

            if (!ReturnPropertiesCB.Checked)
            {
                filters.ReturnAllProperties  = false;
                filters.ReturnPropertyValues = false;
                filters.PropertyIDs          = null;
            }
            else
            {
                filters.ReturnAllProperties  = PropertyFiltersCTRL.ReturnAllProperties;
                filters.ReturnPropertyValues = PropertyFiltersCTRL.ReturnPropertyValues;

                if (!filters.ReturnAllProperties)
                {
                    filters.PropertyIDs = PropertyFiltersCTRL.PropertyIDs;
                }
                else
                {
                    filters.PropertyIDs = null;
                }
            }

            if (m_callback != null)
            {
                m_callback(filters);
            }
        }
示例#5
0
        /// <summary>
        /// Feedback event hamdler: called when the browse filters have changed in an external dialog.
        /// </summary>
        /// <param name="filters">The new filters.</param>
        private void OnBrowseFiltersChanged(OpcDa::BrowseFilters filters)
        {
            //TODO: how to clear filters?
            IBrowse cn = (IBrowse)m_BrowseTV.SelectedNode;

            cn.DefaultBrowseFilters = filters;
        }
示例#6
0
        /// <summary>
        /// Add server to the tree.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="filters">The filters <see cref="OpcDa::BrowseFilters"/>.</param>
        public void AddServer(Server server, OpcDa::BrowseFilters filters)
        {
            var node = new OPCSessionServer(server, m_OPCEnvironment);

            node.DefaultBrowseFilters = filters;
            m_OPCEnvironment.Expand();
        }
示例#7
0
 /// <summary>
 /// Browses for children of the element at the current node.
 /// </summary>
 protected void Browse(AddressSpaceDataBase.TagsTableRow itemID, OpcDa::BrowseFilters filters)
 {
     try
     {
         // begin a browse.
         OpcDa::BrowsePosition position = null;
         foreach (var element in m_Dictionary.Browse(itemID, filters, out position))
         {
             AddBrowseElement(element);
         }
         // loop until all elements have been fetched.
         while (position != null)
         {
             DialogResult result = MessageBox.Show(
                 "More items meeting search criteria exist. Continue browse?",
                 "Browse Items",
                 MessageBoxButtons.YesNo, MessageBoxIcon.Question
                 );
             if (result != DialogResult.Yes)
             {
                 break;
             }
             // fetch next batch of elements, add children.
             foreach (var element in m_Dictionary.BrowseNext(ref position))
             {
                 AddBrowseElement(element);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
示例#8
0
 /// <summary>
 /// Prompts a user to create a new subscription with a modal dialog.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="supportedLocales">The supported locales.</param>
 /// <param name="options">The options.</param>
 public void ShowDialog(Server server, OpcDa::BrowseFilters filters, string[] supportedLocales, IOptions options)
 {
     if (server == null)
     {
         throw new ArgumentNullException("server");
     }
     if (server.IsConnected)
     {
         m_BrowseCTRL.ShowSingleServer((Server)server.Duplicate(), (OpcDa::BrowseFilters)filters.Clone(), true);
     }
     else
     {
         m_Dictionary.DefaultFileName = server.Name;
         if (!m_Dictionary.Open())
         {
             return;
         }
         if (m_Dictionary.Dictionary.ServersTable.Count > 0)
         {
             supportedLocales = m_Dictionary.Dictionary.ServersTable[0].Locales;
         }
         m_BrowseCTRL.ShowSingleServer(m_Dictionary.Dictionary, filters, true);
     }
     ShowDialog(supportedLocales, options);
 }
 /// <summary>
 /// Initializes the control with the specified server.
 /// </summary>
 public void Initialize(OpcDa::BrowseFilters filters, Subscription subscription)
 {
     // Add the subscription at the root of the tree
     if (subscription == null)
     {
         throw new ArgumentNullException("subscription");
     }
     m_SubscriptionTreeView.Nodes.Add(new SubscriptionTreeNode4RW(subscription));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OPCServerTreeNodes"/> class with the specified label text.
 /// </summary>
 /// <param name="server">The server to add.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="view">The <see cref="OPCTreeView"/> to add new object..</param>
 internal OPCBrowseServer(Server server, OpcDa::BrowseFilters filters)
     : base(server.Name, server, filters, server.PreferedSpecyfication)
 {
     CreatedEception = null;
     State           = Tag.IsConnected ? state.connected : state.disconnectd;
     if (Tag.IsConnected)
     {
         this.Browse(true);
         this.Expand();
     }
 }
示例#11
0
        /// <summary>
        /// Displays the edit browse filters dialog.
        /// </summary>
        private void EditFiltersMI_Click(object sender, System.EventArgs e)
        {
            var sn = m_BrowseTV.SelectedNode as IBrowse;
            OpcDa::BrowseFilters cf = sn.DefaultBrowseFilters;

            using (BrowseFiltersDlg cd = new BrowseFiltersDlg())
            {
                cd.Show(Form.ActiveForm, cf, new BrowseFiltersChangedCallback(OnBrowseFiltersChanged));
                //TODO remove applay buton and event handler and assigne result after returning.
            }
        }
 internal OPCBrowseServer(AddressSpaceDataBase.ServersTableRow server, OpcDa::BrowseFilters filters) :
     base(server.URLString, null, filters, Opc.Specification.NONE)
 {
     CreatedEception = null;
     m_ServerDictionaryDescription = server;
     try
     {
         DefaultSpecification = server.Specification;
         Tag = (Server)Factory.GetServerForURL(server.URL, DefaultSpecification);
         m_SupportedLocales = server.Locales;
         State = state.dictionary;
         this.Browse(true);
         this.Expand();
     }
     catch (Exception ex) { ReportException(ex); }
 }
示例#13
0
 /// <summary>
 /// Shows the single server.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="SelectContextMenuIsEnabled">if set to <c>true</c> context menu: select is enabled.</param>
 public void ShowSingleServer(AddressSpaceDataBase dictionary, OpcDa::BrowseFilters filters, bool SelectContextMenuIsEnabled)
 {
     if (dictionary == null)
     {
         throw new ArgumentNullException("Dictionary cannot be null");
     }
     if (filters == null)
     {
         filters = new OpcDa::BrowseFilters();
     }
     this.m_SelectContextMenuIsEnabled = SelectContextMenuIsEnabled;
     Clear();
     if (dictionary.ServersTable.Count > 0)
     {
         m_BrowseTV.Nodes.Add(new OPCBrowseServer(dictionary.ServersTable[0], filters));
     }
 }
 /// <summary>
 /// Opens the dioctionary dialog.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="filters">The filters.</param>
 public static void OpenDioctionaryDialog(Server server, OpcDa::BrowseFilters filters)
 {
     if (server == null)
     {
         return;
     }
     using (DictionaryDialog dic = new DictionaryDialog())
     {
         if (filters == null)
         {
             filters = new OpcDa::BrowseFilters();
             filters.ReturnAllProperties  = true;
             filters.ReturnPropertyValues = true;
         }
         dic.ShowSingleServer(server, filters);
         dic.ShowDialog();
         dic.m_BrowseTreeCtrl.Clear();
     }
 }
示例#15
0
        /// <summary>
        /// Connect and browses the address space for a single server. The server is disposed while disposing this control.
        /// </summary>
        /// <param name="server">The server to show.</param>
        /// <param name="filters">The filters to apply.</param>
        /// <param name="SelectContextMenuIsEnabled">if set to <c>true</c> context menu: select is enabled.</param>
        //TODO define filters while caling
        public void ShowSingleServer(Server server, OpcDa::BrowseFilters filters, bool SelectContextMenuIsEnabled)
        {
            this.Cursor = Cursors.WaitCursor;
            this.m_SelectContextMenuIsEnabled = SelectContextMenuIsEnabled;
            System.Diagnostics.Debug.Assert(!server.IsConnected);
            if ((server == null) || (server.IsConnected))
            {
                throw new ArgumentNullException("server");
            }
            if (filters == null)
            {
                filters = new OpcDa::BrowseFilters();
            }
            Clear();
            var m_singleServer = new OPCBrowseServer(server, filters);

            m_BrowseTV.Nodes.Add(m_singleServer);
            m_BrowseTV.SelectedNode = m_singleServer;
            m_singleServer.Connect();
            this.Cursor = Cursors.Default;
        }
示例#16
0
 /// <summary>
 /// Browses for children of the element at the current node.
 /// </summary>
 protected void Browse(Opc.ItemIdentifier itemID, OpcDa::BrowseFilters filters)
 {
     try
     {
         // begin a browse.
         OpcDa::BrowsePosition position = null;
         OpcDa.BrowseElement[] children = m_Server.Browse(itemID, filters, out position);
         if (children == null)
         {
             return;
         }
         foreach (var element in m_Server.Browse(itemID, filters, out position))
         {
             AddBrowseElement(element);
         }
         // loop until all elements have been fetched.
         while (position != null)
         {
             DialogResult result = MessageBox.Show(
                 "More items meeting search criteria exist. Continue browse?",
                 "Browse Items",
                 MessageBoxButtons.YesNo, MessageBoxIcon.Question
                 );
             if (result != DialogResult.Yes)
             {
                 break;
             }
             // fetch next batch of elements add children.
             foreach (OpcDa::BrowseElement element in m_Server.BrowseNext(ref position))
             {
                 AddBrowseElement(element);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="mBrowseServer" /> class.
 /// </summary>
 /// <param name="parent">The <see cref="OPCBrowseServer" /> parent.</param>
 /// <param name="filters">The filters.</param>
 internal mBrowseServer(OPCBrowseServer parent, OpcDa::BrowseFilters filters)
     : base(parent.Tag)
 {
     mParent = parent;
     Browse(null, filters);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectDataNode{ObjectType, ParentType}"/> class.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="specification">The preferred specification.</param>
 internal ConnectDataNode(string text, ObjectType obj, OpcDa::BrowseFilters filters, Opc.Specification specification)
     : base(text, obj, filters)
 {
     m_Spcification = specification;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DiscoveryNode&lt;ObjectType, ParentType&gt;"/> class.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="obj">The server to add.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="specification">The specification.</param>
 internal DiscoveryNode(string text, ObjectType obj, OpcDa::BrowseFilters filters, Opc.Specification specification)
     : base(text, obj, filters, specification)
 {
 }
示例#20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrowseTreeNode"/> class.
 /// </summary>
 /// <param name="text">The label <see cref="System.Windows.Forms.TreeNode.Text"/> of the new tree node.</param>
 /// <param name="obj">The object coupled with the node.</param>
 /// <param name="filters">The filters to apply.</param>
 internal BrowseTreeNode(string text, ObjectType obj, OpcDa::BrowseFilters filters)
     : base(text, obj)
 {
     pfilters = filters;
     SetForeColor();
 }
 private void ShowSingleServer(Server server, OpcDa::BrowseFilters filters)
 {
     m_PropertiesCTRL.Initialize(null);
     m_Dictionary.DefaultFileName = server.Name;
     m_BrowseTreeCtrl.ShowSingleServer(server, filters, false);
 }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Network"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="computerName">Name of the computer.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="specification">The specification.</param>
 internal Network
     (BrowseTreeCtrl parent, string computerName, OpcDa::BrowseFilters filters, Opc.Specification specification)
     : base(computerName, filters, specification)
 {
     m_Parent = parent;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="mBrowseServer"/> class.
 /// </summary>
 /// <param name="parent">The <see cref="OPCServerTreeNodes"/> parent.</param>
 /// <param name="filters">The filters.</param>
 internal mBrowseDictionary(OPCBrowseServer parent, OpcDa::BrowseFilters filters)
     : base((AddressSpaceDataBase)parent.m_ServerDictionaryDescription.Table.DataSet)
 {
     mParent = parent;
     Browse(null, filters);
 }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="mBrowseDictionary"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="itemID">The item ID.</param>
 /// <param name="filters">The filters.</param>
 internal mBrowseDictionary(BrowseElementNode parent, OpcDa::BrowseFilters filters)
     : base((AddressSpaceDataBase)parent.m_TableRow.Table.DataSet)
 {
     m_Parent = parent;
     base.Browse(parent.m_TableRow, filters);
 }
示例#25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="mBrowseServer"/> class.
 /// </summary>
 /// <param name="parent">The <see cref="Server"/> parent.</param>
 /// <param name="itemID">The <see cref="ItemIdentifier"/> in the address space to browse .</param>
 /// <param name="filters">The filters.</param>
 internal mBrowseServer(BrowseElementNode parent, Opc.ItemIdentifier itemID, OpcDa::BrowseFilters filters)
     : base(parent.FindServer())
 {
     m_Parent = parent;
     base.Browse(itemID, filters);
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComputerTreeNodes"/> class with the specified label text.
 /// </summary>
 /// <param name="computerName">Name of the computer.</param>
 /// <param name="filters">The filters.</param>
 /// <param name="specification">The specification.</param>
 internal ComputerTreeNodes(string computerName, OpcDa::BrowseFilters filters, Opc.Specification specification)
     : base(computerName, null, filters, specification)
 {
     AssignImageIndex();
     AddDummyNode();
 }