Commit 4567cee4 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Implemented sending procedure

parent 8785fe21
......@@ -5,7 +5,7 @@ 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;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.subscriptions.topic.ProcessedTopic;
public interface ProcessingServer extends HostComponent {
Topic getServerTopic();
......
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