Skip to content

Commit

Permalink
core: simulation: change mrsp format
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter authored and flomonster committed Apr 25, 2024
1 parent ac3cb6c commit 9c3dd76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SimulationResponse(
val base: ReportTrain,
val provisional: ReportTrain,
@Json(name = "final_output") val finalOutput: CompleteReportTrain,
val mrsp: List<MRSPPoint>,
val mrsp: MRSPResponse,
@Json(name = "power_restrictions") val powerRestrictions: List<PowerRestriction>,
) {
companion object {
Expand All @@ -26,9 +26,9 @@ class SimulationResponse(
}
}

class MRSPPoint(
val position: Offset<Path>,
val speed: Double,
class MRSPResponse(
val positions: List<Offset<Path>>,
val speeds: List<Double>,
)

class CompleteReportTrain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,25 @@ fun runStandaloneSimulation(
schedule
)

val mrspResponse =
speedLimits.iteratePoints().map { MRSPPoint(Offset(it.position.meters), it.speed) }
return SimulationResponse(
base = maxEffortResult,
provisional = provisionalResult,
finalOutput = finalEnvelopeResult,
mrsp = mrspResponse,
mrsp = makeMRSPResponse(speedLimits),
powerRestrictions = makePowerRestrictions(curvesAndConditions, powerRestrictionsLegacyMap)
)
}

fun makeMRSPResponse(speedLimits: Envelope): MRSPResponse {
val positions = mutableListOf<Offset<Path>>()
val speeds = mutableListOf<Double>()
for (point in speedLimits.iteratePoints()) {
positions.add(Offset(point.position.meters))
speeds.add(point.speed)
}
return MRSPResponse(positions, speeds)
}

/** Build the power restriction map */
fun makePowerRestrictions(
curvesAndConditions: RollingStock.CurvesAndConditions,
Expand Down

0 comments on commit 9c3dd76

Please sign in to comment.