Skip to content

Commit

Permalink
core: stdcm: use the correct block length in unavailable space builder
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter committed Oct 17, 2023
1 parent 74e4c51 commit d09c49e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static Multimap<Integer, OccupancySegment> computeUnavailableSpace(
var secPreBlockLength = blockInfra.getBlockLength(secondPredecessorBlock);
unavailableSpace.put(secondPredecessorBlock, new OccupancySegment(
timeRange.lowerEndpoint(), timeRange.upperEndpoint(),
Math.max(0, secPreBlockLength - SIGHT_DISTANCE), preBlockLength
Math.max(0, secPreBlockLength - SIGHT_DISTANCE), secPreBlockLength
));
}
}
Expand All @@ -83,6 +83,14 @@ public static Multimap<Integer, OccupancySegment> computeUnavailableSpace(
}
}
}
// validation
for (var entry : unavailableSpace.entries()) {
assert entry.getValue().distanceStart() <= entry.getValue().distanceEnd();
assert entry.getValue().timeStart() <= entry.getValue().timeEnd();
assert entry.getValue().distanceEnd() <= blockInfra.getBlockLength(entry.getKey());
assert 0 <= entry.getValue().distanceStart();
assert 0 <= entry.getValue().timeEnd();
}
return unavailableSpace;
}

Expand Down

0 comments on commit d09c49e

Please sign in to comment.