-
Notifications
You must be signed in to change notification settings - Fork 58
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
...n/java/org/eclipse/mosaic/fed/application/ambassador/util/EventNicenessPriorityRegister.java
Outdated
Show resolved
Hide resolved
...n/java/org/eclipse/mosaic/fed/application/ambassador/util/EventNicenessPriorityRegister.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/mosaic/interactions/electricity/ChargingStationDiscoveryResponse.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@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.
-
A specific version is needed especially when storing the serialized objects in files or databases and reading them later. Then the version plays a crucial role to determine if a previously stored object is compatible for deserialization or not. Since we don't do such things, we decided long ago that we use
1
always and everywhere where we implementSerializable
. -
We transfer interactions between PHABMACS and MOSAIC by using this object-serialization, thus we need to implement the
Serializable
interface for all interactions, and for all objects which are used by interactions. Nevertheless, since we serialize/deserialize the objects just for the transport from/to PHABMACS, we don't need to care about versioning, thus using version1
again everywhere.
...ation/src/main/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassador.java
Outdated
Show resolved
Hide resolved
.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
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.
@iwillitried yes, there is another .gitignore
in mosaic-starter which ignores the logs
directory. That should suffice and you can remove the /logs/
entry here.
.../main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ElectricVehicleUnit.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@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 😅
.../main/java/org/eclipse/mosaic/interactions/electricity/ChargingStationDiscoveryResponse.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/mosaic/interactions/electricity/ChargingStationDiscoveryResponse.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/mosaic/fed/application/app/api/os/ElectricVehicleOperatingSystem.java
Outdated
Show resolved
Hide resolved
...n/java/org/eclipse/mosaic/fed/application/ambassador/util/EventNicenessPriorityRegister.java
Outdated
Show resolved
Hide resolved
...ic-objects/src/main/java/org/eclipse/mosaic/lib/objects/electricity/ChargingStationData.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/mosaic/fed/application/app/api/os/ElectricVehicleOperatingSystem.java
Outdated
Show resolved
Hide resolved
...pse/mosaic/fed/application/ambassador/simulation/electric/objects/ChargingStationObject.java
Outdated
Show resolved
Hide resolved
...pse/mosaic/fed/application/ambassador/simulation/electric/objects/ChargingStationObject.java
Show resolved
Hide resolved
...pse/mosaic/fed/application/ambassador/simulation/electric/providers/ChargingStationTree.java
Outdated
Show resolved
Hide resolved
...pse/mosaic/fed/application/ambassador/simulation/electric/providers/ChargingStationTree.java
Outdated
Show resolved
Hide resolved
public class ChargingStationTree extends ChargingStationIndex { | ||
private final int bucketSize; | ||
|
||
private KdTree<ChargingStationObject> chargingStationTree; |
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 find the code where this Tree is updated... can you help me? The tree should be updated (= take all data from indexedChargingStations and put it into the tree) latest every time before a search is issued?
...n/java/org/eclipse/mosaic/fed/application/ambassador/util/EventNicenessPriorityRegister.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public void onChargingStationUpdate() { |
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 know that for e.g. TrafficLightTree this does not exist, but please add tests for the functions in ChargingStationIndex and ChargingStationTree
- Merged contents of ChargingStationTree into ChargingStationIndex - ChargingStationIndex is not abstract anymore - small changes regarding function naming and removal of empty lines
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.
Minor changes required. Also, please check if all unit tests are green, currently, ApplicationAmbassadorTest.processInteraction_ChargingStationRegistration
fails
.setChargingStationData(chargingStationData); | ||
} | ||
|
||
public List<ChargingStationObject>getChargingStationsInCircle(GeoCircle circle) { |
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.
Code style: missing space before method name
public void onChargingStationUpdate() { | ||
if (chargingStationTree == null) { // initialize before first update is called | ||
List<ChargingStationObject> allChargingStations = new ArrayList<>(indexedChargingStations.values()); | ||
chargingStationTree = new KdTree<>(new SpatialObjectAdapter<>(), allChargingStations, bucketSize); | ||
treeTraverser = new SpatialTreeTraverser.InRadius<>(); | ||
} | ||
} |
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.
Does this need to be public? I would make that private, rename it to initSearchTree()
and move it right below updateChargingStation
method where it is needed
public void initialize() { | ||
// initialization at first update | ||
} |
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 this method if we don't do anything 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.
removed it
public List<ChargingStationData> getChargingStationsInArea(GeoCircle searchArea) { | ||
return SimulationKernel.SimulationKernel.getChargingStationIndex().getChargingStationsInCircle(searchArea) | ||
.stream().map(ChargingStationObject::getChargingStationData) | ||
.collect(Collectors.toList()); |
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.
use toList()
instead of .collect(Collectors.toList());
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.
ok
} | ||
|
||
return this.chargingStationIndex; | ||
} |
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.
code style: missing blank line after this method.
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.
ok
…ingStationRegistration(...)
Description
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