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

feat(charging): provide the charging stations within a certain area #446

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kschrab
Copy link
Contributor

@kschrab kschrab commented Dec 12, 2024

Description

  • New method to provide a list of available charging stations within the vicinity of the vehicle (only for Electric Vehicles).

Issue(s) related to this PR

  • Resolves internal issue 950

Affected parts of the online documentation

Changes in the documentation required?

Definition of Done

Prerequisites

  • You have read CONTRIBUTING.md carefully.
  • You have signed the Contributor License Agreement.
  • Your GitHub user id is linked with your Eclipse Account.

Required

  • The title of this merge request follows the scheme type(scope): description (in the style of Conventional Commits)
  • You have assigned a suitable label to this pull request (e.g., enhancement, or bugfix)
  • origin/main has been merged into your Fork.
  • Coding guidelines have been followed (see CONTRIBUTING.md).
  • All checks on GitHub pass.
  • All tests on Jenkins pass.

Requested (can be enforced by maintainers)

  • New functionality is covered by unit tests or integration tests. Code coverage must not decrease.
  • If a bug has been fixed, a new unit test has been written (beforehand) to prove misbehavior
  • There are no new SpotBugs warnings.

Special notes to reviewer

}

@Serial
private static final long serialVersionUID = 1L;
Copy link
Contributor

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?

Copy link
Contributor

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 Interactions 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 Interactions 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 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. 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 implement Serializable.

  2. 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 version 1 again everywhere.

.tiles
/logs/
Copy link
Contributor

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

Copy link
Contributor Author

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.

}

@Serial
private static final long serialVersionUID = 1L;
Copy link
Contributor

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 Interactions 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 Interactions 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 😅

@kschrab kschrab added the enhancement New feature or request label Jan 21, 2025
@kschrab kschrab marked this pull request as ready for review January 21, 2025 12:58
public class ChargingStationTree extends ChargingStationIndex {
private final int bucketSize;

private KdTree<ChargingStationObject> chargingStationTree;
Copy link
Contributor

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?

}

@Override
public void onChargingStationUpdate() {
Copy link
Contributor

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
Copy link
Contributor Author

@kschrab kschrab left a 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) {
Copy link
Contributor Author

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

Comment on lines +75 to +81
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<>();
}
}
Copy link
Contributor Author

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

Comment on lines 51 to 53
public void initialize() {
// initialization at first update
}
Copy link
Contributor Author

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?

Copy link
Contributor

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());
Copy link
Contributor Author

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());

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

}

return this.chargingStationIndex;
}
Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants