3 import org.simgrid.msg.Host;
4 import org.simgrid.msg.MsgException;
6 import peersim.core.Node;
7 import peersim.edsim.EDProtocol;
8 import peersim.edsim.NextCycleEvent;
11 * This class extends {@link org.simgrid.msg.Process}, it creates a process for
12 * each event added in {@link PSGSimulator#add}.
14 * This class performs to launch the appropriate call according to the type of
17 * - A NextCycleEvent: the event will be delivered to the
18 * {@link PSGProcessCycle} for treatment.
20 * - Otherwise the event is delivered to the destination protocol, that must
21 * implement {@link EDProtocol}, and the processEvent method is executed.
23 * @author Khaled Baati 12/11/2014
24 * @version version 1.1
26 public class PSGProcessLauncher extends org.simgrid.msg.Process {
27 private EDProtocol prot = null;
34 * Constructs a new process from the name of a host and with the associated
42 * the start time of the process
44 * the event added to the simulator
46 * the protocol identifier
48 public PSGProcessLauncher(Host host, String name, double delay, Object event,
50 super(host, name, null, delay, -1);
57 public PSGProcessLauncher(Host host, String name, String[] args) {
62 public void main(String[] args) throws MsgException {
63 Node node = NodeHost.getNode(host);
64 if (event instanceof NextCycleEvent) {
65 PSGProcessCycle.nextCycle(Host.currentHost(), host.getName(),
68 prot = (EDProtocol) node.getProtocol(pid);
69 prot.processEvent(node, pid, event);