public static void WriteHRDeviceStatsInXml(HeatRecoveryDevice hrDevice, string filename = null, string path = null, XmlWriterSettings xmlWriterSettings = null) { string tableName = "Logtable"; string absPath = CreateXmlFile(filename, path, xmlWriterSettings); var entryElem = new XElement("Entry"); entryElem.Add(new XAttribute("Time", DateTime.Now.ToString())); entryElem.Add(new XAttribute("Voltage", hrDevice.Voltage.ToString())); entryElem.Add(new XAttribute("Current", hrDevice.Current.ToString())); entryElem.Add(new XAttribute("Power", hrDevice.Power.ToString())); entryElem.Add(new XAttribute("EngineSpeed", hrDevice.EngineSpeed.ToString())); var doc = XDocument.Load(absPath); var root = doc.Element("Root"); var tableElem = root.Element(tableName); if (tableElem == null) //if node with given tablename doesn't exist yet... { tableElem = new XElement(tableName); //...create one and... root.Add(tableElem); //...add it to root node } tableElem.Add(entryElem); //add the new entry element to the table node doc.Save(absPath); }
public MainWindow() { InitializeComponent(); HrDevice = this.DataContext as HeatRecoveryDevice; HrDevice.SelectedLevelChanged += OnSelectedLevelChanged; HrDevice.CurrentLevelChanged += OnCurrentLevelChanged; SetFanTimer(1000 / 60); //run with 60fps (60-times per second) }