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
930bb6e9
Commit
930bb6e9
authored
Mar 04, 2020
by
Julian Zobel
Browse files
Tracefile movement now correctly activates and deactivates the bypass stuff
parent
5a7c6b8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/TracefileMovementModel.java
View file @
930bb6e9
...
...
@@ -24,8 +24,10 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Scanner
;
import
de.tud.kom.p2psim.api.churn.ChurnGenerator
;
import
de.tud.kom.p2psim.api.network.SimNetInterface
;
import
de.tud.kom.p2psim.api.network.SimNetworkComponent
;
import
de.tud.kom.p2psim.api.scenario.ConfigurationException
;
...
...
@@ -42,6 +44,7 @@ import de.tudarmstadt.maki.simonstrator.api.Event;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.LifecycleComponent
;
public
class
TracefileMovementModel
implements
MovementModel
,
EventHandler
{
...
...
@@ -96,7 +99,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
initialized
=
true
;
Event
.
scheduleWithDelay
(
timeBetweenMoveOperations
,
this
,
null
,
EVENT_MOVE
);
}
...
...
@@ -143,13 +146,16 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
}
}
else
{
else
{
step
=
steps
.
pop
();
if
(!
DefaultTopology
.
isWithinWorldBoundaries
(
component
.
getRealPosition
()))
{
component
.
updateCurrentLocation
(
new
PositionVector
(
step
.
x
,
step
.
y
));
startupComponent
(
component
);
}
step
=
step
s
.
pop
(
);
component
.
updateCurrentLocation
(
new
PositionVector
(
step
.
x
,
step
.
y
));
else
{
component
.
updateCurrentLocation
(
new
PositionVector
(
step
.
x
,
step
.
y
)
);
}
}
}
else
{
...
...
@@ -176,14 +182,27 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
}
private
void
shutdownComponent
(
SimLocationActuator
node
)
{
node
.
updateCurrentLocation
(
new
PositionVector
(
DEFAULT_POSITION
));
SimNetworkComponent
net
=
(
SimNetworkComponent
)
node
.
getHost
().
getNetworkComponent
();
SimNetworkComponent
net
=
(
SimNetworkComponent
)
node
.
getHost
().
getNetworkComponent
();
for
(
SimNetInterface
netI
:
net
.
getSimNetworkInterfaces
())
{
if
(
netI
.
isOnline
())
{
netI
.
goOffline
();
}
}
try
{
List
<
LifecycleComponent
>
comps
=
node
.
getHost
().
getComponents
(
LifecycleComponent
.
class
);
for
(
LifecycleComponent
lifecycleComponent
:
comps
)
{
lifecycleComponent
.
stopComponent
();
}
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
node
.
updateCurrentLocation
(
new
PositionVector
(
DEFAULT_POSITION
));
}
private
void
startupComponent
(
SimLocationActuator
node
)
{
...
...
@@ -195,6 +214,19 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
netI
.
goOnline
();
}
}
try
{
List
<
LifecycleComponent
>
comps
=
node
.
getHost
().
getComponents
(
LifecycleComponent
.
class
);
for
(
LifecycleComponent
lifecycleComponent
:
comps
)
{
lifecycleComponent
.
startComponent
();
}
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
}
@Override
...
...
@@ -245,7 +277,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
e
.
printStackTrace
();
}
System
.
out
.
println
(
actuator
.
getHost
().
getId
()
+
" <> "
+
tracefile
.
getName
());
//
System.out.println(actuator.getHost().getId() + " <> " + tracefile.getName());
components
.
put
(
actuator
,
stepQueue
);
}
...
...
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