Example #1
0
        public ConnectedApNode(tConnectedAP apoint)
        {
            if (apoint == null)
            {
                return;
            }

            Name = apoint.iedName + "." + apoint.apName;
            Tag  = apoint;
            if (apoint.Address != null)
            {
                var n = new AddressNode(apoint.Address);
                this.Nodes.Add(n);
            }
            if (apoint.GSE != null)
            {
                for (int i = 0; i < apoint.GSE.Length; i++)
                {
                    var n = new GseNode(apoint.GSE[i]);
                    n.Index = i;
                    this.Nodes.Add(n);
                }
            }
            if (apoint.SMV != null)
            {
                for (int i = 0; i < apoint.SMV.Length; i++)
                {
                    var n = new SmvNode(apoint.SMV[i]);
                    n.Index = i;
                    this.Nodes.Add(n);
                }
            }
        }
Example #2
0
        /// <summary>
        /// This method shows the information to edit all values pre-configured for SMV,
        /// SMVControl and SMVoptions classes.
        /// </summary>
        /// <param name="sMVControl">
        /// Sampled Value Controls class.
        /// </param>
        /// <param name="sMVOptions">
        /// Sampled Value Options class.
        /// </param>
        /// <param name="smv">
        /// Sampled Value class.
        /// </param>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        public void SMVHandler(object sMVControl, object sMVOptions, string[] smv, TreeNode treeSCL)
        {
            tSampledValueControl sMVCtrl = (tSampledValueControl)sMVControl;

            sMVCtrl.datSet = this.datSet.SelectedItem.ToString();
            SCL sCL = (SCL)treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;
            tSampledValueControlSmvOpts sMVOpts = (tSampledValueControlSmvOpts)sMVOptions;
            TreeNode nodeSMVControl             = new TreeNode();
            TreeNode nodeSMV;

            nodeSMVControl.Name = sMVCtrl.name;
            nodeSMVControl.Text = sMVCtrl.name;
            nodeSMVControl.Tag  = sMVCtrl;
            TreeNode nodetSMV;
            tSMV     tsmv = new tSMV();

            if (this.objectManagement.AddObjectToArrayObjectOfParentObject(sMVCtrl, treeSCL.Tag))
            {
                if (treeSCL.TreeView.SelectedNode.Tag is tLN0)
                {
                    tLN0     ln0       = (tLN0)treeSCL.Tag;
                    TreeNode parentSMV = new TreeNode();
                    parentSMV.Name = "tSampledValueControl[]";
                    parentSMV.Text = "SampledValueControl";
                    parentSMV.Tag  = ln0.SampledValueControl;
                    treeSCL.Nodes.Add(parentSMV);
                    treeSCL = parentSMV;
                }
                else
                {
                    treeSCL = treeSCL.TreeView.SelectedNode;
                }
                treeSCL.Nodes.Add(nodeSMVControl);
                this.objectManagement.AddObjectToSCLObject(sMVOpts, sMVCtrl);
                TreeNode nodeOP = new TreeNode();
                nodeOP.Name = "SMVOpts";
                nodeOP.Text = "SMVOpts";
                nodeOP.Tag  = sMVOpts;
                nodeSMVControl.Nodes.Add(nodeOP);
            }
            treeViewSCL.CreateCommNode(sCL, treeSCL);
            TreeNode connAPRef = new TreeNode();

            for (int i = 0; i < sCL.Communication.SubNetwork.Length; i++)
            {
                connAPRef = treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, apParentName, iedParentName, "apName", "iedName");
                if (connAPRef == null && sCL.Communication.SubNetwork[i].ConnectedAP == null)
                {
                    treeViewSCL.CreateConnectedNode(sCL, treeSCL, apParentName, iedParentName, i);
                    connAPRef = treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, apParentName, iedParentName, "apName", "iedName");
                }
                if (connAPRef != null)
                {
                    tsmv.cbName = sMVCtrl.name;
                    tsmv.ldInst = smv[0];
                    tsmv.desc   = smv[5];
                    nodeSMV     = new TreeNode();
                    this.objectManagement.AddObjectToArrayObjectOfParentObject(tsmv, connAPRef.Tag);
                    if (connAPRef.Nodes["tSMV[]"] == null)
                    {
                        tConnectedAP tconn = (tConnectedAP)connAPRef.Tag;
                        nodeSMV.Text = "SMV";
                        nodeSMV.Name = "tSMV[]";
                        nodeSMV.Tag  = tconn.SMV;
                        connAPRef.Nodes.Add(nodeSMV);
                    }
                    else
                    {
                        nodeSMV = connAPRef.Nodes["tSMV[]"];
                    }
                    nodetSMV      = new TreeNode();
                    nodetSMV.Text = sMVCtrl.name;
                    nodetSMV.Name = smv[0] + "." + sMVCtrl.name;
                    nodetSMV.Tag  = tsmv;
                    nodeSMV.Nodes.Add(nodetSMV);
                    AttributeReferences aReferences = new AttributeReferences();
                    aReferences.Insert(tsmv, nodeSMVControl);
                    tAddress taddr = new tAddress();
                    this.objectManagement.AddObjectToSCLObject(taddr, tsmv);
                    TreeNode nodeAddress = new TreeNode();
                    nodeAddress.Text = "Address";
                    nodeAddress.Name = "Address";
                    nodeAddress.Tag  = taddr;
                    nodetSMV.Nodes.Add(nodeAddress);
                    TreeNode nodetP = new TreeNode();
                    nodetP.Name = "tP[]";
                    nodetP.Text = "P";
                    nodeAddress.Nodes.Add(nodetP);
                    Utils utilsOM = new Utils();

                    tP            t_mac  = new tP();
                    tP_MACAddress t_mac_ = new tP_MACAddress();
                    this.objectManagement.EmptySourcetoDestinyObject(t_mac_, t_mac);
                    t_mac.Value = this.mac.Text;
                    utilsOM.AddTPTreeNode(t_mac, "tP_mac", "tP", taddr, nodetP);

                    tP       t_app  = new tP();
                    tP_APPID t_app_ = new tP_APPID();
                    this.objectManagement.EmptySourcetoDestinyObject(t_app_, t_app);
                    t_app.Value = this.appID.Text;
                    utilsOM.AddTPTreeNode(t_app, "tP_app", "tP", taddr, nodetP);

                    tP t_vlap = new tP();
                    tP_VLANPRIORITY t_vlap_ = new tP_VLANPRIORITY();
                    this.objectManagement.EmptySourcetoDestinyObject(t_vlap_, t_vlap);
                    t_vlap.Value = this.vLANP.Text;
                    utilsOM.AddTPTreeNode(t_vlap, "tP_vlanp", "tP", taddr, nodetP);

                    tP        t_vlani  = new tP();
                    tP_VLANID t_vlani_ = new tP_VLANID();
                    this.objectManagement.EmptySourcetoDestinyObject(t_vlani_, t_vlani);
                    t_vlani.Value = this.vLANI.Text;
                    utilsOM.AddTPTreeNode(t_vlani, "tP_vlani", "tP", taddr, nodetP);
                }
            }
        }
Example #3
0
        /// <summary>
        /// This method Adds a new Node. shows the information to edit all values pre-configured for GSE and GSEControl classes.
        /// </summary>
        /// <param name="treeSCL">
        /// TreeNode reference.
        /// </param>
        /// <param name="gsc">
        /// Array of GSEControl values
        /// </param>
        public void AddGSE()
        {
            // Add a GSEControl to IED
            tGSEControl cgse = new tGSEControl();

            cgse.name   = this.cbName.Text;
            cgse.appID  = this.appId.Text;
            cgse.desc   = this.desc.Text;
            cgse.type   = tGSEControlTypeEnum.GOOSE;
            cgse.datSet = this.datSet.SelectedItem.ToString();
            ld.LN0.AddGSEControl(cgse);
            if (!this.tvscl.AddGSEControlNode(ied.name, ap.name, ld.inst, cgse))
            {
                MessageBox.Show("Can't update Tree for new GSEControl",
                                "Adding a New GOOSE",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            // Add a GSE to Network
            tGSE gse = new tGSE();

            gse.cbName = cgse.name;
            gse.desc   = cgse.desc;
            gse.ldInst = ld.inst;
            gse.InitAddess();
            if (gse.Address != null && gse.Address.P != null)
            {
                for (int i = 0; i < gse.Address.P.Length; i++)
                {
                    if (gse.Address.P[i].typeEnum == tPTypeEnum.MAC_Address)
                    {
                        gse.Address.P[i].Value = this.mac.Text;
                    }
                    if (gse.Address.P[i].typeEnum == tPTypeEnum.APPID)
                    {
                        gse.Address.P[i].Value = this.appId.Text;
                    }
                    if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_PRIORITY)
                    {
                        gse.Address.P[i].Value = this.vLANP.Text;
                    }
                    if (gse.Address.P[i].typeEnum == tPTypeEnum.VLAN_ID)
                    {
                        gse.Address.P[i].Value = this.vLANI.Text;
                    }
                }
            }
            int iedindex = this.scl.GetIED(ied.name);
            var lcap     = this.scl.GetIEDConnectedAP(iedindex);

            for (int i = 0; i < lcap.Count; i++)
            {
                IEDConnectedAP iap = (IEDConnectedAP)lcap[i];
                tConnectedAP   cap = this.scl.GetConnectedAP(iap.subnetwork, iap.connectedap);
                if (cap.apName.Equals(ap.name) &&
                    cap.iedName.Equals(ied.name))
                {
                    cap.AddGSE(gse);
                    System.Console.WriteLine("Adding a new GSE Node...");
                    if (!this.tvscl.AddGSENode(ied.name, ap.name, ld.inst, gse))
                    {
                        MessageBox.Show("Can't update Tree new GSE",
                                        "Adding a New GOOSE",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
        }
        /// <summary>
        /// This method shows the information to edit all values pre-configured for
        /// subnetwork, connectedAP and tps
        /// </summary>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        /// <param name="apParentName">
        /// Name of Access Point where belongs the communication configurations.
        /// </param>
        /// <param name="iedParentName">
        /// Name of IED where belongs the communication configurations.
        /// </param>
        private void CommunicationHandler(TreeNode treeSCL, string apParentName, string iedParentName)
        {
            tConnectedAP tconn = new tConnectedAP();
            tSubNetwork  tsub  = new tSubNetwork();

            tsub.desc = this.descSubNet.Text;
            String[] comm  = new String[6];
            String[] names = new String[6];
            this.nameSubNet.Text = this.nameSubNetCB.SelectedItem.ToString();
            tsub.name            = this.nameSubNet.Text;
            comm[0]  = this.ip.Text;
            comm[1]  = this.mask.Text;
            comm[2]  = this.gateway.Text;
            comm[3]  = this.tsel.Text;
            comm[4]  = this.psel.Text;
            comm[5]  = this.ssel.Text;
            names[0] = "IP";
            names[1] = "IP_SUBNET";
            names[2] = "IP_GATEWAY";
            names[3] = "OSI_TSEL";
            names[4] = "OSI_PSEL";
            names[5] = "OSI_SSEL";
            for (int i = 0; i < this.scl.Communication.SubNetwork.Length; i++)
            {
                if (this.scl.Communication.SubNetwork[i].name == this.nameSubNetCB.SelectedItem.ToString())
                {
                    this.scl.Communication.SubNetwork[i].name = this.nameSubNet.Text;
                    this.scl.Communication.SubNetwork[i].desc = this.descSubNet.Text;
                    TreeNode connected = this.treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, apParentName, iedParentName, "apName", "iedName");
                    if (connected != null)
                    {
                        tconn         = (tConnectedAP)connected.Tag;
                        tconn.iedName = iedParentName;
                        tconn.apName  = apParentName;
                        if (this.objectManagement.ModifyObjectOfArrayObjectOfParentObject(tconn, connected.Index, connected.Parent.Parent.Tag))
                        {
                            if (connected.FirstNode != null)
                            {
                                object   arrayOf = connected.FirstNode.Tag;
                                tP[]     arr     = (tP[])this.objectManagement.FindVariable(arrayOf, "P");
                                tAddress tad     = new tAddress();
                                tconn.Address   = tad;
                                tconn.Address.P = arr;
                                connected.Tag   = tconn;
                                if (arr != null)
                                {
                                    for (int j = 0; j < arr.Length; j++)
                                    {
                                        for (int k = 0; k < names.Length; k++)
                                        {
                                            if (arr[j].type.ToString() == names[k])
                                            {
                                                arr[j].Value = comm[k].ToString();
                                            }
                                        }
                                    }
                                    this.objectManagement.ModifyObjectOfArrayObjectOfParentObject((tP[])arr, 0, tconn.Address.P);
                                }
                                else
                                {
                                    DrawCommunication();
                                }
                            }
                            else
                            {
                                DrawCommunication();
                            }
                        }
                    }
                    else
                    {
                        DrawCommunication();
                    }
                }
            }
        }