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
6b5da450
Commit
6b5da450
authored
Aug 14, 2018
by
Jose Ignacio Monreal Bailey
Browse files
Adding summary of messages sent by nodes, and disabling reuse of objects
parent
17891c48
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/simengine/Simulator.java
View file @
6b5da450
...
@@ -30,6 +30,7 @@ import java.util.Locale;
...
@@ -30,6 +30,7 @@ import java.util.Locale;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
import
de.tud.kom.p2psim.impl.util.Summary
;
import
org.apache.commons.math.random.JDKRandomGenerator
;
import
org.apache.commons.math.random.JDKRandomGenerator
;
import
org.apache.commons.math.random.RandomGenerator
;
import
org.apache.commons.math.random.RandomGenerator
;
...
@@ -273,6 +274,8 @@ public class Simulator implements RandomGeneratorComponent, GlobalComponent {
...
@@ -273,6 +274,8 @@ public class Simulator implements RandomGeneratorComponent, GlobalComponent {
// SkyNetBatchSimulator.getInstance().finish(finishedWithoutError);
// SkyNetBatchSimulator.getInstance().finish(finishedWithoutError);
// }
// }
Summary
.
simulationFinished
();
for
(
SimulatorObserver
so
:
observers
)
{
for
(
SimulatorObserver
so
:
observers
)
{
so
.
simulationFinished
();
so
.
simulationFinished
();
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/RSUMovementModel.java
View file @
6b5da450
...
@@ -66,7 +66,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
...
@@ -66,7 +66,7 @@ public class RSUMovementModel implements MovementModel, EventHandler {
private
long
timeBetweenMoveOperations
;
private
long
timeBetweenMoveOperations
;
private
boolean
initialized
=
false
;
private
boolean
initialized
=
false
;
private
boolean
_reuseComponents
=
tru
e
;
private
boolean
_reuseComponents
=
fals
e
;
private
TrafficLightController
_controller
;
private
TrafficLightController
_controller
;
private
SimulationSetupExtractor
_extractor
;
private
SimulationSetupExtractor
_extractor
;
...
...
src/de/tud/kom/p2psim/impl/topology/movement/VehicleMovementModel.java
View file @
6b5da450
...
@@ -56,7 +56,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
...
@@ -56,7 +56,7 @@ public class VehicleMovementModel implements MovementModel, EventHandler {
private
static
final
Location
DEFAULT_LOCATION
=
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
);
private
static
final
Location
DEFAULT_LOCATION
=
new
PositionVector
(
Double
.
NaN
,
Double
.
NaN
);
private
boolean
_reuseComponents
=
tru
e
;
private
boolean
_reuseComponents
=
fals
e
;
private
static
VehicleMovementModel
MOVEMENT
;
private
static
VehicleMovementModel
MOVEMENT
;
...
...
src/de/tud/kom/p2psim/impl/util/Summary.java
0 → 100644
View file @
6b5da450
package
de.tud.kom.p2psim.impl.util
;
import
de.tud.kom.p2psim.api.common.SimHost
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.vehicular.trafficlights.DefaultTrafficLightInformationComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
public
class
Summary
{
private
static
String
csvOutputFilename
=
""
;
public
static
void
simulationFinished
()
{
Map
<
String
,
List
<
SimHost
>>
hosts
=
Simulator
.
getInstance
().
getScenario
().
getHosts
();
List
<
SimHost
>
simHostList
=
hosts
.
getOrDefault
(
"TrafficLights"
,
null
);
for
(
SimHost
simHost
:
simHostList
)
{
try
{
DefaultTrafficLightInformationComponent
trafficLightInformationComponent
=
simHost
.
getComponent
(
DefaultTrafficLightInformationComponent
.
class
);
csvOutputFilename
=
simHost
.
getProperties
().
getProperty
(
"csvOutputFile"
);
writeToCSV
(
trafficLightInformationComponent
.
getTrafficLightId
(),
trafficLightInformationComponent
.
getNumberOfMessagesSent
());
}
catch
(
ComponentNotAvailableException
e
)
{
e
.
printStackTrace
();
}
}
}
private
static
void
writeToCSV
(
String
id
,
Double
msgSent
)
{
try
{
File
file
=
new
File
(
csvOutputFilename
);
String
log
=
""
;
if
(!
file
.
exists
())
{
file
.
createNewFile
();
log
+=
"id;messagesSent;\n"
;
}
FileWriter
fileWriter
=
new
FileWriter
(
file
.
getAbsoluteFile
(),
true
);
BufferedWriter
bufferedWriter
=
new
BufferedWriter
(
fileWriter
);
log
+=
id
+
";"
+
String
.
valueOf
(
msgSent
)
+
";\n"
;
bufferedWriter
.
write
(
log
);
bufferedWriter
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/de/tud/kom/p2psim/impl/vehicular/trafficlights/DefaultTrafficLightInformationComponent.java
View file @
6b5da450
...
@@ -19,12 +19,22 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
...
@@ -19,12 +19,22 @@ public class DefaultTrafficLightInformationComponent implements TrafficLightInfo
private
SimulationSetupExtractor
extractor
;
private
SimulationSetupExtractor
extractor
;
private
String
trafficLightId
;
private
String
trafficLightId
;
private
Double
numberOfMessagesSent
;
public
DefaultTrafficLightInformationComponent
(
Host
host
,
TrafficLightController
controller
,
SimulationSetupExtractor
extractor
)
{
public
DefaultTrafficLightInformationComponent
(
Host
host
,
TrafficLightController
controller
,
SimulationSetupExtractor
extractor
)
{
this
.
host
=
host
;
this
.
host
=
host
;
this
.
controller
=
controller
;
this
.
controller
=
controller
;
this
.
extractor
=
extractor
;
this
.
extractor
=
extractor
;
this
.
numberOfMessagesSent
=
0.0
;
}
public
void
incrementNumberOfMessagesSent
()
{
numberOfMessagesSent
++;
}
public
double
getNumberOfMessagesSent
()
{
return
numberOfMessagesSent
;
}
}
@Override
@Override
...
...
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