Пример #1
0
 public void HydrateFromParamList(BTVersion version, List<string> rspParams)
 {
     Debug.Assert(rspParams.Count == 6, "rspParams.Count == 6");
     try
     {
         var index = 0;
         RecipeSlot = Convert.ToInt32(rspParams[index++]);
         var volUnits = (Units == BTUnits.US) ? VolumeUnitType.gal : VolumeUnitType.l;
         Grain = new VolumeType { Value = Convert.ToDecimal(rspParams[index++]) / 1000, volume = volUnits };
         GrainLoss = new VolumeType { Value = Convert.ToDecimal(rspParams[index++]) / 1000, volume = volUnits };
         Preboil = new VolumeType { Value = Convert.ToDecimal(rspParams[index++]) / 1000, volume = volUnits };
         Strike = new VolumeType { Value = Convert.ToDecimal(rspParams[index++]) / 1000, volume = volUnits };
         Sparge = new VolumeType { Value = Convert.ToDecimal(rspParams[index++]) / 1000, volume = volUnits };
     }
     catch (Exception ex)
     {
         throw new BTComException("Error converting parameter list to BTCalcVols.", ex);
     }
 }
Пример #2
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");
        }
Пример #3
0
        public void HydrateFromBinary(BTVersion version, byte[] btBuf, int offset, int len)
        {
            var index = offset;
            var volUnits = (Units == BTUnits.US) ? VolumeUnitType.gal : VolumeUnitType.l;

            RecipeSlot = btBuf[index++];

            decimal dVal;
            dVal = (btBuf[index++] << 24) + (btBuf[index++] << 16) + (btBuf[index++] << 8) + (btBuf[index++] << 0);
            Grain = new VolumeType { Value = dVal / 1000, volume = volUnits };

            dVal = (btBuf[index++] << 24) + (btBuf[index++] << 16) + (btBuf[index++] << 8) + (btBuf[index++] << 0);
            GrainLoss = new VolumeType { Value = dVal / 1000, volume = volUnits };

            dVal = (btBuf[index++] << 24) + (btBuf[index++] << 16) + (btBuf[index++] << 8) + (btBuf[index++] << 0);
            Preboil = new VolumeType { Value = dVal / 1000, volume = volUnits };

            dVal = (btBuf[index++] << 24) + (btBuf[index++] << 16) + (btBuf[index++] << 8) + (btBuf[index++] << 0);
            Strike = new VolumeType { Value = dVal / 1000, volume = volUnits };

            dVal = (btBuf[index++] << 24) + (btBuf[index++] << 16) + (btBuf[index++] << 8) + (btBuf[index++] << 0);
            Sparge = new VolumeType { Value = dVal / 1000, volume = volUnits };
        }