Ejemplo n.º 1
0
        public void HydrateFromBinary(BTVersion version, byte[] btBuf, int offset, int len)
        {
            var index = offset;
            RecipeSlot = btBuf[index++];
            var tempUnits = (Units == BTUnits.US) ? TemperatureUnitType.F : TemperatureUnitType.C;

            decimal dVal = btBuf[index++];
            Strike = new TemperatureType { Value = dVal, degrees = tempUnits };

            dVal = btBuf[index++];
            FirstStep = new TemperatureType { Value = dVal, degrees = tempUnits };
        }
Ejemplo n.º 2
0
        public void HydrateFromParamList(BTVersion version, List<string> rspParams)
        {
            Debug.Assert(rspParams.Count == 3, "rspParams.Count == 3");
            try
            {
                var index = 0;
                RecipeSlot = Convert.ToInt32(rspParams[index++]);
                var tempUnits = (Units == BTUnits.US) ? TemperatureUnitType.F : TemperatureUnitType.C;

                Strike = new TemperatureType { Value = Convert.ToDecimal(rspParams[index++]), degrees = tempUnits };
                FirstStep = new TemperatureType { Value = Convert.ToDecimal(rspParams[index++]), degrees = tempUnits };
            }
            catch (Exception ex)
            {
                throw new BTComException("Error converting parameter list to BTCalcTemps.", ex);
            }
        }
Ejemplo n.º 3
0
        public void HydrateFromBinary(BTVersion version, byte[] btBuf, int offset, int len)
        {
            var index = offset;
            if (len != 52)
                throw new Exception("BTRecipe.HydrateFromBinary: Buffer Size Error.");

            // recipe slot
            Slot = btBuf[index++];

            // recipe units
            Units = (BTUnits)btBuf[index++];

            // name
            byte[] nameArray = new byte[BTConfig.RecipeNameSize];
            int i;
            for (i = 0; i < BTConfig.RecipeNameSize; i++)
            {
                nameArray[i] = btBuf[index++];
                if (nameArray[i] < 0x20)
                    nameArray[i] = (byte)' ';
            }
            Debug.Assert(btBuf[index] == 0, "btBuf[index] == 0");
            index++;
            ASCIIEncoding encoder = new ASCIIEncoding();
            Name = encoder.GetString(nameArray).Trim();

            // mash steps DoughIn, Acid Rest, Protein Rest, Sacch1 Rest, Sacch2 Rest, Mash Out
            //		PreHeat is handled separately
            foreach (var mashStep in MashSteps.Where(mashStep => mashStep.Key != MashStepID.PreHeat))
            {
                mashStep.Value.step_temperature =
                    new TemperatureType
                        {
                            Value = btBuf[index++],
                            degrees = Units == BTUnits.US ? TemperatureUnitType.F
                                      	: TemperatureUnitType.C
                        };

                mashStep.Value.step_time =
                    new TimeType { Value = btBuf[index++], duration = TimeUnitType.min };
            }

            // mash heat source
            MashHeatSource = (BTVesselID)btBuf[index++];

            // sparge temp
            SpargeTemp = new TemperatureType
            {
                Value = btBuf[index++],
                degrees = Units == BTUnits.US
                                   ? TemperatureUnitType.F
                                   : TemperatureUnitType.C
            };

            // pitch temp
            PitchTemp = new TemperatureType
            {
                Value = btBuf[index++],
                degrees = Units == BTUnits.US
                                   ? TemperatureUnitType.F
                                   : TemperatureUnitType.C
            };

            // HLT Setpoint
            HLTSetpoint = new TemperatureType
            {
                Value = btBuf[index++],
                degrees = Units == BTUnits.US
                                  ? TemperatureUnitType.F
                                  : TemperatureUnitType.C
            };

            // batch volume
            decimal dVal = (btBuf[index++] << 24) |
                            (btBuf[index++] << 16) |
                            (btBuf[index++] << 8) |
                            (btBuf[index++] << 0);
            BatchVolume = new VolumeType
            {
                Value = dVal / 1000,
                volume = Units == BTUnits.US
                                   ? VolumeUnitType.gal
                                   : VolumeUnitType.l
            };

            // grain weight
            dVal = (btBuf[index++] << 24) |
                    (btBuf[index++] << 16) |
                    (btBuf[index++] << 8) |
                    (btBuf[index++] << 0);
            GrainWeight = new MassType
            {
                Value = dVal / 1000,
                mass = (Units == BTUnits.US)
                                ? MassUnitType.lb
                                : MassUnitType.kg
            };
            // boil time
            BoilTime = new TimeType
            {
                Value = (btBuf[index++] << 8) |
                        (btBuf[index++] << 0),
                duration = TimeUnitType.min
            };

            // mash ratio
            dVal = (btBuf[index++] << 8) |
                    (btBuf[index++] << 0);
            MashRatio = dVal / 100;

            // boil additions
            Additions = (UInt16)((btBuf[index++] << 8) +
                                 (btBuf[index++] << 0));

            Debug.Assert(index == offset + len, "index == offset + len");
        }