3 import java.util.LinkedHashMap;
5 import org.simgrid.msg.Host;
6 import org.simgrid.msg.MsgException;
8 import peersim.core.Control;
11 * This class executes all controls object scheduled in the
12 * {@link PSGPlatform#controlStepMap} collection.
14 * @author Khaled Baati 10/12/2014
15 * @version version 1.1
17 public class PSGProcessController extends org.simgrid.msg.Process {
19 private Map<Control, Double> controlStepMapTmp = new LinkedHashMap<Control, Double>();
21 public PSGProcessController(Host host, String name, String[] args) {
22 super(host, name, null);
26 public void main(String[] args) throws MsgException {
27 Double nextControlEvent;
28 for (Map.Entry<Control, Double> entry : PSGPlatform.controlStepMap
30 controlStepMapTmp.put(entry.getKey(), entry.getValue());
32 while (PSGPlatform.getTime() <= PSGPlatform.getDuration()) {
33 for (Map.Entry<Control, Double> entrytmp : controlStepMapTmp
35 Control cle = entrytmp.getKey();
36 Double valeur = entrytmp.getValue();
37 if (PSGPlatform.getTime() % valeur == 0) {
39 if (PSGPlatform.getTime() != 0)
40 for (Map.Entry<Control, Double> entry : PSGPlatform.controlStepMap
42 if (cle == entry.getKey())
43 controlStepMapTmp.replace(cle, valeur, valeur
49 nextControlEvent = next();
50 if (nextControlEvent + PSGPlatform.getTime() >= PSGPlatform.getDuration()) {
53 waitFor(nextControlEvent);
58 private Double next() {
59 Double min = controlStepMapTmp.values().iterator().next();
60 for (Map.Entry<Control, Double> entry : controlStepMapTmp.entrySet()) {
61 Double valeur = (entry.getValue() - PSGPlatform.getClock());