Ejemplo n.º 1
0
        /// <summary>
        /// 读取设备的配置文件.  系统初始化必要步骤.
        /// </summary>
        public static void InitializeDevicesData()
        {
            XDocument configXml         = XDocument.Load(@".\Config.xml");
            XElement  PowerPlantElement = configXml.Root;
            XElement  ServerElement     = PowerPlantElement.Element("Server");

            //锅炉类 list 初始化
            XElement BoilersElement = ServerElement.Element("Boilers");
            IEnumerable <XElement> BoilerElements = BoilersElement.Elements("Boiler");

            foreach (XElement aBoilderXElement in BoilerElements)
            {
                Boiler boiler = new Boiler();
                boiler.BoilerID    = Convert.ToInt32(aBoilderXElement.Attribute("BoilerID").Value);
                boiler.Caption     = aBoilderXElement.Attribute("Caption").Value;
                boiler.MapFilePath = aBoilderXElement.Attribute("MapFilePath").Value;
                boilersList.Add(boiler);
            }

            //板卡类 list 初始化
            XElement CaptureCardsElement = ServerElement.Element("CaptureCards");
            IEnumerable <XElement> CaptureCardElements = CaptureCardsElement.Elements("CaptureCard");

            foreach (XElement aCaptureCardXElement in CaptureCardElements)
            {
                CaptureCard aCaptureCard = new CaptureCard();
                aCaptureCard.CaptureCardID = Convert.ToInt32(aCaptureCardXElement.Attribute("CaptureCardID").Value);
                aCaptureCard.CaptureDriver = new CaptureDriver((EnumDriverName)Enum.Parse(typeof(EnumDriverName), aCaptureCardXElement.Attribute("Driver").Value));
                captureCardsList.Add(aCaptureCard);

                //传感器类 list 初始化
                IEnumerable <XElement> sensorElements = aCaptureCardXElement.Elements("Sensor");
                foreach (XElement aSensorElement in sensorElements)
                {
                    Sensor aSensor = new Sensor();

                    aSensor.SensorID       = Convert.ToInt32(aSensorElement.Attribute("SensorID").Value);
                    aSensor.ChannelNumber  = Convert.ToInt32(aSensorElement.Attribute("ChannelNumber").Value);
                    aSensor.BoilerID       = Convert.ToInt32(aSensorElement.Attribute("BoilerID").Value);
                    aSensor.Multiplicative = Convert.ToInt32(aSensorElement.Attribute("Multiplicative").Value);
                    aSensor.BaseNoise      = Convert.ToDouble(aSensorElement.Attribute("BaseNoise").Value);
                    aSensor.Uplimit        = Convert.ToDouble(aSensorElement.Attribute("Uplimit").Value);
                    aSensor.Downlimit      = Convert.ToDouble(aSensorElement.Attribute("Downlimit").Value);
                    aSensor.FFT            = Convert.ToInt32(aSensorElement.Attribute("FFT").Value);
                    aSensor.MapLeft        = Convert.ToInt32(aSensorElement.Attribute("MapLeft").Value);
                    aSensor.MapTop         = Convert.ToInt32(aSensorElement.Attribute("MapTop").Value);
                    aSensor.Boiler         = boilersList.Find(x => x.BoilerID == aSensor.BoilerID);

                    allSensorsList.Add(aSensor);
                }
            }
        }
Ejemplo n.º 2
0
 public Sensor(int SensorID, CaptureCard CaptureCard, int ChannelNumber, int BoilerID, int Multiplicative,
               double BaseNoise, double Uplimit, double Downlimit, int FFT, Boiler Boiler)
 {
     this.SensorID       = SensorID;
     this.CaptureCard    = CaptureCard;
     this.ChannelNumber  = ChannelNumber;
     this.BoilerID       = BoilerID;
     this.Multiplicative = Multiplicative;
     this.BaseNoise      = BaseNoise;
     this.Uplimit        = Uplimit;
     this.Downlimit      = Downlimit;
     this.FFT            = FFT;
     this.Boiler         = Boiler;
 }