Commit a7eafdc2 authored by Nils Richerzhagen's avatar Nils Richerzhagen
Browse files

Merge branch 'nr/debugMonitor-clemens' into 'nr/monitoring-req-resp'

Merge nr/debug monitor clemens into nr/monitoring

See merge request !1
parents ec039bcc fca66901
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);
}
}
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