-
Notifications
You must be signed in to change notification settings - Fork 456
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
Bug fix regarding multiple plug in #2909
Conversation
}else { | ||
Id<Charger> chargerId = tuple.getSecond(); | ||
Charger c = chargingInfrastructure.getChargers().get(chargerId); | ||
if(c.getLogic().getQueuedVehicles().contains(electricFleet.getElectricVehicles().get(evId)))c.getLogic().removeVehicle(electricFleet.getElectricVehicles().get(evId), event.getTime());// so it is important to remove the vehicle from queue as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat and rearrange your code (e.g. by adding local variables) so it is easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a local variable for the EV for easier reading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code should be shorter and easier to read like this:
if(vehiclesAtChargers.remove(evId) != null || c.getLogic().getQueuedVehicles().contains(ev)){
Id<Charger> chargerId = tuple.getSecond();
Charger c = chargingInfrastructure.getChargers().get(chargerId);
c.getLogic().removeVehicle(ev, event.getTime());
}
this makes me wonder whether we need the By definetely removing the vehicle both from the charger logic and it's queue, I think we don't need this helper memory map and can thus also get rid of three methods, i.e. do not need to implement neither of the following itnerfaces
As a result, the method in focus here would only be as follows:
@auzpatwary37 can you confirm ? |
@tschlenther this would throw an error in the charging with queuing logic. This is because if the vehicle is not found anywhere the precondition checker in the remove vehicle function in the ChargingWithQueuingLogic class throws an error that the vehicle is neither plugged in nor in queue in this charger. |
right. thanks. Thank you for the bug fix!! |
thanks again for providing this bug fix. i will address in another PR with the attempt for clean and short code |
actually, this should already have been fixed in #2442 |
@tschlenther maybe, seems like the same issue. Adding the vehicles that are queued in the chargers as well will indeed fix the issue without modifying the condition. We are still using an old version and currently trying to shift to the most recent one. |
I have added necessary comments in he file for a smooth understanding. Basically, when the charging end event happens the vehicles are removed from the vehiclesAtCharger map. But if the charging is not started, they are never put into the map in the first place. So, assuming if the vehicles are not there they are full charge is not right as they might be still in the queue and was never plugged in the first place. As a result, the queue in the charging logic is not cleaned and they still await for plug in. The car can then be put into the logic of another charger and gets plugged in simultaneously in two chargers, hence the bug.