public TimeValues(MyBrewery myBrewRecipe, float initialTemperature) { this.downTime = 10F; this.Start = 0F; this.MyBrewRecipe = myBrewRecipe; HeatingCharacteristics = new Heating(myBrewRecipe, initialTemperature); }
//public event PropertyChangedEventHandler PropertyChanged; //MyDelegate myDelegate = new MyDelegate(WriteDataPoint); public ChartViewModel() { this.myBrewRecipe = new MyBrewery(); this.TimeValues = new TimeValues(myBrewRecipe, tapWaterTemperature); this.MashTunBrewDiagram = new MashTun(myBrewRecipe.temperatures, myBrewRecipe.timesMashTun); this.FirstMashBrewDiagram = new FirstMash(myBrewRecipe.temperatures, myBrewRecipe.timesFirstMash); this.SecondMashBrewDiagram = new SecondMash(myBrewRecipe.temperatures, myBrewRecipe.timesSecondMash); this.Title = "Brewing diagram"; #region Heating float timeFromTapWaterToMashIn = (myBrewRecipe.temperatures.mashInTemperature - tapWaterTemperature) / maxRampTo55degC; float timeFromMashInToProtease = (myBrewRecipe.temperatures.proteaseTemperature - myBrewRecipe.temperatures.mashInTemperature) / maxRampTo65degC; float timeFromProteaseToFirstAmylase = (myBrewRecipe.temperatures.firstAmylaseTemperature - myBrewRecipe.temperatures.proteaseTemperature) / maxRampTo65degC; float timeFromFirstAmylaseToSecondAmylase = (myBrewRecipe.temperatures.secondAmylaseTemperature - myBrewRecipe.temperatures.firstAmylaseTemperature) / maxRampTo72degC; float timeFromSecondAmylaseToBoiling = (myBrewRecipe.temperatures.boilingTemperature - myBrewRecipe.temperatures.secondAmylaseTemperature) / maxRampTo100degC; #endregion // dtemprary 10 minutes for prepousteni //myDelegate+= WriteDataPoint(); this.MashTun = new List <DataPoint> { new DataPoint(TimeValues.Start, tapWaterTemperature), new DataPoint(TimeValues.HeatToMashIn, tapWaterTemperature), new DataPoint(TimeValues.MashInStart, MashTunBrewDiagram.MashIn.Temperature), new DataPoint(TimeValues.HeatToProteaseActivation, MashTunBrewDiagram.MashIn.Temperature), new DataPoint(TimeValues.ProteaseStart, MashTunBrewDiagram.ProteaseActivation.Temperature), new DataPoint(TimeValues.FirstMashBoilingEnd, MashTunBrewDiagram.ProteaseActivation.Temperature), new DataPoint(TimeValues.FirstMashBoilingEnd + TimeValues.downTime, MashTunBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.HeatToSecondMashSecondAmylaseActivation, MashTunBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.SecondMashBoilingEnd, MashTunBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.SecondMashBoilingEnd + TimeValues.downTime, MashTunBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.HeatToMashOutActivation + TimeValues.downTime, MashTunBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.MashOutStart, MashTunBrewDiagram.MashOut.Temperature), new DataPoint(TimeValues.MashOutEnd, MashTunBrewDiagram.MashOut.Temperature) }; this.FirstMash = new List <DataPoint> { new DataPoint(TimeValues.HeatToFirstMashFirstAmylaseActivation, MashTunBrewDiagram.ProteaseActivation.Temperature), new DataPoint(TimeValues.FirstMashFirstAmylaseStart, FirstMashBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.HeatToFirstMashSecondAmylaseActivation, FirstMashBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.FirstMashSecondAmylaseStart, FirstMashBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.FirstMashHeatToBoilingTemperature, FirstMashBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.FirstMashBoilingStart, FirstMashBrewDiagram.Boiling.Temperature), new DataPoint(TimeValues.FirstMashBoilingEnd, FirstMashBrewDiagram.Boiling.Temperature), new DataPoint(TimeValues.FirstMashBoilingEnd + TimeValues.downTime, MashTunBrewDiagram.FirstAmylaseActivation.Temperature) }; this.SecondMash = new List <DataPoint> { new DataPoint(TimeValues.HeatToSecondMashSecondAmylaseActivation, MashTunBrewDiagram.FirstAmylaseActivation.Temperature), new DataPoint(TimeValues.SecondMashSecondAmylaseStart, SecondMashBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.SecondMashHeatToBoiling, SecondMashBrewDiagram.SecondAmylaseActivation.Temperature), new DataPoint(TimeValues.SecondMashBoilingStart, SecondMashBrewDiagram.Boiling.Temperature), new DataPoint(TimeValues.SecondMashBoilingEnd, SecondMashBrewDiagram.Boiling.Temperature), new DataPoint(TimeValues.SecondMashBoilingEnd + TimeValues.downTime, MashTunBrewDiagram.SecondAmylaseActivation.Temperature) }; this.RealSituationMashTun = new List <DataPoint>(); this.RealSituationMashing = new List <DataPoint>(); }
public MainWindow() { InitializeComponent(); //myBrewery = new MyBrewery(); chartViewModel = new ChartViewModel(); myBrewery = new MyBrewery(chartViewModel); //externalDataHandling = new ExternalDataHandling(myBrewery); //MyBrewery plot.DataContext = myBrewery; actualMashTunTemperature.DataContext = myBrewery; actualTemperatureOfMashing.DataContext = myBrewery; setMashTunTemperature.DataContext = myBrewery; setTemperatureOfMashing.DataContext = myBrewery; realTemperatureOfMashTun.DataContext = myBrewery; realTemperatureOfMashing.DataContext = myBrewery; newTemperatureSetting.DataContext = myBrewery; outputFromHardware.DataContext = myBrewery; stirrerState.DataContext = myBrewery; txtBoxCalibrationOfMashTunThermometer.DataContext = myBrewery; // Progress times progressTime.DataContext = myBrewery; progressTimeOfFirstMash.DataContext = myBrewery; progressOfSecondMash.DataContext = myBrewery; progressTimeMashIn.DataContext = myBrewery; progressTimeProtease.DataContext = myBrewery; progressMashTunProtease.DataContext = myBrewery; progressMashTunFirstAmylase.DataContext = myBrewery; progressTimeFirstMashFirstAmylase.DataContext = myBrewery; progressTimeFirstMashSecondAmylase.DataContext = myBrewery; progressTimeFirstMashBoiling.DataContext = myBrewery; progressOfSecondMashSecondAmylase.DataContext = myBrewery; progressOfSecondMashBoiling.DataContext = myBrewery; //ChartModel mashTun.DataContext = chartViewModel; firstMash.DataContext = chartViewModel; secondMash.DataContext = chartViewModel; //ExternalComunication connect.DataContext = myBrewery.ExternalDataHandling; commErrors.DataContext = myBrewery.ExternalDataHandling; comPort.DataContext = myBrewery.ExternalDataHandling; outputFromHardware.DataContext = myBrewery.ExternalDataHandling; //Controls //turnStirerOff.DataContext = myBrewery; }
internal ExternalDataHandling(MyBrewery myBrewery) { this.stringBuilderForErrors = new StringBuilder(); //Set up myBrewery this._myBrewery = myBrewery; //Sets up serial port this._serial = new SerialPort(); this._serial.PortName = "COM14"; this._serial.BaudRate = 9600; this._serial.Parity = Parity.None; this._serial.DataBits = 8; this._serial.StopBits = StopBits.One; this._serial.ReadTimeout = 5000; this._serial.WriteTimeout = 50; //this.serial.Handshake = Handshake.None; this.stringBuilder = new StringBuilder(); ActualConnectionState = (ButtonConnectVsDisconnect)ButtonConnectVsDisconnect.Connect; //Sets button State and Creates function call on data recieved this._serial.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(Recieve); }
//private delegate void UpdateUiTextDelegate(string text); private void Recieve(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { try { MyBrewery.ExtractTemperatureFromString(_serial.ReadLine(), Constants.startSequence, Constants.endSequence); WriteOutPutToViewModel(); //WriteDataToViewModel(); } catch (TimeoutException ex) { stringBuilderForErrors.Append($"{DateTime.Now} This was red {_serial.ReadExisting()} {ex.ToString()}\r"); CommErrors = stringBuilderForErrors.ToString(); } catch (System.IO.IOException ex) { stringBuilderForErrors.Append($"{DateTime.Now} {ex.ToString()}\r"); CommErrors = stringBuilderForErrors.ToString(); } finally { //serial.Close(); } //dispatcher.Invoke(DispatcherPriority.Send, new UpdateUiTextDelegate(WriteData), recieved_data); }