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

Bl/#2184 person enters body vehicle missing 4ci #2230

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/main/scala/beam/agentsim/agents/PersonAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,22 @@ class PersonAgent(
netTripCosts // Again, includes tolls but "net" here means actual money paid by the person
)
)
var dataForNextLegOrActivity = data.copy(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than a var, how about a val that better illustrates this anyway:

val dataForNextLegOrActivity = if(...)
    //stuff
    data.copy(...)
else data.copy(...default...)

restOfCurrentTrip = data.restOfCurrentTrip.tail,
currentVehicle = Vector(body.id),
currentTripCosts = 0.0
)
if (data.restOfCurrentTrip.head.unbecomeDriverOnCompletion) {
val vehicleToExit = data.currentVehicle.head
currentBeamVehicle.unsetDriver()
nextNotifyVehicleResourceIdle.foreach(currentBeamVehicle.manager.get ! _)
eventsManager.processEvent(
new PersonLeavesVehicleEvent(_currentTick.get, Id.createPersonId(id), data.currentVehicle.head)
new PersonLeavesVehicleEvent(_currentTick.get, Id.createPersonId(id), vehicleToExit)
)
dataForNextLegOrActivity = data.copy(
restOfCurrentTrip = data.restOfCurrentTrip.tail,
currentVehicle = if (data.currentVehicle.size > 1) data.currentVehicle.tail else Vector(),
currentTripCosts = 0.0
)
if (currentBeamVehicle != body) {
if (currentBeamVehicle.beamVehicleType.vehicleCategory != Bike) {
Expand All @@ -679,11 +690,8 @@ class PersonAgent(
}
}
}
goto(ProcessingNextLegOrStartActivity) using data.copy(
restOfCurrentTrip = data.restOfCurrentTrip.tail,
currentVehicle = Vector(body.id),
currentTripCosts = 0.0
)
goto(ProcessingNextLegOrStartActivity) using dataForNextLegOrActivity

}

when(ReadyToChooseParking, stateTimeout = Duration.Zero) {
Expand Down