Commit 3628bb28 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Merge branch 'nr/monitoring-req-resp' into 'master'

Integrate current Monitoring-API back into master

See merge request !7
parents b70a1a89 1c266b56
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);
}
}
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);
}
}
...@@ -65,7 +65,7 @@ public interface Location extends Transmitable, Cloneable { ...@@ -65,7 +65,7 @@ public interface Location extends Transmitable, Cloneable {
* *
* In most simulation setups, instead of geographic coordinates, we simply * In most simulation setups, instead of geographic coordinates, we simply
* rely on x and y (therefore, please use distanceTo and bearingTo for * 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>. * <strong>x</strong>.
* *
* @return longitude (or x) * @return longitude (or x)
......
...@@ -92,6 +92,11 @@ public final class SiSTypes { ...@@ -92,6 +92,11 @@ public final class SiSTypes {
public static final SiSType<Double> LATENCY_CELL = create("LATENCY_CELL", public static final SiSType<Double> LATENCY_CELL = create("LATENCY_CELL",
Double.class, new AggregationDouble()); 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 * [none] Just a dummy Test attribute of type double. Do not use in
* production code. * production code.
......
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