-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
jdeeco-core/src/cz/cuni/mff/d3s/deeco/runners/DEECoNodeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cz.cuni.mff.d3s.deeco.runners; | ||
|
||
import cz.cuni.mff.d3s.deeco.runtime.DEECoException; | ||
import cz.cuni.mff.d3s.deeco.runtime.DEECoNode; | ||
import cz.cuni.mff.d3s.deeco.runtime.DEECoPlugin; | ||
|
||
public interface DEECoNodeFactory { | ||
|
||
public DEECoNode createNode(DEECoPlugin... nodeSpecificPlugins) throws DEECoException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
jdeeco-core/src/cz/cuni/mff/d3s/deeco/runners/DEECoRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cz.cuni.mff.d3s.deeco.runners; | ||
|
||
public interface DEECoRunner extends DEECoNodeFactory { | ||
|
||
public void start(); | ||
|
||
} |
40 changes: 30 additions & 10 deletions
40
jdeeco-core/src/cz/cuni/mff/d3s/deeco/runners/DEECoSimulation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,52 @@ | ||
package cz.cuni.mff.d3s.deeco.runners; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import cz.cuni.mff.d3s.deeco.runtime.DEECoException; | ||
import cz.cuni.mff.d3s.deeco.runtime.DEECoNode; | ||
import cz.cuni.mff.d3s.deeco.runtime.DEECoPlugin; | ||
import cz.cuni.mff.d3s.deeco.scheduler.notifier.SimulationSchedulerNotifier; | ||
|
||
/** | ||
* Main class for launching DEECo simulations. | ||
* Main entry for launching DEECo simulations. | ||
* | ||
* @author Ilias Gerostathopoulos <iliasg@d3s.mff.cuni.cz> | ||
*/ | ||
public class DEECoSimulation extends DEECoRun { | ||
|
||
private boolean terminationTimeSet = false; | ||
public class DEECoSimulation implements DEECoSimulationRunner { | ||
|
||
public DEECoSimulation(SimulationSchedulerNotifier simulationSchedulerNotifier, DEECoPlugin... simulationWideplugins) { | ||
super(simulationSchedulerNotifier, simulationWideplugins); | ||
} | ||
List<DEECoNode> deecoNodes; | ||
DEECoPlugin[] nodeWideplugins; | ||
|
||
SimulationSchedulerNotifier simulationSchedulerNotifier; | ||
boolean terminationTimeSet = false; | ||
|
||
public void setTerminationTime(long terminationTime) { | ||
simulationSchedulerNotifier.setTerminationTime(terminationTime); | ||
terminationTimeSet = true; | ||
public DEECoSimulation(SimulationSchedulerNotifier simulationSchedulerNotifier, DEECoPlugin... nodeWideplugins) { | ||
this.nodeWideplugins = nodeWideplugins; | ||
this.simulationSchedulerNotifier = simulationSchedulerNotifier; | ||
deecoNodes = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public void start() throws TerminationTimeNotSetException { | ||
if (!terminationTimeSet) { | ||
throw new TerminationTimeNotSetException( | ||
"Before starting a simulation you have to specify the termination time."); | ||
} | ||
simulationSchedulerNotifier.start(); | ||
} | ||
|
||
@Override | ||
public DEECoNode createNode(DEECoPlugin... nodeSpecificPlugins) throws DEECoException { | ||
DEECoNode node = new DEECoNode(simulationSchedulerNotifier, DEECoRun.getAllPlugins(nodeWideplugins, nodeSpecificPlugins)); | ||
deecoNodes.add(node); | ||
return node; | ||
} | ||
|
||
@Override | ||
public void setTerminationTime(long terminationTime) { | ||
simulationSchedulerNotifier.setTerminationTime(terminationTime); | ||
terminationTimeSet = true; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
jdeeco-core/src/cz/cuni/mff/d3s/deeco/runners/DEECoSimulationRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cz.cuni.mff.d3s.deeco.runners; | ||
|
||
public interface DEECoSimulationRunner extends DEECoNodeFactory { | ||
|
||
public void start() throws TerminationTimeNotSetException; | ||
|
||
public void setTerminationTime(long terminationTime); | ||
|
||
} |