Commit db6cbf51 authored by Clemens Krug's avatar Clemens Krug
Browse files

Reworked the Node Debug Monitor

+ Made the node debug a standalone component similar to the Monitor class positioned properly inside the api and peerfact.
+ Added filtering capabilities
+ Added logging in some classes deep in the architecture the provide node information
parent 2f1d37a4
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 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
}
}
public static Map<Class, HashMap<String, Object>> getNodeData(INodeID nodeID)
{
return getDebugMonitor().getNodeData(nodeID);
}
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;
/**
* Created by Clemens on 02.04.2017.
*/
public interface NodeDebugMonitorComponent extends GlobalComponent
{
void update(Class<?> subject, INodeID nodeID, String entry, Object value);
Map<Class, HashMap<String, Object>> getNodeData(INodeID nodeID);
void addUpdateListener(NodeDebugUpdateListener listener);
void removeUpdateListener(NodeDebugUpdateListener listener);
/**
* When set to true this method needs to create the
* appropriate visualisation component.
* @param enabled
*/
void setEnableVis(boolean enabled);
interface NodeDebugUpdateListener
{
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