Commit 8785fe21 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Added functionality to decouple receiving and sending from workload

parent b8135828
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.hybrid;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.LocationBasedEnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation;
public interface CommunicationListener {
void onReceiveInformation(EnvironmentInformation<? extends LocationBasedEnvironmentProperty> pInformation);
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.hybrid;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
public interface VehicularReceiver extends HostComponent {
void initialize();
void registerCommunicationListener(CommunicationListener pListener);
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.hybrid;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.LocationBasedEnvironmentProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.EnvironmentInformation;
public interface VehicularSender extends HostComponent {
void initialize();
boolean send(EnvironmentInformation<? extends LocationBasedEnvironmentProperty> pInformation);
}
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.processing;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
import de.tudarmstadt.maki.simonstrator.peerfact.application.vehicular.processing.topic.ProcessedTopic;
public interface ProcessingServer extends HostComponent {
Topic getServerTopic();
boolean isActive();
List<SubscriptionTopicType> getSubscriptionType();
List<ProcessedTopic> getSubscriptions(SubscriptionTopicType... pTypes);
}
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions;
public enum SubscriptionTopicType {
GLOBAL, EVENT_BASED, GEOHASH, EDGE_BASED
}
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.topic;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public class GlobalTopic implements ProcessedTopic {
private Topic _topic;
public GlobalTopic(Topic pTopic) {
_topic = pTopic;
}
@Override
public Topic getTopic() {
return _topic;
}
@Override
public SubscriptionTopicType getTopicType() {
return SubscriptionTopicType.GLOBAL;
}
@Override
public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
return true;
}
@Override
public boolean matchesHost(Host pHost) {
return true;
}
}
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.topic;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public interface ProcessedTopic {
Topic getTopic();
SubscriptionTopicType getTopicType();
boolean matchesInformationRequirements(PointInformation<?> pInformation);
boolean matchesHost(Host pHost);
}
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.topic;
import java.util.HashSet;
import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.VehicularPointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public class RoadBasedTopic implements ProcessedTopic {
private Topic _topic;
private RoadNetworkEdge _edge;
public RoadBasedTopic(PubSubComponent pPubSub, RoadNetworkEdge pEdge) {
_topic = pPubSub.createTopic(pEdge.getEdgeID());
_edge = pEdge;
}
@Override
public Topic getTopic() {
return _topic;
}
@Override
public SubscriptionTopicType getTopicType() {
return SubscriptionTopicType.EDGE_BASED;
}
@Override
public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
if (pInformation instanceof VehicularPointInformation) {
VehicularPointInformation<?> vehicularInfo = (VehicularPointInformation<?>) pInformation;
return _edge.equals(vehicularInfo.getEdge());
}
return false;
}
@Override
public boolean matchesHost(Host pHost) {
try {
VehicleInformationComponent vehicleInfo = pHost.getComponent(VehicleInformationComponent.class);
RoadNetworkRoute currentRoute = vehicleInfo.getCurrentRoute();
RoadNetworkEdge currentRoad = currentRoute.getStart();
Set<RoadNetworkEdge> roads = new HashSet<>();
roads.add(currentRoad);
roads.addAll(currentRoad.getAccessibleEdges());
return roads.contains(_edge);
} catch (ComponentNotAvailableException e) {
}
return false;
}
}
package de.tudarmstadt.maki.simonstrator.peerfact.application.vehicular.processing.topic;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public class GlobalTopic implements ProcessedTopic {
private Topic _topic;
public GlobalTopic(Topic pTopic) {
_topic = pTopic;
}
@Override
public Topic getTopic() {
return _topic;
}
@Override
public SubscriptionTopicType getTopicType() {
return SubscriptionTopicType.GLOBAL;
}
@Override
public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
return true;
}
@Override
public boolean matchesHost(Host pHost) {
return true;
}
}
package de.tudarmstadt.maki.simonstrator.peerfact.application.vehicular.processing.topic;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public interface ProcessedTopic {
Topic getTopic();
SubscriptionTopicType getTopicType();
boolean matchesInformationRequirements(PointInformation<?> pInformation);
boolean matchesHost(Host pHost);
}
package de.tudarmstadt.maki.simonstrator.peerfact.application.vehicular.processing.topic;
import java.util.HashSet;
import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.PubSubComponent;
import de.tudarmstadt.maki.simonstrator.api.component.pubsub.attribute.Topic;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.PointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.VehicularPointInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.SubscriptionTopicType;
public class RoadBasedTopic implements ProcessedTopic {
private Topic _topic;
private RoadNetworkEdge _edge;
public RoadBasedTopic(PubSubComponent pPubSub, RoadNetworkEdge pEdge) {
_topic = pPubSub.createTopic(pEdge.getEdgeID());
_edge = pEdge;
}
@Override
public Topic getTopic() {
return _topic;
}
@Override
public SubscriptionTopicType getTopicType() {
return SubscriptionTopicType.EDGE_BASED;
}
@Override
public boolean matchesInformationRequirements(PointInformation<?> pInformation) {
if (pInformation instanceof VehicularPointInformation) {
VehicularPointInformation<?> vehicularInfo = (VehicularPointInformation<?>) pInformation;
return _edge.equals(vehicularInfo.getEdge());
}
return false;
}
@Override
public boolean matchesHost(Host pHost) {
try {
VehicleInformationComponent vehicleInfo = pHost.getComponent(VehicleInformationComponent.class);
RoadNetworkRoute currentRoute = vehicleInfo.getCurrentRoute();
RoadNetworkEdge currentRoad = currentRoute.getStart();
Set<RoadNetworkEdge> roads = new HashSet<>();
roads.add(currentRoad);
roads.addAll(currentRoad.getAccessibleEdges());
return roads.contains(_edge);
} catch (ComponentNotAvailableException e) {
}
return false;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment