-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tutorial): minor improvements on tutorial applications (#409)
* fix: Use own position when logging at which point the route was changed * fix: separate event-tx and message-rx functionality * fix: rather print connections than nodes because that's the more critical information * fix: remove redundant information * refactor: use precise wording, as the route switch may still fail
- Loading branch information
Showing
6 changed files
with
85 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ight-communication/src/main/java/org/eclipse/mosaic/app/tutorial/MessageReceivingApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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: [email protected] | ||
*/ | ||
|
||
package org.eclipse.mosaic.app.tutorial; | ||
|
||
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.app.AbstractApplication; | ||
import org.eclipse.mosaic.fed.application.app.api.CommunicationApplication; | ||
import org.eclipse.mosaic.fed.application.app.api.os.VehicleOperatingSystem; | ||
import org.eclipse.mosaic.interactions.communication.V2xMessageTransmission; | ||
import org.eclipse.mosaic.lib.enums.AdHocChannel; | ||
import org.eclipse.mosaic.lib.util.scheduling.Event; | ||
|
||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class MessageReceivingApp extends AbstractApplication<VehicleOperatingSystem> implements CommunicationApplication { | ||
|
||
@Override | ||
public void onStartup() { | ||
getLog().infoSimTime(this, "Initialize application"); | ||
getOs().getAdHocModule().enable(new AdHocModuleConfiguration() | ||
.addRadio() | ||
.channel(AdHocChannel.CCH) | ||
.power(50) | ||
.create()); | ||
getLog().infoSimTime(this, "Activated AdHoc Module"); | ||
} | ||
|
||
@Override | ||
public void onShutdown() { | ||
getLog().infoSimTime(this, "Shutdown application"); | ||
} | ||
|
||
@Override | ||
public void processEvent(Event event) throws Exception { | ||
getLog().infoSimTime(this, "Received event: {}", event.getResourceClassSimpleName()); | ||
} | ||
|
||
@Override | ||
public void onMessageReceived(ReceivedV2xMessage receivedV2xMessage) { | ||
getLog().infoSimTime(this, "Received V2X Message from {}", receivedV2xMessage.getMessage().getRouting().getSource().getSourceName()); | ||
} | ||
|
||
@Override | ||
public void onAcknowledgementReceived(ReceivedAcknowledgement acknowledgedMessage) { | ||
} | ||
|
||
@Override | ||
public void onCamBuilding(CamBuilder camBuilder) { | ||
} | ||
|
||
@Override | ||
public void onMessageTransmitted(V2xMessageTransmission v2xMessageTransmission) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters