Skip to content

Commit 1025752

Browse files
authored
Fix empty fuel pump bug in GasStationRefueling sample (#44)
Adds check for empty fuel pump before attempting to draw fuel in GasStationRefueling sample, preventing an invalid get request for 0 fuel. Note: this bug only materialises when attributes are changed from current values such that an empty fuel pump occurs during simulation.
1 parent 2d00846 commit 1025752

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Samples/GasStationRefueling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private IEnumerable<Event> Car(string name, Simulation env, Resource gasStation,
5555

5656
// Get the required amount of fuel
5757
var litersRequired = FuelTankSize - fuelTankLevel;
58-
if (litersRequired > fuelPump.Level) {
58+
if (litersRequired > fuelPump.Level && fuelPump.Level > 0) {
5959
var level = fuelPump.Level;
6060
yield return fuelPump.Get(level); // draw it empty
6161
yield return env.Timeout(TimeSpan.FromSeconds(level / RefuelingSpeed));

0 commit comments

Comments
 (0)