public DO(string doName, List <KeyValuePair <string, string> > doData, TreeNode tn, MasterTypes mType, int mNo, int iNo) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); SetSupportedControlTypes(); try { donType = (doType)Enum.Parse(typeof(doType), doName); } catch (System.ArgumentException) { } if (doData != null && doData.Count > 0) { foreach (KeyValuePair <string, string> dokp in doData) { try { if (this.GetType().GetProperty(dokp.Key) != null) //Ajay: 02/07/2018 { this.GetType().GetProperty(dokp.Key).SetValue(this, dokp.Value); } } catch (System.NullReferenceException) { } } } }
public DO(string doName, List <KeyValuePair <string, string> > doData, TreeNode tn, MasterTypes mType, int mNo, int iNo) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); //IMP: Call only after master types are set... SetSupportedResponseTypes(); SetSupportedControlTypes(); //IMP: Call only after master types are set... //First set the root element value... try { donType = (doType)Enum.Parse(typeof(doType), doName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", doName); } //Parse n store values... if (doData != null && doData.Count > 0) { foreach (KeyValuePair <string, string> dokp in doData) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", dokp.Key, dokp.Value); try { if (this.GetType().GetProperty(dokp.Key) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(dokp.Key).SetValue(this, dokp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", dokp.Key, dokp.Value); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } }
public DO(XmlNode doNode, MasterTypes mType, int mNo, int iNo, bool imported) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); //IMP: Call only after master types are set... SetSupportedResponseTypes(); //IMP: Call only after master types are set... SetSupportedControlTypes(); //IMP: Call only after master types are set... //Parse n store values... Utils.WriteLine(VerboseLevel.DEBUG, "doNode name: '{0}'", doNode.Name); if (doNode.Attributes != null) { //First set the root element value... try { donType = (doType)Enum.Parse(typeof(doType), doNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", doNode.Name); } if (masterType == MasterTypes.ADR || masterType == MasterTypes.IEC101 || masterType == MasterTypes.IEC103 || masterType == MasterTypes.MODBUS || masterType == MasterTypes.Virtual) { foreach (XmlAttribute item in doNode.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); } } } //Namrata: 17/7/2017 if (masterType == MasterTypes.IEC61850Client) { if (doNode.Name == "DO") { foreach (XmlAttribute xmlattribute in doNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value); try { if (xmlattribute.Name == "ResponseType") { Iec61850DOResponseType = doNode.Attributes[1].Value; } else if (xmlattribute.Name == "Index") { Iec61850DOIndex = doNode.Attributes[2].Value; } else if (xmlattribute.Name == "FC") { fc = doNode.Attributes[3].Value; } else { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", xmlattribute.Name, xmlattribute.Value); } } } } Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (doNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = doNode.Value; } if (imported)//Generate a new unique id... { this.DONo = (Globals.DONo + 1).ToString(); //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.DOIndex + 1).ToString(); } }
public DO(XmlNode doNode, MasterTypes mType, int mNo, int iNo, bool imported) { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); SetSupportedControlTypes(); if (doNode.Attributes != null) { try { donType = (doType)Enum.Parse(typeof(doType), doNode.Name); } catch (System.ArgumentException) { } if (masterType == MasterTypes.ADR || masterType == MasterTypes.IEC103 || masterType == MasterTypes.MODBUS || masterType == MasterTypes.Virtual || masterType == MasterTypes.IEC104 || masterType == MasterTypes.SPORT || masterType == MasterTypes.LoadProfile) //Ajay: 31/07/2018 LoadProfile added { foreach (XmlAttribute item in doNode.Attributes) { try { if (this.GetType().GetProperty(item.Name) != null) { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { } } } //Namrata: 08/05/2018 if (masterType == MasterTypes.IEC101) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Utils.XMLFileName); XmlAttribute attrName = xmlDoc.CreateAttribute("Select"); attrName.Value = "ENABLE"; bool IsExist = false; arrAttributes.OfType <string>().ToList().ForEach(item => { if (!doNode.Attributes.OfType <XmlNode>().ToList().Select(x => x.Name).ToList().Contains(item)) { IsExist = true; } }); if (IsExist) { doNode.Attributes.SetNamedItem(attrName); } foreach (XmlAttribute item in doNode.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); } } } //Namrata: 17/7/2017 if (masterType == MasterTypes.IEC61850Client) { if (doNode.Name == "DO") { foreach (XmlAttribute xmlattribute in doNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value); try { if (xmlattribute.Name == "ResponseType") { //Ajay: 04/08/2018 Seq changed due to CModel added //Iec61850DOResponseType = doNode.Attributes[1].Value; Iec61850DOResponseType = doNode.Attributes["ResponseType"].Value; } else if (xmlattribute.Name == "Index") { //Ajay: 04/08/2018 Seq changed due to CModel added //Iec61850DOIndex = doNode.Attributes[2].Value; Iec61850DOIndex = doNode.Attributes["Index"].Value; } else if (xmlattribute.Name == "FC") { //Ajay: 04/08/2018 Seq changed due to CModel added //fc = doNode.Attributes[3].Value; fc = doNode.Attributes["FC"].Value; } else { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", xmlattribute.Name, xmlattribute.Value); } } } } Utils.Write(VerboseLevel.DEBUG, "\n"); } else if (doNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = doNode.Value; } if (imported)//Generate a new unique id... { this.DONo = (Globals.DONo + 1).ToString(); //Commented as asked by Amol, 29/12/2k16: this.Index = (Globals.DOIndex + 1).ToString(); } }