From eb5db43efd8e0212fd864131423ca81548cc41dd Mon Sep 17 00:00:00 2001 From: Karl Schrab Date: Tue, 3 Sep 2024 18:10:00 +0200 Subject: [PATCH] feat(application): servers don't have access on AdHocModule anymore (#404) * Major refactoring of operating system interface hierarchy with a clear definition of which modules are available via additional interfaces. * An OperatingSystem itself is not "owner" of a module anymore (but the implementing simulation unit is). Instead an specific OperatingSystem defines which modules it provides, by defining additional interfaces `CommunicativeCell`, `Perceptive`, `Navigable` and so on. * `AbstractSimulationUnit` still implements and provides functionality a specific unit not necessarily needs, e.g., the `AbstractSimulationUnit` provides an `AdhocModule`, even if the implementing `ServerSimulationUnit` does not need such. Still, a server application can not access the `AdhocModule` anymore due to the clear definition of the `OperatingSystem` interfaces. * Moved `navigation` package inside `simulation` package alongside `perception` and `communication`. --- .../examples/commuter/SimpleCommuterApp.java | 4 +- .../app/tutorial/WeatherWarningApp.java | 2 +- .../src/test/java/WeatherWarningAppTest.java | 3 +- bundle/src/assembly/resources/etc/logback.xml | 2 +- .../ambassador/ApplicationAmbassador.java | 2 +- .../ambassador/SimulationKernel.java | 2 +- .../navigation/INavigationModuleOwner.java | 29 --------- .../simulation/AbstractSimulationUnit.java | 10 ++- .../ambassador/simulation/RoadSideUnit.java | 4 +- .../ambassador/simulation/ServerUnit.java | 16 +---- .../ambassador/simulation/VehicleUnit.java | 9 +-- .../simulation/communication/AdHocModule.java | 13 ++-- .../simulation/communication/CellModule.java | 54 ++++++++++------ .../CommunicationModuleOwner.java | 8 --- .../CentralNavigationComponent.java | 2 +- .../navigation/INavigationModule.java | 2 +- .../navigation/IRoutingModule.java | 2 +- .../navigation/NavigationModule.java | 2 +- .../navigation/RoadPositionFactory.java | 2 +- .../perception/PerceptionModuleOwner.java | 13 ++-- .../os/ChargingStationOperatingSystem.java | 9 ++- .../app/api/os/OperatingSystem.java | 61 ++++++------------- .../api/os/RoadSideUnitOperatingSystem.java | 17 +++--- .../app/api/os/ServerOperatingSystem.java | 12 ++-- .../api/os/TrafficLightOperatingSystem.java | 10 ++- .../app/api/os/VehicleOperatingSystem.java | 9 ++- .../api/os/modules/AdHocCommunicative.java | 33 ++++++++++ .../app/api/os/modules/CellCommunicative.java | 32 ++++++++++ .../app/api/os/modules/Locatable.java | 42 +++++++++++++ .../app/api/os/modules/Navigable.java | 33 ++++++++++ .../app/api/os/modules/Perceptive.java | 33 ++++++++++ .../app/api/os/modules/Routable.java | 32 ++++++++++ .../app/etsi/AbstractCamSendingApp.java | 10 +-- .../ambassador/ApplicationAmbassadorTest.java | 2 +- .../ambassador/SimulationKernelRule.java | 2 +- .../ambassador/UnitSimulatorTest.java | 2 +- .../AbstractSimulationUnitTest.java | 2 +- .../ambassador/simulation/VehicleTest.java | 2 +- .../CentralNavigationComponentTest.java | 2 +- .../CentralNavigationComponentTestRule.java | 2 +- .../navigation/MyTestRouting.java | 2 +- .../navigation/NavigationModuleTest.java | 2 +- .../navigation/RoadPositionFactoryTest.java | 2 +- .../perception/PerceptionModifierTest.java | 2 +- .../SimplePerceptionModuleTest.java | 2 +- .../app/etsi/EtsiApplicationTest.java | 8 +-- 46 files changed, 348 insertions(+), 198 deletions(-) delete mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/navigation/INavigationModuleOwner.java rename fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/CentralNavigationComponent.java (99%) rename fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/INavigationModule.java (98%) rename fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/IRoutingModule.java (97%) rename fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/NavigationModule.java (99%) rename fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/RoadPositionFactory.java (98%) create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/AdHocCommunicative.java create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/CellCommunicative.java create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Locatable.java create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Navigable.java create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Perceptive.java create mode 100644 fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Routable.java rename fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/CentralNavigationComponentTest.java (99%) rename fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/CentralNavigationComponentTestRule.java (97%) rename fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/MyTestRouting.java (89%) rename fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/NavigationModuleTest.java (99%) rename fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/{ => simulation}/navigation/RoadPositionFactoryTest.java (98%) diff --git a/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/commuter/SimpleCommuterApp.java b/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/commuter/SimpleCommuterApp.java index 3050fad55..089a1eef0 100644 --- a/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/commuter/SimpleCommuterApp.java +++ b/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/commuter/SimpleCommuterApp.java @@ -15,8 +15,8 @@ package org.eclipse.mosaic.app.examples.commuter; -import org.eclipse.mosaic.fed.application.ambassador.navigation.INavigationModule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.RoadPositionFactory; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.INavigationModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.RoadPositionFactory; import org.eclipse.mosaic.fed.application.ambassador.util.UnitLogger; import org.eclipse.mosaic.fed.application.app.AbstractApplication; import org.eclipse.mosaic.fed.application.app.api.Application; diff --git a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java index de6e871e2..5e4e065d9 100644 --- a/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java +++ b/app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java @@ -15,11 +15,11 @@ package org.eclipse.mosaic.app.tutorial; -import org.eclipse.mosaic.fed.application.ambassador.navigation.INavigationModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModuleConfiguration; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CamBuilder; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedAcknowledgement; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedV2xMessage; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.INavigationModule; import org.eclipse.mosaic.fed.application.app.AbstractApplication; import org.eclipse.mosaic.fed.application.app.api.CommunicationApplication; import org.eclipse.mosaic.fed.application.app.api.VehicleApplication; diff --git a/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java b/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java index fa912fce3..0e9b0be6d 100644 --- a/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java +++ b/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java @@ -22,10 +22,10 @@ import static org.mockito.Mockito.when; import org.eclipse.mosaic.app.tutorial.WeatherWarningApp; -import org.eclipse.mosaic.fed.application.ambassador.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.VehicleParameters; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedV2xMessage; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.ambassador.util.UnitLogger; import org.eclipse.mosaic.fed.application.app.api.os.VehicleOperatingSystem; import org.eclipse.mosaic.lib.enums.SensorType; @@ -34,7 +34,6 @@ import org.eclipse.mosaic.lib.objects.road.IConnection; import org.eclipse.mosaic.lib.objects.road.IRoadPosition; import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; -import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; import org.eclipse.mosaic.lib.objects.v2x.V2xReceiverInformation; import org.eclipse.mosaic.lib.objects.v2x.etsi.Denm; import org.eclipse.mosaic.lib.objects.vehicle.VehicleData; diff --git a/bundle/src/assembly/resources/etc/logback.xml b/bundle/src/assembly/resources/etc/logback.xml index 98cca0d1d..4a1baf924 100644 --- a/bundle/src/assembly/resources/etc/logback.xml +++ b/bundle/src/assembly/resources/etc/logback.xml @@ -159,7 +159,7 @@ - + diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassador.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassador.java index c431b037a..730249f61 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassador.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassador.java @@ -16,11 +16,11 @@ package org.eclipse.mosaic.fed.application.ambassador; import org.eclipse.mosaic.fed.application.ambassador.eventresources.RemoveVehicles; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit; import org.eclipse.mosaic.fed.application.ambassador.simulation.TrafficLightGroupUnit; import org.eclipse.mosaic.fed.application.ambassador.simulation.TrafficManagementCenterUnit; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedV2xMessage; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.ambassador.util.EventNicenessPriorityRegister; import org.eclipse.mosaic.fed.application.app.api.MosaicApplication; diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernel.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernel.java index b74ae0394..9a73fa1d4 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernel.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernel.java @@ -15,8 +15,8 @@ package org.eclipse.mosaic.fed.application.ambassador; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.config.CApplicationAmbassador; import org.eclipse.mosaic.interactions.communication.V2xMessageRemoval; diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/navigation/INavigationModuleOwner.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/navigation/INavigationModuleOwner.java deleted file mode 100644 index 0ccdbb867..000000000 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/navigation/INavigationModuleOwner.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 Fraunhofer FOKUS and others. All rights reserved. - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contact: mosaic@fokus.fraunhofer.de - */ - -package org.eclipse.mosaic.fed.application.ambassador.navigation; - -/** - * Interface to implement if a class navigation module should be the owner of a {@link NavigationModule}. - */ -public interface INavigationModuleOwner { - - /** - * Returns the navigation module of the vehicle. - * - * @return the navigation module of the vehicle. - */ - INavigationModule getNavigationModule(); -} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java index ccd09b22b..65f7cda5b 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java @@ -20,6 +20,7 @@ import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AbstractCommunicationModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CellModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CommunicationModuleOwner; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedAcknowledgement; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedV2xMessage; import org.eclipse.mosaic.fed.application.ambassador.util.ClassNameParser; @@ -60,6 +61,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Set; @@ -72,7 +74,7 @@ * It supplies all functionality for loading applications, communication with the RTI * and the processing of events, etc. */ -public abstract class AbstractSimulationUnit implements EventProcessor, OperatingSystem { +public abstract class AbstractSimulationUnit implements EventProcessor, OperatingSystem, CommunicationModuleOwner { /** * Id (name) which indicates the unit. @@ -99,7 +101,7 @@ public abstract class AbstractSimulationUnit implements EventProcessor, Operatin /** * Environment sensor data. */ - private final HashMap environmentEvents = new HashMap<>(); + private final Map environmentEvents = new HashMap<>(); private final AdHocModule adhocModule; @@ -213,8 +215,6 @@ public final long getSimulationTime() { return SimulationKernel.SimulationKernel.getCurrentSimulationTime(); } - - @Override public GeoPoint getInitialPosition() { return initialPosition; } @@ -466,12 +466,10 @@ final byte[] getAndResetUserTaggedValue() { return tmp; } - @Override public AdHocModule getAdHocModule() { return this.adhocModule; } - @Override public final CellModule getCellModule() { return this.cellModule; } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/RoadSideUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/RoadSideUnit.java index 2b59ccc30..2e63d3a4e 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/RoadSideUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/RoadSideUnit.java @@ -16,9 +16,9 @@ package org.eclipse.mosaic.fed.application.ambassador.simulation; import org.eclipse.mosaic.fed.application.ambassador.ErrorRegister; -import org.eclipse.mosaic.fed.application.ambassador.navigation.IRoutingModule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CamBuilder; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.IRoutingModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.app.api.CommunicationApplication; import org.eclipse.mosaic.fed.application.app.api.os.RoadSideUnitOperatingSystem; import org.eclipse.mosaic.lib.enums.RsuType; diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java index f294cb125..458bb4cc5 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java @@ -16,12 +16,10 @@ package org.eclipse.mosaic.fed.application.ambassador.simulation; import org.eclipse.mosaic.fed.application.ambassador.ErrorRegister; -import org.eclipse.mosaic.fed.application.ambassador.navigation.IRoutingModule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.NavigationModule; -import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CamBuilder; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.IRoutingModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.app.api.os.ServerOperatingSystem; -import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.objects.mapping.ServerMapping; import org.eclipse.mosaic.lib.util.scheduling.Event; @@ -54,21 +52,11 @@ public ServerUnit(String unitName) { routingModule = new NavigationModule(this); } - @Override - public GeoPoint getPosition() { - throw new UnsupportedOperationException("Servers aren't mapped to a location."); - } - @Override public CamBuilder assembleCamMessage(CamBuilder camBuilder) { throw new UnsupportedOperationException("Servers can't send CAMs."); } - @Override - public AdHocModule getAdHocModule() { - throw new UnsupportedOperationException("Servers can't access AdHoc functionality."); - } - @Override public IRoutingModule getRoutingModule() { return routingModule; diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleUnit.java index 71ce0fa5d..8844f47f8 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleUnit.java @@ -17,11 +17,12 @@ import org.eclipse.mosaic.fed.application.ambassador.ErrorRegister; import org.eclipse.mosaic.fed.application.ambassador.SimulationKernel; -import org.eclipse.mosaic.fed.application.ambassador.navigation.INavigationModule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.NavigationModule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.RoadPositionFactory; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CamBuilder; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.INavigationModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.NavigationModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.RoadPositionFactory; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.NopPerceptionModule; +import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.PerceptionModuleOwner; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.SimplePerceptionConfiguration; import org.eclipse.mosaic.fed.application.app.api.CommunicationApplication; import org.eclipse.mosaic.fed.application.app.api.VehicleApplication; @@ -54,7 +55,7 @@ /** * This class represents a vehicle in the application simulator. */ -public class VehicleUnit extends AbstractSimulationUnit implements VehicleOperatingSystem { +public class VehicleUnit extends AbstractSimulationUnit implements VehicleOperatingSystem, PerceptionModuleOwner { @Nonnull private final NavigationModule navigationModule; diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/AdHocModule.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/AdHocModule.java index 4f5ae55fc..32c0cc322 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/AdHocModule.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/AdHocModule.java @@ -17,12 +17,13 @@ import static java.lang.Integer.min; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; import org.eclipse.mosaic.interactions.communication.AdHocCommunicationConfiguration; import org.eclipse.mosaic.lib.enums.AdHocChannel; +import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.objects.addressing.AdHocMessageRoutingBuilder; import org.eclipse.mosaic.lib.objects.communication.AdHocConfiguration; import org.eclipse.mosaic.lib.objects.communication.InterfaceConfiguration; -import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; import org.slf4j.Logger; @@ -115,9 +116,7 @@ public Integer sendCam() { log.warn("sendCAM: Ad hoc communication disabled (!adhocModule.isEnabled())."); return null; } - - final MessageRouting routing = createMessageRouting().topoBroadCast(); - return super.sendCam(routing); + return super.sendCam(createMessageRouting().topoBroadCast()); } @Override @@ -141,6 +140,10 @@ public void sendV2xMessage(V2xMessage msg) { * @return the created builder for further configuration */ public AdHocMessageRoutingBuilder createMessageRouting() { - return new AdHocMessageRoutingBuilder(this.getOwner().getId(), this.getOwner().getPosition()); + if (!(getOwner() instanceof Locatable)) { + throw new UnsupportedOperationException("Cannot send message from senders without a location."); + } + GeoPoint position = ((Locatable) getOwner()).getPosition(); + return new AdHocMessageRoutingBuilder(getOwner().getId(), position); } } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java index 61984251c..df6dada0d 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/communication/CellModule.java @@ -15,15 +15,12 @@ package org.eclipse.mosaic.fed.application.ambassador.simulation.communication; -import org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem; -import org.eclipse.mosaic.fed.application.app.api.os.ServerOperatingSystem; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; import org.eclipse.mosaic.interactions.communication.CellularCommunicationConfiguration; -import org.eclipse.mosaic.lib.enums.DestinationType; import org.eclipse.mosaic.lib.geo.GeoCircle; import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.objects.addressing.CellMessageRoutingBuilder; import org.eclipse.mosaic.lib.objects.communication.CellConfiguration; -import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; import org.eclipse.mosaic.lib.objects.v2x.V2xMessage; import org.slf4j.Logger; @@ -40,7 +37,7 @@ public class CellModule extends AbstractCommunicationModule getPerceptionModule(); - } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ChargingStationOperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ChargingStationOperatingSystem.java index b0156cde6..8dbd89aca 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ChargingStationOperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ChargingStationOperatingSystem.java @@ -15,16 +15,19 @@ package org.eclipse.mosaic.fed.application.app.api.os; +import org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; import org.eclipse.mosaic.lib.objects.electricity.ChargingStationData; import javax.annotation.Nullable; /** * This interface extends the basic {@link OperatingSystem} and - * is implemented by the {@link org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit} - * {@link org.eclipse.mosaic.fed.application.ambassador.simulation.ChargingStationUnit}. + * is implemented by the {@link org.eclipse.mosaic.fed.application.ambassador.simulation.ChargingStationUnit}. */ -public interface ChargingStationOperatingSystem extends OperatingSystem { +public interface ChargingStationOperatingSystem + extends OperatingSystem, Locatable, CellCommunicative, AdHocCommunicative { /** * Returns the charging station information. diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/OperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/OperatingSystem.java index 1bc3d1152..27e1f5509 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/OperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/OperatingSystem.java @@ -15,14 +15,11 @@ package org.eclipse.mosaic.fed.application.app.api.os; -import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; -import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CellModule; -import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CommunicationModuleOwner; import org.eclipse.mosaic.fed.application.app.api.Application; import org.eclipse.mosaic.lib.enums.SensorType; -import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.util.scheduling.EventManager; import org.eclipse.mosaic.rti.TIME; +import org.eclipse.mosaic.rti.api.Interaction; import java.io.File; import java.util.List; @@ -31,7 +28,7 @@ * This interface describes all necessary functionality for units to be * simulated. */ -public interface OperatingSystem extends CommunicationModuleOwner { +public interface OperatingSystem { /** * Returns the path to the application simulator configuration directory. @@ -54,6 +51,13 @@ public interface OperatingSystem extends CommunicationModuleOwner { */ String getId(); + /** + * Get the group of this simulation unit, defined in the mapping. + * + * @return the group of this simulation unit. + */ + String getGroup(); + /** * Returns the simulation time. Unit: [ns]. * @@ -74,22 +78,12 @@ default long getSimulationTimeMs() { } /** - * This data element provides an absolute geographical longitude and latitude in a WGS84 - * coordinate system with a granularity of 1/8 micro degrees. Compliant to SAE J2735 - * DE_Longitude. - * - * @return the position. - */ - GeoPoint getInitialPosition(); - - /** - * This data element provides an absolute geographical longitude and latitude in a WGS84 - * coordinate system with a granularity of 1/8 micro degrees. Compliant to SAE J2735 - * DE_Longitude. + * Returns The state of the supplied sensor. * - * @return the position. + * @param type The {@link SensorType} type to use. + * @return Strength of the measured environment sensor data. */ - GeoPoint getPosition(); + int getStateOfEnvironmentSensor(SensorType type); /** * Send a log tuple for the ITEF visualizer. @@ -97,6 +91,7 @@ default long getSimulationTimeMs() { * @param logTupleId log tuple identifier * @param values list of values to be logged */ + @Deprecated void sendItefLogTuple(long logTupleId, int... values); /** @@ -109,26 +104,11 @@ default long getSimulationTimeMs() { String sendSumoTraciRequest(byte[] command); /** - * Returns The state of the supplied sensor. - * - * @param type The {@link SensorType} type to use. - * @return Strength of the measured environment sensor data. - */ - int getStateOfEnvironmentSensor(SensorType type); - - /** - * Returns the cellular communication module of this unit. + * Sends the given {@link Interaction} to the runtime infrastructure. * - * @return the {@link CellModule} of this unit. + * @param interaction the {@link Interaction} to be send */ - CellModule getCellModule(); - - /** - * Returns the ad-hoc communication module of this unit. - * - * @return the {@link AdHocModule} of this unit. - */ - AdHocModule getAdHocModule(); + void sendInteractionToRti(Interaction interaction); /** * Get the list of all applications running on this simulation unit. @@ -143,11 +123,4 @@ default long getSimulationTimeMs() { * @return the list containing all applications. */ Iterable getApplicationsIterator(Class applicationClass); - - /** - * Get the group of this simulation unit, defined in the mapping. - * - * @return the group of this simulation unit. - */ - String getGroup(); } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/RoadSideUnitOperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/RoadSideUnitOperatingSystem.java index 620cd95bd..944ed0d41 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/RoadSideUnitOperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/RoadSideUnitOperatingSystem.java @@ -15,19 +15,16 @@ package org.eclipse.mosaic.fed.application.app.api.os; -import org.eclipse.mosaic.fed.application.ambassador.navigation.IRoutingModule; +import org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Routable; /** * This interface extends the basic {@link OperatingSystem} and - * is implemented by the {@link org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit} - * {@link org.eclipse.mosaic.fed.application.ambassador.simulation.RoadSideUnit}. + * is implemented by the {@link org.eclipse.mosaic.fed.application.ambassador.simulation.RoadSideUnit}. */ -public interface RoadSideUnitOperatingSystem extends OperatingSystem { +public interface RoadSideUnitOperatingSystem + extends OperatingSystem, Locatable, Routable, CellCommunicative, AdHocCommunicative { - /** - * Gives access to a routing facility for calculating routes through the road network. - * - * @return the {@link IRoutingModule} - */ - IRoutingModule getRoutingModule(); } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ServerOperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ServerOperatingSystem.java index dd08d511e..8f002ece1 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ServerOperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/ServerOperatingSystem.java @@ -15,18 +15,14 @@ package org.eclipse.mosaic.fed.application.app.api.os; -import org.eclipse.mosaic.fed.application.ambassador.navigation.IRoutingModule; +import org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Routable; /** * Note: This interface is empty for now and currently only functions as a marker-interface. Future extensions * might add features. */ -public interface ServerOperatingSystem extends OperatingSystem { +public interface ServerOperatingSystem + extends OperatingSystem, Routable, CellCommunicative { - /** - * Gives access to a routing facility for calculating routes through the road network. - * - * @return the {@link IRoutingModule} - */ - IRoutingModule getRoutingModule(); } diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/TrafficLightOperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/TrafficLightOperatingSystem.java index c8d07c72e..70bdc2918 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/TrafficLightOperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/TrafficLightOperatingSystem.java @@ -17,6 +17,9 @@ import org.eclipse.mosaic.fed.application.ambassador.util.EventNicenessPriorityRegister; import org.eclipse.mosaic.fed.application.app.AbstractApplication; +import org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; import org.eclipse.mosaic.lib.objects.trafficlight.TrafficLight; import org.eclipse.mosaic.lib.objects.trafficlight.TrafficLightGroup; import org.eclipse.mosaic.lib.objects.trafficlight.TrafficLightProgram; @@ -35,7 +38,8 @@ * than processing of a not specific event in an application which doesn't happen inside of {@link AbstractApplication#onStartup()} method * and therefore is called *before* the event is processed in an application using this OS. */ -public interface TrafficLightOperatingSystem extends OperatingSystem { +public interface TrafficLightOperatingSystem + extends OperatingSystem, Locatable, CellCommunicative, AdHocCommunicative { /** * Returns all traffic light programs that are registered for a traffic light group using this operating system. @@ -59,7 +63,7 @@ public interface TrafficLightOperatingSystem extends OperatingSystem { TrafficLightProgramPhase getCurrentPhase(); /** - * Returns all traffic lights a traffic light group using this operating system consist of + * Returns all traffic lights a traffic light group using this operating system. * * @return all traffic lights within a traffic light group */ @@ -73,7 +77,7 @@ public interface TrafficLightOperatingSystem extends OperatingSystem { * @param trafficLightProgramId id of the traffic light program to look into * @param trafficLightId id of a traffic light * @return a sequence of states for a certain traffic light within a traffic light program with given id - * or a sequence of states for the current program. + * or a sequence of states for the current program. */ Collection getSignalSequence(String trafficLightProgramId, int trafficLightId); diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/VehicleOperatingSystem.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/VehicleOperatingSystem.java index bc67e8c6b..2c44b56d6 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/VehicleOperatingSystem.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/VehicleOperatingSystem.java @@ -15,9 +15,12 @@ package org.eclipse.mosaic.fed.application.app.api.os; -import org.eclipse.mosaic.fed.application.ambassador.navigation.INavigationModuleOwner; import org.eclipse.mosaic.fed.application.ambassador.simulation.VehicleParameters; -import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.PerceptionModuleOwner; +import org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Locatable; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Navigable; +import org.eclipse.mosaic.fed.application.app.api.os.modules.Perceptive; import org.eclipse.mosaic.interactions.vehicle.VehicleLaneChange; import org.eclipse.mosaic.interactions.vehicle.VehicleSensorActivation.SensorType; import org.eclipse.mosaic.lib.enums.VehicleStopMode; @@ -33,7 +36,7 @@ * {@link org.eclipse.mosaic.fed.application.ambassador.simulation.VehicleUnit}. */ public interface VehicleOperatingSystem - extends OperatingSystem, INavigationModuleOwner, PerceptionModuleOwner { + extends OperatingSystem, Locatable, Navigable, Perceptive, CellCommunicative, AdHocCommunicative { /** * Returns the current vehicle data state. diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/AdHocCommunicative.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/AdHocCommunicative.java new file mode 100644 index 000000000..8cf4b34a5 --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/AdHocCommunicative.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; + +/** + * Interface to mark an {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as + * an owner of a {@link AdHocModule} to enable ad-hoc communication, thus making it communicative via ITS-G5. + */ +public interface AdHocCommunicative extends Locatable { + + /** + * Returns the ad-hoc communication module of this unit. + * + * @return the {@link AdHocModule} of this unit. + */ + AdHocModule getAdHocModule(); + +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/CellCommunicative.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/CellCommunicative.java new file mode 100644 index 000000000..783b8f60a --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/CellCommunicative.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.CellModule; + +/** + * Interface to mark an {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as + * an owner of a {@link CellModule} to enable cellular communication, thus making it communicative via cell. + */ +public interface CellCommunicative { + + /** + * Returns the cellular communication module of this unit. + * + * @return the {@link CellModule} of this unit. + */ + CellModule getCellModule(); +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Locatable.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Locatable.java new file mode 100644 index 000000000..5742d64b4 --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Locatable.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.lib.geo.GeoPoint; + +/** + * Interface that marks a {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as locatable, + * meaning that is located somewhere in world and is able to provide its location. + */ +public interface Locatable { + + /** + * This data element provides an absolute geographical longitude and latitude in a WGS84 + * coordinate system. + * + * @return the position. + */ + GeoPoint getInitialPosition(); + + /** + * This data element provides an absolute geographical longitude and latitude in a WGS84 + * coordinate system. + * + * @return the position. + */ + GeoPoint getPosition(); + +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Navigable.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Navigable.java new file mode 100644 index 000000000..02bdb2ab2 --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Navigable.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.INavigationModule; + +/** + * Interface to mark an {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as + * an owner of a {@link INavigationModule} to calculate routes from its current position to any target, + * thus making it navigable. + */ +public interface Navigable extends Locatable { + + /** + * Returns a navigation module to calculate and switch routes to any target. + * + * @return the {@link INavigationModule} of this unit. + */ + INavigationModule getNavigationModule(); +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Perceptive.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Perceptive.java new file mode 100644 index 000000000..17f44133f --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Perceptive.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.SimplePerceptionConfiguration; +import org.eclipse.mosaic.fed.application.app.api.perception.PerceptionModule; + +/** + * Interface to mark an {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as + * an owner of a {@link PerceptionModule} to perceive surrounding vehicles, thus making it perceptive. + * + */ +public interface Perceptive { + + /** + * Returns the perception module of this unit. + */ + PerceptionModule getPerceptionModule(); + +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Routable.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Routable.java new file mode 100644 index 000000000..daa2479f6 --- /dev/null +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/modules/Routable.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contact: mosaic@fokus.fraunhofer.de + */ + +package org.eclipse.mosaic.fed.application.app.api.os.modules; + +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.IRoutingModule; + +/** + * Interface to mark an {@link org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem} as + * an owner of a {@link IRoutingModule} to calculates routes from A to B, thus making it routable. + */ +public interface Routable { + + /** + * Returns a routing module to calculate arbitrary routes from any point to any other. + * + * @return the {@link IRoutingModule} of the unit. + */ + IRoutingModule getRoutingModule(); +} diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/etsi/AbstractCamSendingApp.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/etsi/AbstractCamSendingApp.java index 7893a5ae6..693facba8 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/etsi/AbstractCamSendingApp.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/app/etsi/AbstractCamSendingApp.java @@ -18,6 +18,7 @@ import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModuleConfiguration; import org.eclipse.mosaic.fed.application.app.ConfigurableApplication; import org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem; +import org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative; import org.eclipse.mosaic.fed.application.config.CEtsi; import org.eclipse.mosaic.lib.enums.AdHocChannel; import org.eclipse.mosaic.lib.geo.CartesianPoint; @@ -34,7 +35,7 @@ * @see RoadSideUnitCamSendingApp * @see TrafficLightCamSendingApp */ -public abstract class AbstractCamSendingApp extends ConfigurableApplication { +public abstract class AbstractCamSendingApp extends ConfigurableApplication { private Data data; @@ -49,13 +50,14 @@ protected AbstractCamSendingApp() { /** * Constructor with a configuration class and a configuration filename. * - * @param configClazz Configuration class defining ETSI specific parameter. + * @param configClass Configuration class defining ETSI specific parameter. * @param configFileName Configuration filename. */ - protected AbstractCamSendingApp(Class configClazz, String configFileName) { - super(configClazz, configFileName); + protected AbstractCamSendingApp(Class configClass, String configFileName) { + super(configClass, configFileName); } + /** * Abstract method generating a {@link Data}-object from * the applications' state. diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassadorTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassadorTest.java index 56cc5c5c1..e58ad6110 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassadorTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/ApplicationAmbassadorTest.java @@ -27,8 +27,8 @@ import static org.mockito.Mockito.when; import org.eclipse.mosaic.fed.application.ambassador.eventresources.StartApplications; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedAcknowledgement; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.app.TestApplicationWithSpy; import org.eclipse.mosaic.fed.application.app.TestChargingStationApplication; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernelRule.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernelRule.java index a73858161..83c909eae 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernelRule.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/SimulationKernelRule.java @@ -15,7 +15,7 @@ package org.eclipse.mosaic.fed.application.ambassador; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.lib.math.DefaultRandomNumberGenerator; import org.eclipse.mosaic.lib.util.junit.TestUtils; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/UnitSimulatorTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/UnitSimulatorTest.java index fe94798d0..b54ae0d5e 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/UnitSimulatorTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/UnitSimulatorTest.java @@ -22,8 +22,8 @@ import static org.mockito.Mockito.verify; import org.eclipse.mosaic.fed.application.ambassador.eventresources.RemoveVehicles; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.app.TestApplicationWithSpy; import org.eclipse.mosaic.fed.application.app.TestVehicleApplication; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnitTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnitTest.java index 3aa64991a..84c341b46 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnitTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnitTest.java @@ -19,7 +19,7 @@ import org.eclipse.mosaic.fed.application.ambassador.SimulationKernel; import org.eclipse.mosaic.fed.application.ambassador.SimulationKernelRule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.app.TestElectricVehicleApplication; import org.eclipse.mosaic.fed.application.app.TestVehicleApplication; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleTest.java index d46e24163..80cdec57a 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/VehicleTest.java @@ -21,8 +21,8 @@ import org.eclipse.mosaic.fed.application.ambassador.SimulationKernel; import org.eclipse.mosaic.fed.application.ambassador.SimulationKernelRule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModuleConfiguration; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent; import org.eclipse.mosaic.fed.application.app.TestVehicleApplication; import org.eclipse.mosaic.fed.application.config.CApplicationAmbassador; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTest.java similarity index 99% rename from fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTest.java rename to fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTest.java index 177e0440b..77e905f13 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTest.java @@ -13,7 +13,7 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.fed.application.ambassador.navigation; +package org.eclipse.mosaic.fed.application.ambassador.simulation.navigation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTestRule.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTestRule.java similarity index 97% rename from fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTestRule.java rename to fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTestRule.java index b003d7ef3..fb6d220e1 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/CentralNavigationComponentTestRule.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/CentralNavigationComponentTestRule.java @@ -13,7 +13,7 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.fed.application.ambassador.navigation; +package org.eclipse.mosaic.fed.application.ambassador.simulation.navigation; import static org.mockito.Mockito.mock; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/MyTestRouting.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/MyTestRouting.java similarity index 89% rename from fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/MyTestRouting.java rename to fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/MyTestRouting.java index 556a5bf49..8410e5900 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/MyTestRouting.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/MyTestRouting.java @@ -13,7 +13,7 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.fed.application.ambassador.navigation; +package org.eclipse.mosaic.fed.application.ambassador.simulation.navigation; import org.eclipse.mosaic.lib.routing.norouting.NoRouting; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/NavigationModuleTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/NavigationModuleTest.java similarity index 99% rename from fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/NavigationModuleTest.java rename to fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/NavigationModuleTest.java index 7d4cae745..2d25c1280 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/NavigationModuleTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/NavigationModuleTest.java @@ -13,7 +13,7 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.fed.application.ambassador.navigation; +package org.eclipse.mosaic.fed.application.ambassador.simulation.navigation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/RoadPositionFactoryTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/RoadPositionFactoryTest.java similarity index 98% rename from fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/RoadPositionFactoryTest.java rename to fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/RoadPositionFactoryTest.java index 3d87c67b8..13a96b31f 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/navigation/RoadPositionFactoryTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/navigation/RoadPositionFactoryTest.java @@ -13,7 +13,7 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.fed.application.ambassador.navigation; +package org.eclipse.mosaic.fed.application.ambassador.simulation.navigation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/PerceptionModifierTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/PerceptionModifierTest.java index 3c375712b..f63fa467d 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/PerceptionModifierTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/PerceptionModifierTest.java @@ -26,8 +26,8 @@ import org.eclipse.mosaic.fed.application.ambassador.SimulationKernel; import org.eclipse.mosaic.fed.application.ambassador.SimulationKernelRule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.VehicleUnit; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.errormodels.BoundingBoxOcclusion; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.errormodels.DimensionsModifier; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.errormodels.DistanceFilter; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/SimplePerceptionModuleTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/SimplePerceptionModuleTest.java index cf1d81514..110eaf9f1 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/SimplePerceptionModuleTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/ambassador/simulation/perception/SimplePerceptionModuleTest.java @@ -24,8 +24,8 @@ import org.eclipse.mosaic.fed.application.ambassador.SimulationKernel; import org.eclipse.mosaic.fed.application.ambassador.SimulationKernelRule; -import org.eclipse.mosaic.fed.application.ambassador.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.VehicleUnit; +import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.index.TrafficObjectIndex; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.index.objects.VehicleObject; import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.index.providers.TrafficLightTree; diff --git a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/app/etsi/EtsiApplicationTest.java b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/app/etsi/EtsiApplicationTest.java index 947c5a1df..484627a70 100644 --- a/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/app/etsi/EtsiApplicationTest.java +++ b/fed/mosaic-application/src/test/java/org/eclipse/mosaic/fed/application/app/etsi/EtsiApplicationTest.java @@ -28,7 +28,7 @@ import org.eclipse.mosaic.fed.application.ambassador.SimulationKernelRule; import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.AdHocModule; import org.eclipse.mosaic.fed.application.ambassador.util.UnitLoggerImpl; -import org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem; +import org.eclipse.mosaic.fed.application.app.api.os.VehicleOperatingSystem; import org.eclipse.mosaic.fed.application.config.CEtsi; import org.eclipse.mosaic.lib.enums.AdHocChannel; import org.eclipse.mosaic.lib.geo.GeoPoint; @@ -60,7 +60,7 @@ public class EtsiApplicationTest { private CEtsi etsiConfiguration; - private AbstractCamSendingApp app; + private AbstractCamSendingApp app; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -68,7 +68,7 @@ public class EtsiApplicationTest { private final EventManager eventManagerMock = this::captureEvent; @Mock - public OperatingSystem osMock; + public VehicleOperatingSystem osMock; @Mock public AdHocModule adHocModuleMock; @@ -83,7 +83,7 @@ public class EtsiApplicationTest { @Before public void setup() throws NoSuchFieldException { - app = spy(new AbstractCamSendingApp() { + app = spy(new AbstractCamSendingApp() { @Override public Data generateEtsiData() { Data newTestData = new Data();