Beispiel #1
0
        public Branch(String Name, OPCServer Server = null, Branch Parent = null)
        {
            this._Name = Name;
            this._Children = new List<Branch>();
            this._Leafs = new List<Leaf>();

            if (Parent != null)
            {
                this._HasParent     = true;
                this._Parent = Parent;
                Parent.addChildren(this);
                this.DataChanged += Parent.Branch_DataChanged;
            }
            else
            {
                this._HasParent     = false;
                this._Parent        = null;
            }

            if (Server != null)
            {
                this._OPCGroup = Server.OPCGroups.Add(this._Name);
                this._OPCGroup.UpdateRate   = 200;              //ms
                this._OPCGroup.IsActive     = true;             //Grupo activo
                this._OPCGroup.IsSubscribed = false;
                this._HasOPCGroup           = true;
            }
            else
            {
                this._HasOPCGroup           = false;
                this._OPCGroup              = null;
            }

            this._HasChildren               = false;
            this._HasLeafs                   = false;
        }
Beispiel #2
0
        private void browseLeaf(Branch Parent)
        {
            _OPCBrowser.ShowLeafs();

            if (_OPCBrowser.Count > 0)
            {
                for (int i = 1; i <= _OPCBrowser.Count; i++)
                {
                    Leaf l = new Leaf(Parent: Parent, Name: _OPCBrowser.Item(i), ClientHandle: this.ClientHandle, Browser: this._OPCBrowser);
                }
            }
        }
Beispiel #3
0
        private void browseBranch(Branch Parent)
        {
            _OPCBrowser.ShowBranches();

            if (_OPCBrowser.Count > 0)
            {
                for (int i = 1; i <= _OPCBrowser.Count; i++)
                {
                    _OPCBrowser.MoveDown(_OPCBrowser.Item(i));

                    //string BranchName = _OPCBrowser.CurrentPosition;

                    //while(BranchName.Contains("."))
                    //{
                    //    BranchName = BranchName.Substring(_OPCBrowser.CurrentPosition.IndexOf(".") + 1);
                    //}

                    Branch b = new Branch(Name: _OPCBrowser.CurrentPosition, Server: this._OPCServer, Parent: Parent);

                    browseBranch(b);
                    browseLeaf(b);

                    _OPCBrowser.MoveUp();
                    _OPCBrowser.ShowBranches();
                }
            }
        }
Beispiel #4
0
        public void Conectar()
        {
            this._OPCServer.Connect(_serverName);
            this._OPCServer.ServerShutDown += _OPCServer_ServerShutDown;

            this._OPCBranch = new Branch(Name: _serverName);
            this._OPCBranch.DataChanged += _OPCBranch_DataChanged;

            this._OPCBrowser = this._OPCServer.CreateBrowser();

            this._Connected = true;

            if (Connected != null)
                Connected(this, null);
        }
Beispiel #5
0
        public Leaf(Branch Parent, string Name, int ClientHandle, OPCBrowser Browser)
        {
            this._Parent            = Parent;
            this._Name              = Name;
            this._ClientHandle      = ClientHandle;

            this._Parent.addLeaf(this);

            this._OPCItem           = this._Parent.OPCGroup.OPCItems.AddItem(Browser.GetItemID(this._Name), this._ClientHandle);
            this._OPCItem.IsActive  = true;
        }
Beispiel #6
0
        public void addChildren(Branch branch)
        {
            if (_HasChildren == false)
            {
                this._HasChildren    = true;
            }

            this._Children.Add(branch);
        }