3 import java.util.Map.Entry;
5 import org.simgrid.msg.Host;
6 import peersim.cdsim.CDProtocol;
7 import peersim.core.Node;
8 import peersim.core.Protocol;
11 * This class handle an event of type NextCycleEvent, received on the protocol
12 * identified by a pid among all CDProtocols defined in the
13 * {@link PSGPlatform#cdProtocolsStepMap} collection.
15 * It executes the nextCyle method associated to this protocol.
17 * @author Khaled Baati 27/10/2014
18 * @version version 1.1
20 public class PSGProcessCycle {
23 * Executes the nextCycle method of the CDprotocol with the appropriate
24 * parameters, and schedules the next call using {@link PSGSimulator#add}.
27 * the host on which this component is run
35 * the protocol identifier
37 public static void nextCycle(Host host, String name, double delay,
38 Object event, int pid) {
39 CDProtocol cdp = null;
40 Node node = NodeHost.getNode(host);
41 cdp = (CDProtocol) node.getProtocol(pid);
42 cdp.nextCycle(node, pid);
44 for (Entry<Protocol, Double> entry : PSGPlatform.cdProtocolsStepMap
46 Double step = entry.getValue();
47 for (Entry<Protocol, Integer> p : PSGPlatform.protocolsPidsMap
49 if (p.getValue() == pid) {
53 if (PSGPlatform.getTime() <= PSGPlatform.getDuration() && host.isOn()) {
54 PSGSimulator.add(PSGPlatform.sgToPsTime(step), event, node, pid);