Example #1
0
        private static MashStepType[] GetMashSteps(BTUnits units)
        {
            var mashSteps = new List<MashStepType>();

            foreach (var mashStepName in Enum.GetNames(typeof(MashStepID)))
            {
                var mashStep = new MashStepType
                {
                    name = mashStepName,
                    type = MashStepTypeType.infusion,
                    infuse_amount = NewVolumeType(0.0m, units == BTUnits.Metric),
                    step_temperature = NewTemperatureType(0.0m, units == BTUnits.Metric),
                    step_time = NewTimeType(0.0m, TimeUnitType.min),
                    ramp_time = NewTimeType(0.0m, TimeUnitType.min),
                    end_temperature = NewTemperatureType(0.0m, units == BTUnits.Metric),
                    description = String.Empty,
                    water_grain_ratio = 0.0m,
                    water_grain_ratioSpecified = mashStepName == MashStepID.DoughIn.ToString(),
                    decoction_amount = NewVolumeType(0, units == BTUnits.Metric),
                    infuse_temperature = NewTemperatureType(0, units == BTUnits.Metric),
                };
                mashSteps.Add(mashStep);
            }

            return mashSteps.ToArray();
        }
Example #2
0
        private static List<MashStepType> ImportMashSteps(beer_xml beerXMLv2, XElement xmlRecipe)
        {
            var qry = from xmlElements in xmlRecipe.Descendants("MASH_STEP")
                                select xmlElements;

            var mashStepList = new List<MashStepType>();

            if (qry.Count() == 0)
            {
                Messages.Add(new Message { Type = MessageType.Error, Text = "No Mash Steps found in input file." });
                return mashStepList;
            }

            string str;

            foreach (var xmlElement in qry)
            {
                var xmlMashStep = new MashStepType();

                xmlMashStep.name = GetXmlString(xmlElement, "NAME", true);

                str = GetXmlString(xmlElement, "TYPE", true);
                switch (str.RemoveBlanks().ToLower().Trim())
                {
                    case "infusion":
                        xmlMashStep.type = MashStepTypeType.infusion;
                        break;
                    case "temperature":
                        xmlMashStep.type = MashStepTypeType.temperature;
                        break;
                    case "decoction":
                        xmlMashStep.type = MashStepTypeType.decoction;
                        break;
                    default:
                        Messages.Add(new Message
                        {
                            Type = MessageType.Error,
                            Text = String.Format("Required String element '{0}' is missing.", "TYPE")
                        });
                        break;
                }

                if (xmlMashStep.type == MashStepTypeType.infusion)
                    xmlMashStep.infuse_amount = GetXmlVolumeType(xmlElement, "INFUSE_AMOUNT", true, VolumeUnitType.l);
                else if (xmlMashStep.type == MashStepTypeType.temperature)
                    xmlMashStep.infuse_amount = GetXmlVolumeType(xmlElement, "INFUSE_AMOUNT", false, VolumeUnitType.l);

                xmlMashStep.step_temperature = GetXmlTemperatureType(xmlElement, "STEP_TEMP", true, TemperatureUnitType.C);
                xmlMashStep.step_time = GetXmlTimeType(xmlElement, "STEP_TIME", true, TimeUnitType.min);
                xmlMashStep.ramp_time = GetXmlTimeType(xmlElement, "RAMP_TIME", true, TimeUnitType.min);
                xmlMashStep.end_temperature = GetXmlTemperatureType(xmlElement, "END_TEMP", true, TemperatureUnitType.C);

                xmlMashStep.description = GetXmlString(xmlElement, "DESCRIPTION", false);

                xmlMashStep.water_grain_ratioSpecified = xmlElement.Element("WATER_GRAIN_RATIO") != null;
                if (xmlMashStep.water_grain_ratioSpecified)
                    xmlMashStep.water_grain_ratio = GetXmlDecimal(xmlElement, "WATER_GRAIN_RATIO", true);

                xmlMashStep.decoction_amount = GetXmlVolumeType(xmlElement, "DECOCTION_AMT", false, VolumeUnitType.l);
                xmlMashStep.infuse_temperature = GetXmlTemperatureType(xmlElement, "INFUSE_TEMP", false, TemperatureUnitType.C);

                mashStepList.Add(xmlMashStep);
            }

            return mashStepList;
        }