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
241dc003
Commit
241dc003
authored
Feb 20, 2018
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
First working version of monitoring
parent
85482a86
Changes
5
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/simengine/Scheduler.java
View file @
241dc003
...
...
@@ -44,7 +44,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.core.TimeComponent;
* @author Sebastian Kaune
*/
public
class
Scheduler
implements
EventHandler
,
SchedulerComponent
,
TimeComponent
{
SchedulerComponent
,
TimeComponent
{
// Flag to allow the compiler to remove the unneeded debug code
private
static
final
boolean
DEBUG_CODE
=
false
;
...
...
@@ -449,6 +449,7 @@ public class Scheduler implements EventHandler,
*
* @return current scheduler time
*/
@Override
public
long
getCurrentTime
()
{
return
currentTime
;
}
...
...
@@ -518,6 +519,7 @@ public class Scheduler implements EventHandler,
return
simTime
;
}
@Override
public
int
compareTo
(
SchedulerEvent
o
)
{
int
comp
=
Double
.
compare
(
this
.
simTime
,
o
.
simTime
);
return
comp
==
0
?
Double
.
compare
(
this
.
globalOrderIdx
,
o
.
globalOrderIdx
)
:
comp
;
...
...
@@ -567,6 +569,10 @@ public class Scheduler implements EventHandler,
}
}
public
double
getTimeSkew
()
{
return
timeSkew
;
}
/**
* Sets the simulation speed lock, changes in setRealTime or setTimeSkew
* will not apply while the lock is set.
...
...
src/de/tud/kom/p2psim/impl/simengine/Simulator.java
View file @
241dc003
src/de/tud/kom/p2psim/impl/topology/movement/vehicular/sumo/simulation/controller/traci/TraciSimulationController.java
View file @
241dc003
...
...
@@ -826,12 +826,10 @@ public class TraciSimulationController implements VehicleController, SimulationS
List
<
RoadNetworkLane
>
lanes
=
_roadNetwork
.
getEdge
(
pEdgeID
).
getLanes
();
if
(
lanes
.
size
()
>
0
)
{
List
<
Location
>
laneShape
=
getLaneShape
(
lanes
.
get
(
0
).
getLaneID
());
for
(
Location
location
:
laneShape
)
{
if
(
0
<=
location
.
getLongitude
()
&&
location
.
getLongitude
()
<=
_endX
-
_startX
&&
0
<=
location
.
getLatitude
()
&&
location
.
getLatitude
()
<=
_endY
-
_startY
)
{
if
(
laneShape
.
size
()
>
1
)
{
return
true
;
}
}
}
return
false
;
}
return
true
;
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/SimControlPanel.java
View file @
241dc003
...
...
@@ -20,6 +20,7 @@
package
de.tud.kom.p2psim.impl.topology.views.visualization.ui
;
import
java.awt.Color
;
import
java.awt.Dimension
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
...
...
@@ -28,12 +29,16 @@ import javax.swing.AbstractAction;
import
javax.swing.Action
;
import
javax.swing.Box
;
import
javax.swing.BoxLayout
;
import
javax.swing.JButton
;
import
javax.swing.JCheckBoxMenuItem
;
import
javax.swing.JLabel
;
import
javax.swing.JMenu
;
import
javax.swing.JMenuBar
;
import
javax.swing.JPanel
;
import
javax.swing.JSlider
;
import
javax.swing.JSpinner
;
import
javax.swing.JToggleButton
;
import
javax.swing.SpinnerNumberModel
;
import
javax.swing.SwingConstants
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
...
...
@@ -44,6 +49,9 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisInfo
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisualizationListener
;
import
de.tud.kom.p2psim.impl.util.guirunner.Config
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
/**
* Menu-Bar containing means to alter the simulation speed, pause and un-pause
...
...
@@ -70,6 +78,8 @@ public class SimControlPanel extends JMenuBar implements ActionListener, ChangeL
private
ComponentVisManager
visManager
;
private
JPanel
runUntil
;
public
SimControlPanel
(
ComponentVisManager
visManager
)
{
// super("Control");
this
.
visManager
=
visManager
;
...
...
@@ -86,6 +96,8 @@ public class SimControlPanel extends JMenuBar implements ActionListener, ChangeL
this
.
add
(
getSpeedLabel
());
this
.
add
(
Box
.
createHorizontalStrut
(
10
));
this
.
add
(
getPlayPauseButton
());
this
.
add
(
Box
.
createHorizontalStrut
(
10
));
this
.
add
(
getRunUntil
());
this
.
add
(
Box
.
createHorizontalGlue
());
}
...
...
@@ -162,6 +174,53 @@ public class SimControlPanel extends JMenuBar implements ActionListener, ChangeL
return
speedslider
;
}
protected
JPanel
getRunUntil
()
{
if
(
runUntil
==
null
)
{
runUntil
=
new
JPanel
();
runUntil
.
setBackground
(
new
Color
(
0
,
0
,
0
,
0
));
JButton
button
=
new
JButton
(
"Run until"
);
runUntil
.
add
(
button
);
JSpinner
spinner
=
new
JSpinner
(
new
SpinnerNumberModel
(
0
,
0
,
Simulator
.
getEndTime
()
/
Time
.
MINUTE
,
1
));
runUntil
.
add
(
spinner
);
runUntil
.
add
(
new
JLabel
(
"min"
));
button
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
pE
)
{
int
value
=
(
int
)((
double
)
spinner
.
getValue
());
boolean
wasPaused
=
isSimulatorPaused
;
if
(
Time
.
getCurrentTime
()
<
value
*
Time
.
MINUTE
)
{
if
(
wasPaused
)
{
unpauseSimulation
();
}
double
timeSkew
=
Simulator
.
getScheduler
().
getTimeSkew
();
Simulator
.
getScheduler
().
setTimeSkew
(
0
);
Event
.
scheduleWithDelay
(
value
*
Time
.
MINUTE
-
Time
.
getCurrentTime
(),
new
EventHandler
()
{
@Override
public
void
eventOccurred
(
Object
pContent
,
int
pType
)
{
if
(
Simulator
.
getScheduler
().
getTimeSkew
()
==
0
)
{
Simulator
.
getScheduler
().
setTimeSkew
(
timeSkew
);
}
if
(
wasPaused
)
{
pauseSimulation
();
}
}
},
null
,
0
);
}
}
});
}
return
runUntil
;
}
protected
JLabel
getSpeedLabel
()
{
if
(
speedlabel
==
null
)
{
speedlabel
=
new
JLabel
(
"max"
);
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/world/NodeInfoComponentVis.java
View file @
241dc003
...
...
@@ -27,6 +27,7 @@ import java.awt.Graphics;
import
java.awt.Graphics2D
;
import
java.awt.Point
;
import
java.awt.RenderingHints
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.LinkedList
;
...
...
@@ -112,7 +113,7 @@ implements VisualizationComponent {
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
boolean
first
=
true
;
for
(
NodeVis
vis
:
nodes
)
{
for
(
NodeVis
vis
:
new
ArrayList
<>(
nodes
)
)
{
vis
.
draw
(
g2
);
if
(
first
)
{
first
=
false
;
...
...
@@ -238,7 +239,7 @@ implements VisualizationComponent {
g2
.
setStroke
(
new
BasicStroke
(
3
));
for
(
int
color
=
0
;
color
<
segments
;
color
++)
{
if
(!
activeLayers
[
color
])
{
if
(
activeLayers
.
length
<=
color
||
!
activeLayers
[
color
])
{
continue
;
}
g2
.
setColor
(
Color
.
DARK_GRAY
);
...
...
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