Commit f4446c2b authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Merge branch 'tm/sumo-integration' of...

Merge branch 'tm/sumo-integration' of dev.kom.e-technik.tu-darmstadt.de:simonstrator/simonstrator-api into tm/vehicular-services
parents b8d44ba6 5695b105
package de.tudarmstadt.maki.simonstrator.api;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.core.NodeDebugMonitorComponent;
import java.util.HashMap;
import java.util.Map;
/**
* Bridge to local node debug monitoring. Provides logging capabilities and
* data access for per node information.
*/
public class NodeDebugMonitor
{
private static NodeDebugMonitorComponent monitor = null;
private static NodeDebugMonitorComponent getDebugMonitor()
{
if(monitor != null) return monitor;
try {
return Binder.getComponent(NodeDebugMonitorComponent.class);
} catch (ComponentNotAvailableException e) {
throw new AssertionError("NodeDebugMonitorComponent is not available! Did you set in in your config?");
}
}
/**
* Update the info for a node.
* @param nodeId id of the node the info belongs to.
* @param entry The description/key of the entry
* @param value The value of the entry.
*/
public static void update(Class<?> subject, INodeID nodeId, String entry, Object value)
{
try
{
getDebugMonitor().update(subject, nodeId, entry, value);
}
catch (AssertionError e)
{
//Fail silently
}
}
/**
* Gets the data of a node separated by the classes the information came from.
* @param nodeID The node of which the information should be collected.
* @return A hashmap of hashmaps with each inner hashmap holding the information provided by one
* specific class.
*/
public static Map<Class, HashMap<String, Object>> getNodeData(INodeID nodeID)
{
return getDebugMonitor().getNodeData(nodeID);
}
/**
* Add a listener which will be informed about data updates.
* @param listener The listener to add.
*/
public static void addUpdateListener(NodeDebugMonitorComponent.NodeDebugUpdateListener listener)
{
getDebugMonitor().addUpdateListener(listener);
}
}
......@@ -104,7 +104,7 @@ public abstract class AbstractMetric<M extends MetricValue<?>> implements
@Override
public boolean isOverallMetric() {
assert (perHost == null && overallMetric != null)
|| (perHost != null && overallMetric == null);
|| (perHost != null && overallMetric == null) : name;
return perHost == null;
}
......
package de.tudarmstadt.maki.simonstrator.api.component.core;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.GlobalComponent;
import java.util.HashMap;
import java.util.Map;
/**
* The actual node debug monitoring component. As opposed to the {@link de.tudarmstadt.maki.simonstrator.api.NodeDebugMonitor}
* which only serves as a bridge, a class implementing this interface provides the actual functionality.
*/
public interface NodeDebugMonitorComponent extends GlobalComponent
{
/**
* Update an entry for a node.
* @param subject The class which provided the info
* @param nodeID The node the info is about
* @param entry The string entry/key of the information
* @param value The value of the information
*/
void update(Class<?> subject, INodeID nodeID, String entry, Object value);
/**
* Gets the data of a node separated by the classes the information came from.
* @param nodeID The node of which the information should be collected.
* @return A hashmap of hashmaps with each inner hashmap holding the information provided by one
* specific class.
*/
Map<Class, HashMap<String, Object>> getNodeData(INodeID nodeID);
/**
* Add a listener which will be informed about data updates.
* @param listener The listener to add.
*/
void addUpdateListener(NodeDebugUpdateListener listener);
/**
* Removes a listener so that it won't be notified anymore.
* @param listener the listener to remove
*/
void removeUpdateListener(NodeDebugUpdateListener listener);
/**
* When set to true this method needs to create the
* appropriate visualisation component.
* @param enabled wether to enable the visualisation or not
*/
void setEnableVis(boolean enabled);
/**
* Listener for updates of the per node information.
*/
interface NodeDebugUpdateListener
{
/**
* Called upon an update of the data of a node.
* @param subject The class that provided the info
* @param nodeId the node the info is about
* @param entry the actual entry/key of the info
* @param value the value of the info.
*/
void onNodeDebugUpdate(Class subject, INodeID nodeId, String entry, Object value);
}
}
......@@ -79,4 +79,18 @@ public interface LocationPubSubComponent extends PubSubComponent {
List<Attribute<?>> attributes, Location location,
double radiusOfInterest, byte[] payload);
/**
* Creates a notification that is valid at the current location of the
* client (as known by the filter scheme)
*
* @param topic
* @param attributes
* @param radiusOfInterest
* @param payload
* optional, can be null
* @return
*/
public Notification createLocalNotification(Topic topic, List<Attribute<?>> attributes, double radiusOfInterest,
byte[] payload);
}
......@@ -24,20 +24,17 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* Based on the Google Location Service (LocationClient) provided for the
* Android Platform. Provides access to the last known location (energy
* efficient) or QoS-Specifications for regular location updates.
* TODO documentation
*
* @see http
* ://developer.android.com/reference/com/google/android/gms/location/package
* -summary.html
* @author Bjoern Richerzhagen
* @deprecated Should this really be part of the API? Currently, I do not get
* its intention. (BR)
*
*/
@Deprecated
public interface FutureLocationSensor {
/**
* Retrieve the last known location
* TODO documentation
*
* @return
*/
......
......@@ -23,8 +23,10 @@ package de.tudarmstadt.maki.simonstrator.api.component.sensor.location;
import de.tudarmstadt.maki.simonstrator.api.common.Transmitable;
/**
* Again, based on Android.Location. Does not support direction and speed at the
* moment.
* Again, based on Android.Location.
*
* Updated August 2017 (Bjoern Richerzhagen): added optional methods for bearing
* and speed. This should at some time deprecate the SpeedSensor.
*
* @see http://developer.android.com/reference/android/location/Location.html
*
......@@ -65,7 +67,7 @@ public interface Location extends Transmitable, Cloneable {
*
* In most simulation setups, instead of geographic coordinates, we simply
* rely on x and y (therefore, please use distanceTo and bearingTo for
* calculations)! In such circumstances, the Latitude corresponds to
* calculations)! In such circumstances, the Longitude corresponds to
* <strong>x</strong>.
*
* @return longitude (or x)
......@@ -101,6 +103,36 @@ public interface Location extends Transmitable, Cloneable {
*/
public long getAgeOfLocation();
/**
* Bearing (or heading) of the current movement vector in degrees between 0
* (exclusive) and 360 (inclusive). If the location does not have a bearing,
* 0 is returned.
*
* @return
*/
default public double getBearing() {
return 0;
}
/**
* Current movement speed. This value is only meaningful, if hasSpeed()
* returns true.
*
* @return
*/
default public double getSpeed() {
return 0;
}
/**
* True, if the location object has associated speed information.
*
* @return
*/
default public boolean hasSpeed() {
return false;
}
/**
* Accuracy of this location estimate in meters (0 meaning perfect
* accuracy).
......
......@@ -43,13 +43,6 @@ public interface LocationActuator extends LocationSensor {
*/
public void updateCurrentLocation(Location newLocation);
/**
* Returns the current target {@link AttractionPoint} a node is approaching.
*
* @return
*/
public AttractionPoint getCurrentTargetAttractionPoint();
/**
* A way to interact with node movement from within applications and the
* like. This is an optional operation - it is expected to throw an
......
......@@ -27,10 +27,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.SensorComponent;
* Android Platform. Provides access to the last known location (energy
* efficient) or QoS-Specifications for regular location updates.
*
* Also offers access to the target attraction point
*
* @see http
* ://developer.android.com/reference/com/google/android/gms/location/package
* -summary.html
* @author Bjoern Richerzhagen
* @author Julian Zobel
*
*/
public interface LocationSensor extends SensorComponent {
......@@ -74,4 +77,12 @@ public interface LocationSensor extends SensorComponent {
*/
public LocationRequest getLocationRequest();
/**
* Retrieve the targeted {@link AttractionPoint}, representing the location
* the node is currently approaching.
*
* @return
*/
public AttractionPoint getCurrentTargetAttractionPoint();
}
/*
* 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.sensor.route;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* Basic interface for a route object (unifying SUMO and OSM-based models).
*
* @author Bjoern Richerzhagen
*
*/
public interface Route {
/**
* Target location of this route.
*
* @return
*/
public Location getTargetLocation();
/**
* True, if the Route contains segment information.
*
* @return
*/
public boolean hasSegmentInformation();
/**
* Segment we are currently on.
*
* @return
*/
public RouteSegment getCurrentSegment();
/**
* List of segments that are still ahead of us (this list INCLUDES the
* current segment!)
*
* @return segments ahead, in order (the next segment is the first entry in
* the list).
*/
public List<RouteSegment> getSegmentsAhead();
/**
* List of segments we already left behind (this list does NOT include the
* current segment).
*
* @return segments left behind, in order (the segment we just left behind
* is the LAST entry in the list).
*/
public List<RouteSegment> getSegmentsBehind();
/**
* A route segment (path segment), basically (part of) a road. This is
* assumed to have a unique string ID.
*
* @author Bjoern Richerzhagen
*
*/
public interface RouteSegment {
/**
* Unique ID of this route segment
*
* @return
*/
public String getSegmentId();
/**
* Route points of this segment (at least the START and END location,
* but may provide additional intermediate points).
*
* @return
*/
public List<Location> getSegmentLocations();
}
}
......@@ -21,15 +21,106 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.route;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.SensorComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.Route.RouteSegment;
/**
* A sensor that provides access to the chosen route of a component. This is
* only useful within mobility models that define routing to some extend (e.g.,
* SUMO or OSM-based mobility models).
*
* @author Tobias Meuser
*
* @author Tobias Meuser, Bjoern Richerzhagen
*
*/
public interface RouteSensor extends SensorComponent {
public RoadNetworkRoute getCurrentRoute();
/**
* Returns the current route of the component.
*
* @return
*/
public Route getRoute();
/**
* Adds a listener for route updates
*
* @param listener
*/
public void addRouteListener(RouteListener listener);
/**
* Removes a listener for route updates
*
* @param listener
*/
public void removeRouteListener(RouteListener listener);
/**
* Adds a listener for segment updates along routes
*
* @param listener
*/
public void addRouteSegmentListener(RouteSegmentListener listener);
/**
* Removes a listener for segment updates along routes
*
* @param listener
*/
public void removeRouteSegmentListener(RouteSegmentListener listener);
/**
* A listener to be informed of each segment change along a route. This is
* realized as a separate listener, as the required computations should only
* be performed in case anyone is interested at all :)
*
* @author Bjoern Richerzhagen
*
*/
public interface RouteSegmentListener {
/**
* A route consists of several segments (basically street segments)
* along which the component moves towards the target. Whenever a
* component updates its current segment, this method is invoked.
*
* @param route
* @param leftSegment
* @param enteredSegment
*/
public void onChangedRouteSegment(RouteSensor sensor, Route route, RouteSegment leftSegment,
RouteSegment enteredSegment);
}
/**
* A listener for route updates and movement along the route.
*
* @author Bjoern Richerzhagen
*
*/
public interface RouteListener {
/**
* Triggered whenever the component reached the end of the current
* route.
*
* @param sensor
* @param route
*/
public void onReachedDestination(RouteSensor sensor, Route route);
/**
* Triggered whenever the route of the current component changes (either
* due to a new target being chosen or due to updates along the route).
*
* @param sensor
* @param oldRoute
* (may be null!)
* @param newRoute
*/
public void onChangedRoute(RouteSensor sensor, Route oldRoute, Route newRoute);
}
}
/*
* 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.sensor.route;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
/**
* Masks the dependency on the RoadNetwork behind another sensor class.
*
* @author Bjoern Richerzhagen, based on Tobias Meuser
*
*/
public interface VehicularRouteSensor extends RouteSensor {
/**
* Representation of the current route as a road network.
*
* @return
*/
public RoadNetworkRoute getCurrentRoute();
}
......@@ -21,12 +21,19 @@
package de.tudarmstadt.maki.simonstrator.api.component.sensor.speed;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.SensorComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor;
/**
*
* @author Tobias Meuser
*
* @deprecated this should (at some time) be replaced by the respective
* information in {@link Location}, available via the
* {@link LocationSensor} (BR)
*
*/
@Deprecated
public interface SpeedSensor extends SensorComponent {
double getCurrentSpeed();
}
......@@ -103,6 +103,11 @@ public final class SiSTypes {
public static final SiSType<Double> LATENCY_CELL = create("LATENCY_CELL",
Double.class, new AggregationDouble());
/**
* Current estimated node speed in m/s in the physical world.
*/
public static final SiSType<Double> PHY_SPEED = create("PHY_SPEED", Double.class, new AggregationDouble());
/**
* [none] Just a dummy Test attribute of type double. Do not use in
* production code.
......
......@@ -22,12 +22,12 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteActuator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.RouteSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.route.VehicularRouteSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.speed.SpeedActuator;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.speed.SpeedSensor;
public interface VehicleInformationComponent
extends HostComponent, RouteSensor, RouteActuator, SpeedSensor, SpeedActuator {
extends HostComponent, VehicularRouteSensor, RouteActuator, SpeedSensor, SpeedActuator {
void setVehicleID(String vehicleID);
void resetVehicleID();
......
......@@ -2,6 +2,12 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information
import java.io.Serializable;
/**
* @deprecated We should not have a second representation of locations within
* the API. Try to mask the functionality behind Location (which now
* provides speed and heading)
*/
@Deprecated
public class Position implements Serializable, Comparable<Position> {
/**
*
......
......@@ -3,6 +3,10 @@ package de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information
import java.util.ArrayList;
import java.util.List;
/**
* @deprecated unused?
*/
@Deprecated
public class Route {
private List<Street> _waypoints;
......
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.api.information;
/**
* @deprecated unused?
*/
@Deprecated
public class Street {
private String _edgeID;
......
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