Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve computation of vehicle loading times #940

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class SimulatedRegionOverviewBehaviorTransferVehiclesComponent
).length,
remainingTime:
activeActivityState.startTime +
activeActivityState.loadDelay -
(activeActivityState.loadDelay ?? 0) -
currentTime,
}))
);
Expand Down
8 changes: 5 additions & 3 deletions shared/src/simulation/activities/load-vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export class LoadVehicleActivityState implements SimulationActivityState {

@IsInt()
@Min(0)
public readonly loadDelay: number = 0;
@IsOptional()
public readonly loadDelay: number | undefined = undefined;
lukasrad02 marked this conversation as resolved.
Show resolved Hide resolved

@IsInt()
@Min(0)
Expand Down Expand Up @@ -242,7 +243,7 @@ export const loadVehicleActivity: SimulationActivity<LoadVehicleActivityState> =

// Calculate loading time based on the patients and personnel to be loaded
// Do not do the calculation if the time is already set (which could occur if an instance of this activity was imported from an older state version)
if (activityState.loadDelay === 0) {
if (activityState.loadDelay === undefined) {
activityState.loadDelay =
patientMovementsCount *
activityState.loadTimePerPatient +
Expand All @@ -256,8 +257,9 @@ export const loadVehicleActivity: SimulationActivity<LoadVehicleActivityState> =
}

if (
activityState.loadDelay !== undefined &&
activityState.startTime + activityState.loadDelay <=
draftState.currentTime
draftState.currentTime
) {
// terminate if the occupation has changed
if (
Expand Down