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 }; }
public void HydrateFromParamList(BTVersion version, List<string> rspParams) { throw new NotImplementedException(); }
public void HydrateFromBinary(BTVersion version, byte[] btBuf, int offset, int len) { if (len != 95) throw new Exception("BTLog.HydrateFromBinary: Buffer Size Error."); var startIndex = offset; Schema = btBuf[offset++]; TimeStamp = GetUInt32(btBuf, offset); offset += sizeof(UInt32); //StepStatus for (var i = 0; i < StepStatus.Length; i++) { StepStatus[i] = btBuf[offset++]; } //MashTimer MashTimerValue = GetUInt32(btBuf, offset); offset += sizeof(UInt32); MashTimerStatus = btBuf[offset++] != 0; //BoilTimer BoilTimerValue = GetUInt32(btBuf, offset); offset += sizeof(UInt32); BoilTimerStatus = btBuf[offset++] != 0; //AlarmStatus AlarmStatus = btBuf[offset++] != 0; //Vessel Vol & Flow for (var i = 0; i < VesselVolumeAvg.Length; i++) { VesselVolumeAvg[i] = GetUInt32(btBuf, offset); offset += sizeof(UInt32); VesselFlowRate[i] = GetUInt32(btBuf, offset); offset += sizeof(UInt32); } //Temperature for (var i = 0; i < Temperature.Length; i++) { Temperature[i] = GetInt16(btBuf, offset) / 100m; offset += sizeof(Int16); } //SteamPressure SteamPressure = GetUInt32(btBuf, offset); offset += sizeof(UInt32); //HeatOutput for (var i = 0; i < HeatOutput.Length; i++) { HeatOutput[i] = btBuf[offset++]; } //HeatSetpoint for (var i = 0; i < HeatSetpoint.Length; i++) { HeatSetpoint[i] = GetInt16(btBuf, offset); offset += sizeof(Int16); } //AutoValveMode SteamPressure = GetUInt16(btBuf, offset); offset += sizeof(UInt16); //ValveProfile SteamPressure = GetUInt32(btBuf, offset); offset += sizeof(UInt32); System.Diagnostics.Debug.Assert(offset == startIndex + len, "offset == startIndex + len"); }
public List<string> EmitToParamsList(BTVersion version) { throw new NotImplementedException(); }
public byte EmitToBinary(BTVersion version, byte[] cmdBuf, byte offset) { throw new NotImplementedException(); }
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); } }
public void HydrateFromParamList(BTVersion version, List<string> rspParams) { Debug.Assert(rspParams.Count == 23, "rspParams.Count == 23"); try { // skip recipe slot var index = 1; Name = rspParams[index++].Trim(); DoughIn.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); DoughIn.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); AcidRest.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); AcidRest.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); ProteinRest.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); ProteinRest.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); Sacch1Rest.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); Sacch1Rest.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); Sacch2Rest.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); Sacch2Rest.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); MashOut.step_time = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); MashOut.step_temperature = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); SpargeTemp = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); HLTSetpoint = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); BatchVolume = NewVolumeType(Convert.ToDecimal(rspParams[index++]) / 1000, IsMetric); GrainWeight = NewMassType(Convert.ToDecimal(rspParams[index++]), IsMetric); BoilTime = NewTimeType(Convert.ToDecimal(rspParams[index++]), TimeUnitType.min); MashRatio = Convert.ToDecimal(rspParams[index++]) / 100; PitchTemp = NewTemperatureType(Convert.ToDecimal(rspParams[index++]), IsMetric); Additions = Convert.ToUInt32(rspParams[index++]); if (!version.IsAsciiSchema0) MashHeatSource = (BTVesselID)(Convert.ToInt32(rspParams[index++])); } catch (Exception ex) { throw new BTComException("Error converting parameter list to BTRecipe.", ex); } }
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"); }
public List<string> EmitToParamsList(BTVersion version) { List<string> paramsList; try { paramsList = new List<string> { Convert.ToString(Slot), // 1 Name, // 2 Convert.ToString(DoughIn.step_temperature.Value), // 3 Convert.ToString(DoughIn.step_time.Value), // 4 Convert.ToString(AcidRest.step_temperature.Value), // 5 Convert.ToString(AcidRest.step_time.Value), // 6 Convert.ToString(ProteinRest.step_temperature.Value), // 7 Convert.ToString(ProteinRest.step_time.Value), // 8 Convert.ToString(Sacch1Rest.step_temperature.Value), // 9 Convert.ToString(Sacch1Rest.step_time.Value), // 10 Convert.ToString(Sacch2Rest.step_temperature.Value), // 11 Convert.ToString(Sacch2Rest.step_time.Value), // 12 Convert.ToString(MashOut.step_temperature.Value), // 13 Convert.ToString(MashOut.step_time.Value), // 14 Convert.ToString(SpargeTemp.Value), // 15 Convert.ToString(HLTSetpoint.Value), // 16 Convert.ToString(BatchVolume.Value * 1000), // 17 Convert.ToString(GrainWeight.Value), // 18 Convert.ToString(BoilTime.Value), // 19 Convert.ToString(MashRatio * 100), // 20 Convert.ToString(PitchTemp.Value), // 21 Convert.ToString(Additions) // 22 //Convert.ToString((int)Units) // 23 not sent as command parameter, #define configured in BT }; if (!version.IsAsciiSchema0) paramsList.Add(Convert.ToString((int)MashHeatSource)); } catch (Exception ex) { throw new BTComException("Error converting BTRecipe to parameter list.", ex); } return paramsList; }
public byte EmitToBinary(BTVersion version, byte[] cmdBuf, byte offset) { var index = offset; // units cmdBuf[index++] = (byte)Units; // name ASCIIEncoding encoder = new ASCIIEncoding(); var nameBuf = encoder.GetBytes(Name); for (var i = 0; i < 19; i++) { if (i < nameBuf.Length) cmdBuf[index++] = nameBuf[i]; else cmdBuf[index++] = (byte)' '; } cmdBuf[index++] = 0; // mash steps (PreHeat get sent separately) foreach (var mashStep in MashSteps.Where(mashStep => mashStep.Key != MashStepID.PreHeat)) { cmdBuf[index++] = (byte)mashStep.Value.step_temperature.Value; cmdBuf[index++] = (byte)mashStep.Value.step_time.Value; } // mash heat source cmdBuf[index++] = (byte)MashHeatSource; // Sparge Temp cmdBuf[index++] = (byte)SpargeTemp.Value; // Pitch Temp cmdBuf[index++] = (byte)PitchTemp.Value; // HLT Setpoint cmdBuf[index++] = (byte)HLTSetpoint.Value; // Batch Volume UInt32 uiVal = (UInt32)(BatchVolume.Value * 1000); cmdBuf[index++] = uiVal.Byte3(); cmdBuf[index++] = uiVal.Byte2(); cmdBuf[index++] = uiVal.Byte1(); cmdBuf[index++] = uiVal.Byte0(); // Grain Weight uiVal = (UInt32)(BatchVolume.Value * 1000); cmdBuf[index++] = uiVal.Byte3(); cmdBuf[index++] = uiVal.Byte2(); cmdBuf[index++] = uiVal.Byte1(); cmdBuf[index++] = uiVal.Byte0(); // Boil Time uiVal = (UInt32)(BoilTime.Value); cmdBuf[index++] = uiVal.Byte1(); cmdBuf[index++] = uiVal.Byte0(); // Mash Ratio uiVal = (UInt32)(MashRatio); cmdBuf[index++] = uiVal.Byte1(); cmdBuf[index++] = uiVal.Byte0(); // Boil Adds uiVal = Additions; cmdBuf[index++] = uiVal.Byte1(); cmdBuf[index++] = uiVal.Byte0(); return (byte)(index - offset); }
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); } }
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 }; }