diff --git a/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/emergencybrake/EmergencyBrakeApp.java b/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/emergencybrake/EmergencyBrakeApp.java index 56e95839b..3eb618c69 100644 --- a/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/emergencybrake/EmergencyBrakeApp.java +++ b/app/tutorials/example-applications/src/main/java/org/eclipse/mosaic/app/examples/emergencybrake/EmergencyBrakeApp.java @@ -136,7 +136,12 @@ private void detectEmergencyBrake() { // Prepare the DENMessage MessageRouting routing = - getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).topoBroadCast(); + getOs().getAdHocModule().createMessageRouting() + .channel(AdHocChannel.CCH) + .singlehop() + .broadcast() + .topological() + .build(); Denm denm = new Denm(routing, new DenmContent(getOs().getSimulationTime(), vehicleLongLat, roadId, SensorType.SPEED, 1, curSpeed, curDeceleration * 9.81f, null, null, null), 200); diff --git a/app/tutorials/traffic-light-communication/src/main/java/org/eclipse/mosaic/app/tutorial/RoadSideUnitApp.java b/app/tutorials/traffic-light-communication/src/main/java/org/eclipse/mosaic/app/tutorial/RoadSideUnitApp.java index ccd587341..b70e923b8 100644 --- a/app/tutorials/traffic-light-communication/src/main/java/org/eclipse/mosaic/app/tutorial/RoadSideUnitApp.java +++ b/app/tutorials/traffic-light-communication/src/main/java/org/eclipse/mosaic/app/tutorial/RoadSideUnitApp.java @@ -37,7 +37,12 @@ public class RoadSideUnitApp extends AbstractApplication { private final static long TIME_INTERVAL = TIME.SECOND; - //Use TopoBroadcast instead of GeoBroadcast because latter is not compatible with OMNeT++ or ns-3 + //Use topologically-scoped broadcast instead of geologically-scoped broadcast because latter is not compatible with OMNeT++ or ns-3 private void sendTopoBroadcastMessage() { - final MessageRouting routing = getOperatingSystem() - .getAdHocModule() - .createMessageRouting() - .topoBroadCast(); + final MessageRouting routing = getOperatingSystem().getAdHocModule().createMessageRouting() + .singlehop() + .broadcast() + .topological() + .build(); getOs().getAdHocModule().sendV2xMessage(new GreenWaveMsg(routing, TrafficLightApp.SECRET)); getLog().infoSimTime(this, "Sent secret passphrase"); } 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 07c591bb8..a4625a28c 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 @@ -208,7 +208,7 @@ private void reactOnEnvironmentData(SensorType type, int strength) { if (useCellNetwork()) { mr = getOs().getCellModule().createMessageRouting().topoCast("server_0"); } else { - mr = getOs().getAdHocModule().createMessageRouting().geoBroadCast(dest); + mr = getOs().getAdHocModule().createMessageRouting().broadcast().geographical(dest).build(); } /* diff --git a/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java b/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java index 897dbf1d5..288a43982 100644 --- a/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java +++ b/app/tutorials/weather-warning/src/test/java/WeatherWarningAppTest.java @@ -30,6 +30,7 @@ import org.eclipse.mosaic.fed.application.app.api.os.VehicleOperatingSystem; import org.eclipse.mosaic.fed.application.app.api.perception.BasicSensorModule; import org.eclipse.mosaic.lib.enums.SensorType; +import org.eclipse.mosaic.lib.geo.GeoArea; import org.eclipse.mosaic.lib.objects.addressing.AdHocMessageRoutingBuilder; import org.eclipse.mosaic.lib.objects.addressing.SourceAddressContainer; import org.eclipse.mosaic.lib.objects.road.IConnection; @@ -129,7 +130,9 @@ private void setupMessageRouting() { AdHocMessageRoutingBuilder adHocMessageRoutingBuilderMock = mock(AdHocMessageRoutingBuilder.class); when(adHocModuleMock.createMessageRouting()).thenReturn(adHocMessageRoutingBuilderMock); MessageRouting messageRoutingMock = mock(MessageRouting.class); - when(adHocMessageRoutingBuilderMock.geoBroadCast(any())).thenReturn(messageRoutingMock); + when(adHocMessageRoutingBuilderMock.broadcast()).thenReturn(adHocMessageRoutingBuilderMock); + when(adHocMessageRoutingBuilderMock.geographical(any(GeoArea.class))).thenReturn(adHocMessageRoutingBuilderMock); + when(adHocMessageRoutingBuilderMock.build()).thenReturn(messageRoutingMock); } private void setupVehiclePosition() { 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 daeef9c6c..01ae9a43d 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 @@ -116,7 +116,7 @@ public Integer sendCam() { log.warn("sendCAM: Ad hoc communication disabled (!adhocModule.isEnabled())."); return null; } - return super.sendCam(createMessageRouting().topoBroadCast()); + return super.sendCam(createMessageRouting().singlehop().broadcast().topological().build()); } @Override diff --git a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java index aa350edc1..89b149e68 100644 --- a/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java +++ b/fed/mosaic-cell/src/test/java/org/eclipse/mosaic/fed/cell/chain/ChainManagerTest.java @@ -127,7 +127,7 @@ public void testStartEvent_cellRouting() { @Test public void testStartEvent_adhocRouting() { //SETUP - routing.set(new AdHocMessageRoutingBuilder("veh_0", null).topoBroadCast()); + routing.set(new AdHocMessageRoutingBuilder("veh_0", null).singlehop().broadcast().topological().build()); V2xMessageTransmission sendV2xMsg = new V2xMessageTransmission(12 * TIME.SECOND, v2XMessage); diff --git a/fed/mosaic-output/src/test/java/org/eclipse/mosaic/fed/output/generator/file/format/InteractionFormatterTest.java b/fed/mosaic-output/src/test/java/org/eclipse/mosaic/fed/output/generator/file/format/InteractionFormatterTest.java index aceac29e4..9979c6cce 100644 --- a/fed/mosaic-output/src/test/java/org/eclipse/mosaic/fed/output/generator/file/format/InteractionFormatterTest.java +++ b/fed/mosaic-output/src/test/java/org/eclipse/mosaic/fed/output/generator/file/format/InteractionFormatterTest.java @@ -103,7 +103,7 @@ public void setUp() { // ====================================================== AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", null); - MessageRouting messageRouting = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast(); + MessageRouting messageRouting = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build(); V2xMessage em = new V2xMessage.Empty(messageRouting); diff --git a/fed/mosaic-sns/src/test/java/org/eclipse/mosaic/fed/sns/ambassador/SnsAmbassadorTest.java b/fed/mosaic-sns/src/test/java/org/eclipse/mosaic/fed/sns/ambassador/SnsAmbassadorTest.java index 01115f625..ade649bdf 100644 --- a/fed/mosaic-sns/src/test/java/org/eclipse/mosaic/fed/sns/ambassador/SnsAmbassadorTest.java +++ b/fed/mosaic-sns/src/test/java/org/eclipse/mosaic/fed/sns/ambassador/SnsAmbassadorTest.java @@ -135,17 +135,17 @@ public void topoBroadcast_differentSendingRadiusPerVehicle() throws InternalFede //RUN + ASSERT AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", vehToPosition.get("veh_0")); - MessageRouting routing1 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast(); + MessageRouting routing1 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build(); sendMessage(routing1); assertReceivedMessages("veh_1"); adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_1", vehToPosition.get("veh_1")); - MessageRouting routing2 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast(); + MessageRouting routing2 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build(); sendMessage(routing2); assertReceivedMessages("veh_0", "veh_2"); adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_2", vehToPosition.get("veh_2")); - MessageRouting routing3 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast(); + MessageRouting routing3 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build(); sendMessage(routing3); assertReceivedMessages(); @@ -168,8 +168,10 @@ public void geoBroadcast_vehiclesInRowWithCustomRadius() throws InternalFederate // RUN + ASSERT AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", vehToPosition.get("veh_0")); MessageRouting routing1 = adHocMessageRoutingBuilder - .viaChannel(AdHocChannel.CCH) - .geoBroadCast(new GeoCircle(vehToPosition.get("veh_2"), 300)); + .channel(AdHocChannel.CCH) + .broadcast() + .geographical(new GeoCircle(vehToPosition.get("veh_2"), 300)) + .build(); sendMessage(routing1); assertReceivedMessages("veh_1", "veh_2"); diff --git a/fed/mosaic-sumo/src/main/java/org/eclipse/mosaic/fed/sumo/ambassador/AbstractSumoAmbassador.java b/fed/mosaic-sumo/src/main/java/org/eclipse/mosaic/fed/sumo/ambassador/AbstractSumoAmbassador.java index 40e02ded6..eb958d069 100644 --- a/fed/mosaic-sumo/src/main/java/org/eclipse/mosaic/fed/sumo/ambassador/AbstractSumoAmbassador.java +++ b/fed/mosaic-sumo/src/main/java/org/eclipse/mosaic/fed/sumo/ambassador/AbstractSumoAmbassador.java @@ -1043,6 +1043,7 @@ private void receiveInteraction(VehicleSensorActivation vehicleSensorActivation) */ private void receiveInteraction(VehicleParametersChange vehicleParametersChange) throws InternalFederateException { if (externalVehicles.containsKey(vehicleParametersChange.getVehicleId())) { + changeExternalParameters(vehicleParametersChange); return; } @@ -1283,6 +1284,17 @@ private void removeExternalVehiclesFromUpdates(VehicleUpdates updates) { updates.getRemovedNames().removeIf(vehicle -> externalVehicles.remove(vehicle) != null); } + public void changeExternalParameters(VehicleParametersChange vehicleParametersChange) throws InternalFederateException { + final String veh_id = vehicleParametersChange.getVehicleId(); + for (final VehicleParameter param : vehicleParametersChange.getVehicleParameters()) { + // Only color is supported as a parameter for external vehicles so far. + if (param.getParameterType() == VehicleParameter.VehicleParameterType.COLOR) { + final Color color = param.getValue(); + bridge.getVehicleControl().setColor(veh_id, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + } + } + } + /** * This handles the case that sumo handles routing and creates new routes while doing so. * diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java index c2aaba997..953bb6c71 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/addressing/AdHocMessageRoutingBuilder.java @@ -19,11 +19,11 @@ import org.eclipse.mosaic.lib.enums.DestinationType; import org.eclipse.mosaic.lib.enums.ProtocolType; import org.eclipse.mosaic.lib.geo.GeoArea; -import org.eclipse.mosaic.lib.geo.GeoCircle; import org.eclipse.mosaic.lib.geo.GeoPoint; -import org.eclipse.mosaic.lib.geo.GeoRectangle; import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; +import org.apache.commons.lang3.Validate; + import java.net.Inet4Address; /** @@ -32,8 +32,23 @@ */ public class AdHocMessageRoutingBuilder { + /** + * The maximum time to live (TTL). + */ + private final static int MAXIMUM_TTL = 255; + private final SourceAddressContainer sourceAddressContainer; + private AdHocChannel channel = AdHocChannel.CCH; + private NetworkAddress destination = null; + private Integer hops = MAXIMUM_TTL; + private DestinationType routing = null; + private GeoArea targetArea = null; + + private boolean channelChanged = false; + private boolean destinationChanged = false; + private boolean routingChanged = false; + private boolean hopsChanged = false; /** * The constructor for {@link AdHocMessageRoutingBuilder}. @@ -54,7 +69,23 @@ public AdHocMessageRoutingBuilder(String hostName, GeoPoint sourcePosition) { ); } - private MessageRouting build(DestinationAddressContainer dac) { + /** + * Build a {@link MessageRouting} object based on the values configured through the AdHocMessageRoutingBuilder. + * Needs at least the destination and the routing strategy to have been set. + * @return {@link MessageRouting} + */ + public MessageRouting build() { + checkNecessaryValues(); + return new MessageRouting(new DestinationAddressContainer( + routing, destination, channel, hops, targetArea, ProtocolType.UDP), + sourceAddressContainer); + } + + /** + * Build a {@link MessageRouting} object based on the given {@link DestinationAddressContainer}. + * @return {@link MessageRouting} + */ + public MessageRouting build(DestinationAddressContainer dac) { return new MessageRouting(dac, sourceAddressContainer); } @@ -64,106 +95,126 @@ private MessageRouting build(DestinationAddressContainer dac) { * @param adHocChannel specific ad hoc channel {@link AdHocChannel} * @return this builder */ - public AdHocMessageRoutingBuilder viaChannel(AdHocChannel adHocChannel) { + public AdHocMessageRoutingBuilder channel(AdHocChannel adHocChannel) { + Validate.isTrue(!channelChanged, "Channel has already been set!"); this.channel = adHocChannel; + this.channelChanged = true; return this; } /** - * Creates geo broadcast to destination area. - * - * @param geoArea destination circle {@link GeoCircle} or destination rectangle {@link GeoRectangle} - * @return MessageRouting + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an array of bytes. + * @return this builder. */ - public MessageRouting geoBroadCast(GeoArea geoArea) { - return build(new DestinationAddressContainer( - DestinationType.AD_HOC_GEOCAST, - new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS), - channel, - null, - geoArea, - ProtocolType.UDP - )); + public AdHocMessageRoutingBuilder destination(byte[] ipAddress) { + return destination(new NetworkAddress(ipAddress)); } /** - * Creates geo cast to specific IP address using a specific {@link AdHocChannel}. - * Note: the SNS doesn't support explicit addressing when geoCasting - * - * @param geoArea destination circle {@link GeoCircle} or destination rectangle {@link GeoRectangle} - * @param ipAddress specific ip address in byte array representation - * @return MessageRouting + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as an {@link Inet4Address}. + * @return this builder. */ - public MessageRouting geoCast(GeoArea geoArea, byte[] ipAddress) { - return build(new DestinationAddressContainer( - DestinationType.AD_HOC_GEOCAST, - new NetworkAddress(ipAddress), - channel, - null, - geoArea, - ProtocolType.UDP - )); + public AdHocMessageRoutingBuilder destination(Inet4Address ipAddress) { + return destination(new NetworkAddress(ipAddress)); } /** - * Creates a topological broadcast using {@link AdHocChannel} SCH1 and single hop. - * - * @return MessageRouting + * Sets the destination of the message being built. + * @param receiverName The string name of the receiving entity. + * @return this builder. */ - public MessageRouting topoBroadCast() { - return topoCast(NetworkAddress.BROADCAST_ADDRESS.getAddress(), 1); + public AdHocMessageRoutingBuilder destination(String receiverName) { + return destination(IpResolver.getSingleton().nameToIp(receiverName)); } /** - * Creates a topological broadcast using a specific {@link AdHocChannel} and specific number of hops. - * Note: The SNS will dismiss hop value, since it only allows for single-hop TopoCasts - * - * @param hops number of hops - * @return MessageRouting + * Sets the destination of the message being built. + * @param ipAddress The IP address of the target destination as a {@link NetworkAddress}. + * @return this builder. */ - public MessageRouting topoBroadCast(int hops) { - return topoCast(NetworkAddress.BROADCAST_ADDRESS.getAddress(), hops); + public AdHocMessageRoutingBuilder destination(NetworkAddress ipAddress) { + Validate.isTrue(!destinationChanged, "Destination has already been set!"); + this.destination = ipAddress; + this.destinationChanged = true; + return this; } /** - * Creates a topological cast using a specific destination host name, a specific {@link AdHocChannel} and specific number of hops. - * Note: The SNS will dismiss hop value, since it only allows for single-hop TopoCasts, so if receiver can't be reached, within - * one hop transmission will fail. - * - * @param receiverName destination host name - * @param hops number of hops - * @return MessageRouting + * A convenience method that sets the destination IP address to the broadcast address. + * @return this builder. */ - public MessageRouting topoCast(String receiverName, int hops) { - return topoCast(IpResolver.getSingleton().nameToIp(receiverName).getAddress(), hops); + public AdHocMessageRoutingBuilder broadcast() { + return destination(new NetworkAddress(NetworkAddress.BROADCAST_ADDRESS)); } /** - * Creates a topological cast using a specific destination IP address, a specific {@link AdHocChannel} and specific number of hops. - * Note: The SNS will dismiss hop value, since it only allows for single-hop TopoCasts, so if receiver can't be reached, within - * one hop transmission will fail. - * - * @param ipAddress destination IP address - * @param hops number of hops - * @return MessageRouting + * Configures the message to use a topologically scoped routing strategy. + * @return this builder. */ - public MessageRouting topoCast(byte[] ipAddress, int hops) { - return build(new DestinationAddressContainer( - DestinationType.AD_HOC_TOPOCAST, - new NetworkAddress(ipAddress), - channel, - require8BitTtl(hops), - null, - ProtocolType.UDP - )); + public AdHocMessageRoutingBuilder topological() { + Validate.isTrue(!routingChanged, "Routing strategy has already been set!"); + this.routing = DestinationType.AD_HOC_TOPOCAST; + this.routingChanged = true; + return this; } /** - * The maximum time to live (TTL). + * Configures the message to use a topologically scoped routing strategy. + * @param area the area which the message will be transmitted to. + * @return this builder. */ - private final static int MAXIMUM_TTL = 255; + public AdHocMessageRoutingBuilder geographical(GeoArea area) { + Validate.isTrue(!routingChanged, "Routing strategy has already been set!"); + this.routing = DestinationType.AD_HOC_GEOCAST; + this.targetArea = area; + this.routingChanged = true; + return this; + } + + /** + * Sets the maximum number of hops in the routing to the given number. + * @param hops the maximum number of hops that should be possible in routing. + * @return this builder. + */ + public AdHocMessageRoutingBuilder hops(int hops) { + Validate.isTrue(!hopsChanged, "Hops have already been set!"); + this.hops = require8BitTtl(hops); + this.hopsChanged = true; + return this; + } + + /** + * A convenience method that sets the maximum number of hops in the routing to one. + * @return this builder. + */ + public AdHocMessageRoutingBuilder singlehop() { + hops(1); + return this; + } + + private void checkNecessaryValues() { + checkDestination(); + checkRouting(); + } + + private void checkDestination() { + if (destination == null) { + throw new IllegalArgumentException("No destination address was given! Aborting."); + } + } + + private void checkRouting() { + if (routing == null) { + throw new IllegalArgumentException("No routing protocol was given! Aborting."); + } + } private static int require8BitTtl(final int ttl) { + if (ttl == 0) { + throw new IllegalArgumentException("TTL can't be zero!"); + } if (ttl > MAXIMUM_TTL || ttl < 0) { throw new IllegalArgumentException("Passed time to live shouldn't exceed 8-bit limit!"); } diff --git a/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/AdHocMessageRoutingBuilderTest.java b/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/AdHocMessageRoutingBuilderTest.java index f2e998b14..e01073675 100644 --- a/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/AdHocMessageRoutingBuilderTest.java +++ b/lib/mosaic-objects/src/test/java/org/eclipse/mosaic/lib/objects/v2x/AdHocMessageRoutingBuilderTest.java @@ -61,8 +61,9 @@ public void setup() { */ @Test public void testAllTTLValues() { - for (int i = 0; i <= MAXIMUM_TTL; ++i) { - MessageRouting routing = builder.viaChannel(adHocChannel).topoCast(ipAddress, i); + for (int i = 1; i <= MAXIMUM_TTL; ++i) { + builder = new AdHocMessageRoutingBuilder("veh_0", null); + MessageRouting routing = builder.channel(adHocChannel).destination(ipAddress).topological().hops(i).build(); assertEquals(i, routing.getDestination().getTimeToLive()); } } @@ -72,7 +73,7 @@ public void testAllTTLValues() { */ @Test(expected = IllegalArgumentException.class) public void testLowerTTL() { - builder.viaChannel(adHocChannel).topoCast(ipAddress, -1); + builder.channel(adHocChannel).destination(ipAddress).topological().hops(-1); } /** @@ -80,13 +81,13 @@ public void testLowerTTL() { */ @Test(expected = IllegalArgumentException.class) public void testHigherTTL() { - builder.viaChannel(adHocChannel).topoCast(ipAddress, 256); + builder.channel(adHocChannel).destination(ipAddress).topological().hops(256); } @Test public void geoBroadcastCircle() { // run - MessageRouting routing = builder.geoBroadCast(geoCircle); + MessageRouting routing = builder.broadcast().geographical(geoCircle).build(); // assert assertEquals(DestinationType.AD_HOC_GEOCAST, routing.getDestination().getType()); @@ -99,7 +100,7 @@ public void geoBroadcastCircle() { @Test public void geoBroadcastRectangle() { // run - MessageRouting routing = builder.geoBroadCast(geoRectangle); + MessageRouting routing = builder.broadcast().geographical(geoRectangle).build(); // assert assertEquals(DestinationType.AD_HOC_GEOCAST, routing.getDestination().getType()); @@ -112,7 +113,7 @@ public void geoBroadcastRectangle() { @Test public void geoBroadcastCircleAdHocChannel() { // run - MessageRouting routing = builder.viaChannel(adHocChannel).geoBroadCast(geoCircle); + MessageRouting routing = builder.channel(adHocChannel).broadcast().geographical(geoCircle).build(); // assert assertEquals(DestinationType.AD_HOC_GEOCAST, routing.getDestination().getType()); @@ -125,7 +126,7 @@ public void geoBroadcastCircleAdHocChannel() { @Test public void geoBroadcastrectangleAdHocChannel() { // run - MessageRouting routing = builder.viaChannel(adHocChannel).geoBroadCast(geoRectangle); + MessageRouting routing = builder.channel(adHocChannel).broadcast().geographical(geoRectangle).build(); // assert assertEquals(DestinationType.AD_HOC_GEOCAST, routing.getDestination().getType()); @@ -138,7 +139,7 @@ public void geoBroadcastrectangleAdHocChannel() { @Test public void geocast() { // run - MessageRouting routing = builder.viaChannel(adHocChannel).geoCast(geoCircle, destinationAddress.getIPv4Address().getAddress()); + MessageRouting routing = builder.channel(adHocChannel).destination(destinationAddress).geographical(geoCircle).build(); // assert assertEquals(DestinationType.AD_HOC_GEOCAST, routing.getDestination().getType()); @@ -151,7 +152,7 @@ public void geocast() { @Test public void topoBroadcastAdHocChannel() { // run - MessageRouting routing = builder.viaChannel(adHocChannel).topoBroadCast(); + MessageRouting routing = builder.channel(adHocChannel).singlehop().broadcast().topological().build(); // assert assertEquals(DestinationType.AD_HOC_TOPOCAST, routing.getDestination().getType()); @@ -165,7 +166,7 @@ public void topoBroadcastAdHocChannel() { @Test public void topoBroadcastAdHocChannelHops() { // run - MessageRouting routing = builder.viaChannel(adHocChannel).topoBroadCast(hops); + MessageRouting routing = builder.channel(adHocChannel).broadcast().topological().hops(hops).build(); // assert assertEquals(DestinationType.AD_HOC_TOPOCAST, routing.getDestination().getType()); diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendV2xAppAdHoc.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendV2xAppAdHoc.java index 722b2c42a..5d2400ee6 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendV2xAppAdHoc.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendandreceive/SendV2xAppAdHoc.java @@ -91,16 +91,17 @@ protected void sendMessage() { switch (sendMode) { case geobroad: logInfo = "geobroadcasting message #" + sequenceNbr; - routing = getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).geoBroadCast(dest); + routing = getOs().getAdHocModule().createMessageRouting().channel(AdHocChannel.CCH).broadcast().geographical(dest).build(); break; case geouni: logInfo = "geounicasting message #" + sequenceNbr; routing = - getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).geoCast(dest, new byte[]{0, 0, 0, 1}); + getOs().getAdHocModule().createMessageRouting().channel(AdHocChannel.CCH) + .destination(new byte[]{0, 0, 0, 1}).geographical(dest).build(); break; case topo: logInfo = "topocasting message #" + sequenceNbr; - routing = getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).topoBroadCast(); + routing = getOs().getAdHocModule().createMessageRouting().channel(AdHocChannel.CCH).singlehop().broadcast().topological().build(); break; default: throw new RuntimeException("Unknown sendMode."); diff --git a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java index a4258443b..d579b343d 100644 --- a/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java +++ b/test/mosaic-integration-tests/src/test/java/org/eclipse/mosaic/test/app/sendonshutdown/SendOnShutdownApp.java @@ -27,7 +27,7 @@ public void onStartup() { getOs().getAdHocModule().enable(); getOs().getAdHocModule().sendV2xMessage(new ShutdownMessage( - getOs().getAdHocModule().createMessageRouting().topoCast("rsu_0", 1) + getOs().getAdHocModule().createMessageRouting().destination("rsu_0").topological().build() )); } @@ -38,7 +38,7 @@ public void onShutdown() { )); getOs().getAdHocModule().sendV2xMessage(new ShutdownMessage( - getOs().getAdHocModule().createMessageRouting().topoCast("rsu_0", 1) + getOs().getAdHocModule().createMessageRouting().destination("rsu_0").topological().build() )); }