// for setting GUI properly public void SetZapfhahnValues(Zapfsaeule selectedZapfsaeule, Zapfhahn selectedZapfhahn, CustomerSimulation customerSimulation) { this.customerSimulation = customerSimulation; this.selectedZapfsaeule = selectedZapfsaeule; this.selectedZapfhahn = selectedZapfhahn; this.selectedFuelType = selectedZapfhahn.GetFuelType(); // Transaction vo de Zapfsüle wo im GUI slektiert isch SelectedFuelLabel.Content = selectedZapfhahn.GetFuelType().GetFuelTypeName(); CostPerLiterTextBlock.Text = $"{(decimal)selectedZapfhahn.GetFuelType().GetCostPerLiterInCent() / 100}.-"; CostBox.Text = this.selectedZapfsaeule.GetCurrentTransactionFuelAmount() * (decimal)this.selectedZapfhahn.GetFuelType().GetCostPerLiterInCent() / 100 + ".-"; LiterBox.Text = this.selectedZapfsaeule.GetCurrentTransactionFuelAmount() + " L"; if (this.selectedZapfsaeule.isTanking()) { TakeFuel.Content = "Stop"; } else if (this.selectedZapfsaeule.isLocked()) { TakeFuel.Content = "Go pay"; TakeFuel.Background = Brushes.LightGray; TakeFuel.IsEnabled = false; } else if (selectedZapfsaeule.isLocked() == false) { TakeFuel.Content = "Start Tanking"; TakeFuel.ClearValue(BackgroundProperty); TakeFuel.IsEnabled = true; } RefreshTransactions(); }
//--------------------------------------------------------------------- private IFuelType GetFuelType(InputVar <int> fuelTypeIndex, Dictionary <string, int> lineNumbers, InputParameters parameters) { IFuelType selectedFT = null; foreach (IFuelType ftype in parameters.FuelTypes) { if (ftype.Index == fuelTypeIndex.Value) { return(ftype); } } if (selectedFT == null) { throw new InputValueException(fuelTypeIndex.Value.String, "The fuel type {0} was not previously listed", fuelTypeIndex.Value.String); } int lineNumber; if (lineNumbers.TryGetValue(fuelTypeIndex.Value.String, out lineNumber)) { throw new InputValueException(fuelTypeIndex.Value.String, "The fuel type {0} was previously used on line {1}", fuelTypeIndex.Value.String, lineNumber); } else { lineNumbers[fuelTypeIndex.Value.String] = LineNumber; } return(selectedFT); }
/// <summary> /// Switch for: /// Pumps Gas from a selected Zapfsäule. If the Zapfsaeule is already Tanking the Process is stopped /// If The Zapfsaeule isnt tanking yet the Zapfsaeule is locked and the Tanking process is started /// </summary> /// <param name="zapfsaeule">the selected zapfsaeule to tank from</param> /// <param name="fuelType">the selected fueltype to take from the zapfsaeule</param> public void PumpGasFromZapfsauele(Zapfsaeule zapfsaeule, IFuelType fuelType) { if (zapfsaeule.isTanking()) { this.tankstellenkasse.AddTransaction(zapfsaeule.StopTankingTimer()); } else { FuelTank currentFuelTank = this.availableFuelTanks.Find(x => x.GetFuelType() == fuelType); zapfsaeule.StartTankingTimer(currentFuelTank, this.SaveFuelTanks); zapfsaeule.Lock(); } }
//--------------------------------------------------------------------- /// <summary> /// Writes a trailer file. /// </summary> /// <param name="gisFilePath"> /// Path of the .gis file that the trailer file is associated with. /// The name of the trailer file is the path with the ".gis" /// extension replaced with ".trl". /// </param> /// <param name="FuelTypes"> /// List of forest types assigned to classes 1, 2, ... /// </param> public static void Write(string gisFilePath, IFuelType[] FuelTypes) { string trlFilePath = Path.ChangeExtension(gisFilePath, ".trl"); using (BinaryWriter writer = new BinaryWriter(File.Open(trlFilePath, FileMode.Create))) { // Record 1 writer.Write(Trail74Record); // Records 2 to 7 (color scheme) // record color values // ------ ------------ // 2 green classes 0 - 127 (doc says 0-128 but that's 129 values) // 3 green classes 128 - 255 (doc says 129-255 but that's only 127 values) // 4 red classes 0 - 127 (see note for green) // 5 red classes 128 - 255 (see note for green) // 6 blue classes 0 - 127 (see note for green) // 7 blue classes 128 - 255 (see note for green) writer.Write(PadTo256Values(green)); writer.Write(PadTo256Values(red)); writer.Write(PadTo256Values(blue)); // Record 8 writer.Write(Trail74Record); // Records 9 to 16 (histogram values) for (int record = 9; record <= 16; record++) writer.Write(allZeroesRecord); // Records 17 on up (class names: 4 per record) writer.Write(MakeClassName(Class0Name)); //foreach (IFuelType FuelType in FuelTypes) // writer.Write(MakeClassName(FuelType.Name.ToString)); } }
public HondaV6Engine(IFuelType fuelType) { _fuelType = fuelType; }
public BMWI6Engine(IFuelType fuelType) { _fuelType = fuelType; }
//--------------------------------------------------------------------- protected override IInputParameters Parse() { ReadLandisDataVar(); InputParameters parameters = new InputParameters(PlugIn.ModelCore.Species.Count); InputVar <int> timestep = new InputVar <int>("Timestep"); ReadVar(timestep); parameters.Timestep = timestep.Value; // Table of Fuel coefficients InputVar <string> speciesName = new InputVar <string>("Species"); InputVar <double> FuelCoeff = new InputVar <double>("Fuel Coefficient"); Dictionary <string, int> lineNumbers = new Dictionary <string, int>(); const string HardwoodLabel = "HardwoodMaximum"; while (!AtEndOfInput && CurrentName != HardwoodLabel) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(speciesName, currentLine); ISpecies species = GetSpecies(speciesName.Value); CheckForRepeatedName(speciesName.Value, "species", lineNumbers); ReadValue(FuelCoeff, currentLine); parameters.FuelCoefficients[species.Index] = FuelCoeff.Value; CheckNoDataAfter(string.Format("the {0} column", FuelCoeff.Name), currentLine); GetNextLine(); } const string FuelTypeNames = "FuelTypes"; //------------------------------------------------------------ InputVar <int> hardwoodMax = new InputVar <int>("HardwoodMaximum"); ReadVar(hardwoodMax); parameters.HardwoodMax = hardwoodMax.Value; InputVar <int> deadFirMaxAge = new InputVar <int>("DeadFirMaxAge"); ReadVar(deadFirMaxAge); parameters.DeadFirMaxAge = deadFirMaxAge.Value; //------------------------------------------------------------ // Read definitions of Fuel maps PlugIn.ModelCore.UI.WriteLine(" Reading in the Fuel Assignment table..."); ReadName(FuelTypeNames); List <string> speciesNames = new List <string>(); InputVar <int> fi = new InputVar <int>("Fuel Index (should match table in dynamic fire input file)"); InputVar <BaseFuelType> bft = new InputVar <BaseFuelType>("Base Fuel Type"); InputVar <int> minAge = new InputVar <int>("Min Age"); InputVar <int> maxAge = new InputVar <int>("Max Age"); lineNumbers.Clear(); Dictionary <int, int> FuelTypeLineNumbers = new Dictionary <int, int>(); const string DisturbanceConversionTable = "DisturbanceConversionTable"; const string EcoregionTable = "EcoregionTable"; while (!AtEndOfInput && CurrentName != DisturbanceConversionTable && CurrentName != EcoregionTable) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(fi, currentLine); CheckForRepeatedIndex(fi.Value, "fuel type", FuelTypeLineNumbers); IFuelType currentFuelType = new FuelType(PlugIn.ModelCore.Species.Count, PlugIn.ModelCore.Ecoregions.Count); parameters.FuelTypes.Add(currentFuelType); currentFuelType.Index = fi.Value; ReadValue(bft, currentLine); currentFuelType.BaseFuel = bft.Value; // Read the age ranges for the species: ReadValue(minAge, currentLine); currentFuelType.MinAge = minAge.Value; TextReader.SkipWhitespace(currentLine); string word = TextReader.ReadWord(currentLine); if (word != "to") { StringBuilder message = new StringBuilder(); message.AppendFormat("Expected \"to\" after the minimum age ({0})", minAge.Value.String); if (word.Length > 0) { message.AppendFormat(", but found \"{0}\" instead", word); } throw NewParseException(message.ToString()); } ReadValue(maxAge, currentLine); currentFuelType.MaxAge = maxAge.Value; // Read the species for the fuel type: speciesNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(speciesName, currentLine); string name = speciesName.Value.Actual; bool negativeMultiplier = name.StartsWith("-"); if (negativeMultiplier) { name = name.Substring(1); if (name.Length == 0) { throw new InputValueException(speciesName.Value.String, "No species name after \"-\""); } } ISpecies species = GetSpecies(new InputValue <string>(name, speciesName.Value.String)); if (speciesNames.Contains(species.Name)) { throw NewParseException("The species {0} appears more than once.", species.Name); } speciesNames.Add(species.Name); currentFuelType[species.Index] = negativeMultiplier ? -1 : 1; TextReader.SkipWhitespace(currentLine); } if (speciesNames.Count == 0) { throw NewParseException("At least one species is required."); } GetNextLine(); } //---------------------------------------------------------- // Optional ecoregion data if (ReadOptionalName(EcoregionTable)) { PlugIn.ModelCore.UI.WriteLine(" Loading Ecoregion data..."); InputVar <int> fi2 = new InputVar <int>("Fuel Index (Ecoregion Table)"); InputVar <string> ecoregionName = new InputVar <string>("Ecoregion Name"); lineNumbers.Clear(); while (!AtEndOfInput && CurrentName != DisturbanceConversionTable) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(fi2, currentLine); IFuelType currentFuelType = GetFuelType(fi2, lineNumbers, parameters); bool[] ecoregions = new bool[PlugIn.ModelCore.Ecoregions.Count]; for (int i = 0; i < PlugIn.ModelCore.Ecoregions.Count; i++) { ecoregions[i] = false; } // Read the ecoregions for the fuel type: List <string> ecoNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(ecoregionName, currentLine); IEcoregion ecoregion = GetEcoregion(ecoregionName.Value); if (ecoNames.Contains(ecoregion.Name)) { throw NewParseException("The ecoregion {0} appears more than once.", ecoregion.Name); } ecoNames.Add(ecoregion.Name); ecoregions[ecoregion.Index] = true; TextReader.SkipWhitespace(currentLine); } currentFuelType.Ecoregions = ecoregions; GetNextLine(); } } //------------------------------------------------------------ // Read definitions of Disturbance Types PlugIn.ModelCore.UI.WriteLine(" Reading in the Disturbance Type table..."); ReadName(DisturbanceConversionTable); InputVar <int> fti = new InputVar <int>("Fuel Index"); InputVar <int> maxAgeS = new InputVar <int>("Max Age"); InputVar <string> prescriptionName = new InputVar <string>("Prescription"); lineNumbers.Clear(); Dictionary <int, int> distTypeLineNumbers = new Dictionary <int, int>(); const string MapFileNames = "MapFileNames"; const string PctConiferFileName = "PctConiferFileName"; const string PctDeadFirFileName = "PctDeadFirFileName"; while (!AtEndOfInput && CurrentName != MapFileNames) { StringReader currentLine = new StringReader(CurrentLine); ReadValue(fti, currentLine); IDisturbanceType currentDisturbanceType = new DisturbanceType(); parameters.DisturbanceTypes.Add(currentDisturbanceType); currentDisturbanceType.FuelIndex = fti.Value; ReadValue(maxAgeS, currentLine); currentDisturbanceType.MaxAge = maxAgeS.Value; List <string> prescriptionNames = new List <string>(); TextReader.SkipWhitespace(currentLine); while (currentLine.Peek() != -1) { ReadValue(prescriptionName, currentLine); prescriptionNames.Add(prescriptionName.Value); TextReader.SkipWhitespace(currentLine); } if (prescriptionNames.Count == 0) { throw NewParseException("At least one prescription is required."); } currentDisturbanceType.PrescriptionNames = prescriptionNames; GetNextLine(); } //------------------------------------------------------------ // Template for filenames of Fuel maps PlugIn.ModelCore.UI.WriteLine(" Reading in map names..."); InputVar <string> mapFileNames = new InputVar <string>(MapFileNames); ReadVar(mapFileNames); parameters.MapFileNames = mapFileNames.Value; // //GetNextLine(); //------------------------------------------------------------ // Template for filenames of percent conifer maps InputVar <string> pctConiferFileName = new InputVar <string>(PctConiferFileName); ReadVar(pctConiferFileName); parameters.PctConiferFileName = pctConiferFileName.Value; //GetNextLine(); //------------------------------------------------------------ // Template for filenames of percent dead fir maps InputVar <string> pctDeadFirFileName = new InputVar <string>(PctDeadFirFileName); ReadVar(pctDeadFirFileName); parameters.PctDeadFirFileName = pctDeadFirFileName.Value; CheckNoDataAfter(string.Format("the {0} parameter", PctDeadFirFileName)); return(parameters); }
public BMWI6Engine(IFuelType fuelType) { _fuelType = fuelType; }
public HondaV6Engine(IFuelType fuelType) { _fuelType = fuelType; }
/// <summary> /// constructor for the Zapfhahn /// </summary> /// <param name="fuelType">Fueltype which the gas nozzle will dispense</param> public Zapfhahn(IFuelType fuelType) { this.fueltype = fuelType; }