diff --git a/src/main/java/tmltranslator/TMLCP.java b/src/main/java/tmltranslator/TMLCP.java index fc2f87bd8749668a79411490550f44d7d00de29b..f4510692a2f40d1a3cbcbbdbaf10ac3300e8a0d7 100755 --- a/src/main/java/tmltranslator/TMLCP.java +++ b/src/main/java/tmltranslator/TMLCP.java @@ -37,7 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - package tmltranslator; import myutil.TraceManager; @@ -329,15 +328,16 @@ public class TMLCP extends TMLElement { } } - public void splitADs() { - - ArrayList<TMLCPActivityDiagram> all = new ArrayList<TMLCPActivityDiagram>(); - all.addAll(mainCP.splitADs()); - for (TMLCPActivityDiagram diag : otherCPs) { - all.addAll(diag.splitADs()); - } - otherCPs.addAll(all); - } + // Issue #69; Unused TMLCPJunction +// public void splitADs() { +// +// List<TMLCPActivityDiagram> all = new ArrayList<TMLCPActivityDiagram>(); +// all.addAll(mainCP.splitADs()); +// for (TMLCPActivityDiagram diag : otherCPs) { +// all.addAll(diag.splitADs()); +// } +// otherCPs.addAll(all); +// } public TMLCPElement getNonConnectedElement() { TMLCPElement elt; @@ -378,10 +378,10 @@ public class TMLCP extends TMLElement { List<TMLCPActivityDiagram> CPlist = new ArrayList<TMLCPActivityDiagram>(); List<TMLCPSequenceDiagram> SDlist = new ArrayList<TMLCPSequenceDiagram>(); - List<TMLAttribute> listAttributes = new ArrayList<TMLAttribute>(); + // List<TMLAttribute> listAttributes = new ArrayList<TMLAttribute>(); TMLCPActivityDiagram tempCP; TMLCPSequenceDiagram tempSD; - TMLAttribute attr; + // TMLAttribute attr; int i, j, k; TraceManager.addDev("The data structure contains " + getNumSections() + " CP sections (AD) and " + @@ -450,22 +450,22 @@ public class TMLCP extends TMLElement { TraceManager.addDev("Sequence Diagram n. " + (i+1) + ": " + tempSD.getName() + "\n"); //Print Variables - listAttributes = tempSD.getAttributes(); + //listAttributes = tempSD.getAttributes(); //TraceManager.addDevf("\tAttributes:\n"); - for (j = 0; j < listAttributes.size(); j++) { - attr = listAttributes.get(j); + // for (j = 0; j < listAttributes.size(); j++) { + // attr = listAttributes.get(j); //TraceManager.addDev("\t\t %s\t%s\t%s\n", attr.getName(), attr.getType(), attr.getInitialValue()); - } + //} //Print Instances - List<TMLSDInstance> listInstances; - TMLSDInstance inst; - listInstances = tempSD.getInstances(); - TraceManager.addDev("\tInstances:"); - for (j = 0; j < listInstances.size(); j++) { - inst = listInstances.get(j); + //List<TMLSDInstance> listInstances; + //TMLSDInstance inst; + //listInstances = tempSD.getInstances(); + //TraceManager.addDev("\tInstances:"); + // for (j = 0; j < listInstances.size(); j++) { + // inst = listInstances.get(j); //TraceManager.addDev("\t\t" + inst.getName() + "\n"); - } + //} //Print Messages List<TMLSDMessage> listMessages; diff --git a/src/main/java/tmltranslator/tmlcp/TMLCPActivityDiagram.java b/src/main/java/tmltranslator/tmlcp/TMLCPActivityDiagram.java index 7cdd59a3c08fb1ae8184191861b4a61705474339..4076aa65b88407bf149640dd1c9a4459c874c1e8 100755 --- a/src/main/java/tmltranslator/tmlcp/TMLCPActivityDiagram.java +++ b/src/main/java/tmltranslator/tmlcp/TMLCPActivityDiagram.java @@ -37,9 +37,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ - - - package tmltranslator.tmlcp; import tmltranslator.TMLCP; @@ -314,118 +311,119 @@ public class TMLCPActivityDiagram extends TMLElement { } } + // Issue #69; Unused TMLCPJunction // The splitting works only if there is no other operations than sequences and references to ADs/SDs // between forks and joins // The function removes junctions, and creates one new AD per junction - public Collection<TMLCPActivityDiagram> splitADs() { - int id = 0; - TMLCPActivityDiagram diag; - - //TraceManager.addDev("Splitting AD: " + getName()); - - // For each junction, we create a new AD - ArrayList<TMLCPJunction> junctions = new ArrayList<TMLCPJunction>(); - ArrayList<TMLCPRefAD> refsAD = new ArrayList<TMLCPRefAD>(); - ArrayList<TMLCPElement> toBeRemoved = new ArrayList<TMLCPElement>(); - HashMap<TMLCPJunction, TMLCPActivityDiagram> refs = new HashMap<TMLCPJunction, TMLCPActivityDiagram>(); - for(TMLCPElement elt: elements) { - if (elt instanceof TMLCPJunction) { - junctions.add((TMLCPJunction)elt); - diag = new TMLCPActivityDiagram(elt.getName() + "_" + id, referenceObject); - TMLCPStart start = new TMLCPStart("StartFrom_" + elt.getName(), elt.getReferenceObject()); - diag.setStartElement(start); - diag.addTMLCPElement(start); - refs.put((TMLCPJunction)elt, diag); - //TraceManager.addDev("Adding a new diag named: " + diag.getName()); - } - } - - // We replace all elements leading to a junction by a call to the corresponding ref AD, keeping the same nexts - for(TMLCPJunction junction: junctions) { - TMLCPActivityDiagram toAD = refs.get(junction); - //TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), junction.getReferenceObject()); - //refsAD.add(ref); - elements.remove(junction); - //elements.add(ref); - - // Replacing next to junction by new refs - int index; - // int ID = 0; - for(TMLCPElement elt: elements) { - while(((index = elt.getNextElements().indexOf(junction)) != -1)) { - //TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName() + "_" + ID, junction.getReferenceObject()); - //ID ++; - TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), junction.getReferenceObject()); - //ID ++; - refsAD.add(ref); - //elements.add(ref); - elt.setNextElementAtIndex(ref, index); - /*TMLCPStop stop = new TMLCPStop(ref.getName() + "__stop_after_ref_" + ID, ref.getReferenceObject()); - elements.add(stop); - ref.addNextElement(stop);*/ - } - //ref.setNexts(junction.getNextElements()); - } - } - - // Removing nexts in new refs, and putting a stop - for(TMLCPRefAD ref: refsAD) { - ref.clearNexts(); - elements.add(ref); - TMLCPStop stop = new TMLCPStop(ref.getName() + "__stop_after_ref", ref.getReferenceObject()); - elements.add(stop); - ref.addNextElement(stop); - } - - // Moving elements from old AD to split ADs - //int cpt = 0; - for(TMLCPJunction junction: junctions) { - diag = refs.get(junction); - //TMLCPRefAD refAD = refsAD.get(cpt); - //cpt++; - - // To be modified-> add elements from RefADs - // Also, avoid to add already met elements - addElementsFromJunction(junction, diag.getStartElement(), diag, refs, toBeRemoved); - } - - // Removing elements from main diagram - for(TMLCPElement elt: toBeRemoved) { - elements.remove(elt); - } - - - - // Returns new elements - return refs.values(); - } - - private void addElementsFromJunction(TMLCPElement originInOld, TMLCPElement originInNew, TMLCPActivityDiagram newDiag, Map<TMLCPJunction, TMLCPActivityDiagram> refs, List<TMLCPElement> toBeRemoved) { - if (originInOld.getNextElements() == null) { - return; - } - - for(TMLCPElement elt: originInOld.getNextElements()) { - //TraceManager.addDev("Exploring elt (0):" + elt.getName()); - if (elt instanceof TMLCPJunction) { - // Must replace the junction by a ref to an AD - TMLCPActivityDiagram toAD = refs.get(elt); - TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), elt.getReferenceObject()); - newDiag.addTMLCPElement(ref); - originInNew.setNextElement(ref); - } else { - //TraceManager.addDev("Exploring elt (1):" + elt.getName()); - if (originInOld != originInNew) { - originInNew.addNextElement(elt); - } - if (!newDiag.contains(elt)) { - newDiag.addTMLCPElement(elt); - toBeRemoved.add(elt); - addElementsFromJunction(elt, elt, newDiag, refs, toBeRemoved); - } - } - } - } +// private Collection<TMLCPActivityDiagram> splitADs() { +// int id = 0; +// TMLCPActivityDiagram diag; +// +// //TraceManager.addDev("Splitting AD: " + getName()); +// +// // For each junction, we create a new AD +//// List<TMLCPJunction> junctions = new ArrayList<TMLCPJunction>(); +// List<TMLCPRefAD> refsAD = new ArrayList<TMLCPRefAD>(); +// List<TMLCPElement> toBeRemoved = new ArrayList<TMLCPElement>(); +//// Map<TMLCPJunction, TMLCPActivityDiagram> refs = new HashMap<TMLCPJunction, TMLCPActivityDiagram>(); +// for(TMLCPElement elt: elements) { +// if (elt instanceof TMLCPJunction) { +// junctions.add((TMLCPJunction)elt); +// diag = new TMLCPActivityDiagram(elt.getName() + "_" + id, referenceObject); +// TMLCPStart start = new TMLCPStart("StartFrom_" + elt.getName(), elt.getReferenceObject()); +// diag.setStartElement(start); +// diag.addTMLCPElement(start); +// refs.put((TMLCPJunction)elt, diag); +// //TraceManager.addDev("Adding a new diag named: " + diag.getName()); +// } +// } +// +// // We replace all elements leading to a junction by a call to the corresponding ref AD, keeping the same nexts +// for(TMLCPJunction junction: junctions) { +// TMLCPActivityDiagram toAD = refs.get(junction); +// //TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), junction.getReferenceObject()); +// //refsAD.add(ref); +// elements.remove(junction); +// //elements.add(ref); +// +// // Replacing next to junction by new refs +// int index; +// // int ID = 0; +// for(TMLCPElement elt: elements) { +// while(((index = elt.getNextElements().indexOf(junction)) != -1)) { +// //TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName() + "_" + ID, junction.getReferenceObject()); +// //ID ++; +// TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), junction.getReferenceObject()); +// //ID ++; +// refsAD.add(ref); +// //elements.add(ref); +// elt.setNextElementAtIndex(ref, index); +// /*TMLCPStop stop = new TMLCPStop(ref.getName() + "__stop_after_ref_" + ID, ref.getReferenceObject()); +// elements.add(stop); +// ref.addNextElement(stop);*/ +// } +// //ref.setNexts(junction.getNextElements()); +// } +// } +// +// // Removing nexts in new refs, and putting a stop +// for(TMLCPRefAD ref: refsAD) { +// ref.clearNexts(); +// elements.add(ref); +// TMLCPStop stop = new TMLCPStop(ref.getName() + "__stop_after_ref", ref.getReferenceObject()); +// elements.add(stop); +// ref.addNextElement(stop); +// } +// +// // Moving elements from old AD to split ADs +// //int cpt = 0; +// for(TMLCPJunction junction: junctions) { +// diag = refs.get(junction); +// //TMLCPRefAD refAD = refsAD.get(cpt); +// //cpt++; +// +// // To be modified-> add elements from RefADs +// // Also, avoid to add already met elements +// addElementsFromJunction(junction, diag.getStartElement(), diag, refs, toBeRemoved); +// } +// +// // Removing elements from main diagram +// for(TMLCPElement elt: toBeRemoved) { +// elements.remove(elt); +// } +// +// +// +// // Returns new elements +// return refs.values(); +// } + +// private void addElementsFromJunction(TMLCPElement originInOld, TMLCPElement originInNew, TMLCPActivityDiagram newDiag, Map<TMLCPJunction, TMLCPActivityDiagram> refs, List<TMLCPElement> toBeRemoved) { +// if (originInOld.getNextElements() == null) { +// return; +// } +// +// for(TMLCPElement elt: originInOld.getNextElements()) { +// //TraceManager.addDev("Exploring elt (0):" + elt.getName()); +// if (elt instanceof TMLCPJunction) { +// // Must replace the junction by a ref to an AD +// TMLCPActivityDiagram toAD = refs.get(elt); +// TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName(), elt.getReferenceObject()); +// newDiag.addTMLCPElement(ref); +// originInNew.setNextElement(ref); +// } else { +// //TraceManager.addDev("Exploring elt (1):" + elt.getName()); +// if (originInOld != originInNew) { +// originInNew.addNextElement(elt); +// } +// if (!newDiag.contains(elt)) { +// newDiag.addTMLCPElement(elt); +// toBeRemoved.add(elt); +// addElementsFromJunction(elt, elt, newDiag, refs, toBeRemoved); +// } +// } +// } +// } public TMLCPElement getNonConnectedElement() { @@ -509,6 +507,7 @@ public class TMLCPActivityDiagram extends TMLElement { } } + @Override public String toString() { String s = "*** Activity diagram " + getName() + "\n"; for(TMLCPElement elt: elements) { @@ -516,5 +515,4 @@ public class TMLCPActivityDiagram extends TMLElement { } return s + "\n"; } - } //End of class diff --git a/src/main/java/tmltranslator/tmlcp/TMLCPJunction.java b/src/main/java/tmltranslator/tmlcp/TMLCPJunction.java deleted file mode 100755 index c0ac565fef1b0776f7e1ae37fd10fcc5f66c2971..0000000000000000000000000000000000000000 --- a/src/main/java/tmltranslator/tmlcp/TMLCPJunction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.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 tmltranslator.tmlcp; - -/** -* Class TMLCPJunction -* Creation: 18/02/2014 -* @version 1.0 18/02/2014 -* @author Ludovic APVRILLE - */ -public class TMLCPJunction extends TMLCPElement { - - public TMLCPJunction(String _name, Object _referenceObject) { - super(_name, _referenceObject); - } - -} diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index 545af8aa925b49b37457394b07315957ad9aa89e..ea8fa2e3678ace381db547c86b47f79c866dcb40 100755 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -1078,7 +1078,7 @@ public class GTMLModeling { if (!(alreadyConsidered.contains(port1))) { portstome = tmlcdp.tmlctdp.getPortsConnectedTo(port1, componentsToTakeIntoAccount); //TraceManager.addDev("Considering port1 = " +port1.getPortName() + " size of connecting ports:" + portstome.size()); - Iterator<?> ite = portstome.listIterator(); + // Iterator<?> ite = portstome.listIterator(); /*while(ite.hasNext()) { TraceManager.addDev("port=" + ((TMLCPrimitivePort)(ite.next())).getPortName()); }*/ @@ -2691,6 +2691,8 @@ public class GTMLModeling { // Syntax has been checked -> splitting ads // The splitting works only if there is no other operations than sequences and references to ADs/SDs // between forks and joins + + // Issue #69; Unused TMLCPJunction tmlcp.splitADs(); TraceManager.addDev("<--- TMLCP modeling:"); @@ -3078,7 +3080,8 @@ public class GTMLModeling { tmlcp.correctReferences(); //Update references to the right activity and sequence diagrams //tmlcp.generateNexts(); // Add nexts elements to CPElements //tmlcp.removeADConnectors(); // Remove connectors since nexts have been filled - tmlcp.splitADs(); // Splitting ADs so as to remove junctions -> new ADs are introduced for each junction inside an AD + // Issue #69; Unused TMLCPJunction + //tmlcp.splitADs(); // Splitting ADs so as to remove junctions -> new ADs are introduced for each junction inside an AD /*for( TMLCPSequenceDiagram seqDiag: tmlcp.getCPSequenceDiagrams() ) { TraceManager.addDev( "**********" ); @@ -3096,7 +3099,7 @@ public class GTMLModeling { throws MalformedTMLDesignException { tmltranslator.tmlcp.TMLCPStart start; tmltranslator.tmlcp.TMLCPStop stop; - tmltranslator.tmlcp.TMLCPJunction junction; + // tmltranslator.tmlcp.TMLCPJunction junction; tmltranslator.tmlcp.TMLCPJoin join; tmltranslator.tmlcp.TMLCPFork fork; tmltranslator.tmlcp.TMLCPChoice choice; @@ -3157,11 +3160,12 @@ public class GTMLModeling { refAD = new tmltranslator.tmlcp.TMLCPRefAD(compID, component); AD.addTMLCPElement(refAD); } - if (component instanceof ui.tmlcp.TMLCPJunction) { - //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); - junction = new tmltranslator.tmlcp.TMLCPJunction(compID, component); - AD.addTMLCPElement(junction); - } + // Issue #69; Unused TMLCPJunction +// if (component instanceof ui.tmlcp.TMLCPJunction) { +// //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); +// junction = new tmltranslator.tmlcp.TMLCPJunction(compID, component); +// AD.addTMLCPElement(junction); +// } if (component instanceof ui.tmlcp.TMLCPJoin) { //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); join = new tmltranslator.tmlcp.TMLCPJoin(compID, component);