private void DeviceView_Load(object sender, System.EventArgs e) { this.Log.Initialize(typeof(DeviceView)); this.deviceProxy = this.DeviceLifetimeManager.DeviceProxy; this.DeviceLifetimeManager.DeviceEventListener.PropertyChanged += DeviceEventListener_PropertyChanged; var deviceName = ApplicationSettings.GetString("DeviceName"); this.deviceConfiguration = DeviceConfigurationRegistry.Instance.Get(deviceName) as HcsDeviceConfiguration; // The size is not correct by this time. Therefore, start a timer for it var drawtimer = new System.Windows.Forms.Timer { Interval = 100 }; drawtimer.Tick += DrawHeaters; drawtimer.Start(); }
public override IDeviceConfiguration[] ReadConfigurations() { var result = new List<IDeviceConfiguration>(); using (var reader = XmlReader.Create(this.ConfigurationFile)) { while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element) continue; if (!reader.Name.Equals("device")) continue; var element = XNode.ReadFrom(reader) as XElement; if (element == null) continue; var name = this.GetInnerElementValue(element, "name"); var handshake = this.GetInnerElementValue(element, "handshake"); var connectionConfiguration = new SerialConnectionConfiguration(); var protocol = element.Descendants("protocol").FirstOrDefault(); if (protocol != null) { var port = this.GetInnerElementValue(protocol, "port"); var baudrate = this.GetInnerElementValue(protocol, "baudrate"); var parity = this.GetInnerElementValue(protocol, "parity"); var databits = this.GetInnerElementValue(protocol, "databits"); var stopbits = this.GetInnerElementValue(protocol, "stopbits"); var readperiod = this.GetInnerElementValue(protocol, "readperiod"); var checksumEnabled = this.GetInnerElementValue(protocol, "checksum"); connectionConfiguration.PortName = port; connectionConfiguration.Baudrate = Convert.ToInt32(baudrate); connectionConfiguration.Parity = (Parity)Convert.ToInt32(parity); connectionConfiguration.DataBits = Convert.ToInt32(databits); connectionConfiguration.StopBits = (StopBits)Convert.ToInt32(stopbits); connectionConfiguration.ReadPeriod = Convert.ToInt32(readperiod); connectionConfiguration.ChecksumEnabled = Convert.ToBoolean(checksumEnabled); } var panelConfigurationList = new List<PanelConfiguration>(); var settlementElement = element.Descendants("settlement").FirstOrDefault(); if (settlementElement != null) { panelConfigurationList.AddRange(from panelConfigElement in settlementElement.Descendants("panel") let id = panelConfigElement.Attribute("id").Value let panelName = panelConfigElement.Attribute("name").Value let regions = this.ParseRegions(panelConfigElement.Descendants("region")) select new PanelConfiguration { Id = Convert.ToInt32(id), Name = panelName, RegionConfigurations = regions }); } var handshakeValue = handshake == null ? HandshakeType.None : handshake.ToEnum<HandshakeType>(); var deviceConfiguration = new HcsDeviceConfiguration(name, handshakeValue, connectionConfiguration) { Settlement = panelConfigurationList }; result.Add(deviceConfiguration); } } return result.ToArray(); }