Skip to content
Snippets Groups Projects
GTMLModeling.java 195 KiB
Newer Older
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici, Matteo Bertolino
 * 
 * ludovic.apvrille AT telecom-paristech.fr
 * andrea.enrici AT telecom-paristech.fr
 * matteo.bertolino AT telecom-paristech.fr
 * This software is a computer program whose purpose is to allow the
 * edition of TURTLE analysis, design and deployment diagrams, to
 * allow the generation of RT-LOTOS or Java code from this diagram,
 * and at last to allow the analysis of formal validation traces
 * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
 * from INRIA Rhone-Alpes.
 * 
 * This software is governed by the CeCILL  license under French law and
 * abiding by the rules of distribution of free software.  You can  use,
 * modify and/ or redistribute the software under the terms of the CeCILL
 * license as circulated by CEA, CNRS and INRIA at the following URL
 * "http://www.cecill.info".
 * 
 * As a counterpart to the access to the source code and  rights to copy,
 * modify and redistribute granted by the license, users are provided only
 * with a limited warranty  and the software's author,  the holder of the
 * economic rights,  and the successive licensors  have only  limited
 * liability.
 * 
 * In this respect, the user's attention is drawn to the risks associated
 * with loading,  using,  modifying and/or developing or reproducing the
 * software by the user in light of its specific status of free software,
 * that may mean  that it is complicated to manipulate,  and  that  also
 * therefore means  that it is reserved for developers  and  experienced
 * professionals having in-depth computer knowledge. Users are therefore
 * encouraged to load and test the software's suitability as regards their
 * requirements in conditions enabling the security of their systems and/or
 * data to be ensured and,  more generally, to use and operate it in the
 * same conditions as regards security.
 * 
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL license and that you accept its terms.
 */





package ui;

import avatartranslator.AvatarSpecification;
import myutil.Conversion;
import myutil.TraceManager;
import tmltranslator.*;
import tmltranslator.modelcompiler.ArchUnitMEC;
import tmltranslator.tmlcp.TMLCPElement;
import tmltranslator.tmlcp.TMLSDAction;
import tmltranslator.tmlcp.TMLSDEvent;
import tmltranslator.tmlcp.TMLSDMessage;
import tmltranslator.TMLCheckingError;
import translator.CheckingError;
import ui.tmlad.*;
import ui.tmlcd.TMLChannelOperator;
import ui.tmlcd.TMLEventOperator;
import ui.tmlcd.TMLRequestOperator;
import ui.tmlcd.TMLTaskOperator;
import ui.tmlcompd.TMLCPath;
import ui.tmlcompd.TMLCPrimitiveComponent;
import ui.tmlcompd.TMLCPrimitivePort;
import ui.tmlcompd.*;
import ui.tmlcompd.TMLCRecordComponent;
import ui.tmldd.*;
import ui.tmlsd.TGConnectorMessageTMLSD;
import ui.tmlsd.TMLSDControllerInstance;
import ui.tmlsd.TMLSDStorageInstance;
import ui.tmlsd.TMLSDTransferInstance;

import java.util.*;
import java.awt.Point;
 * Class GTMLModeling
 * Use to translate graphical TML modeling to  "tmlmodeling"
 * Creation: 23/11/2005
 * @version 1.1 30/05/2014
 * @author Ludovic APVRILLE, Andrea ENRICI
public class GTMLModeling  {
    private TMLDesignPanel tmldp;
    private TMLComponentDesignPanel tmlcdp;
    private TMLArchiPanel tmlap;
    private TMLModeling<TGComponent> tmlm;
    private List<CheckingError> checkingErrors, warnings;
    private List<? extends TGComponent> tasksToTakeIntoAccount;
    private List<? extends TGComponent> componentsToTakeIntoAccount;
    private List<? extends TGComponent> components;
    private List<String> removedChannels, removedRequests, removedEvents;
    private static CorrespondanceTGElement listE;
    private Map<String, String> table;
    public AvatarSpecification avspec;
    //private ArrayList<HwNode> nodesToTakeIntoAccount;
    private List<TGComponent> nodesToTakeIntoAccount;

    private TMLMapping<TGComponent> map;
    private TMLArchitecture archi;

    //Attributes specific to Communication Patterns
    private TMLCP tmlcp;
    private TMLCommunicationPatternPanel tmlcpp;
    //   private Vector<TDiagramPanel> diagramPanelsToTakeIntoAccount;
    //    private Vector<TDiagramPanel> panels;

    private Map<String, SecurityPattern> securityPatterns = new HashMap<String, SecurityPattern>();

    private boolean putPrefixName = false;

    public GTMLModeling(TMLDesignPanel _tmldp, boolean resetList) {
        tmldp = _tmldp;
        table = new Hashtable<String, String>();
        if (resetList) {
            listE = new CorrespondanceTGElement();
        }
    }

    public GTMLModeling(TMLComponentDesignPanel _tmlcdp, boolean resetList) {
        tmlcdp = _tmlcdp;
        table = new Hashtable<String, String>();
        if (resetList) {
            listE = new CorrespondanceTGElement();
        }
    }

    public GTMLModeling(TMLArchiPanel _tmlap, boolean resetList) {
        tmlap = _tmlap;
        //System.out.println(tmlap.getMainGUI());
        //TURTLEPanel tup = (TURTLEPanel)(tmlap.getMainGUI().getTURTLEPanel(namePanel));
        //if (tup instanceof TMLDesignPanel) {
        //tmldp = tmlap.getMainGUI().
        table = new Hashtable<String, String>();
        if (resetList) {
            listE = new CorrespondanceTGElement();
        }
    }

    public GTMLModeling( TMLCommunicationPatternPanel _tmlcpp, boolean resetList ) {
        tmlcpp = _tmlcpp;
        table = new Hashtable<String, String>();
        if (resetList) {
            listE = new CorrespondanceTGElement();
        }
    }

    public TMLModeling<TGComponent> translateToTMLModeling(boolean _resetID) {
        return translateToTMLModeling(false, _resetID);
    }

    public void putPrefixName(boolean _b) {
        putPrefixName = _b;
    }

	public void processAttacker(){
		//System.out.println("processing...");
		//System.out.println(tmlm.getAttackerTasks());
		if (tmlm==null){
			return;
		}
		List<TMLTask> attackers = tmlm.getAttackerTasks();
		for (TMLTask attacker: attackers){
			//System.out.println(attacker.getName());
			TMLCPrimitiveComponent atcomp = tmlcdp.getPrimitiveComponentByName(attacker.getName().split("__")[1]);
			//System.out.println("comp " + attacker.getName().split("__")[1]);
			if (atcomp !=null){
				//Find activity diagram
				TMLActivityDiagramPanel tadp = tmlcdp.getTMLActivityDiagramPanel(attacker.getName().split("__")[1]);
				List<TGComponent> list = tadp.getComponentList();
				//System.out.println("list " + list);
				for (TGComponent tgc: list){
					if (tgc instanceof TMLADWriteChannel){
						TMLADWriteChannel wr = (TMLADWriteChannel) tgc;
						if (wr.isAttacker()){
							//System.out.println("channel " + wr.getChannelName());
							String channelToAdd = wr.getChannelName();

                            
							//Find ports to attach
							List<TMLCPrimitivePort> ports = tmlcdp.tmlctdp.getPortsByName(channelToAdd);
							//System.out.println("orts " + ports);
							if (ports.size()!=2){	
								//throw error
								//System.out.println("ERROR");
								continue;
							}

							//Remove Port Connector
							tmlcdp.tmlctdp.removeOneConnector(ports.get(0).getTGConnectingPointAtIndex(0));


							//Add write port to attacker component
							TMLCChannelOutPort originPort = new TMLCChannelOutPort(atcomp.getX(), atcomp.getY(), tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, atcomp, tmlcdp.tmlctdp);
                            originPort.commName=channelToAdd;
							tmlcdp.tmlctdp.addComponent(originPort, atcomp.getX(), atcomp.getY(),true,true);

							//Add fork/join to Component Diagram 
							TMLCJoin join = new TMLCJoin(atcomp.getX(), atcomp.getY(), tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp);
							tmlcdp.tmlctdp.addComponent(join, atcomp.getX(), atcomp.getY(),false,true);
					
							//Add 3 connectors, from each port to the join
							TMLCPortConnector conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, originPort.getTGConnectingPointAtIndex(0), join.getTGConnectingPointAtIndex(1), new Vector<Point>());
	                        tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							if (!ports.get(0).isOrigin()){
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(0).getTGConnectingPointAtIndex(0), join.getTGConnectingPointAtIndex(0), new Vector<Point>());
Dominique Blouin's avatar
Dominique Blouin committed
								tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(1).getTGConnectingPointAtIndex(0), join.getTGConnectingPointAtIndex(6), new Vector<Point>());
Dominique Blouin's avatar
Dominique Blouin committed
								tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							}
							else {
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(0).getTGConnectingPointAtIndex(0), join.getTGConnectingPointAtIndex(6), new Vector<Point>());
Dominique Blouin's avatar
Dominique Blouin committed
								tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(1).getTGConnectingPointAtIndex(0), join.getTGConnectingPointAtIndex(0), new Vector<Point>());
Dominique Blouin's avatar
Dominique Blouin committed
								tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							}
						}
					}
					else if (tgc instanceof TMLADReadChannel){
						TMLADReadChannel rd = (TMLADReadChannel) tgc;
						if (rd.isAttacker()){
							//System.out.println("channel " + rd.getChannelName());
							String channelToAdd = rd.getChannelName();

                            
							//Find ports to attach
							List<TMLCPrimitivePort> ports = tmlcdp.tmlctdp.getPortsByName(channelToAdd);
							//System.out.println("orts " + ports);
							if (ports.size()!=2){	
								//throw error
								//System.out.println("ERROR");
								continue;
							}

							//Remove Port Connector
							tmlcdp.tmlctdp.removeOneConnector(ports.get(0).getTGConnectingPointAtIndex(0));


							//Add write port to attacker component
							TMLCChannelOutPort destPort = new TMLCChannelOutPort(atcomp.getX(), atcomp.getY(), tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, atcomp, tmlcdp.tmlctdp);
                            destPort.commName=channelToAdd;
							destPort.isOrigin=false;
							tmlcdp.tmlctdp.addComponent(destPort, atcomp.getX(), atcomp.getY(),true,true);

							//Add fork/join to Component Diagram 
							TMLCFork fork = new TMLCFork(atcomp.getX(), atcomp.getY(), tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp);
							tmlcdp.tmlctdp.addComponent(fork, atcomp.getX(), atcomp.getY(),false,true);
					
							//Add 3 connectors, from each port to the join
							TMLCPortConnector conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, destPort.getTGConnectingPointAtIndex(0), fork.getTGConnectingPointAtIndex(1), new Vector<Point>());
	                        tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							if (ports.get(0).isOrigin()){
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(0).getTGConnectingPointAtIndex(0), fork.getTGConnectingPointAtIndex(0), new Vector<Point>());
                        		tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(1).getTGConnectingPointAtIndex(0), fork.getTGConnectingPointAtIndex(6), new Vector<Point>());
                        		tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							}
							else {
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(0).getTGConnectingPointAtIndex(0), fork.getTGConnectingPointAtIndex(6), new Vector<Point>());
                        		tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
								conn = new TMLCPortConnector(0, 0, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxX(), true, null, tmlcdp.tmlctdp, ports.get(1).getTGConnectingPointAtIndex(0), fork.getTGConnectingPointAtIndex(0), new Vector<Point>());
                        		tmlcdp.tmlctdp.addComponent(conn, 0,0,false,true);
							}

						}
					}
				}
			}
		}
	}

    public TMLModeling<TGComponent> translateToTMLModeling(boolean onlyTakenIntoAccount, boolean _resetID) {
        tmlm = new TMLModeling<>(_resetID);
        checkingErrors = new LinkedList<CheckingError> ();
        warnings = new LinkedList<CheckingError> ();

        //boolean b;

        if (tmldp != null) {
            components = tmldp.tmltdp.getComponentList();
            if (tasksToTakeIntoAccount == null) {
                tasksToTakeIntoAccount = components;
            }
            removedChannels = new LinkedList<String>();
            removedRequests = new LinkedList<String>();
            removedEvents = new LinkedList<String>();

            try {


                addTMLTasks();
                addTMLChannels();
                addTMLEvents();
                addTMLRequests();
                //addTMLPragmas();
                TraceManager.addDev("At line 151");
                generateTasksActivityDiagrams();
                removeActionsWithDollars();
                removeActionsWithRecords();
            } catch (MalformedTMLDesignException mtmlde) {
                TraceManager.addDev("Modeling error:" + mtmlde.getMessage());
            }

            /*TMLTextSpecification spec = new TMLTextSpecification();
              spec.toTextFormat(tmlm);
              TraceManager.addDev("TMLModeling=\n" + spec.toString());*/

            // Cheking syntax
            TMLSyntaxChecking syntax = new TMLSyntaxChecking(tmlm);
            syntax.checkSyntax();

            int type;
            TGComponent tgc;

            if (syntax.hasErrors() >0) {
                for(TMLError error: syntax.getErrors()) {
                    //TraceManager.addDev("Adding checking error");
                    if (error.type == TMLError.ERROR_STRUCTURE) {
                        type = CheckingError.STRUCTURE_ERROR;
                    } else {
                        type = CheckingError.BEHAVIOR_ERROR;
                    }

                    tgc = listE.getTG(error.element);
                    if (tgc != null) {
                        UICheckingError ce = new UICheckingError(type, error.message);
                        ce.setTDiagramPanel(tgc.getTDiagramPanel());
                        ce.setTGComponent(tgc);
                        checkingErrors.add(ce);
                    } else {
                        TMLCheckingError ce = new TMLCheckingError(type, error.message);
                        ce.setTMLTask(error.task);
                        checkingErrors.add(ce);
                    }
                }
            }
        } else if (tmlcdp != null) {
            if (onlyTakenIntoAccount) {
                components = componentsToTakeIntoAccount;
            } else {
                components = tmlcdp.tmlctdp.getPrimitiveComponentList();
                if (componentsToTakeIntoAccount == null) {
                    componentsToTakeIntoAccount = components;
                }
            }

            removedChannels = new LinkedList<String>();
            removedRequests = new LinkedList<String>();
            removedEvents = new LinkedList<String>();

            try {

                // Checking paths
                if (tmlcdp != null) {
                    if (tmlcdp.tmlctdp != null) {
Dominique Blouin's avatar
Dominique Blouin committed
                        List<TMLCPath> faultyPaths = tmlcdp.tmlctdp.updatePorts();
                        for(TMLCPath fp: faultyPaths) {
                            if (fp != null) {
                                // There is a faulty path
                                // Create an error
                                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, fp.getErrorMessage());
                                ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                ce.setTGComponent(fp.getFaultyComponent());
                                checkingErrors.add(ce);
                                //throw new MalformedTMLDesignException("Bad path:" + path.getErrorMessage());
                            }
                        }
                    }
                }

                addTMLComponents();
				//Adapt for attacker
				TraceManager.addDev("Processing attacker");
				processAttacker();
                TraceManager.addDev("Adding channels");
                addTMLCChannels();
                TraceManager.addDev("Adding events");
                addTMLCEvents();
                TraceManager.addDev("Adding requests");
                addTMLCRequests();
                //addTMLPragmas();
                TraceManager.addDev("At line 211");
                generateTasksActivityDiagrams();
                removeActionsWithDollars();
                removeActionsWithRecords();
            } catch (MalformedTMLDesignException mtmlde) {
                TraceManager.addDev("Modeling error:" + mtmlde.getMessage());
            }

            TMLSyntaxChecking syntax = new TMLSyntaxChecking(tmlm);
            syntax.checkSyntax();

            int type;
            TGComponent tgc;

            if (syntax.hasErrors() >0) {
                for(TMLError error: syntax.getErrors()) {
                    //TraceManager.addDev("Adding checking error");
                    if (error.type == TMLError.ERROR_STRUCTURE) {
                        type = CheckingError.STRUCTURE_ERROR;
                    } else {
                        type = CheckingError.BEHAVIOR_ERROR;
                    }
                    tgc = listE.getTG(error.element);
                    if (tgc != null) {
                        UICheckingError ce = new UICheckingError(type, error.message);
                        ce.setTDiagramPanel(tgc.getTDiagramPanel());
                        ce.setTGComponent(tgc);
                        checkingErrors.add(ce);
                    } else {
                        TMLCheckingError ce = new TMLCheckingError(type, error.message);
                        ce.setTMLTask(error.task);
                        checkingErrors.add(ce);
                    }
                }
            }
        }

        return tmlm;
    }

    public TMLDesignPanel getTMLDesignPanel()  {
        return tmldp;
    }

    public CorrespondanceTGElement getCorrespondanceTable() {
        return listE;
    }

    public void setTasks(Vector<? extends TGComponent> tasks) {
        tasksToTakeIntoAccount = new LinkedList<TGComponent>(tasks);
    }

    public void setComponents(Vector<? extends TGComponent> components) {
        componentsToTakeIntoAccount = new LinkedList<TGComponent>(components);
    }

    public void setNodes(Vector<TGComponent> nodes) {
        nodesToTakeIntoAccount = new LinkedList<TGComponent>(nodes);
    }

    //    public void setDiagramPanels( Vector<TDiagramPanel> panels ) {
    //        diagramPanelsToTakeIntoAccount = new Vector<TDiagramPanel>( panels );
    //    }

    public List<CheckingError> getCheckingErrors() {
        return checkingErrors;
    }

    public List<CheckingError> getCheckingWarnings() {
        return warnings;
    }
    //
    //    private void addTMLPragmas(){
    //  TGComponent tgc;
    //  components = tmlap.tmlap.getComponentList();
    //  ListIterator iterator = components.listIterator();
    //  while(iterator.hasNext()) {
    //      tgc = (TGComponent)(iterator.next());
    //      if (tgc instanceof TGCNote){
    //          TGCNote note = (TGCNote) tgc;
    //          String[] vals = note.getValues();
    //          for (String s: vals){
    //              TraceManager.addDev("Val " + s);
    //              if (s.contains("#") && s.contains(" ")){
    //                          map.addPragma(s.split(" "));
    //              }
    //          }
    //      }
    //        }
    //    }
    private void addTMLTasks() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLTask tmlt;
        TMLTaskOperator tmlto;
        TMLActivityDiagramPanel tmladp;

        Iterator<? extends TGComponent> iterator = tasksToTakeIntoAccount.listIterator();
        while(iterator.hasNext()) {
            tgc = iterator.next();
            if (tgc instanceof TMLTaskOperator) {
                tmlto = (TMLTaskOperator)tgc;
                tmladp = tmldp.getTMLActivityDiagramPanel(tmlto.getValue());
                if (tmladp == null) {
                    String msg = tmlto.getValue() + " has no activity diagram";
                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                    ce.setTDiagramPanel(tmldp.tmltdp);
                    ce.setTGComponent(tgc);
                    checkingErrors.add(ce);
                    throw new MalformedTMLDesignException(tmlto.getValue() + " msg");
                }

                if (tmlm.getTMLTaskByName(tmlto.getValue()) != null) {
                    String msg = "Two tasks have the same name: " + tmlto.getValue() + " (mapping problem?)";
                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                    ce.setTDiagramPanel(tmldp.tmltdp);
                    ce.setTGComponent(tgc);
                    checkingErrors.add(ce);
                    throw new MalformedTMLDesignException(tmlto.getValue() + " msg");
                }

                tmlt = new TMLTask(makeName(tgc, tmlto.getValue()), tmlto, tmladp);
                listE.addCor(tmlt, tgc);
                tmlm.addTask(tmlt);
                tmlt.setExit(tmlto.isExit());
                addAttributesTo(tmlt, tmlto);
            }
        }
    }

    private void addTMLComponents() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLCPrimitiveComponent tmlcpc;
        TMLActivityDiagramPanel tmladp;
        TMLTask tmlt;
        TMLComponentDesignPanel tmlcdptmp;

        Iterator<? extends TGComponent> iterator = componentsToTakeIntoAccount.listIterator();
        while(iterator.hasNext()) {
            tgc = iterator.next();
            if (tgc instanceof TMLCPrimitiveComponent) {
                tmlcpc = (TMLCPrimitiveComponent)tgc;
                tmlcdptmp = (TMLComponentDesignPanel)(tmlcpc.getTDiagramPanel().getMGUI().getTURTLEPanelOfTDiagramPanel(tmlcpc.getTDiagramPanel()));
                tmladp = tmlcdptmp.getReferencedTMLActivityDiagramPanel(tmlcpc.getTDiagramPanel(), tmlcpc.getValue());
                if (tmladp == null) {
                    String msg = " has no activity diagram";
                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                    ce.setTDiagramPanel(tmlcdp.tmlctdp);
                    ce.setTGComponent(tgc);
                    checkingErrors.add(ce);
                    throw new MalformedTMLDesignException(tmlcpc.getValue() + " msg");
                }
                if (tmlm.getTMLTaskByName(tmlcpc.getValue()) != null) {
                    String msg = "Two components have the same name: " + tmlcpc.getValue() + " (mapping problem?)";
                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                    ce.setTDiagramPanel(tmlcdp.tmlctdp);
                    ce.setTGComponent(tgc);
                    checkingErrors.add(ce);
                    throw new MalformedTMLDesignException(tmlcpc.getValue() + " msg");
                }
                tmlt = new TMLTask(makeName(tgc, tmlcpc.getValue()), tmlcpc, tmladp);
				tmlt.setAttacker(tmlcpc.isAttacker());
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
                TraceManager.addDev("Task added:" + tmlt.getName() + " with tadp=" + tmladp + " major=" + tmladp.getMGUI().getMajorTitle(tmladp));
                listE.addCor(tmlt, tgc);
                tmlm.addTask(tmlt);
                tmlt.setExit(false);
                //tmlt.setExit(tmlcpc.isExit());
                addAttributesTo(tmlt, tmlcpc);
            }
        }
    }

    private void addTMLChannels() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLChannelOperator tmlco;
        Iterator<? extends TGComponent> iterator = components.listIterator();
        TMLTaskInterface t1, t2;
        TMLChannel channel;
        TMLTask tt1, tt2;
        String name;

        while(iterator.hasNext()) {
            tgc = iterator.next();
            if (tgc instanceof TMLChannelOperator) {
                tmlco = (TMLChannelOperator)tgc;
                //TraceManager.addDev("Found channel: " + tmlco.getChannelName());
                t1 = tmldp.tmltdp.getTask1ToWhichIamConnected(tmlco);
                t2 = tmldp.tmltdp.getTask2ToWhichIamConnected(tmlco);
                if ((t1 != null) && (t2 != null) && (tasksToTakeIntoAccount.contains(t1)) && (tasksToTakeIntoAccount.contains(t2)) ) {
                    name = makeName(tgc, tmlco.getChannelName());
                    channel = new TMLChannel(name, tmlco);
                    TraceManager.addDev("name=" + name + " makeName1 =" + makeName(tgc, t1.getTaskName())  + " chname=" + tmlco.getChannelName());
                    addToTable(makeName(tgc, t1.getTaskName()) + "/" + tmlco.getChannelName(), name);
                    addToTable(makeName(tgc, t2.getTaskName()) + "/" + tmlco.getChannelName(), name);
                    channel.setSize(tmlco.getChannelSize());
                    channel.setType(tmlco.getChannelType());
                    channel.setMax(tmlco.getChannelMax());
                    if (tmlm.hasSameChannelName(channel)) {
                        if (tmlm.hasAlmostSimilarChannel(channel)) {
                            String msg = " channel " + tmlco.getChannelName() + " is declared several times differently";
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmldp.tmltdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(tmlco.getChannelName() + " msg");
                        }
                    } else {
                        tt1 = tmlm.getTMLTaskByName(makeName((TGComponent)t1, t1.getTaskName()));
                        tt2 = tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName()));
                        channel.setTasks(tt1, tt2);
                        tmlm.addChannel(channel);
                        listE.addCor(channel, tgc);
                        //TraceManager.addDev("Adding channel " + channel.getName());
                    }
                } else {
                    removedChannels.add(new String(tmlco.getChannelName()));
                    UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Channel " +  tmlco.getChannelName() + " has been removed");
                    ce.setTDiagramPanel(tmldp.tmltdp);
                    ce.setTGComponent(tmlco);
                    warnings.add(ce);
                }
            }
        }
    }

    private void addTMLEvents() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLEventOperator tmleo;
        Iterator<? extends TGComponent> iterator = components.listIterator();
        TMLTaskInterface t1, t2;
        TMLEvent event;
        TType tt;
        TMLType tmlt;
        TMLTask tt1, tt2;
        String name;

        while(iterator.hasNext()) {
            tgc = iterator.next();
            if (tgc instanceof TMLEventOperator) {
                tmleo = (TMLEventOperator)tgc;
                //TraceManager.addDev("Found event: " + tmleo.getEventName());
                t1 = tmldp.tmltdp.getTask1ToWhichIamConnected(tmleo);
                t2 = tmldp.tmltdp.getTask2ToWhichIamConnected(tmleo);
                if ((t1 != null) && (t2 != null) && (tasksToTakeIntoAccount.contains(t1)) && (tasksToTakeIntoAccount.contains(t2)) ) {
                    name = makeName(tgc, tmleo.getEventName());
                    event = new TMLEvent(name, tmleo, tmleo.getMaxSamples(), tmleo.isBlocking());
                    addToTable(makeName(tgc, t1.getTaskName()) + "/" + tmleo.getEventName(), name);
                    addToTable(makeName(tgc, t2.getTaskName()) + "/" + tmleo.getEventName(), name);
                    for(int i=0; i<tmleo.getEventMaxParam(); i++) {
                        tt = tmleo.getParamAt(i);
                        if ((tt != null) && (tt.getType() != TType.NONE)) {
                            tmlt = new TMLType(tt.getType());
                            event.addParam(tmlt);
                            //TraceManager.addDev("Event " + event.getName() + " add param");
                        }
                    }
                    if (tmlm.hasSameEventName(event)) {
                        if (tmlm.hasAlmostSimilarEvent(event)) {
                            String msg = " event " + tmleo.getEventName() + " is declared several times differently";
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmldp.tmltdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(tmleo.getEventName() + " msg");
                        }
                    } else {
                        tt1 = tmlm.getTMLTaskByName(makeName((TGComponent)t1, t1.getTaskName()));
                        tt2 = tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName()));
                        event.setTasks(tt1, tt2);
                        tmlm.addEvent(event);
                        listE.addCor(event, tgc);
                        //TraceManager.addDev("Adding event " + event.getName());
                    }
                } else {
                    TraceManager.addDev( "Removing event "+ new String(tmleo.getEventName()) );
                    removedEvents.add(new String(tmleo.getEventName()));
                    UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Event " +  tmleo.getEventName() + " has been removed");
                    ce.setTDiagramPanel(tmldp.tmltdp);
                    ce.setTGComponent(tmleo);
                    warnings.add(ce);
                }
            }
        }
    }

    private void addTMLRequests() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLRequestOperator tmlro;
        Iterator<? extends TGComponent> iterator = components.listIterator();
        TMLTaskInterface t1, t2;
        TMLRequest request;
        TType tt;
        TMLType tmlt;
        TMLTask task;
        TMLAttribute tmlattr;
        TMLType tmltt;
        String name;

        while(iterator.hasNext()) {
            tgc = iterator.next();
            
            if (tgc instanceof TMLRequestOperator) {
                tmlro = (TMLRequestOperator)tgc;
                //TraceManager.addDev("Found request: " + tmlro.getRequestName());
                t1 = tmldp.tmltdp.getTask1ToWhichIamConnected(tmlro);
                t2 = tmldp.tmltdp.getTask2ToWhichIamConnected(tmlro);
                if ((t1 != null) && (t2 != null) && (tasksToTakeIntoAccount.contains(t1)) && (tasksToTakeIntoAccount.contains(t2)) ) {
                    name = makeName(tgc, tmlro.getRequestName());
                    addToTable(makeName(tgc, t1.getTaskName()) + "/" + tmlro.getRequestName(), name);
                    addToTable(makeName(tgc, t2.getTaskName()) + "/" + tmlro.getRequestName(), name);
                    // Check whether there is another request having a different name but with the same destination task
                    request = tmlm.getRequestByDestinationTask(tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName())));

                    if (request != null) {
                        if (request.getName().compareTo(name) != 0) {
                            String msg = "Two requests declared with different names have the same destination task: " + tmlro.getRequestName();
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmldp.tmltdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(tmlro.getRequestName() + " msg");
                        }
                    }

                    request = tmlm.getRequestNamed(name);
                    if (request == null) {
                        request = new TMLRequest(name, tmlro);

                        request.setDestinationTask(tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName())));
                        tmlm.addRequest(request);
                        for(int i=0; i<tmlro.getRequestMaxParam(); i++) {
                            tt = tmlro.getParamAt(i);
                            if ((tt != null) && (tt.getType() != TType.NONE)) {
                                tmlt = new TMLType(tt.getType());
                                request.addParam(tmlt);
                            }
                        }
                    } else {
                        // Must check whether the destination task is the same
                        if (request.getDestinationTask() != tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName()))) {
                            String msg = "Two requests are declared with the same name but with two different destination tasks: " + tmlro.getRequestName();
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmldp.tmltdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(tmlro.getRequestName() + " msg");
                        }

                        // Must check whether the two requests are compatible (parameters)
                        int nbOfParamsCurrent = 0;
                        for(int i=0; i<tmlro.getRequestMaxParam(); i++) {
                            tt = tmlro.getParamAt(i);
                            if ((tt != null) && (tt.getType() != TType.NONE)) {
                                nbOfParamsCurrent ++;
                            }
                        }
                        if (request.getNbOfParams() != nbOfParamsCurrent) {
                            String msg = "request " + tmlro.getRequestName() + " is declared several times with different parameters";
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmldp.tmltdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(tmlro.getRequestName() + " msg");
                        }

                        // Must check param types as well
                        int cpti = 0;
                        for(int i=0; i<tmlro.getRequestMaxParam(); i++) {
                            tt = tmlro.getParamAt(i);
                            if ((tt != null) && (tt.getType() != TType.NONE)) {
                                tmlt = new TMLType(tt.getType());
                                if (request.getType(cpti).getType() != tmlt.getType()) {
                                    String msg = "request " + tmlro.getRequestName() + " is declared several times with different types in parameters";
                                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                    ce.setTDiagramPanel(tmldp.tmltdp);
                                    ce.setTGComponent(tgc);
                                    checkingErrors.add(ce);
                                    throw new MalformedTMLDesignException(tmlro.getRequestName() + " msg");
                                }
                                cpti ++;
                            }
                        }
                    }

                    // More: test the compatibility of the request!
                    if (request.getDestinationTask() != tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName()))) {
                        String msg = "request " + tmlro.getRequestName() + " is declared several times differently (compatibility issue)";
                        UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                        ce.setTDiagramPanel(tmldp.tmltdp);
                        ce.setTGComponent(tgc);
                        checkingErrors.add(ce);
                        throw new MalformedTMLDesignException(tmlro.getRequestName() + " msg");
                    }
                    request.addOriginTask(tmlm.getTMLTaskByName(makeName((TGComponent)t1, t1.getTaskName())));

                    task = tmlm.getTMLTaskByName(makeName((TGComponent)t2, t2.getTaskName()));
                    task.setRequested(true);
                    task.setRequest(request);

                    // Request attributes
                    //TraceManager.addDev("Requests attributes");
                    String attname;
                    for(int j=0; j<request.getNbOfParams(); j++) {
                        attname = "arg" + (j + 1) + "__req";
                        if (task.getAttributeByName(attname) == null) {
                            tmltt = new TMLType(request.getType(j).getType());
                            tmlattr = new TMLAttribute(attname, tmltt);
                            tmlattr.initialValue = tmlattr.getDefaultInitialValue();
                            TraceManager.addDev("Adding " + tmlattr.getName() + " to " + task.getName() + "with value =" + tmlattr.initialValue);
                            task.addAttribute(tmlattr);
                        }
                    }


                } else {
                    removedRequests.add(new String(tmlro.getRequestName()));
                    UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "Request " +  tmlro.getRequestName() + " has been removed");
                    ce.setTDiagramPanel(tmldp.tmltdp);
                    ce.setTGComponent(tmlro);
                    warnings.add(ce);
                }
            }
        }
    }

    private void addTMLCChannels() throws MalformedTMLDesignException {
        TGComponent tgc;
        TMLCPrimitiveComponent tmlc;
        Iterator<? extends TGComponent> iterator = components.listIterator();
        Iterator<TMLCPrimitivePort> li;//, li2;
        List<TMLCPrimitivePort> ports, portstome;
        String name, name1, name2;
        TMLCPrimitivePort port1, port2;

        int j;

        //TMLTaskInterface t1, t2;
        TMLChannel channel;
        TMLTask tt1, tt2;

        List<TGComponent> alreadyConsidered = new ArrayList<TGComponent>();

        TraceManager.addDev("*** Adding channels ***");

        while(iterator.hasNext()) {
            tgc = iterator.next();
            if (tgc instanceof TMLCPrimitiveComponent) {
                tmlc = (TMLCPrimitiveComponent)tgc;
                //TraceManager.addDev("Component:" + tmlc.getValue());
                ports = tmlc.getAllChannelsOriginPorts();
                //TraceManager.addDev("Ports size:" + ports.size());
                li = ports.listIterator();
                while(li.hasNext()) {
                    port1 = li.next();
                    if (!(alreadyConsidered.contains(port1))) {
                        portstome = tmlcdp.tmlctdp.getPortsConnectedTo(port1, componentsToTakeIntoAccount);
                        TraceManager.addDev("******** Considering port1 = " +port1.getPortName() + " size of connecting ports:" + portstome.size());

                        Iterator<TMLCPrimitivePort> ite = portstome.listIterator();
                        while(ite.hasNext()) {
                            TraceManager.addDev("port=" + ite.next().getPortName());
                        }

                        if (portstome.size() < 1) {
                            String msg = "port " + port1.getPortName() + " is not correctly connected";
                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                            ce.setTDiagramPanel(tmlcdp.tmlctdp);
                            ce.setTGComponent(tgc);
                            checkingErrors.add(ce);
                            throw new MalformedTMLDesignException(msg);
                        }

                        if (portstome.size() == 1) {
                            port2 = portstome.get(0);
                            alreadyConsidered.add(port1);
                            alreadyConsidered.add(port2);

                            String []text1 = port1.getPortName().split(",");
                            String []text2 = port2.getPortName().split(",");

                            for (j=0; j<Math.min(text1.length, text2.length); j++) {
                                name1 = text1[j].trim();
                                name2 = text2[j].trim();

                                /*if (name1.equals(name2)) {
                                  name = makeName(tgc, name1);
                                  } else {
                                  name = makeName(tgc, name1 + "__" + name2);
                                  }*/

                                name = makeName(port1, name1) + "__" + makeName(port2, name2);

                                if (makeName(port1, name1).compareTo(makeName(port2, name2)) == 0) {
                                    name = makeName(port1, name1);
                                }

                                //TraceManager.addDev("Adding to table : " + makeName(port1, port1.getFather().getValue()) + "/" + name1);
                                addToTable(makeName(port1, port1.getFather().getValue()) + "/" + name1, name);
                                //TraceManager.addDev("Adding to table : " + makeName(port2, port2.getFather().getValue()) + "/" + name2);
                                addToTable(makeName(port2, port2.getFather().getValue()) + "/" + name2, name);

                                channel = new TMLChannel(name, port1);
                                channel.setSize(port1.getSize());
                                channel.setMax(port1.getMax());
                                channel.ports.add(port1);
                                channel.ports.add(port2);
                                if (port1.isBlocking() && port2.isBlocking()) {
                                    channel.setType(TMLChannel.BRBW);
                                } else if (!port1.isBlocking() && port2.isBlocking()) {
                                    channel.setType(TMLChannel.BRNBW);
                                } else if (!port1.isBlocking() && !port2.isBlocking()) {
                                    channel.setType(TMLChannel.NBRNBW);
                                } else {
                                    String msg = "Ports " + name1 + " and " + name2 + " are not compatible (NBRBW)";
                                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                    ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                    ce.setTGComponent(port1);
                                    checkingErrors.add(ce);
                                    throw new MalformedTMLDesignException(msg);
                                }

                                if (tmlm.hasSameChannelName(channel)) {
                                    if (tmlm.hasAlmostSimilarChannel(channel)) {
                                        String msg = " channel " + name + " is declared several times differently";
                                        UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                        ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                        ce.setTGComponent(tgc);
                                        checkingErrors.add(ce);
                                        throw new MalformedTMLDesignException(msg);
                                    }
                                } else {
                                    tt1 = tmlm.getTMLTaskByName(makeName(port1, port1.getFather().getValue()));
                                    tt2 = tmlm.getTMLTaskByName(makeName(port2, port2.getFather().getValue()));
                                    channel.setTasks(tt1, tt2);

                                    if (port1.isLossy()) {
                                        channel.setLossy(true, port1.getLossPercentage(), port1.getMaxNbOfLoss());
                                    }

                                    //complex channels are used only for transformation towards the simulator
                                    TMLPort tmlport1, tmlport2;
                                    tmlport1 = new TMLPort( port1.getPortName(), port1 );
                                    tmlport1.setPrex( port1.isPrex() );
                                    tmlport1.setPostex( port1.isPostex() );
                                    tmlport1.setAssociatedEvent( port1.getAssociatedEvent() );
                                    tmlport2 = new TMLPort( port2.getPortName(), port2 );
                                    tmlport2.setPrex( port2.isPrex() );
                                    tmlport2.setPostex( port2.isPostex() );
                                    tmlport2.setAssociatedEvent( port2.getAssociatedEvent() );
                                    channel.setPorts( tmlport1, tmlport2 );
                                    tmlm.addChannel(channel);
                                    listE.addCor(channel, tgc);
                                    TraceManager.addDev("Adding channel " + channel.getName());
                                }
                            }
                        } else {
                            // Complex channel "1 -> many"
                            TMLCPrimitivePort port;


                            // Only one channel per port
                            if (port1.getPortName().indexOf(",") != -1) {
                                String msg = "Multiple definition of channels with more than one output port is not allowed: " + port1.getPortName();
                                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                ce.setTGComponent(port1);
                                checkingErrors.add(ce);
                                throw new MalformedTMLDesignException(msg);
                            }
                            for(j=0; j<portstome.size(); j++) {
                                port = portstome.get(j);
                                if (port.getPortName().indexOf(",") != -1) {
                                    String msg = "Multiple definition of channels with more than one output port is not allowed: " + port.getPortName();
                                    UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                    ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                    ce.setTGComponent(port);
                                    checkingErrors.add(ce);
                                    throw new MalformedTMLDesignException(msg);
                                }
                            }

                            // Name of port
                            name = makeName(port1, port1.getPortName());
                            for(j=0; j<portstome.size(); j++) {
                                name += "__" + portstome.get(j).getPortName();
                            }

                            // Correspondance table
                            alreadyConsidered.add(port1);
                            addToTable(makeName(port1, port1.getFather().getValue()) + "/" + port1.getPortName(), name);
                            for(j=0; j<portstome.size(); j++) {
                                port = portstome.get(j);
                                alreadyConsidered.add(port);
                                addToTable(makeName(port, port.getFather().getValue()) + "/" + port.getPortName(), name);
                            }

                            // Channel attributes
                            port = portstome.get(0);
                            channel = new TMLChannel(name, port1);
                            channel.ports.add(port1);
                            for(j=0; j<portstome.size(); j++) {
                                TMLCPrimitivePort p = portstome.get(j);
                                channel.ports.add(p);
                            }
                            channel.setSize(port1.getSize());
                            channel.setMax(port1.getMax());
                            if (port1.isBlocking() && port.isBlocking()) {
                                channel.setType(TMLChannel.BRBW);
                            } else if (!port1.isBlocking() && port.isBlocking()) {
                                channel.setType(TMLChannel.BRNBW);
                            } else if (!port1.isBlocking() && !port.isBlocking()) {
                                channel.setType(TMLChannel.NBRNBW);
                            } else {
                                String msg = "Ports " + port1.getPortName() + " and " + port.getPortName() + " are not compatible (NBRBW)";
                                UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, msg);
                                ce.setTDiagramPanel(tmlcdp.tmlctdp);
                                ce.setTGComponent(port1);
                                checkingErrors.add(ce);
                                throw new MalformedTMLDesignException(msg);