예제 #1
0
        // Get Parsed Wind Generator Data
        public List <ClsGenaratorWind> GetWindDataList(XDocument xdoc)
        {
            List <ClsGenaratorWind> windGenerators = new List <ClsGenaratorWind>();

            //Parse Wind Genarator Data
            var selectWindGen = from windResult in xdoc.Descendants("WindGenerator")
                                select windResult;

            foreach (var windData in selectWindGen)
            {
                ClsGenaratorWind windGenerator = new ClsGenaratorWind();
                var selectGen = from genResult in windData.Descendants("Day")
                                select genResult;

                windGenerator.FuelGenName       = windData.Element("Name").Value;
                windGenerator.FuelGenaratorType = windData.Element("Location").Value;

                //Daily Generation Value = Energy x Price x ValueFactor
                foreach (var genData in selectGen)
                {
                    if (windGenerator.FuelGenaratorType == "Offshore")
                    {
                        windGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorLow + windGenerator.DailyGenerationValue;
                    }
                    else if (windData.Element("Location").Value == "Onshore")
                    {
                        windGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorHigh + windGenerator.DailyGenerationValue;
                    }
                    windGenerator.Date = DateTime.Parse(genData.Element("Date").Value).ToUniversalTime();

                    Console.WriteLine("Total:-" + windGenerator.DailyGenerationValue);
                }

                windGenerators.Add(windGenerator);
            }
            return(windGenerators);
        }
예제 #2
0
        //This method processes the file
        public void ProcessFile(string FilePath)
        {
            Console.WriteLine("Reading File: " + FilePath);

            List <ClsGenaratorWind> windGenerators = new List <ClsGenaratorWind>();
            List <ClsGenaratorGas>  gasGenerators  = new List <ClsGenaratorGas>();
            List <ClsGenaratorCoal> coalGenerators = new List <ClsGenaratorCoal>();

            XDocument xdoc = XDocument.Load(FilePath);


            //Parse Wind Genarator Data
            var selectWindGen = from windResult in xdoc.Descendants("WindGenerator")
                                select windResult;

            foreach (var windData in selectWindGen)
            {
                ClsGenaratorWind windGenerator = new ClsGenaratorWind();
                var selectGen = from genResult in windData.Descendants("Day")
                                select genResult;

                windGenerator.FuelGenName       = windData.Element("Name").Value;
                windGenerator.FuelGenaratorType = windData.Element("Location").Value;

                foreach (var genData in selectGen)
                {
                    if (windGenerator.FuelGenaratorType == "Offshore")
                    {
                        windGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorLow + windGenerator.DailyGenerationValue;
                    }
                    else if (windData.Element("Location").Value == "Onshore")
                    {
                        windGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorHigh + windGenerator.DailyGenerationValue;
                    }
                    Console.WriteLine("Total:-" + windGenerator.DailyGenerationValue);
                }

                windGenerators.Add(windGenerator);
            }


            //Parse Gas Genarator Data
            Console.WriteLine("Gas");
            var selectGasGen = from r in xdoc.Descendants("GasGenerator")
                               select r;

            foreach (var gasData in selectGasGen)
            {
                ClsGenaratorGas gasGenerator = new ClsGenaratorGas();

                var selectGen = from genResult in gasData.Descendants("Day")
                                select genResult;

                gasGenerator.FuelGenName = gasData.Element("Name").Value;

                foreach (var genData in selectGen)
                {
                    gasGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorMedium + gasGenerator.DailyGenerationValue;
                    gasGenerator.DailyEmissionsValue  = double.Parse(genData.Element("Energy").Value) * double.Parse(gasData.Element("EmissionsRating").Value) * ClsFactors.EmissionFactorMedium + gasGenerator.DailyEmissionsValue;

                    Console.WriteLine("Total:-" + gasGenerator.DailyGenerationValue + "  Emission:- " + gasGenerator.DailyEmissionsValue);
                }

                gasGenerators.Add(gasGenerator);
            }


            //Parse Coal Generation Data
            Console.WriteLine("Coal");
            var selectCoalGen = from r in xdoc.Descendants("CoalGenerator")
                                select r;


            //            Daily Generation Value = Energy x Price x ValueFactor
            //Daily Emissions = Energy x EmissionRating x EmissionFactor
            //Actual Heat Rate = TotalHeatInput / ActualNetGeneration
            foreach (var coalData in selectCoalGen)
            {
                ClsGenaratorCoal coalGenerator = new ClsGenaratorCoal();

                var selectGen = from genResult in coalData.Descendants("Day")
                                select genResult;

                coalGenerator.FuelGenName = coalData.Element("Name").Value;

                coalGenerator.ActualHeatRate = double.Parse(coalData.Element("TotalHeatInput").Value) / double.Parse(coalData.Element("ActualNetGeneration").Value);

                foreach (var genData in selectGen)
                {
                    coalGenerator.DailyGenerationValue = double.Parse(genData.Element("Energy").Value) * double.Parse(genData.Element("Price").Value) * ClsFactors.ValueFactorMedium + coalGenerator.DailyGenerationValue;
                    coalGenerator.DailyEmissionsValue  = double.Parse(genData.Element("Energy").Value) * double.Parse(coalData.Element("EmissionsRating").Value) * ClsFactors.EmissionFactorHigh + coalGenerator.DailyEmissionsValue;

                    Console.WriteLine("Total:-" + coalGenerator.DailyGenerationValue + "  Emission:- " + coalGenerator.DailyEmissionsValue + "  Actual Heat Rate:- " + coalGenerator.ActualHeatRate);
                }

                coalGenerators.Add(coalGenerator);
            }

            GetTotalGeneratorValues(windGenerators, gasGenerators, coalGenerators);
        }