Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
3628bb28
Commit
3628bb28
authored
Aug 04, 2017
by
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
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/NodeDebugMonitor.java
0 → 100644
View file @
3628bb28
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
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/core/NodeDebugMonitorComponent.java
0 → 100644
View file @
3628bb28
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
);
}
}
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/location/Location.java
View file @
3628bb28
...
...
@@ -65,7 +65,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 L
at
itude corresponds to
* calculations)! In such circumstances, the L
ong
itude corresponds to
* <strong>x</strong>.
*
* @return longitude (or x)
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sis/type/SiSTypes.java
View file @
3628bb28
...
...
@@ -92,6 +92,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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment