public XmlNode exportXMLnode() { XmlDocument xmlDoc = new XmlDocument(); StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); XmlNode rootNode = null; if (isNodeComment) { rootNode = xmlDoc.CreateComment(comment); xmlDoc.AppendChild(rootNode); return(rootNode); } rootNode = xmlDoc.CreateElement(dimnType.ToString()); xmlDoc.AppendChild(rootNode); if (slaveType == SlaveTypes.IEC61850Server) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attr2 = xmlDoc.CreateAttribute("ReportingIndex"); attr2.Value = iec61850reportingindex.ToString(); rootNode.Attributes.Append(attr2); XmlAttribute attrDataType = xmlDoc.CreateAttribute("DataType"); attrDataType.Value = DataType.ToString(); rootNode.Attributes.Append(attrDataType); XmlAttribute attrCommandType = xmlDoc.CreateAttribute("CommandType"); attrCommandType.Value = CommandType.ToString(); rootNode.Attributes.Append(attrCommandType); XmlAttribute attrDeadband = xmlDoc.CreateAttribute("BitPos"); attrDeadband.Value = BitPos.ToString(); rootNode.Attributes.Append(attrDeadband); XmlAttribute attrMultiplier = xmlDoc.CreateAttribute("Complement"); attrMultiplier.Value = Complement.ToString(); rootNode.Attributes.Append(attrMultiplier); XmlAttribute attrConstant = xmlDoc.CreateAttribute("Description"); attrConstant.Value = Description.ToString(); rootNode.Attributes.Append(attrConstant); } if ((slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN)) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } } return(rootNode); }
public XmlNode exportXMLnode() { XmlDocument xmlDoc = new XmlDocument(); StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); XmlNode rootNode = null; if (isNodeComment) { rootNode = xmlDoc.CreateComment(comment); xmlDoc.AppendChild(rootNode); return(rootNode); } rootNode = xmlDoc.CreateElement(dimnType.ToString()); xmlDoc.AppendChild(rootNode); #region IEC61850Server if (slaveType == SlaveTypes.IEC61850Server) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attr2 = xmlDoc.CreateAttribute("ReportingIndex"); attr2.Value = iec61850reportingindex.ToString(); rootNode.Attributes.Append(attr2); XmlAttribute attrDataType = xmlDoc.CreateAttribute("DataType"); attrDataType.Value = DataType.ToString(); rootNode.Attributes.Append(attrDataType); XmlAttribute attrCommandType = xmlDoc.CreateAttribute("CommandType"); attrCommandType.Value = CommandType.ToString(); rootNode.Attributes.Append(attrCommandType); XmlAttribute attrDeadband = xmlDoc.CreateAttribute("BitPos"); attrDeadband.Value = BitPos.ToString(); rootNode.Attributes.Append(attrDeadband); XmlAttribute attrMultiplier = xmlDoc.CreateAttribute("Complement"); attrMultiplier.Value = Complement.ToString(); rootNode.Attributes.Append(attrMultiplier); XmlAttribute attrConstant = xmlDoc.CreateAttribute("Description"); attrConstant.Value = Description.ToString(); rootNode.Attributes.Append(attrConstant); } #endregion IEC61850Server #region SPORTSLAVE,IEC101SLAVE,IEC104,MODBUSSLAVE,UNKNOWN if ((slaveType == SlaveTypes.DNP3SLAVE) || (slaveType == SlaveTypes.SPORTSLAVE) || (slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN) || (slaveType == SlaveTypes.MQTTSLAVE) || (slaveType == SlaveTypes.SMSSLAVE)) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } } #endregion SPORTSLAVE,IEC101SLAVE,IEC104,MODBUSSLAVE,UNKNOWN #region GDisplaySlave if (slaveType == SlaveTypes.GRAPHICALDISPLAYSLAVE) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attrCellNo = xmlDoc.CreateAttribute("CellNo"); attrCellNo.Value = CellNo.ToString(); rootNode.Attributes.Append(attrCellNo); XmlAttribute attrWidget = xmlDoc.CreateAttribute("Widget"); attrWidget.Value = Widget.ToString(); rootNode.Attributes.Append(attrWidget); //XmlAttribute attrUnit = xmlDoc.CreateAttribute("Unit"); //attrUnit.Value = UnitID.ToString(); //rootNode.Attributes.Append(attrUnit); XmlAttribute attrComplement = xmlDoc.CreateAttribute("Complement"); attrComplement.Value = Complement.ToString(); rootNode.Attributes.Append(attrComplement); XmlAttribute attrDescription = xmlDoc.CreateAttribute("Description"); attrDescription.Value = Description.ToString(); rootNode.Attributes.Append(attrDescription); } #endregion GDisplaySlave return(rootNode); }