-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat(charging): provide the charging stations within a certain area #446
base: main
Are you sure you want to change the base?
feat(charging): provide the charging stations within a certain area #446
Conversation
@@ -46,4 +46,7 @@ public class EventNicenessPriorityRegister { | |||
|
|||
// batteryUpdated | |||
public final static long BATTERY_UPDATED = -99_998_900; | |||
|
|||
// discover charging stations | |||
public final static long CHARGING_STATIONS_DISCOVERY = -99_998_900; |
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.
Can somebody explain me at which point the "niceness" is required? What is the effect of this priorization and why do we need it and don't go with FCFS?
Why do we use this only sometimes (in process(final EnvironmentSensorUpdates environmentSensorUpdates)
it's not used)
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.
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.
AFAIK, our DefaultEventScheduler
doesn't care about the niceness of an event.
It uses a PriorityQueue
using the time as priority. If there a ties, i.e. same execution time, Events are executed in an arbitrary order. I think ideally, we would use the defined niceness values to deterministically break those ties.
In the (highly unstable) MultiThreadedEventScheduler
the niceness value is actually used. However, I'm not certain if it has any effect there.
So yes, we don't use this properly anyhow, but if we would it would be to break ties (I think)
@iwillitried for this reason the value of CHARGING_STATIONS_DISCOVERY
should probably be unique.
@@ -46,4 +46,7 @@ public class EventNicenessPriorityRegister { | |||
|
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.
|
||
@Override | ||
public int hashCode() { | ||
return new HashCodeBuilder(9, 97) |
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.
What are those magic numbers here?
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.
Those are the seeds for the hash function. Refer to the Apache Documentation for more insights :)
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 remove magic numbers, e.g.
// seeds: hard-coded, randomly chosen, non-zero, odd number
final static int INITIAL_ODD_NUMBER= 9;
final static int MULTIPLIER_ODD_NUMBER = 97;
return new HashCodeBuilder(INITIAL_ODD_NUMBER, MULTIPLIER_ODD_NUMBER);
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 don't think this is necessary. At least we don't typically do it when overriding the hashCode
function.
Probably the most sensible solution would be to use the default constructor of HashCodeBuilder
, which uses 37 and 17 by default.
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.
} | ||
|
||
@Serial | ||
private static final long serialVersionUID = 1L; |
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.
Why do we have the serial number here? If it's an interaction-specific thing, why don't we use it in the response 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.
Interaction
implements Serializable
, if we would do distributed simulation in some way or another and serialize/deserialize interactions between remote hosts, this UID would be used to assure that all sides have the same class version loaded. When adding new Interaction
s giving a serialVersionUID
of 1 is good, indicating version 1.
Now what we should consider though is that we update this ID whenever we change Interaction
s in a meaningful manner.
(see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html)
I hope this suffices as a explanation 😅
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 think instead of adding the new ChargingStationDiscoveryResponse
interaction. We could/should handle the querying of Charging Stations similar to that of traffic lights (see line 370). Though instead of requiring enabled perception, we assume that EVs have access to a static map of all charging stations.
At least this is how I understood the intention of @kschrab.
.tiles | ||
/logs/ |
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.
This should not be necessary, please remove
@@ -63,6 +75,11 @@ protected boolean handleEventResource(Object resource, long eventType) { | |||
return true; | |||
} | |||
|
|||
if (resource instanceof ChargingStationDiscoveryResponse response) { | |||
onCharginStationDiscoveryResponse((ChargingStationDiscoveryResponse) response); |
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.
This cast is not necessary
onCharginStationDiscoveryResponse((ChargingStationDiscoveryResponse) response); | |
onCharginStationDiscoveryResponse(response); |
} | ||
|
||
@Serial | ||
private static final long serialVersionUID = 1L; |
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.
Interaction
implements Serializable
, if we would do distributed simulation in some way or another and serialize/deserialize interactions between remote hosts, this UID would be used to assure that all sides have the same class version loaded. When adding new Interaction
s giving a serialVersionUID
of 1 is good, indicating version 1.
Now what we should consider though is that we update this ID whenever we change Interaction
s in a meaningful manner.
(see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html)
I hope this suffices as a explanation 😅
|
||
@Override | ||
public int hashCode() { | ||
return new HashCodeBuilder(9, 97) |
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 don't think this is necessary. At least we don't typically do it when overriding the hashCode
function.
Probably the most sensible solution would be to use the default constructor of HashCodeBuilder
, which uses 37 and 17 by default.
|
||
@Override | ||
public int hashCode() { | ||
return new HashCodeBuilder(9, 97) |
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.
* | ||
* @param searchArea The area where the charging stations are search | ||
*/ | ||
void sendChargingStationDiscoveryRequest(GeoCircle searchArea); |
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.
We should probably define the search area as a GeoArea
.
void sendChargingStationDiscoveryRequest(GeoCircle searchArea); | |
void sendChargingStationDiscoveryRequest(GeoArea searchArea); |
Furthermore, we should also discuss what signatures are relevant.
I can think of:
getClosestChargingStation(GeoPosition position)
&getClosestChargingStation()
-> returns the closest charging station either to the current position of the vehicle or to a specified position. E.g., when running low on battery.- Here we should also consider if we just want to consider spatial proximity or also the travel time. As charging stations at the opposite direction of a highway can actually be quite far ->
getShortestPathChargingStation(...)
- Here we should also consider if we just want to consider spatial proximity or also the travel time. As charging stations at the opposite direction of a highway can actually be quite far ->
getChargingStationsInArea(GeoArea geoArea)
-> your use casegetChargingStationsWithinRange(double distance)
-> Get all charging stations that can be reached within a distancegetChargingStationsAlongRoute(double maxDetour)
-> Get all charging stations that are located along the route. This requires advanced routing though.
Description
What is this PR about?
Issue(s) related to this PR
Affected parts of the online documentation
Changes in the documentation required?
Definition of Done
Prerequisites
Required
type(scope): description
(in the style of Conventional Commits)enhancement
, orbugfix
)origin/main
has been merged into your Fork.Requested (can be enforced by maintainers)
Special notes to reviewer