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
PeerfactSim.KOM
Commits
df0769d8
Commit
df0769d8
authored
Mar 08, 2017
by
Simon Luser
Browse files
added disaster metrics vis
parent
db3d7740
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputLivePlot.java
View file @
df0769d8
...
...
@@ -24,12 +24,15 @@ import java.util.LinkedList;
import
java.util.List
;
import
de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.DisasterMetricChartAdapter
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricCDFAdapter
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricChartAdapter
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricPlotAdapter
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.PlottingView
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.MessageWithDisasterType
;
import
de.tudarmstadt.maki.simonstrator.api.MessageWithDisasterType.MessageDisasterType
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
...
...
@@ -70,8 +73,28 @@ public class MetricOutputLivePlot extends AbstractOutput implements
if
(
pView
==
null
)
{
pView
=
VisualizationInjector
.
createPlottingView
(
"Metrics"
);
}
MetricChartAdapter
mca
=
new
MetricChartAdapter
(
metric
,
pView
,
lowerPercentile
,
upperPercentile
,
maxItemCount
);
// extended by choosing disaster adapter, if it is a disaster metric
boolean
isMessageDisasterMetric
=
false
;
for
(
MessageDisasterType
type
:
MessageDisasterType
.
values
())
if
(
metric
.
getName
().
contains
(
MessageWithDisasterType
.
DRAW_ONCE
)
&&
metric
.
getName
().
contains
(
type
.
name
()))
{
isMessageDisasterMetric
=
true
;
break
;
}
if
(
isMessageDisasterMetric
)
continue
;
MetricPlotAdapter
mca
;
if
(
metric
.
getName
().
contains
(
MessageWithDisasterType
.
DRAW_ONCE
))
mca
=
new
DisasterMetricChartAdapter
(
metric
,
pView
,
maxItemCount
);
else
mca
=
new
MetricChartAdapter
(
metric
,
pView
,
lowerPercentile
,
upperPercentile
,
maxItemCount
);
charts
.
add
(
mca
);
if
(
enableCDF
&&
!
metric
.
isOverallMetric
())
{
if
(
pViewCdf
==
null
)
{
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/DisasterMetricChartAdapter.java
0 → 100644
View file @
df0769d8
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.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.tud.kom.p2psim.impl.topology.views.visualization.ui
;
import
java.util.HashMap
;
import
java.util.Map.Entry
;
import
org.jfree.data.xy.YIntervalSeries
;
import
de.tud.kom.p2psim.impl.analyzer.metric.MetricAnalyzer
;
import
de.tudarmstadt.maki.simonstrator.api.MessageWithDisasterType.MessageDisasterType
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricUnit
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricValue
;
public
class
DisasterMetricChartAdapter
implements
MetricPlotAdapter
{
/** the overall metric */
private
final
Metric
metric
;
/** the average of all {@link MessageDisasterType} */
private
MetricValue
<
Number
>
avg
=
null
;
private
YIntervalSeries
avgSeries
=
null
;
/** each type of {@link MessageDisasterType} */
private
HashMap
<
MessageDisasterType
,
MetricValue
<
Number
>>
subMsgTypeValues
;
private
HashMap
<
YIntervalSeries
,
MetricValue
<
Number
>>
subMsgTypeSeries
;
public
DisasterMetricChartAdapter
(
Metric
metric
,
PlottingView
view
,
int
maxItems
)
{
this
.
metric
=
metric
;
// fill subMsgTypeValues
if
(
metric
.
isOverallMetric
())
{
MetricValue
<?>
mv
=
metric
.
getOverallMetric
();
avg
=
(
MetricValue
<
Number
>)
mv
;
subMsgTypeValues
=
new
HashMap
<>();
for
(
MessageDisasterType
type
:
MessageDisasterType
.
values
())
{
Metric
emergencyM
=
MetricAnalyzer
.
getMetric
(
metric
.
getName
()
+
type
);
if
(
emergencyM
!=
null
&&
emergencyM
.
isOverallMetric
())
subMsgTypeValues
.
put
(
type
,
emergencyM
.
getOverallMetric
());
}
}
// fill series
if
(
avg
!=
null
)
{
XYChart
chart
=
view
.
createPlot
(
metric
.
getName
()
+
" -- "
+
metric
.
getDescription
(),
"Average"
);
avgSeries
=
chart
.
getDataset
().
getSeries
(
0
);
if
(
maxItems
>
0
)
avgSeries
.
setMaximumItemCount
(
maxItems
);
subMsgTypeSeries
=
new
HashMap
<>();
for
(
Entry
<
MessageDisasterType
,
MetricValue
<
Number
>>
e
:
subMsgTypeValues
.
entrySet
())
{
YIntervalSeries
tempSerie
=
new
YIntervalSeries
(
e
.
getKey
());
if
(
maxItems
>
0
)
tempSerie
.
setMaximumItemCount
(
maxItems
);
chart
.
getDataset
().
addSeries
(
tempSerie
);
subMsgTypeSeries
.
put
(
tempSerie
,
e
.
getValue
());
}
}
}
@Override
public
void
refresh
()
{
double
seconds
=
(
double
)
Time
.
getCurrentTime
()
/
(
double
)
Time
.
SECOND
;
if
(
avgSeries
!=
null
)
{
double
avgVal
=
scaledValue
(
avg
);
if
(
avg
.
isValid
())
avgSeries
.
add
(
seconds
,
avgVal
,
avgVal
,
avgVal
);
}
for
(
Entry
<
YIntervalSeries
,
MetricValue
<
Number
>>
series
:
subMsgTypeSeries
.
entrySet
())
{
double
tempVal
=
scaledValue
(
series
.
getValue
());
if
(
series
.
getValue
().
isValid
())
series
.
getKey
().
add
(
seconds
,
tempVal
,
tempVal
,
tempVal
);
}
}
/**
* For {@link Time}.
*
* @param mv
* @return
*/
private
double
scaledValue
(
MetricValue
<
Number
>
mv
)
{
if
(
metric
.
getUnit
()
==
MetricUnit
.
TIME
)
{
return
mv
.
getValue
().
doubleValue
()
/
Time
.
SECOND
;
}
return
mv
.
getValue
().
doubleValue
();
}
}
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