From 680b4eb7d6654789ce5e04393f24be77d9e6dc96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Kn=C3=B6pp?= Date: Wed, 15 May 2024 14:07:41 +0200 Subject: [PATCH 1/4] introduced duplicatable V2XMessage functionality --- .../lib/objects/DuplicatableMessage.java | 35 +++++++++++++++++++ .../lib/objects/v2x/GenericV2xMessage.java | 13 ++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java new file mode 100644 index 000000000..dcd82929c --- /dev/null +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java @@ -0,0 +1,35 @@ +/* + * 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.lib.objects; + +import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; + +/** + * Creates a copy of the message + * @param + */ +public interface DuplicatableMessage> { + + /** + * Creates a copy of the V2xMessage. + * The message gets a new ID and routing (to use current vehicle position). + * Only its contents (e.g. payload, type, ...) are copied. + * + * @param routing contains current vehicle position + * @return cloned message + */ + T duplicate(MessageRouting routing); +} diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java index ed03aefd5..3044ea412 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java @@ -15,6 +15,7 @@ package org.eclipse.mosaic.lib.objects.v2x; +import org.eclipse.mosaic.lib.objects.DuplicatableMessage; import org.eclipse.mosaic.lib.objects.ToDataOutput; import org.eclipse.mosaic.lib.util.ClassUtils; @@ -23,7 +24,7 @@ /** * This {@link V2xMessage} implementation can be used for simple message exchange between entities. */ -public final class GenericV2xMessage extends V2xMessage { +public final class GenericV2xMessage extends V2xMessage implements DuplicatableMessage { private static final long serialVersionUID = 1L; @@ -63,6 +64,12 @@ public GenericV2xMessage(MessageRouting routing, ToDataOutput messagePayload, lo this.payload = new EncodedPayload(messagePayload, minimalMessageSize); } + public GenericV2xMessage(GenericV2xMessage message) { + super(message.getRouting()); + this.messageType = message.getMessageType(); + this.payload = message.getPayload(); + } + @Override @Nonnull @@ -82,4 +89,8 @@ public String toString() { + ", encodedPayload=" + payload + '}'; } + public GenericV2xMessage duplicate(MessageRouting routing) { + return new GenericV2xMessage(routing, messageType, payload.getEffectiveLength()); + } + } From 5009c82ea4beb037a11157bdcdd87dbfb75d0eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Kn=C3=B6pp?= Date: Wed, 22 May 2024 10:58:28 +0200 Subject: [PATCH 2/4] 834 resolve PR issues --- .../mosaic/lib/objects/{ => v2x}/DuplicatableMessage.java | 8 +++----- .../eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java | 8 +------- 2 files changed, 4 insertions(+), 12 deletions(-) rename lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/{ => v2x}/DuplicatableMessage.java (83%) diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java similarity index 83% rename from lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java rename to lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java index dcd82929c..5a52c25f4 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/DuplicatableMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java @@ -13,13 +13,11 @@ * Contact: mosaic@fokus.fraunhofer.de */ -package org.eclipse.mosaic.lib.objects; - -import org.eclipse.mosaic.lib.objects.v2x.MessageRouting; +package org.eclipse.mosaic.lib.objects.v2x; /** - * Creates a copy of the message - * @param + * A message that can duplicate itself. + * @param a class that extends {@link org.eclipse.mosaic.lib.objects.v2x.V2xMessage} */ public interface DuplicatableMessage> { diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java index 3044ea412..dc5fd9a7e 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java @@ -15,7 +15,6 @@ package org.eclipse.mosaic.lib.objects.v2x; -import org.eclipse.mosaic.lib.objects.DuplicatableMessage; import org.eclipse.mosaic.lib.objects.ToDataOutput; import org.eclipse.mosaic.lib.util.ClassUtils; @@ -64,12 +63,6 @@ public GenericV2xMessage(MessageRouting routing, ToDataOutput messagePayload, lo this.payload = new EncodedPayload(messagePayload, minimalMessageSize); } - public GenericV2xMessage(GenericV2xMessage message) { - super(message.getRouting()); - this.messageType = message.getMessageType(); - this.payload = message.getPayload(); - } - @Override @Nonnull @@ -89,6 +82,7 @@ public String toString() { + ", encodedPayload=" + payload + '}'; } + @Override public GenericV2xMessage duplicate(MessageRouting routing) { return new GenericV2xMessage(routing, messageType, payload.getEffectiveLength()); } From f70fecb2b74d5360f25338c8b28674f4fa3e3eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Kn=C3=B6pp?= Date: Wed, 22 May 2024 16:25:47 +0200 Subject: [PATCH 3/4] resolving PR issues #2 --- .../org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java | 2 +- .../org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java index 5a52c25f4..ec791776e 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java @@ -19,7 +19,7 @@ * A message that can duplicate itself. * @param a class that extends {@link org.eclipse.mosaic.lib.objects.v2x.V2xMessage} */ -public interface DuplicatableMessage> { +public interface DuplicatableMessage { /** * Creates a copy of the V2xMessage. diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java index dc5fd9a7e..c7b6c22d1 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/GenericV2xMessage.java @@ -23,7 +23,7 @@ /** * This {@link V2xMessage} implementation can be used for simple message exchange between entities. */ -public final class GenericV2xMessage extends V2xMessage implements DuplicatableMessage { +public final class GenericV2xMessage extends V2xMessage implements DuplicatableMessage { private static final long serialVersionUID = 1L; From b10e26cbcb47b8d5a05273b29ac230d024c28108 Mon Sep 17 00:00:00 2001 From: iwillitried <62699721+iwillitried@users.noreply.github.com> Date: Wed, 29 May 2024 10:37:44 +0200 Subject: [PATCH 4/4] Update lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java Co-authored-by: schwepmo <39306374+schwepmo@users.noreply.github.com> --- .../org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java index ec791776e..df5dd3ca3 100644 --- a/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java +++ b/lib/mosaic-objects/src/main/java/org/eclipse/mosaic/lib/objects/v2x/DuplicatableMessage.java @@ -17,7 +17,7 @@ /** * A message that can duplicate itself. - * @param a class that extends {@link org.eclipse.mosaic.lib.objects.v2x.V2xMessage} + * @param a class that extends {@link V2xMessage} */ public interface DuplicatableMessage {