use debug with type boolean and default "false"! add library <% import java.net.ServerSocket; import java.net.Socket; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.BufferedWriter; import java.io.FileWriter; import java.util.Queue; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.LinkedHashMap; import java.lang.reflect.Method; import java.lang.reflect.Field; import com.ms4systems.devs.core.model.impl.CoupledModelImpl; import com.ms4systems.devs.core.model.AtomicModel; import com.ms4systems.devs.core.message.Coupling; import events.Connection; import events.ConnectionRef; import events.Done; import events.Event; import events.NewLink; import events.NewNode; import events.RendezVous; import responses.Events; import responses.Init; import responses.Response; import responses.TraceStart; import requests.Request; import values.IntegerValue; import values.SequenceValue; import values.TupleValue; import values.Value; import controller.MS4MEController; %>! add additional code <% public static MS4MEController controller; %>! use currentStep with type int and default "0"! use notRemoved with type int and default "0"! to start hold in s0 for time 1! when in s0 and receive CloseServer go to s0! from s0 go to s0! external event for s0 with CloseServer <% controller.close(); %>! internal event for s0 <% %>! initialize variables <% createMS4MEController(); %>! add additional code <% private boolean availablePort(String host, int port){ boolean result = true; try { new Socket(host, port).close(); result = false; } catch(IOException e) {} return result; } %>! add additional code <% private void createMS4MEController() { if(controller == null && availablePort("localhost", 4242)) { controller = MS4MEController.start(this); } else { controller.setController(this); } } %>! add additional code <% public void newLink(Port src, Port dest){ controller.newLink(src, dest); } %>! add additional code <% public void newNode(AtomicModel a) { createMS4MEController(); controller.newNode(a); } %>! add additional code <% public void rendezvous(Port src, Port dest, Integer v) { controller.rendezvous(src, dest, v); } %>! add additional code <% public void finalizeConstituent(AtomicModelImpl a) { controller.finalizeConstituent(a); } %>!