public DI(string diName, List <KeyValuePair <string, string> > diData, TreeNode tn, MasterTypes mType, int mNo, int iNo) { string strRoutineName = "DI"; try { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); //Namrata: 17/10/2017 SetSupportedDataTypes(); try { dinType = (diType)Enum.Parse(typeof(diType), diName); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", diName); } if (diData != null && diData.Count > 0) { foreach (KeyValuePair <string, string> dikp in diData) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", dikp.Key, dikp.Value); try { if (this.GetType().GetProperty(dikp.Key) != null) //Ajay: 10/08/2018 { this.GetType().GetProperty(dikp.Key).SetValue(this, dikp.Value); } } catch (System.NullReferenceException) { Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", dikp.Key, dikp.Value); } } Utils.Write(VerboseLevel.DEBUG, "\n"); } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error:" + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DI(string diName, List <KeyValuePair <string, string> > diData, TreeNode tn, MasterTypes mType, int mNo, int iNo) { string strRoutineName = "DI"; try { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); //Namrata: 17/10/2017 SetSupportedDataTypes(); try { dinType = (diType)Enum.Parse(typeof(diType), diName); } catch (System.ArgumentException) { } if (diData != null && diData.Count > 0) { foreach (KeyValuePair <string, string> dikp in diData) { try { if (this.GetType().GetProperty(dikp.Key) != null) //Ajay: 02/07/2018 { this.GetType().GetProperty(dikp.Key).SetValue(this, dikp.Value); } } catch (System.NullReferenceException) { } } } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error:" + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DI(XmlNode diNode, MasterTypes mType, int mNo, int iNo, bool imported) { string StrRoutineName = "DI"; try { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); SetSupportedDataTypes(); //Namrata:17/10/2017 if (diNode.Attributes != null) { try { dinType = (diType)Enum.Parse(typeof(diType), diNode.Name); } catch (System.ArgumentException) { } if (masterType == MasterTypes.ADR || masterType == MasterTypes.IEC101 || 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 diNode.Attributes) { try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { } } //Namrata: 17/7/2017 if (masterType == MasterTypes.ADR) { if (diNode.HasChildNodes) { if (diNode.ChildNodes[0].Name == "Event") { foreach (XmlAttribute xmlattribute in diNode.ChildNodes[0].Attributes) { try { if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value); } } catch (System.NullReferenceException) { } } } } } } //Namrata: 17/7/2017 if (masterType == MasterTypes.IEC61850Client) { if (diNode.Name == "DI") { foreach (XmlAttribute xmlattribute in diNode.Attributes) { try { if (xmlattribute.Name == "ResponseType") { Iec61850DIResponseType = diNode.Attributes[1].Value; } else if (xmlattribute.Name == "Index") { Iec61850DIIndex = diNode.Attributes[2].Value; } else if (xmlattribute.Name == "FC") { fc = diNode.Attributes[3].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) { } } } } } else if (diNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = diNode.Value; } if (imported) { this.DINo = (Globals.DINo + 1).ToString(); } } catch (Exception ex) { MessageBox.Show(StrRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DI(XmlNode diNode, MasterTypes mType, int mNo, int iNo, bool imported) { string StrRoutineName = "DI"; try { masterType = mType; masterNo = mNo; IEDNo = iNo; SetSupportedAttributes(); SetSupportedResponseTypes(); //Namrata: 17/10/2017 SetSupportedDataTypes(); Utils.WriteLine(VerboseLevel.DEBUG, "diNode name: '{0}'", diNode.Name); if (diNode.Attributes != null) { try { dinType = (diType)Enum.Parse(typeof(diType), diNode.Name); } catch (System.ArgumentException) { Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", diNode.Name); } if (masterType == MasterTypes.ADR || masterType == MasterTypes.IEC101 || masterType == MasterTypes.IEC103 || masterType == MasterTypes.MODBUS || masterType == MasterTypes.Virtual) { foreach (XmlAttribute item in diNode.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, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", item.Name, item.Value); } } //Namrata: 17/7/2017 if (masterType == MasterTypes.ADR) { if (diNode.HasChildNodes) { if (diNode.ChildNodes[0].Name == "Event") { foreach (XmlAttribute xmlattribute in diNode.ChildNodes[0].Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value); try { //To Get Values From XML 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); } } } } } } //Namrata: 17/7/2017 if (masterType == MasterTypes.IEC61850Client) { if (diNode.Name == "DI") { foreach (XmlAttribute xmlattribute in diNode.Attributes) { Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value); try { if (xmlattribute.Name == "ResponseType") { Iec61850DIResponseType = diNode.Attributes[1].Value; } else if (xmlattribute.Name == "Index") { Iec61850DIIndex = diNode.Attributes[2].Value; } else if (xmlattribute.Name == "FC") { fc = diNode.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 (diNode.NodeType == XmlNodeType.Comment) { isNodeComment = true; comment = diNode.Value; } if (imported)//Generate a new unique id... { this.DINo = (Globals.DINo + 1).ToString(); } } catch (Exception ex) { MessageBox.Show(StrRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Editor Event public virtual void OnSubvariableTypeChange(diType newType) { }