public void parseVMNode(XmlNode vmNode)
        {
            //Parse n store values...
            Utils.WriteLine(VerboseLevel.DEBUG, "vmNode name: '{0}'", vmNode.Name);
            if (vmNode.Attributes != null)
            {
                //First set the root element value...
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), vmNode.Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", vmNode.Name);
                }

                foreach (XmlAttribute item in vmNode.Attributes)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                    try
                    {
                        if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }
            else if (vmNode.NodeType == XmlNodeType.Comment)
            {
                isNodeComment = true;
                comment       = vmNode.Value;
            }

            foreach (XmlNode node in vmNode)
            {
                //Utils.WriteLine("***** node type: {0}", node.NodeType);
                if (iedList.Count == 1)//IMP: Since only one node should be there for 'IED'
                {
                    //Already added...
                    iedList[0].parseIEDNode(node);
                }
                else
                {
                    if (node.NodeType == XmlNodeType.Comment)
                    {
                        continue;                                      //IMP: Ignore comments in file...
                    }
                    TreeNode tmp = VirtualMasterTreeNode.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
                    iedList.Add(new IED(node, tmp, MasterTypes.Virtual, Int32.Parse(MasterNum), false));
                }
            }
            refreshList();
        }
Beispiel #2
0
        public LoadProfileMaster(string lpName, List <KeyValuePair <string, string> > lpData, TreeNode tn)
        {
            uclp.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
            uclp.lvIEDListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvIEDList_ItemCheck);
            uclp.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
            uclp.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
            uclp.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
            uclp.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
            uclp.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
            uclp.btnFirstClick        += new System.EventHandler(this.btnFirst_Click);
            uclp.btnPrevClick         += new System.EventHandler(this.btnPrev_Click);
            uclp.btnNextClick         += new System.EventHandler(this.btnNext_Click);
            uclp.btnLastClick         += new System.EventHandler(this.btnLast_Click);
            uclp.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
            addListHeaders();
            this.fillOptions();

            //First set the root element value...
            try
            {
                mType = (masterType)Enum.Parse(typeof(masterType), lpName);
            }
            catch (System.ArgumentException)
            {
                Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", lpName);
            }

            //Parse n store values...
            if (lpData != null && lpData.Count > 0)
            {
                foreach (KeyValuePair <string, string> mbkp in lpData)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", mbkp.Key, mbkp.Value);
                    try
                    {
                        if (this.GetType().GetProperty(mbkp.Key) != null)
                        {
                            this.GetType().GetProperty(mbkp.Key).SetValue(this, mbkp.Value);
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", mbkp.Key, mbkp.Value);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }

            if (tn != null)
            {
                tn.Nodes.Clear();
            }
            LoadProfileTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...
            refreshList();
            uclp.lblIED.Text = "IED List (Master No: " + this.masterNum + ")";
        }
        public VirtualMaster(XmlNode mNode, TreeNode tn)
        {
            VirtualMasterTreeNode = tn;//Save local copy so we can use it later...
            addListHeaders();
            fillOptions();

            //Parse n store values...
            Utils.WriteLine(VerboseLevel.DEBUG, "mNode name: '{0}'", mNode.Name);
            if (mNode.Attributes != null)
            {
                //First set the root element value...
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), mNode.Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mNode.Name);
                }

                foreach (XmlAttribute item in mNode.Attributes)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                    try
                    {
                        if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }
            else if (mNode.NodeType == XmlNodeType.Comment)
            {
                isNodeComment = true;
                comment       = mNode.Value;
            }

            tn.Nodes.Clear();
            foreach (XmlNode node in mNode)
            {
                //Utils.WriteLine("***** node type: {0}", node.NodeType);
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;                                      //IMP: Ignore comments in file...
                }
                TreeNode tmp = tn.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
                iedList.Add(new IED(node, tmp, MasterTypes.Virtual, Int32.Parse(MasterNum), false));
            }
            refreshList();
        }
        public PLUMaster(XmlNode sNode, TreeNode tn)
        {
            this.fillOptions();
            //Parse n store values...
            Utils.WriteLine(VerboseLevel.DEBUG, "sNode name: '{0}'", sNode.Name);
            if (sNode.Attributes != null)
            {
                //First set the root element value...
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), sNode.Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name);
                }

                foreach (XmlAttribute item in sNode.Attributes)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                    try
                    {
                        if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }
            else if (sNode.NodeType == XmlNodeType.Comment)
            {
                isNodeComment = true;
                comment       = sNode.Value;
            }
            //Not Used: uciec.lblMain.Text += slaveNum;
        }
        public PLUMaster(string s104Name, List <KeyValuePair <string, string> > s104Data, TreeNode tn)
        {
            this.fillOptions();

            //IMP: Use tn when we want to further add child nodes to 'IEC104'. Check if it's null...

            //First set the root element value...
            try
            {
                mType = (masterType)Enum.Parse(typeof(masterType), s104Name);
            }
            catch (System.ArgumentException)
            {
                Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", s104Name);
            }

            //Parse n store values...
            if (s104Data != null && s104Data.Count > 0)
            {
                foreach (KeyValuePair <string, string> s104kp in s104Data)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", s104kp.Key, s104kp.Value);
                    try
                    {
                        if (this.GetType().GetProperty(s104kp.Key) != null) //Ajay: 10/08/2018
                        {
                            this.GetType().GetProperty(s104kp.Key).SetValue(this, s104kp.Value);
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", s104kp.Key, s104kp.Value);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }

            //Not Used: uciec.lblMain.Text += slaveNum;
        }
        public IEC101Master(string m101Name, List <KeyValuePair <string, string> > m101Data, TreeNode tn)
        {
            string strRoutineName = "IEC101Master";

            try
            {
                uciec101.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
                uciec101.lvIEDListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvIEDList_ItemCheck);
                uciec101.BtnDeleteAllClick    += new System.EventHandler(this.BtnDeleteAll_Click);
                uciec101.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
                uciec101.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
                uciec101.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
                uciec101.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
                uciec101.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
                uciec101.btnFirstClick        += new System.EventHandler(this.btnFirst_Click);
                uciec101.btnPrevClick         += new System.EventHandler(this.btnPrev_Click);
                uciec101.btnNextClick         += new System.EventHandler(this.btnNext_Click);
                uciec101.btnLastClick         += new System.EventHandler(this.btnLast_Click);
                uciec101.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
                addListHeaders();
                fillOptions();
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), m101Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", m101Name);
                }
                if (m101Data != null && m101Data.Count > 0)
                {
                    foreach (KeyValuePair <string, string> m101kp in m101Data)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", m101kp.Key, m101kp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(m101kp.Key) != null) //Ajay: 10/08/2018
                            {
                                this.GetType().GetProperty(m101kp.Key).SetValue(this, m101kp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", m101kp.Key, m101kp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                if (tn != null)
                {
                    tn.Nodes.Clear();
                }
                IEC101TreeNode = tn;
                if (tn != null)
                {
                    tn.Text = "IEC101 " + this.Description;
                }
                refreshList();
                uciec101.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public IEC101Master(XmlNode mNode, TreeNode tn)
        {
            string strRoutineName = "IEC101Master";

            try
            {
                uciec101.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
                uciec101.lvIEDListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvIEDList_ItemCheck);
                uciec101.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
                uciec101.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
                uciec101.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
                uciec101.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
                uciec101.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
                uciec101.btnFirstClick        += new System.EventHandler(this.btnFirst_Click);
                uciec101.btnPrevClick         += new System.EventHandler(this.btnPrev_Click);
                uciec101.btnNextClick         += new System.EventHandler(this.btnNext_Click);
                uciec101.btnLastClick         += new System.EventHandler(this.btnLast_Click);
                uciec101.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
                addListHeaders();
                fillOptions();
                Utils.WriteLine(VerboseLevel.DEBUG, "mNode name: '{0}'", mNode.Name);
                if (mNode.Attributes != null)
                {
                    try
                    {
                        mType = (masterType)Enum.Parse(typeof(masterType), mNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mNode.Name);
                    }
                    foreach (XmlAttribute item in mNode.Attributes)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                        try
                        {
                            if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                else if (mNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = mNode.Value;
                }
                if (tn != null)
                {
                    tn.Nodes.Clear();
                }
                IEC101TreeNode = tn;
                tn.Text        = "IEC101 " + this.Description;
                foreach (XmlNode node in mNode)
                {
                    if (node.NodeType == XmlNodeType.Comment)
                    {
                        continue;                                      //IMP: Ignore comments in file...
                    }
                    TreeNode tmp = tn.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
                    iedList.Add(new IED(node, tmp, MasterTypes.IEC101, Int32.Parse(MasterNum), false));
                }
                refreshList();
                uciec101.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ADRMaster(string ADRName, List <KeyValuePair <string, string> > ADRData, TreeNode tn)
        {
            string strRoutineName = "ADRMaster";

            try
            {
                ucadr.btnAdd.Click          += new System.EventHandler(this.btnAdd_Click);
                ucadr.btnDelete.Click       += new System.EventHandler(this.btnDelete_Click);
                ucadr.btnExportIED.Click    += new System.EventHandler(this.btnExportIED_Click);
                ucadr.btnImportIED.Click    += new System.EventHandler(this.btnImportIED_Click);
                ucadr.btnDoneClick          += new System.EventHandler(this.btnDone_Click);
                ucadr.btnCancelClick        += new System.EventHandler(this.btnCancel_Click);
                ucadr.lvIEDList.DoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
                addListHeaders();
                fillOptions();
                //First set the root element value...
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), ADRName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", ADRName);
                }
                //Parse n store values...
                if (ADRData != null && ADRData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> ADRkp in ADRData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", ADRkp.Key, ADRkp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(ADRkp.Key) != null) //Ajay: 10/08/2018
                            {
                                this.GetType().GetProperty(ADRkp.Key).SetValue(this, ADRkp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", ADRkp.Key, ADRkp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                if (tn != null)
                {
                    tn.Nodes.Clear();
                }
                ADRMasterTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...
                if (tn != null)
                {
                    tn.Text = "ADR " + this.Description;               //Now since we have parsed, we can name the treenode...
                }
                refreshList();
                ucadr.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
            }
            catch (Exception Ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + Ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public MODBUSMaster(string mbName, List <KeyValuePair <string, string> > mbData, TreeNode tn)
        {
            ucmod.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
            ucmod.lvIEDListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvIEDList_ItemCheck);
            ucmod.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
            ucmod.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
            ucmod.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
            ucmod.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
            ucmod.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
            ucmod.btnFirstClick        += new System.EventHandler(this.btnFirst_Click);
            ucmod.btnPrevClick         += new System.EventHandler(this.btnPrev_Click);
            ucmod.btnNextClick         += new System.EventHandler(this.btnNext_Click);
            ucmod.btnLastClick         += new System.EventHandler(this.btnLast_Click);
            ucmod.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
            addListHeaders();
            this.fillOptions();

            //First set the root element value...
            try
            {
                mType = (masterType)Enum.Parse(typeof(masterType), mbName);
            }
            catch (System.ArgumentException)
            {
                Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mbName);
            }

            //Parse n store values...
            if (mbData != null && mbData.Count > 0)
            {
                foreach (KeyValuePair <string, string> mbkp in mbData)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", mbkp.Key, mbkp.Value);
                    try
                    {
                        if (this.GetType().GetProperty(mbkp.Key) != null) //Ajay: 10/08/2018
                        {
                            this.GetType().GetProperty(mbkp.Key).SetValue(this, mbkp.Value);
                        }
                    }
                    catch (System.NullReferenceException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", mbkp.Key, mbkp.Value);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }

            if (tn != null)
            {
                tn.Nodes.Clear();
            }
            MODBUSTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...

            //Now since we have parsed, we can name the treenode...
            //if (tn != null) tn.Text = "MODBUS " + this.Description;
            if (tn != null)
            {
                tn.Text = "MODBUS " + this.Description;
            }

            /* While manually adding, no IED initially...
             * foreach (XmlNode node in mNode)
             * {
             *  //Utils.WriteLine("***** node type: {0}", node.NodeType);
             *  if (node.NodeType == XmlNodeType.Comment) continue;//IMP: Ignore comments in file...
             *  TreeNode tmp = tn.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
             *  iedList.Add(new IED(node, tmp));
             * }
             */
            refreshList();
            ucmod.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
        }
        public MODBUSMaster(XmlNode mNode, TreeNode tn)
        {
            ucmod.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
            ucmod.lvIEDListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvIEDList_ItemCheck);
            ucmod.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
            ucmod.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
            ucmod.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
            ucmod.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
            ucmod.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
            ucmod.btnFirstClick        += new System.EventHandler(this.btnFirst_Click);
            ucmod.btnPrevClick         += new System.EventHandler(this.btnPrev_Click);
            ucmod.btnNextClick         += new System.EventHandler(this.btnNext_Click);
            ucmod.btnLastClick         += new System.EventHandler(this.btnLast_Click);
            ucmod.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
            addListHeaders();
            this.fillOptions();

            //Parse n store values...
            Utils.WriteLine(VerboseLevel.DEBUG, "mNode name: '{0}'", mNode.Name);
            if (mNode.Attributes != null)
            {
                //First set the root element value...
                try
                {
                    mType = (masterType)Enum.Parse(typeof(masterType), mNode.Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mNode.Name);
                }

                foreach (XmlAttribute item in mNode.Attributes)
                {
                    Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                    try
                    {
                        if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/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);
                    }
                }
                Utils.Write(VerboseLevel.DEBUG, "\n");
            }
            else if (mNode.NodeType == XmlNodeType.Comment)
            {
                isNodeComment = true;
                comment       = mNode.Value;
            }

            if (tn != null)
            {
                tn.Nodes.Clear();
            }
            MODBUSTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...

            //Now since we have parsed, we can name the treenode...
            if (tn != null)
            {
                tn.Text = "MODBUS " + this.Description;
            }

            foreach (XmlNode node in mNode)
            {
                //Utils.WriteLine("***** node type: {0}", node.NodeType);
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;                                      //IMP: Ignore comments in file...
                }
                TreeNode tmp = tn.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
                iedList.Add(new IED(node, tmp, MasterTypes.MODBUS, Int32.Parse(MasterNum), false));
            }
            refreshList();
            ucmod.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
        }
Beispiel #11
0
        public ADRMaster(XmlNode mNode, TreeNode tn)
        {
            string strRoutineName = "ADRMaster:ADRMaster";

            try
            {
                ucadr.btnAddClick          += new System.EventHandler(this.btnAdd_Click);
                ucadr.btnDeleteClick       += new System.EventHandler(this.btnDelete_Click);
                ucadr.btnExportIEDClick    += new System.EventHandler(this.btnExportIED_Click);
                ucadr.btnImportIEDClick    += new System.EventHandler(this.btnImportIED_Click);
                ucadr.btnDoneClick         += new System.EventHandler(this.btnDone_Click);
                ucadr.btnCancelClick       += new System.EventHandler(this.btnCancel_Click);
                ucadr.lvIEDListDoubleClick += new System.EventHandler(this.lvIEDList_DoubleClick);
                addListHeaders();
                fillOptions();
                //Parse n store values...
                Utils.WriteLine(VerboseLevel.DEBUG, "mNode name: '{0}'", mNode.Name);
                if (mNode.Attributes != null)
                {
                    //First set the root element value...
                    try
                    {
                        mType = (masterType)Enum.Parse(typeof(masterType), mNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mNode.Name);
                    }
                    foreach (XmlAttribute item in mNode.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);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                else if (mNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = mNode.Value;
                }
                if (tn != null)
                {
                    tn.Nodes.Clear();
                }
                ADRMasterTreeNode = tn; //Save local copy so we can use it to manually add nodes in above constructor...
                                        //Now since we have parsed, we can name the treenode...
                tn.Text = "ADR " + this.Description;
                foreach (XmlNode node in mNode)
                {
                    if (node.NodeType == XmlNodeType.Comment)
                    {
                        continue;                                      //IMP: Ignore comments in file...
                    }
                    TreeNode tmp = tn.Nodes.Add("IED_" + Utils.GenerateShortUniqueKey(), "IED", "IED", "IED");
                    iedList.Add(new IED(node, tmp, MasterTypes.ADR, Int32.Parse(MasterNum), false));
                }
                refreshList();
                ucadr.lblIED.Text = "IED List (Master No: " + this.MasterNum + ")";
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }