Beispiel #1
0
        public DNP3Settings(string iedName, List <KeyValuePair <string, string> > iedData, TreeNode tn, SlaveTypes sType, int sNo)
        {
            string strRoutineName = "DNP3Settings";

            try
            {
                slaveType = sType;
                slaveNum  = sNo;
                SetSupportedAttributes();
                if (tn != null)
                {
                    DNP3TreeNode = tn;
                }
                addListHeaders();
                fillOptions();
                try
                {
                    DType = (DNPType)Enum.Parse(typeof(DNPType), iedName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", iedName);
                }
                if (iedData != null && iedData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> iedkp in iedData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", iedkp.Key, iedkp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(iedkp.Key) != null) //Ajay: 03/07/2018
                            {
                                this.GetType().GetProperty(iedkp.Key).SetValue(this, iedkp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", iedkp.Key, iedkp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                if (tn != null)
                {
                    tn.Text = "DNP3Settings " + "DNP3Settings_" + slaveNum;
                }

                UnsolResNode      = new DNP3UnsolResponse(sType, slaveNum);
                ObjectVarNode     = new DNP3ObjectVariation(sType, slaveNum);
                EncryptionVarNode = new DNP3Encryption(sType, slaveNum);
                DNPSAVarNode      = new DNP3DNPSA(sType, slaveNum);
                DNPSAVarNode      = new DNP3DNPSA(tn, sType, slaveNum);
                //DNPSAUserNode = new DNP3User();

                if (tn != null)
                {
                    tn.Nodes.Add("UnsolicitedResponse", "Unsolicited Response", "UnsolicitedResponse", "UnsolicitedResponse");
                }
                UnsolResNode.parseURNode(null, false);

                if (tn != null)
                {
                    tn.Nodes.Add("ObjectVariation", "Object Variation", "ObjectVariation", "ObjectVariation");
                }
                ObjectVarNode.parseOVNode(null, false);

                if (tn != null)
                {
                    tn.Nodes.Add("Encryption", "Encryption", "Encryption", "Encryption");
                }
                EncryptionVarNode.parseOVNode(null, false);

                if (tn != null)
                {
                    tn.Nodes.Add("DNPSA", "DNPSA", "DNPSA", "DNPSA");
                }
                //tn.Nodes[3].Nodes.Add("USERCONFUser", "USERCONF User", "USERCONFUser", "USERCONFUser");
                DNPSAVarNode.parseOVNode(null, tn);

                refreshList();
                //ucied.lblIED.Text = "IED Details (Unit: " + unitID.ToString() + ")";
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        public DNP3Settings(XmlNode iNode, TreeNode tn, SlaveTypes sType, int sNo, bool imported)
        {
            string strRoutineName = "DNP3Settings";

            try
            {
                slaveType = sType;
                slaveNum  = sNo;
                SetSupportedAttributes();
                if (tn != null)
                {
                    DNP3TreeNode = tn;
                }
                addListHeaders(); fillOptions();
                try
                {
                    DType = (DNPType)Enum.Parse(typeof(DNPType), iNode.Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", iNode.Name);
                }
                foreach (XmlAttribute item in iNode.Attributes)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                    try
                    {
                        if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018
                        {
                            this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", item.Name, item.Value);
                    }
                }
                // if (tn != null) tn.Text = "DNPSettings " + this.Description;
                if (tn != null)
                {
                    tn.Text = "DNP3Settings " + "DNP3Settings_" + slaveNum;
                }
                UnsolResNode      = new DNP3UnsolResponse(sType, slaveNum);
                ObjectVarNode     = new DNP3ObjectVariation(sType, slaveNum);
                EncryptionVarNode = new DNP3Encryption(sType, slaveNum);
                DNPSAVarNode      = new DNP3DNPSA(sType, slaveNum);

                if (tn != null)
                {
                    tn.Nodes.Add("UnsolicitedResponse", "Unsolicited Response", "UnsolicitedResponse", "UnsolicitedResponse");
                }
                //UnsolResNode.parseURNode(iNode.ChildNodes[0], false);
                UnsolResNode.parseURNode(iNode, false);
                if (tn != null)
                {
                    tn.Nodes.Add("ObjectVariation", "Object Variation", "ObjectVariation", "ObjectVariation");
                }
                //ObjectVarNode.parseOVNode(iNode.ChildNodes[0], false);
                ObjectVarNode.parseOVNode(iNode, false);
                if (tn != null)
                {
                    tn.Nodes.Add("Encryption", "Encryption", "Encryption", "Encryption");
                }
                //EncryptionVarNode.parseOVNode(iNode.ChildNodes[0], false);
                EncryptionVarNode.parseOVNode(iNode, false);
                if (tn != null)
                {
                    tn.Nodes.Add("DNPSA", "DNPSA", "DNPSA", "DNPSA");
                }
                //tn.Nodes[3].Nodes.Add("USERCONFUser", "USERCONF User", "USERCONFUser", "USERCONFUser");
                DNPSAVarNode.parseOVNode(iNode, tn);
                //DNPSAVarNode.parseOVNode(iNode, tn);
                refreshList();
                //ucied.lblIED.Text = "IED Details (Unit: " + unitID.ToString() + ")";
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }