private void RemoveNozzle(NozzleControl n) { if (n.NozzleID != 1) { Nozzles.Remove(n); } }
private void ExecuteNewShower(object parameter) { Nozzles.Clear(); EvapEnergy = 0; EvapLoadkgperhrpersqm = 0; TotalEvapLoad = 0; }
public void Created() { var @event = new PetrolStationCreated( id: Id, name: Name, tanks: Tanks.Select(x => x.ToContract()).ToList(), nozzles: Nozzles.Select(x => x.ToContract()).ToList()); EventsToSend.Enqueue(@event); }
private void AddNewNozzle() { NozzleControl n = new NozzleControl { NozzleID = _nozzles.Count + 1 }; if (n.NozzleID == 1) { n.NozzleOrificeID = Constants._defaultOrificeID; n.NozzleSpacing = 0; n.NozzleToYankee = Constants._defaultNozzletoYankee; n.SprayRotation = Constants._defaultNozzlerotation; n.SprayAngle = Constants._defaultNozzleAngle; n.NozzlePressure = Constants._operatingpressure; n.NozzleTypeName = Constants.StandardNozzle; n.NozzleTypes = NozzleTypes; } else { n.NozzleOrificeID = Nozzles[n.NozzleID - 2].NozzleOrificeID; if (n.NozzleID > 2) { n.NozzleSpacing = Nozzles[n.NozzleID - 2].NozzleSpacing; } else { n.NozzleSpacing = Constants._defaultNozzleSpacing; } n.NozzleToYankee = Nozzles[n.NozzleID - 2].NozzleToYankee; n.SprayRotation = Nozzles[n.NozzleID - 2].SprayRotation; n.SprayAngle = Nozzles[n.NozzleID - 2].SprayAngle; n.NozzlePressure = Nozzles[0].NozzlePressure; n.NozzleTypeName = Nozzles[n.NozzleID - 2].NozzleTypeName; n.NozzleTypes = NozzleTypes; n.BoomTop = MaximumNozzleToYankee + Constants._nozzleheight + 20; } Nozzles.Add(n); if (Nozzles.Count > 1) { Nozzles[Nozzles.Count - 1].NozzleToYankee = MaximumNozzleToYankee; } }
private Nozzle FindNozzleForCustomer(Nozzle lastNozzle) { Nozzle bestNozzle = null; Nozzle lowestNozzle = null; do { lowestNozzle = bestNozzle; bestNozzle = Nozzles.ElementAt(Random.Next(Nozzles.Count)); if (bestNozzle.GetCustomerQueueSize() == 0) { break; } if (lastNozzle != null && bestNozzle.Id == lastNozzle.Id) { bestNozzle = Nozzles.ElementAt(Random.Next(Nozzles.Count)); } } while (bestNozzle.GetCustomerQueueSize() != 0 && bestNozzle.GetCustomerQueueSize() > (lowestNozzle?.GetCustomerQueueSize() ?? 0)); return(bestNozzle); }
private void appbarbtnCalculate_Click(object sender, EventArgs e) { double _Pressure = 0.0f; double _Rate = 0.0f; double stdFlowRateOfNozzle = 0f; double flowRate = 0f; double _result; string _resultText = "Could not compute spray rate."; if (string.IsNullOrWhiteSpace(txtNozzleCode.Text)) { MessageBox.Show("A nozzle code is required.\nE.G.: 03 or 025 etc.."); txtNozzleCode.Focus(); return; } if (string.IsNullOrWhiteSpace(txtInputPressure.Text)) { MessageBox.Show("The spraying pressure is required."); txtInputPressure.Focus(); return; } if (string.IsNullOrWhiteSpace(txtInputRate.Text)) { MessageBox.Show("The required spray rate is required."); txtInputRate.Focus(); return; } if (!double.TryParse(txtInputPressure.Text, out _Pressure)) { MessageBox.Show("The pressure could not be converted to a number.\nEnter the value in bar."); txtInputPressure.Focus(); return; } ; if (!double.TryParse(txtInputRate.Text, out _Rate)) { MessageBox.Show("The required spray rate could not be converted to a number.\nEnter the value in litres / ha"); txtInputRate.Focus(); return; } ; if (_Rate <= 0) { MessageBox.Show("The spray rate must be greater than zero.\nEnter the value in litres / ha"); txtInputRate.Focus(); return; } else { if (_Pressure <= 0) { MessageBox.Show("The pressure must be greater than zero.\nEnter the value for the required pressure in bar"); txtInputPressure.Focus(); return; } else { Nozzles _nozzles = new Nozzles(); stdFlowRateOfNozzle = _nozzles.getStdFlowRate(txtNozzleCode.Text); flowRate = Spraying.getFlowRate(_Pressure, stdFlowRateOfNozzle); _result = Spraying.getSpeed(_Rate, flowRate, 0.5f); } } _resultText = String.Format("The required spraying speed is {0:f1} kph.", _result); _resultText = _resultText + String.Format("\nStandard flow rate of the nozzle is {0:f3} l/min.", stdFlowRateOfNozzle); _resultText = _resultText + String.Format("\nFlow rate at {0:f1} bar is {1:f3} l/min.", _Pressure, flowRate); txtOutputSpeed.Text = _resultText; this.Focus(); }
private async void appbarbtnCalculate_Click(object sender, EventArgs e) { double _Pressure = 0.0f; double _Rate = 0.0f; double stdFlowRateOfNozzle = 0f; double flowRate = 0f; double _result; string _resultText = "Could not compute spray rate."; if (string.IsNullOrWhiteSpace(txtNozzleCode.Text)) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("A nozzle code is required.\nE.G.: 03 or 025 etc.."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // return focus to text box // txtNozzleCode.GotFocus(); return; } if (string.IsNullOrWhiteSpace(txtInputPressure.Text)) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The spraying pressure is required."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // MessageBox.Show("The spraying pressure is required."); // txtInputPressure return; } if (string.IsNullOrWhiteSpace(txtInputRate.Text)) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The required spray rate is required."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // txtInputRate.Focus(); return; } if (!double.TryParse(txtInputPressure.Text, out _Pressure)) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The pressure could not be converted to a number.\nEnter the value in bar."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // txtInputPressure.Focus(); return; } ; if (!double.TryParse(txtInputRate.Text, out _Rate)) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The required spray rate could not be converted to a number.\nEnter the value in litres / ha."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // txtInputRate.Focus(); return; } ; if (_Rate <= 0) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The spray rate must be greater than zero.\nEnter the value in litres / ha."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // txtInputRate.Focus(); return; } else { if (_Pressure <= 0) { //Creating instance for the MessageDialog Class //and passing the message in it's Constructor MessageDialog msgbox = new MessageDialog("The pressure must be greater than zero.\nEnter the value for the required pressure in bar."); //Calling the Show method of MessageDialog class //which will show the MessageBox await msgbox.ShowAsync(); // txtInputPressure.Focus(); return; } else { Nozzles _nozzles = new Nozzles(); stdFlowRateOfNozzle = _nozzles.getStdFlowRate(txtNozzleCode.Text); flowRate = Spraying.getFlowRate(_Pressure, stdFlowRateOfNozzle); _result = Spraying.getSpeed(_Rate, flowRate, 0.5f); } } _resultText = String.Format("The required spraying speed is {0:f1} kph.", _result); _resultText = _resultText + String.Format("\nStandard flow rate of the nozzle is {0:f3} l/min.", stdFlowRateOfNozzle); _resultText = _resultText + String.Format("\nFlow rate at {0:f1} bar is {1:f3} l/min.", _Pressure, flowRate); txtOutputSpeed.Text = _resultText; // this.Focus(); }
private void OpenSelectedShowerFile(string _filename) { if (!string.IsNullOrEmpty(_filename) && File.Exists(_filename)) { try { Shower _shower = DeSerializeShower(_filename); if (_shower != null) { YankeeSpeed = _shower.YankeeSpeed; YankeeWidth = _shower.YankeeWidth; YankeeDiameter = _shower.YankeeDiameter; DwellDistance = _shower.DwellDistance; OperatingPressure = _shower.OperatingPressure; ShowerTemperature = _shower.ShowerTemperature; CoverageColour = _shower.CoverageColour; Nozzles.Clear(); int ctr = 0; NozzleControl nc; foreach (SerializedNozzle _sernozzle in _shower.Nozzles) { ctr++; nc = new NozzleControl { NozzleID = ctr, NozzleOrificeID = _sernozzle.NozzleOrificeID, NozzleSpacing = _sernozzle.NozzleSpacing, NozzleToYankee = _sernozzle.NozzleToYankee, SprayRotation = _sernozzle.SprayRotation, SprayAngle = _sernozzle.SprayAngle, NozzlePressure = _sernozzle.NozzlePressure, NozzleTypeName = _sernozzle.NozzleTypeName, NozzleSprayWidth = _sernozzle.NozzleSprayWidth, MaximumSprayAngle = _sernozzle.MaximumSprayAngle, NozzleFlow = _sernozzle.NozzleFlow, SprayPattern = _sernozzle.SprayPattern, NozzleTypes = NozzleTypes }; Nozzles.Add(nc); } NumberNozzles = ctr; MenuItems = MRUList.AddFile(MenuItems, _filename, OpenShowerFile); } else { //MenuItems = MRUList.RemoveFile(MenuItems, _filename); MessageBox.Show("The shower file appears to be corrupted and cannot be loaded.", "Unable to load shower file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } catch { //MenuItems = MRUList.RemoveFile(MenuItems, _filename); MessageBox.Show("The shower file appears to be corrupted and cannot be loaded.", "Unable to load shower file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } } else { MenuItems = MRUList.RemoveFile(MenuItems, _filename); } }