Skip to content

Commit

Permalink
Correctly handle disruption start < evac start; towards #27
Browse files Browse the repository at this point in the history
  • Loading branch information
dhixsingh committed Mar 28, 2018
1 parent 893d228 commit ff47d99
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"disruptions" : [
{
"description" : "Road blocked near -37.077504, 144.203915 due to fallen tree",
"startHHMM" : "0002",
"startHHMM" : "0000",
"endHHMM" : "2359",
"effectiveSpeed" : "0",
"effectiveSpeedUnit" : "KMPH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ void setDataServer(DataServer dataServer) {
/**
* Start publishing disruptions data
*/
public void start() {
Double nextTime = disruptions.higherKey(0.0);
if (nextTime != null) {
dataServer.registerTimedUpdate(PerceptList.DISRUPTION, this, Time.convertTime(nextTime, Time.TimestepUnit.MINUTES, timestepUnit));
}
public void start(int[] hhmm) {
double startTimeInSeconds = Time.convertTime(hhmm[0], Time.TimestepUnit.HOURS, Time.TimestepUnit.SECONDS)
+ Time.convertTime(hhmm[1], Time.TimestepUnit.MINUTES, Time.TimestepUnit.SECONDS);
dataServer.registerTimedUpdate(PerceptList.DISRUPTION, this, Time.convertTime(startTimeInSeconds, Time.TimestepUnit.SECONDS, timestepUnit));
}

/**
Expand All @@ -111,6 +110,5 @@ public void start() {
void setTimestepUnit(Time.TimestepUnit unit) {
timestepUnit = unit;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private static void initializeAndStartDisruptionModel(DataServer dataServer) thr
}
// If the disruptions file was not given, then the model starts but does nothing
model.setTimestepUnit(Time.TimestepUnit.SECONDS);
model.start();
model.start(SimpleConfig.getEvacStartHHMM());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,17 @@ private boolean processDisruptionData( Object data, double now, Scenario scenari
link.getId(), prevSpeed, speedInMpS);
{
double startTime = convertTimeToSeconds(dd.getStartHHMM());
if (startTime < now) {
startTime = now;
}
addNetworkChangeEvent(speedInMpS, link, startTime);
disruptionWriter.write(startTime, link.getId(), link.getCoord(), speedInMpS);
}
{
double startTime = convertTimeToSeconds(dd.getEndHHMM());
if (startTime < now) {
startTime = now;
}
addNetworkChangeEvent(prevSpeed, link, startTime);
disruptionWriter.write(startTime, link.getId(), link.getCoord(), prevSpeed);
}
Expand Down

0 comments on commit ff47d99

Please sign in to comment.