From b682dcf7275e279131f9af6a15cf332e7e7b837b Mon Sep 17 00:00:00 2001 From: dblouin <dominique.blouin@telecom-paristech.fr> Date: Fri, 12 May 2017 10:24:49 +0200 Subject: [PATCH] Issue #38: Exception thrown when validating a communication pattern mapping when not all attributes are set --- src/tmltranslator/HwCrossbar.java | 2 - src/tmltranslator/HwDMA.java | 5 - src/tmltranslator/HwExecutionNode.java | 3 - src/tmltranslator/HwLink.java | 3 - src/tmltranslator/HwVGMN.java | 3 - src/tmltranslator/TMLActivity.java | 30 +- src/tmltranslator/TMLActivityElement.java | 13 +- .../TMLActivityElementChannel.java | 8 +- .../TMLActivityElementEvent.java | 9 +- src/tmltranslator/TMLAttribute.java | 2 - src/tmltranslator/TMLCP.java | 217 +++++------ src/tmltranslator/TMLCPLibArtifact.java | 14 +- src/tmltranslator/TMLCPSyntaxChecking.java | 222 ++++++----- src/tmltranslator/TMLCPTextSpecification.java | 354 +++++++++--------- src/tmltranslator/TMLChoice.java | 4 +- .../TMLCommunicationElement.java | 4 +- src/tmltranslator/TMLEvent.java | 24 +- src/tmltranslator/TMLModeling.java | 96 +++-- src/tmltranslator/TMLPort.java | 2 - src/tmltranslator/TMLRandomSequence.java | 57 ++- src/tmltranslator/TMLSDAttribute.java | 4 +- src/tmltranslator/TMLSDType.java | 2 - src/tmltranslator/TMLSendRequest.java | 4 +- src/tmltranslator/TMLSequence.java | 69 ++-- src/tmltranslator/TMLSyntaxChecking.java | 4 +- src/tmltranslator/TMLTask.java | 48 +-- src/tmltranslator/TMLTextSpecification.java | 82 ++-- src/tmltranslator/TMLType.java | 2 - src/tmltranslator/modelcompiler/Buffer.java | 6 +- src/tmltranslator/modelcompiler/CPMEC.java | 77 +++- .../modelcompiler/CpuMemoryCopyMEC.java | 70 ++-- .../modelcompiler/DoubleDmaMEC.java | 96 ++--- .../modelcompiler/FepBuffer.java | 6 +- .../modelcompiler/FepOperationMEC.java | 4 - .../modelcompiler/InterleaverBuffer.java | 8 +- .../modelcompiler/MapperBuffer.java | 4 +- .../modelcompiler/OperationMEC.java | 4 +- .../modelcompiler/SingleDmaMEC.java | 79 ++-- .../modelcompiler/TMLModelCompiler.java | 2 +- .../tmlcp/TMLCPActivityDiagram.java | 168 ++++----- src/tmltranslator/tmlcp/TMLCPChoice.java | 3 - src/tmltranslator/tmlcp/TMLCPConnector.java | 4 - src/tmltranslator/tmlcp/TMLCPElement.java | 9 +- src/tmltranslator/tmlcp/TMLCPEndGroup.java | 5 - src/tmltranslator/tmlcp/TMLCPFork.java | 5 - src/tmltranslator/tmlcp/TMLCPJoin.java | 20 +- src/tmltranslator/tmlcp/TMLCPJunction.java | 5 - src/tmltranslator/tmlcp/TMLCPRefAD.java | 4 - src/tmltranslator/tmlcp/TMLCPRefSD.java | 4 - src/tmltranslator/tmlcp/TMLCPSequence.java | 5 - .../tmlcp/TMLCPSequenceDiagram.java | 9 +- src/tmltranslator/tmlcp/TMLCPStart.java | 5 - src/tmltranslator/tmlcp/TMLCPStartGroup.java | 5 - src/tmltranslator/tmlcp/TMLCPStop.java | 5 - src/tmltranslator/tmlcp/TMLSDAction.java | 31 +- src/tmltranslator/tmlcp/TMLSDElement.java | 3 - src/tmltranslator/tmlcp/TMLSDEvent.java | 5 - src/tmltranslator/tmlcp/TMLSDInstance.java | 2 - src/tmltranslator/tmlcp/TMLSDMessage.java | 1 - .../tmlcp/TMLSDMessageManipulation.java | 5 - .../tmlcp/TMLSDReceiveMessage.java | 5 - src/tmltranslator/tmlcp/TMLSDSendMessage.java | 5 - .../tmlcp/UndeclaredDiagramException.java | 5 +- .../tmlcp/UndeclaredInstanceException.java | 5 +- .../tmlcp/UndeclaredVariableException.java | 5 +- .../tmlcp/UndefinedDiagramException.java | 5 +- .../tmlcp/UndefinedVariableException.java | 5 +- .../tmlcp/UninitializedVariableException.java | 5 +- .../DiploSimulatorCodeGenerator.java | 8 +- src/ui/ad/TActivityDiagramPanel.java | 1 + src/ui/avatardd/ADDConnector.java | 2 - src/ui/ncdd/NCConnectorNode.java | 4 +- src/ui/tmldd/TMLArchiCPNode.java | 52 ++- src/ui/window/JDialogCommPatternMapping.java | 25 +- 74 files changed, 1015 insertions(+), 1063 deletions(-) diff --git a/src/tmltranslator/HwCrossbar.java b/src/tmltranslator/HwCrossbar.java index bfaf72f347..fefbeb84da 100755 --- a/src/tmltranslator/HwCrossbar.java +++ b/src/tmltranslator/HwCrossbar.java @@ -45,8 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; -import java.util.*; - public class HwCrossbar extends HwCommunicationNode { diff --git a/src/tmltranslator/HwDMA.java b/src/tmltranslator/HwDMA.java index b57747ec66..6cc5e0440e 100755 --- a/src/tmltranslator/HwDMA.java +++ b/src/tmltranslator/HwDMA.java @@ -45,9 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; -import java.util.*; - - public class HwDMA extends HwCommunicationNode { public static final int DEFAULT_BYTE_DATA_SIZE = 4; @@ -59,6 +56,4 @@ public class HwDMA extends HwCommunicationNode { public HwDMA(String _name) { super(_name); } - - } \ No newline at end of file diff --git a/src/tmltranslator/HwExecutionNode.java b/src/tmltranslator/HwExecutionNode.java index 514ff7ecdf..9576b8ed40 100755 --- a/src/tmltranslator/HwExecutionNode.java +++ b/src/tmltranslator/HwExecutionNode.java @@ -45,9 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; -import java.util.*; -import tmltranslator.modelcompiler.*; - public abstract class HwExecutionNode extends HwNode { protected int maximumNbOfTasks; diff --git a/src/tmltranslator/HwLink.java b/src/tmltranslator/HwLink.java index 25acc8ccdc..f546e7ddaa 100755 --- a/src/tmltranslator/HwLink.java +++ b/src/tmltranslator/HwLink.java @@ -45,9 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; -import java.util.*; - - public class HwLink implements Comparable<HwLink> { public HwBus bus; public HwVGMN vgmn;//DG 10.08. diff --git a/src/tmltranslator/HwVGMN.java b/src/tmltranslator/HwVGMN.java index 77beea8a94..ce5c2913db 100755 --- a/src/tmltranslator/HwVGMN.java +++ b/src/tmltranslator/HwVGMN.java @@ -45,9 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; -import java.util.*; - - public class HwVGMN extends HwCommunicationNode { /* public static final int BASIC_ROUND_ROBIN = 0; diff --git a/src/tmltranslator/TMLActivity.java b/src/tmltranslator/TMLActivity.java index 22776278b2..bfd3952a74 100755 --- a/src/tmltranslator/TMLActivity.java +++ b/src/tmltranslator/TMLActivity.java @@ -57,17 +57,20 @@ public class TMLActivity extends TMLElement { public TMLActivity(String name, Object reference) { super(name, reference); - elements = new Vector(); + elements = new Vector<TMLActivityElement>(); } public TMLActivity copy(){ TMLActivity newAct = new TMLActivity(this.name, this.referenceObject); newAct.setFirst(this.first); + for (TMLActivityElement act: elements){ newAct.addElement(act); } + return newAct; } + public boolean contains(TMLActivityElement _elt) { return elements.contains(_elt); } @@ -322,7 +325,6 @@ public class TMLActivity extends TMLElement { } previous.addNext(tmlae); - } public void splitActionStatesWithDollars(TMLTask _task) { @@ -340,7 +342,6 @@ public class TMLActivity extends TMLElement { for(TMLActionState as: states) { splitActionStatesWithDollars(as, _task); } - } private void splitActionStatesWithDollars(TMLActionState _ae, TMLTask _task) { @@ -439,12 +440,11 @@ public class TMLActivity extends TMLElement { } } - public void replaceReadChannelWith(TMLChannel oldChan, TMLChannel newChan) { TMLActivityElement ae; for(int i=0; i<elements.size(); i++) { - ae = (TMLActivityElement)(elements.elementAt(i)); + ae = elements.elementAt(i); if (ae instanceof TMLReadChannel) { ((TMLReadChannel)ae).replaceChannelWith(oldChan, newChan); } @@ -477,10 +477,11 @@ public class TMLActivity extends TMLElement { if (twc.getChannel(j) == chan) { TMLSendEvent send = new TMLSendEvent("SendEvt" + cpt, ae.getReferenceObject()); send.setEvent(evt); - Vector nexts = ae.getNexts(); - for (Object o: nexts) { - send.addNext((TMLActivityElement)o); + //Vector nexts = ae.getNexts(); + for (TMLActivityElement o: ae.getNexts() ) { + send.addNext( o ); } + newElements.add(send); send.addParam(action); ae.clearNexts(); @@ -513,10 +514,11 @@ public class TMLActivity extends TMLElement { TMLWaitEvent receive = new TMLWaitEvent("RecvEvt" + cpt, ae.getReferenceObject()); receive.setEvent(evt2); - Vector nexts = ae.getNexts(); - for (Object o: nexts) { - receive.addNext((TMLActivityElement)o); + // Vector nexts = ae.getNexts(); + for (TMLActivityElement o: ae.getNexts() ) { + receive.addNext( o ); } + send.addNext(receive); newElements.add(send); newElements.add(receive); @@ -544,6 +546,7 @@ public class TMLActivity extends TMLElement { } } } + if (loop != null) { TMLActivityElement next = (loop.getNexts()).get(0); if ((next == null) || (next instanceof TMLStopState)) { @@ -551,12 +554,9 @@ public class TMLActivity extends TMLElement { for(TMLActivityElement elt: elements) { elt.setNewNext(loop, next); } - } + removeEmptyInfiniteLoop(); } - } - - } diff --git a/src/tmltranslator/TMLActivityElement.java b/src/tmltranslator/TMLActivityElement.java index b415034d78..f3fb5be3cc 100755 --- a/src/tmltranslator/TMLActivityElement.java +++ b/src/tmltranslator/TMLActivityElement.java @@ -52,21 +52,25 @@ public class TMLActivityElement extends TMLElement{ protected Vector<TMLActivityElement> nexts; public SecurityPattern securityPattern; private String value=""; + public TMLActivityElement(String _name, Object _referenceObject) { super(_name, _referenceObject); + nexts = new Vector<TMLActivityElement>(); - } public int getNbNext() { return nexts.size(); } + public void setValue(String val){ - value=val; + value=val; } + public String getValue(){ - return value; + return value; } + public TMLActivityElement getNextElement(int _i) { if (_i < getNbNext() ) { return (TMLActivityElement)(nexts.elementAt(_i)); @@ -108,7 +112,4 @@ public class TMLActivityElement extends TMLElement{ } } } - - - } diff --git a/src/tmltranslator/TMLActivityElementChannel.java b/src/tmltranslator/TMLActivityElementChannel.java index c8490e2e20..e8e466d5f9 100755 --- a/src/tmltranslator/TMLActivityElementChannel.java +++ b/src/tmltranslator/TMLActivityElementChannel.java @@ -78,9 +78,9 @@ public class TMLActivityElementChannel extends TMLActivityElement { } public void replaceChannelWith(TMLChannel oldChan, TMLChannel newChan) { - if (channels.contains(oldChan)) { - channels.remove(oldChan); - channels.add(newChan); - } + if (channels.contains(oldChan)) { + channels.remove(oldChan); + channels.add(newChan); + } } } diff --git a/src/tmltranslator/TMLActivityElementEvent.java b/src/tmltranslator/TMLActivityElementEvent.java index dad7db73f8..b79b454af4 100755 --- a/src/tmltranslator/TMLActivityElementEvent.java +++ b/src/tmltranslator/TMLActivityElementEvent.java @@ -50,23 +50,24 @@ import java.util.*; public abstract class TMLActivityElementEvent extends TMLActivityElement { protected TMLEvent event; - protected Vector datas; + protected Vector<String> datas; protected String variable; // Used for notified -> variable in which the result is stored: // 0: no event // >0: nb of event in the list - protected ArrayList<TMLEvent> events; + protected List<TMLEvent> events; public TMLActivityElementEvent(String _name, Object _referenceObject) { super(_name, _referenceObject); - datas = new Vector(); + + datas = new Vector<String>(); } public boolean hasEvents() { return events != null; } - public ArrayList<TMLEvent> getEvents() { + public List<TMLEvent> getEvents() { return events; } diff --git a/src/tmltranslator/TMLAttribute.java b/src/tmltranslator/TMLAttribute.java index fa860c2008..8cf8c2560e 100755 --- a/src/tmltranslator/TMLAttribute.java +++ b/src/tmltranslator/TMLAttribute.java @@ -48,8 +48,6 @@ package tmltranslator; -import myutil.*; - public class TMLAttribute extends DIPLOElement { public TMLType type; diff --git a/src/tmltranslator/TMLCP.java b/src/tmltranslator/TMLCP.java index 455b8de290..81735f2db5 100755 --- a/src/tmltranslator/TMLCP.java +++ b/src/tmltranslator/TMLCP.java @@ -48,7 +48,6 @@ package tmltranslator; import java.util.*; import tmltranslator.tmlcp.*; -import myutil.*; public class TMLCP extends TMLElement { @@ -56,8 +55,8 @@ public class TMLCP extends TMLElement { private ArrayList<TMLCPActivityDiagram> otherCPs; //Ref to other CPs private ArrayList<TMLCPSequenceDiagram> sds; //Ref to SDs - private int hashCode; - private boolean hashCodeComputed = false; +// private int hashCode; +// private boolean hashCodeComputed = false; public TMLCP( String _name, Object _referenceObject ) { super( _name, _referenceObject ); @@ -73,85 +72,85 @@ public class TMLCP extends TMLElement { otherCPs = new ArrayList<TMLCPActivityDiagram>(); sds = new ArrayList<TMLCPSequenceDiagram>(); } - - private void computeHashCode() { - /*TMLArchiTextSpecification architxt = new TMLArchiTextSpecification("spec.tarchi"); - String s = architxt.toTextFormat(this); - hashCode = s.hashCode();*/ - //System.out.println("TARCHI hashcode = " + hashCode); - } - - private boolean checkDiagramDeclaration( TMLCPSequenceDiagram _tmlsdSection ) { - - int i; - TMLCPActivityDiagram CPsection; - - //first check the main CP - if( mainCP.containsSDDiagram( _tmlsdSection.getName() ) ) { - return true; - } - else { - // then check on the other CPs - for( i = 0; i < otherCPs.size(); i++ ) { - CPsection = otherCPs.get(i); - if( CPsection.containsSDDiagram( _tmlsdSection.getName() ) ) { - return true; - } - } - return false; - } - } - - private boolean checkDiagramDeclaration( TMLCPActivityDiagram _tmlcpSection ) { - - int i; - TMLCPActivityDiagram CPsection; - - if( mainCP.containsADDiagram( _tmlcpSection.getName() ) ) { //first check in the main CP's list - return true; - } - else { - for( i = 0; i < otherCPs.size(); i++ ) { // then check in the other CPs' lists - CPsection = otherCPs.get(i); - if( CPsection.containsADDiagram( _tmlcpSection.getName() ) ) { - return true; - } - } - return false; - } - } - - private boolean checkMultipleDiagramDeclaration( TMLCPSequenceDiagram _tmlsdSection ) { - - int i, counterSD = 0; - String tempString; - TMLCPSequenceDiagram tempSD; - - for( i = 0; i < sds.size(); i++ ) { - tempSD = sds.get(i); - tempString = tempSD.getName(); - if( tempString.equals( _tmlsdSection.getName() ) ) { - counterSD++; - } - } - return ( counterSD > 0 ); - } - - private boolean checkMultipleDiagramDeclaration( TMLCPActivityDiagram _tmlcpSection ) { - - int i, counterAD = 0; - String tempString; - TMLCPActivityDiagram tempAD; - - for( i = 0; i < otherCPs.size(); i++ ) { - tempAD = otherCPs.get(i); - tempString = tempAD.getName(); - if( tempString.equals( _tmlcpSection.getName() ) ) { - counterAD++; - } - } - return ( counterAD > 0 ); - } +// +// private void computeHashCode() { +// /*TMLArchiTextSpecification architxt = new TMLArchiTextSpecification("spec.tarchi"); +// String s = architxt.toTextFormat(this); +// hashCode = s.hashCode();*/ +// //System.out.println("TARCHI hashcode = " + hashCode); +// } + +// private boolean checkDiagramDeclaration( TMLCPSequenceDiagram _tmlsdSection ) { +// +// int i; +// TMLCPActivityDiagram CPsection; +// +// //first check the main CP +// if( mainCP.containsSDDiagram( _tmlsdSection.getName() ) ) { +// return true; +// } +// else { +// // then check on the other CPs +// for( i = 0; i < otherCPs.size(); i++ ) { +// CPsection = otherCPs.get(i); +// if( CPsection.containsSDDiagram( _tmlsdSection.getName() ) ) { +// return true; +// } +// } +// return false; +// } +// } + +// private boolean checkDiagramDeclaration( TMLCPActivityDiagram _tmlcpSection ) { +// +// int i; +// TMLCPActivityDiagram CPsection; +// +// if( mainCP.containsADDiagram( _tmlcpSection.getName() ) ) { //first check in the main CP's list +// return true; +// } +// else { +// for( i = 0; i < otherCPs.size(); i++ ) { // then check in the other CPs' lists +// CPsection = otherCPs.get(i); +// if( CPsection.containsADDiagram( _tmlcpSection.getName() ) ) { +// return true; +// } +// } +// return false; +// } +// } + +// private boolean checkMultipleDiagramDeclaration( TMLCPSequenceDiagram _tmlsdSection ) { +// +// int i, counterSD = 0; +// String tempString; +// TMLCPSequenceDiagram tempSD; +// +// for( i = 0; i < sds.size(); i++ ) { +// tempSD = sds.get(i); +// tempString = tempSD.getName(); +// if( tempString.equals( _tmlsdSection.getName() ) ) { +// counterSD++; +// } +// } +// return ( counterSD > 0 ); +// } +// +// private boolean checkMultipleDiagramDeclaration( TMLCPActivityDiagram _tmlcpSection ) { +// +// int i, counterAD = 0; +// String tempString; +// TMLCPActivityDiagram tempAD; +// +// for( i = 0; i < otherCPs.size(); i++ ) { +// tempAD = otherCPs.get(i); +// tempString = tempAD.getName(); +// if( tempString.equals( _tmlcpSection.getName() ) ) { +// counterAD++; +// } +// } +// return ( counterAD > 0 ); +// } public int getHashCode() { return 0; @@ -162,7 +161,6 @@ public class TMLCP extends TMLElement { return hashCode;*/ } - public void setMainCP(TMLCPActivityDiagram _tmlcpSection) { mainCP = _tmlcpSection; } @@ -184,11 +182,11 @@ public class TMLCP extends TMLElement { return sds.size(); } - public ArrayList<TMLCPActivityDiagram> getCPActivityDiagrams() { + public List<TMLCPActivityDiagram> getCPActivityDiagrams() { return otherCPs; } - public ArrayList<TMLCPSequenceDiagram> getCPSequenceDiagrams() { + public List<TMLCPSequenceDiagram> getCPSequenceDiagrams() { return sds; } @@ -196,10 +194,10 @@ public class TMLCP extends TMLElement { return mainCP; } - public ArrayList<String> checkSDsDefinition() { + public List<String> checkSDsDefinition() { - ArrayList<String> undefinedSDs = new ArrayList<String>(); - ArrayList<String> SDlist; + List<String> undefinedSDs = new ArrayList<String>(); + List<String> SDlist; String declaredSD; TMLCPSequenceDiagram definedSD; boolean isSDdefined = false; @@ -248,10 +246,10 @@ public class TMLCP extends TMLElement { return undefinedSDs; } - public ArrayList<String> checkADsDefinition() { + public List<String> checkADsDefinition() { - ArrayList<String> undefinedADs = new ArrayList<String>(); - ArrayList<String> ADlist; + List<String> undefinedADs = new ArrayList<String>(); + List<String> ADlist; String declaredAD; TMLCPActivityDiagram definedAD; boolean isADdefined = false; @@ -351,9 +349,9 @@ public class TMLCP extends TMLElement { return null; } - public LinkedList<TMLCPElement> getAllNonConnectedElements() { - LinkedList<TMLCPElement> list = new LinkedList<TMLCPElement>(); - TMLCPElement elt; + public List<TMLCPElement> getAllNonConnectedElements() { + List<TMLCPElement> list = new LinkedList<TMLCPElement>(); + //TMLCPElement elt; list.addAll(mainCP.getAllNonConnectedElements()); for(TMLCPActivityDiagram diag: otherCPs) { list.addAll(diag.getAllNonConnectedElements()); @@ -361,9 +359,9 @@ public class TMLCP extends TMLElement { return list; } - public LinkedList<TMLCPElement> removeAllNonConnectedElements() { - LinkedList<TMLCPElement> list = new LinkedList<TMLCPElement>(); - TMLCPElement elt; + public List<TMLCPElement> removeAllNonConnectedElements() { + List<TMLCPElement> list = new LinkedList<TMLCPElement>(); + //TMLCPElement elt; list.addAll(mainCP.removeAllNonConnectedElements()); for(TMLCPActivityDiagram diag: otherCPs) { list.addAll(diag.removeAllNonConnectedElements()); @@ -373,9 +371,9 @@ public class TMLCP extends TMLElement { public void printDataStructure() { - ArrayList<TMLCPActivityDiagram> CPlist = new ArrayList<TMLCPActivityDiagram>(); - ArrayList<TMLCPSequenceDiagram> SDlist = new ArrayList<TMLCPSequenceDiagram>(); - ArrayList<TMLAttribute> listAttributes = new ArrayList<TMLAttribute>(); + List<TMLCPActivityDiagram> CPlist = new ArrayList<TMLCPActivityDiagram>(); + List<TMLCPSequenceDiagram> SDlist = new ArrayList<TMLCPSequenceDiagram>(); + List<TMLAttribute> listAttributes = new ArrayList<TMLAttribute>(); TMLCPActivityDiagram tempCP; TMLCPSequenceDiagram tempSD; TMLAttribute attr; @@ -401,7 +399,7 @@ public class TMLCP extends TMLElement { }*/ //Print list of AD sections - ArrayList<String> ADList; + List<String> ADList; ADList = tempCP.getADlist(); System.out.println( "\tDeclared AD: " ); for( j = 0; j < ADList.size(); j++ ) { @@ -409,7 +407,7 @@ public class TMLCP extends TMLElement { } //Print list of SD sections - ArrayList<String> SDList; + List<String> SDList; SDList = tempCP.getSDlist(); System.out.println( "\tDeclared SD: " ); for( j = 0; j < SDList.size(); j++ ) { @@ -417,8 +415,8 @@ public class TMLCP extends TMLElement { } //Print list of Elements - ArrayList<TMLCPElement> ElementsList; - TMLCPElement tempElem; + List<TMLCPElement> ElementsList; + //TMLCPElement tempElem; ElementsList = tempCP.getElements(); System.out.println( "\tDeclared elements:" ); for( j = 0; j < ElementsList.size(); j++ ) { @@ -455,7 +453,7 @@ public class TMLCP extends TMLElement { } //Print Instances - ArrayList<TMLSDInstance> listInstances; + List<TMLSDInstance> listInstances; TMLSDInstance inst; listInstances = tempSD.getInstances(); System.out.println( "\tInstances:" ); @@ -465,8 +463,8 @@ public class TMLCP extends TMLElement { } //Print Messages - ArrayList<TMLSDMessage> listMessages; - ArrayList<TMLAttribute> msgAttributes; + List<TMLSDMessage> listMessages; + List<TMLAttribute> msgAttributes; TMLSDMessage msg; listMessages = tempSD.getMessages(); System.out.println( "\tMessages:" ); @@ -481,6 +479,7 @@ public class TMLCP extends TMLElement { } } + @Override public String toString() { String s = "\n*** Communication Pattern: " + getName() + "***\n"; @@ -491,8 +490,10 @@ public class TMLCP extends TMLElement { } for( tmltranslator.tmlcp.TMLCPSequenceDiagram diag: sds ) { - s += sds.toString(); + s += diag.toString(); +// s += sds.toString(); } + return s; } } //End of the class diff --git a/src/tmltranslator/TMLCPLibArtifact.java b/src/tmltranslator/TMLCPLibArtifact.java index 09ffe7a25b..e97961147c 100755 --- a/src/tmltranslator/TMLCPLibArtifact.java +++ b/src/tmltranslator/TMLCPLibArtifact.java @@ -47,8 +47,6 @@ package tmltranslator; import java.util.*; -import tmltranslator.tmlcp.*; -import myutil.*; public class TMLCPLibArtifact extends TMLElement { @@ -56,16 +54,16 @@ public class TMLCPLibArtifact extends TMLElement { public String portName; public String memoryName; public int priority; - private ArrayList<String> bufferParameters; + private List<String> bufferParameters; - public TMLCPLibArtifact(String _name, Object _referenceObject, String _taskName, String _portName, String _memoryName, int _priority, ArrayList<String> _bufferParameters ) { + public TMLCPLibArtifact(String _name, Object _referenceObject, String _taskName, String _portName, String _memoryName, int _priority, List<String> _bufferParameters ) { super( _name, _referenceObject ); taskName = _taskName; portName = _portName; memoryName = _memoryName; priority = _priority; - bufferParameters = _bufferParameters; + bufferParameters = _bufferParameters; } public TMLCPLibArtifact() { @@ -88,7 +86,7 @@ public class TMLCPLibArtifact extends TMLElement { return priority; } - public ArrayList<String> getBufferParameters() { - return bufferParameters; - } + public List<String> getBufferParameters() { + return bufferParameters; + } } //End of the class diff --git a/src/tmltranslator/TMLCPSyntaxChecking.java b/src/tmltranslator/TMLCPSyntaxChecking.java index 474f8bcd1b..c07c83dc83 100755 --- a/src/tmltranslator/TMLCPSyntaxChecking.java +++ b/src/tmltranslator/TMLCPSyntaxChecking.java @@ -51,31 +51,29 @@ package tmltranslator; import java.io.*; import java.util.*; import compiler.tmlparser.*; -import myutil.*; -import tmltranslator.*; import tmltranslator.tmlcp.*; public class TMLCPSyntaxChecking { - private final String WRONG_ORIGIN_CHANNEL = "is not declared as an origin channel of the task"; - private final String WRONG_DESTINATION_CHANNEL = "is not declared as a destination channel of the task"; - private final String WRONG_ORIGIN_EVENT = "is not declared as an origin event of the task"; - private final String WRONG_DESTINATION_EVENT = "is not declared as a destination event of the task"; - private final String WRONG_ORIGIN_REQUEST = "is not declared as an origin request of the task"; +// private final String WRONG_ORIGIN_CHANNEL = "is not declared as an origin channel of the task"; +// private final String WRONG_DESTINATION_CHANNEL = "is not declared as a destination channel of the task"; +// private final String WRONG_ORIGIN_EVENT = "is not declared as an origin event of the task"; +// private final String WRONG_DESTINATION_EVENT = "is not declared as a destination event of the task"; +// private final String WRONG_ORIGIN_REQUEST = "is not declared as an origin request of the task"; private final String SYNTAX_ERROR = "syntax error"; - private final String WRONG_VARIABLE_IDENTIFIER = "forbidden variable's name"; +// private final String WRONG_VARIABLE_IDENTIFIER = "forbidden variable's name"; private final String VARIABLE_ERROR = "variable is not used according to its type"; private final String UNDECLARED_VARIABLE = "unknown variable"; private final String WRONG_VARIABLE_TYPE = "incorrect variable type"; - private final String SYNTAX_ERROR_VARIABLE_EXPECTED = "syntax error (variable expected)"; - private final String TIME_UNIT_ERROR = "unknown time unit"; +// private final String SYNTAX_ERROR_VARIABLE_EXPECTED = "syntax error (variable expected)"; +// private final String TIME_UNIT_ERROR = "unknown time unit"; - private ArrayList<TMLCPError> errors; - private ArrayList<TMLCPError> warnings; + private List<TMLCPError> errors; + private List<TMLCPError> warnings; private TMLCP tmlcp; - private TMLMapping mapping; + //private TMLMapping mapping; public TMLCPSyntaxChecking( TMLCP _tmlcp ) { @@ -103,18 +101,18 @@ public class TMLCPSyntaxChecking { //First check the mainCP then check the other Activity Diagrams private void checkActivityDiagrams() { - ArrayList<TMLCPActivityDiagram> junctionsList = new ArrayList<TMLCPActivityDiagram>(); + //List<TMLCPActivityDiagram> junctionsList = new ArrayList<TMLCPActivityDiagram>(); TMLCPActivityDiagram mainCP = tmlcp.getMainCP(); //Checking mainCP - ArrayList<TMLCPElement> currentListOfElements = mainCP.getElements(); + List<TMLCPElement> currentListOfElements = mainCP.getElements(); checkStartState( currentListOfElements, mainCP ); checkDisconnectedSubParts( currentListOfElements, mainCP ); checkDiagramsBetweenForkAndJoin( currentListOfElements, mainCP ); //Checking the other ActivityDiagrams - ArrayList<TMLCPActivityDiagram> listADs = tmlcp.getCPActivityDiagrams(); + List<TMLCPActivityDiagram> listADs = tmlcp.getCPActivityDiagrams(); for( TMLCPActivityDiagram diag: listADs ) { currentListOfElements = diag.getElements(); checkStartState( currentListOfElements, diag ); @@ -154,7 +152,7 @@ public class TMLCPSyntaxChecking { } //Check that there is one and only one TMLCPStartState, if no start state or multiple start states, an error is raised - private void checkStartState( ArrayList<TMLCPElement> listElements, TMLCPActivityDiagram diag ) { + private void checkStartState( List<TMLCPElement> listElements, TMLCPActivityDiagram diag ) { int startCounter = 0; for( TMLCPElement elem: diag.getElements() ) { @@ -172,15 +170,15 @@ public class TMLCPSyntaxChecking { //Look for disconnected sub-graphs by detecting elements which do not appear in the field next of any other element in the list //of elements - private void checkDisconnectedSubParts( ArrayList<TMLCPElement> currentListOfElements, TMLCPActivityDiagram diag ) { + private void checkDisconnectedSubParts( List<TMLCPElement> currentListOfElements, TMLCPActivityDiagram diag ) { - ArrayList<TMLCPElement> listOfElementsToCheck = currentListOfElements; + List<TMLCPElement> listOfElementsToCheck = currentListOfElements; int counter = 0; for( TMLCPElement currentElement: currentListOfElements ) { if( !(currentElement instanceof TMLCPStart) ) { for( TMLCPElement element: listOfElementsToCheck ) { - ArrayList<TMLCPElement> nextElements = element.getNextElements(); + List<TMLCPElement> nextElements = element.getNextElements(); if( !nextElements.contains( currentElement ) ) { //counting how many times currentElement is NOT present as a next element counter++; } @@ -194,10 +192,10 @@ public class TMLCPSyntaxChecking { } } - private void checkDiagramsBetweenForkAndJoin( ArrayList<TMLCPElement> currentListOfElements, TMLCPActivityDiagram diag ) { + private void checkDiagramsBetweenForkAndJoin( List<TMLCPElement> currentListOfElements, TMLCPActivityDiagram diag ) { - ArrayList<TMLCPFork> listOfForks = new ArrayList<TMLCPFork>(); - ArrayList<TMLCPJoin> listOfJoins = new ArrayList<TMLCPJoin>(); + List<TMLCPFork> listOfForks = new ArrayList<TMLCPFork>(); + List<TMLCPJoin> listOfJoins = new ArrayList<TMLCPJoin>(); for( TMLCPElement element: currentListOfElements ) { if( element instanceof TMLCPFork ) { @@ -241,85 +239,85 @@ public class TMLCPSyntaxChecking { //Check that all diagrams are connected by retrieving the list of diagrams and checking if they appear as start or end name in //the list of connectors of the AD diagram under examination //At the same time, get the list of guards of choice elements - private void checkActivityDiagramsOLD() { - - ArrayList<TMLCPActivityDiagram> listADs = tmlcp.getCPActivityDiagrams(); - ArrayList<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); - ArrayList<String> listConnectorsStartEndNames = new ArrayList<String>(); - ArrayList<String> listDiagramNames = new ArrayList<String>(); - ArrayList<String> localListOfSDDiagrams = new ArrayList<String>(); - //check that all diagrams are connected - - for( TMLCPActivityDiagram diag: listADs ) { - ArrayList<TMLCPElement> listElements = diag.getElements(); - for( TMLCPElement elem : listElements ) { - if( elem instanceof tmltranslator.tmlcp.TMLCPRefAD ) { - listDiagramNames.add(((tmltranslator.tmlcp.TMLCPRefAD)elem).getName() ); - } - if( elem instanceof tmltranslator.tmlcp.TMLCPRefSD ) { - listDiagramNames.add(((tmltranslator.tmlcp.TMLCPRefSD)elem).getName() ); - localListOfSDDiagrams.add( ( (tmltranslator.tmlcp.TMLCPRefSD)elem ).getName() ); - } - if( elem instanceof TMLCPConnector ) { - listConnectorsStartEndNames.add( ((TMLCPConnector)elem).getEndName() ); - listConnectorsStartEndNames.add( ((TMLCPConnector)elem).getStartName() ); - } - if( elem instanceof tmltranslator.tmlcp.TMLCPChoice ) { - ArrayList<String> guards = ( (tmltranslator.tmlcp.TMLCPChoice)elem ).getGuards(); - HashSet<String> variableList = new HashSet<String>(); - for( String guard: guards ) { - guard = guard.replaceAll("\\s+",""); - if( guard.length() > 0 ) { - String[] token = guard.split( "\\[" ); - if( token[1].equals("]") ) { - break; - } - String[] token1 = token[1].split("="); - if( token1.length > 1 ) { - variableList.add( token1[0] ); - } - else { - String[] token2 = token1[0].split("<"); - if( token2.length > 1 ) { - variableList.add( token2[0] ); - } - else { - String[] token3 = token2[0].split(">"); - variableList.add( token3[0] ); - } - } - } - } - checkChoiceGuards( listSDs, variableList, localListOfSDDiagrams, diag.getName() ); - //check if they have been declared in the instances of a SD diagram - localListOfSDDiagrams = new ArrayList<String>(); - variableList = new HashSet(); - /*for( TMLCPSequenceDiagram diagram: listSDDiagrams ) { - ArrayList<TMLAttribute> listAttributes = diagram.getAttributes(); - for( TMLAttribute attr: listAttributes ) { - if( !variableList.contains( attr.getName() ) ) { - addError( "Variable <<" + attr.getName() + ">> is not declared in any diagram of <<" + diag.getName() + ">>", - TMLCPError.ERROR_STRUCTURE ); - } - } - }*/ - } //endOfLoop over elements - - } - for( String s: listDiagramNames ) { - if( !listConnectorsStartEndNames.contains(s) ) { - addError( "Diagram <<" + s + ">> in diagram <<" + diag.getName() + ">> is not connected", TMLCPError.ERROR_STRUCTURE ); - } - } - listConnectorsStartEndNames = new ArrayList<String>(); - listDiagramNames = new ArrayList<String>(); - } - } - - public void checkChoiceGuards( ArrayList<TMLCPSequenceDiagram> listSDs, HashSet<String> variableList, - ArrayList<String> localListOfSDDiagrams, String diagName ) { - - ArrayList<TMLAttribute> attributeList = new ArrayList<TMLAttribute>(); +// private void checkActivityDiagramsOLD() { +// +// List<TMLCPActivityDiagram> listADs = tmlcp.getCPActivityDiagrams(); +// List<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); +// List<String> listConnectorsStartEndNames = new ArrayList<String>(); +// List<String> listDiagramNames = new ArrayList<String>(); +// List<String> localListOfSDDiagrams = new ArrayList<String>(); +// //check that all diagrams are connected +// +// for( TMLCPActivityDiagram diag: listADs ) { +// List<TMLCPElement> listElements = diag.getElements(); +// for( TMLCPElement elem : listElements ) { +// if( elem instanceof tmltranslator.tmlcp.TMLCPRefAD ) { +// listDiagramNames.add(((tmltranslator.tmlcp.TMLCPRefAD)elem).getName() ); +// } +// if( elem instanceof tmltranslator.tmlcp.TMLCPRefSD ) { +// listDiagramNames.add(((tmltranslator.tmlcp.TMLCPRefSD)elem).getName() ); +// localListOfSDDiagrams.add( ( (tmltranslator.tmlcp.TMLCPRefSD)elem ).getName() ); +// } +// if( elem instanceof TMLCPConnector ) { +// listConnectorsStartEndNames.add( ((TMLCPConnector)elem).getEndName() ); +// listConnectorsStartEndNames.add( ((TMLCPConnector)elem).getStartName() ); +// } +// if( elem instanceof tmltranslator.tmlcp.TMLCPChoice ) { +// List<String> guards = ( (tmltranslator.tmlcp.TMLCPChoice)elem ).getGuards(); +// Set<String> variableList = new HashSet<String>(); +// for( String guard: guards ) { +// guard = guard.replaceAll("\\s+",""); +// if( guard.length() > 0 ) { +// String[] token = guard.split( "\\[" ); +// if( token[1].equals("]") ) { +// break; +// } +// String[] token1 = token[1].split("="); +// if( token1.length > 1 ) { +// variableList.add( token1[0] ); +// } +// else { +// String[] token2 = token1[0].split("<"); +// if( token2.length > 1 ) { +// variableList.add( token2[0] ); +// } +// else { +// String[] token3 = token2[0].split(">"); +// variableList.add( token3[0] ); +// } +// } +// } +// } +// checkChoiceGuards( listSDs, variableList, localListOfSDDiagrams, diag.getName() ); +// //check if they have been declared in the instances of a SD diagram +// localListOfSDDiagrams = new ArrayList<String>(); +// variableList = new HashSet<String>(); +// /*for( TMLCPSequenceDiagram diagram: listSDDiagrams ) { +// ArrayList<TMLAttribute> listAttributes = diagram.getAttributes(); +// for( TMLAttribute attr: listAttributes ) { +// if( !variableList.contains( attr.getName() ) ) { +// addError( "Variable <<" + attr.getName() + ">> is not declared in any diagram of <<" + diag.getName() + ">>", +// TMLCPError.ERROR_STRUCTURE ); +// } +// } +// }*/ +// } //endOfLoop over elements +// +// } +// for( String s: listDiagramNames ) { +// if( !listConnectorsStartEndNames.contains(s) ) { +// addError( "Diagram <<" + s + ">> in diagram <<" + diag.getName() + ">> is not connected", TMLCPError.ERROR_STRUCTURE ); +// } +// } +// listConnectorsStartEndNames = new ArrayList<String>(); +// listDiagramNames = new ArrayList<String>(); +// } +// } + + public void checkChoiceGuards( List<TMLCPSequenceDiagram> listSDs, Set<String> variableList, + List<String> localListOfSDDiagrams, String diagName ) { + + List<TMLAttribute> attributeList = new ArrayList<TMLAttribute>(); for( String s: localListOfSDDiagrams ) { for( TMLCPSequenceDiagram sdDiagram: listSDs ) { if( sdDiagram.getName().equals( s ) ) { @@ -339,10 +337,10 @@ public class TMLCPSyntaxChecking { // - that actions are syntactically correct (no arit operations on boolean, etc.) // - that no 2 or more instances have the same name private void checkSequenceDiagrams() { - ArrayList<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); + List<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); for( TMLCPSequenceDiagram diag: listSDs ) { - ArrayList<TMLAttribute> attributes = diag.getAttributes(); + List<TMLAttribute> attributes = diag.getAttributes(); //checkUniquenessOfAttributesNames( diag ); // already done in the GUI when declaring attributes checkActions( diag, attributes ); // actions must be done on variables that have checkMessages( diag ); // check that attributes have been declared been declared and coherently boolean = boolean + 6 is not allowed @@ -350,8 +348,8 @@ public class TMLCPSyntaxChecking { } } - private void checkActions( TMLCPSequenceDiagram diag, ArrayList<TMLAttribute> attributes ) { - ArrayList<TMLSDAction> actions = diag.getActions(); + private void checkActions( TMLCPSequenceDiagram diag, List<TMLAttribute> attributes ) { + List<TMLSDAction> actions = diag.getActions(); //boolean exists = false; for( TMLSDAction action: actions ) { String[] array = action.toString().split("="); @@ -377,7 +375,7 @@ public class TMLCPSyntaxChecking { // and the receiver instances with the same name private void checkMessages( TMLCPSequenceDiagram diag ) { - ArrayList<TMLSDMessage> messagesList = diag.getMessages(); + List<TMLSDMessage> messagesList = diag.getMessages(); for( TMLSDMessage message: messagesList ) { String senderInstance = message.getSenderName(); @@ -443,8 +441,8 @@ public class TMLCPSyntaxChecking { } private void checkInstances( TMLCPSequenceDiagram diag ) { - ArrayList<TMLSDInstance> instances = diag.getInstances(); - HashSet hash = new HashSet(); + List<TMLSDInstance> instances = diag.getInstances(); + Set<String> hash = new HashSet<String>(); for( TMLSDInstance instance: instances ) { if( !hash.contains( instance.getName() ) ) { hash.add( instance.getName() ); @@ -470,11 +468,11 @@ public class TMLCPSyntaxChecking { return warnings.size(); } - public ArrayList<TMLCPError> getErrors() { + public List<TMLCPError> getErrors() { return errors; } - public ArrayList<TMLCPError> getWarnings() { + public List<TMLCPError> getWarnings() { return warnings; } @@ -523,7 +521,7 @@ public class TMLCPSyntaxChecking { return ret; } - public void parsing( String parseCmd, String action, ArrayList<TMLAttribute> attributes ) { + public void parsing( String parseCmd, String action, List<TMLAttribute> attributes ) { TMLExprParser parser; SimpleNode root; diff --git a/src/tmltranslator/TMLCPTextSpecification.java b/src/tmltranslator/TMLCPTextSpecification.java index 9277c35a0d..0e69dc2f18 100755 --- a/src/tmltranslator/TMLCPTextSpecification.java +++ b/src/tmltranslator/TMLCPTextSpecification.java @@ -49,7 +49,6 @@ package tmltranslator; import java.util.*; -import java.io.*; import myutil.*; import tmltranslator.tmlcp.*; @@ -72,25 +71,25 @@ public class TMLCPTextSpecification { public final static String PARALLELISM_OP = "*"; public final static String SELECTION_OP = "+"; - private int loopCounter = 0; - private int nbLoops = 10; - private String loopDataStructure[] = new String[nbLoops]; + // private int loopCounter = 0; + // private int nbLoops = 10; + //private String loopDataStructure[] = new String[nbLoops]; private String spec; private String title; - private TMLModeling tmlm; - private ArrayList<TMLTXTError> errors; - private ArrayList<TMLTXTError> warnings; + // private TMLModeling tmlm; + private List<TMLTXTError> errors; + private List<TMLTXTError> warnings; // For reading TMLTXT specifications - private boolean inDec = true; - private boolean inTask = false; - private boolean inTaskDec = false; - private boolean inTaskBehavior = false; - private TMLTask task; - private TMLActivityElement tmlae; - private ArrayList<TMLParserSaveElt> parses; +// private boolean inDec = true; +// private boolean inTask = false; +// private boolean inTaskDec = false; +// private boolean inTaskBehavior = false; +// private TMLTask task; +// private TMLActivityElement tmlae; +// private ArrayList<TMLParserSaveElt> parses; /*private static String keywords[] = {"BOOL", "INT", "NAT", "CHANNEL", "EVENT", "REQUEST", "LOSSYCHANNEL", "LOSSYEVENT", "LOSSYREQUEST", "BRBW", "NBRNBW", "BRNBW", "INF", "NIB", "NINB", "TASK", "ENDTASK", "IF", "ELSE", "ORIF", "ENDIF", "FOR", "ENDFOR", @@ -105,18 +104,18 @@ public class TMLCPTextSpecification { private static String SEQUENCE_DIAGRAM = "SEQUENCE"; - private String nextElem; //used to produce the TML text - private String currentElem; //used to produce the TML text - private String currentJunc = "junction"; //used to produce the TML text - private ArrayList<String> junctionList = new ArrayList<String>(); - private ArrayList<Integer> indexOfConnToRemove; - private ArrayList<TMLCPConnector> listTMLCPConnectors; +// private String nextElem; //used to produce the TML text + // private String currentElem; //used to produce the TML text + // private String currentJunc = "junction"; //used to produce the TML text + //private ArrayList<String> junctionList = new ArrayList<String>(); + //private ArrayList<Integer> indexOfConnToRemove; + // private ArrayList<TMLCPConnector> listTMLCPConnectors; private StringBuffer sbFork; - private StringBuffer sbJunction; + //private StringBuffer sbJunction; public TMLCPTextSpecification(String _title) { title = _title; - init(); + // init(); } public TMLCPTextSpecification(String _title, boolean reset) { @@ -124,13 +123,13 @@ public class TMLCPTextSpecification { if (reset) { DIPLOElement.resetID(); } - init(); +// init(); } - private void init() { - indexOfConnToRemove = new ArrayList<Integer>(); - listTMLCPConnectors = new ArrayList<TMLCPConnector>(); - } +// private void init() { +// //indexOfConnToRemove = new ArrayList<Integer>(); +// //listTMLCPConnectors = new ArrayList<TMLCPConnector>(); +// } public void saveFile(String path, String filename) throws FileException { TraceManager.addUser("Saving TMLCP spec file in " + path + filename); @@ -243,10 +242,11 @@ public class TMLCPTextSpecification { StringBuffer sbAttributes = new StringBuffer(""); //Generating code for Sequence Diagrams - ArrayList<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); + List<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); for( TMLCPSequenceDiagram seqDiag: listSDs ) { sb.append( SEQUENCE_DIAGRAM + SP + seqDiag.getName() + CR2 ); - ArrayList<tmltranslator.tmlcp.TMLSDInstance> listInstances = seqDiag.getInstances(); + List<tmltranslator.tmlcp.TMLSDInstance> listInstances = seqDiag.getInstances(); + if( seqDiag.getAttributes().size() > 0 ) { for( TMLAttribute attribute: seqDiag.getAttributes() ) { if( !sbAttributes.toString().contains( attribute.toString() ) ) { //if attribute not already contained, then add it @@ -282,10 +282,10 @@ public class TMLCPTextSpecification { private String makeTMLTextActivityDiagrams( TMLCP tmlcp ) { StringBuffer sb = new StringBuffer(); - StringBuffer sb2 = new StringBuffer(); - ArrayList<TMLCPActivityDiagram> activityDiagList = tmlcp.getCPActivityDiagrams(); - ArrayList<TMLCPActivityDiagram> junctionDiagList = new ArrayList<TMLCPActivityDiagram>(); - ArrayList<String> diagsToRemove = new ArrayList<String>(); + // StringBuffer sb2 = new StringBuffer(); + List<TMLCPActivityDiagram> activityDiagList = tmlcp.getCPActivityDiagrams(); + List<TMLCPActivityDiagram> junctionDiagList = new ArrayList<TMLCPActivityDiagram>(); + List<String> diagsToRemove = new ArrayList<String>(); for( TMLCPActivityDiagram ad: activityDiagList ) { String s = ad.getName(); @@ -384,155 +384,149 @@ public class TMLCPTextSpecification { private String makeSingleActivityDiagram2(TMLCPActivityDiagram ad) { StringBuffer sb = new StringBuffer( TAB + CR + TAB + "<>; " ); - TMLCPElement currentElement, nextElement; - ArrayList<TMLCPElement> nextElements; + TMLCPElement currentElement;//, nextElement; +// ArrayList<TMLCPElement> nextElements; currentElement = getStartState( ad ).getNextElements().get(0); //get the first element after the start state - ArrayList<TMLCPElement> met = new ArrayList<TMLCPElement>(); + List<TMLCPElement> met = new ArrayList<TMLCPElement>(); sb.append(parseElement2(currentElement, met)); return sb.toString() + CR + TAB + "><"; } - private String parseElement2(TMLCPElement currentElement, ArrayList<TMLCPElement> met) { - - if (currentElement == null) { - return ""; - } - - if (met.contains(currentElement)) { - return ""; - } - - if (currentElement instanceof TMLCPJoin) { - return ""; - } + private String parseElement2(TMLCPElement currentElement, List<TMLCPElement> met) { - met.add(currentElement); - - if (currentElement instanceof TMLCPStop) { - //return ""; - return( TAB + "><" ); - } - - if (currentElement instanceof TMLCPFork) { - return parseFork2((TMLCPFork)(currentElement), met); - } + if (currentElement == null) { + return ""; + } - if (currentElement instanceof TMLCPForLoop) { - //TraceManager.addDev("Handling ForLoop: " + currentElement); - return parseForLoop((TMLCPForLoop)(currentElement), met); - } - - if (currentElement instanceof TMLCPChoice) { - return parseChoice2((TMLCPChoice)(currentElement), met); - } - + if (met.contains(currentElement)) { + return ""; + } + + if (currentElement instanceof TMLCPJoin) { + return ""; + } - String ret = parseSequence(currentElement); - //ret += SEQUENCE_OP; - ret += parseElement2(currentElement.getNextElements().get(0), met); - return ret; + met.add(currentElement); + + if (currentElement instanceof TMLCPStop) { + //return ""; + return( TAB + "><" ); + } + + if (currentElement instanceof TMLCPFork) { + return parseFork2((TMLCPFork)(currentElement), met); + } + + if (currentElement instanceof TMLCPForLoop) { + //TraceManager.addDev("Handling ForLoop: " + currentElement); + return parseForLoop((TMLCPForLoop)(currentElement), met); + } + + if (currentElement instanceof TMLCPChoice) { + return parseChoice2((TMLCPChoice)(currentElement), met); + } + + String ret = parseSequence(currentElement); + //ret += SEQUENCE_OP; + ret += parseElement2(currentElement.getNextElements().get(0), met); + return ret; } - private String parseChoice2(TMLCPChoice choice, ArrayList<TMLCPElement> met) { - StringBuffer sb = new StringBuffer(); - ArrayList<TMLCPElement> branches = choice.getNextElements(); - ArrayList<String> guards = choice.getGuards(); + private String parseChoice2(TMLCPChoice choice, List<TMLCPElement> met) { + StringBuffer sb = new StringBuffer(); + List<TMLCPElement> branches = choice.getNextElements(); + List<String> guards = choice.getGuards(); - int index = 0; - - for( TMLCPElement element: branches ) { - sb.append( CR + TAB2 + guards.get(index) + SP); - sb.append(parseElement2(element, met)); - index ++; - } - - return sb.toString(); - + int index = 0; + + for( TMLCPElement element: branches ) { + sb.append( CR + TAB2 + guards.get(index) + SP); + sb.append(parseElement2(element, met)); + index ++; + } + + return sb.toString(); } - - private String parseForLoop(TMLCPForLoop loop, ArrayList<TMLCPElement> met) { - StringBuffer sb = new StringBuffer(); - ArrayList<TMLCPElement> nextElements = loop.getNextElements(); - sb.append( SP + "{" ); + private String parseForLoop(TMLCPForLoop loop, List<TMLCPElement> met) { + StringBuffer sb = new StringBuffer(); + List<TMLCPElement> nextElements = loop.getNextElements(); + sb.append( SP + "{" ); + + //TMLCPElement inLoop = nextElements.get(0); + sb.append("(" + loop.getInit().replaceAll("\\s+","") + ";" + loop.getCondition().replaceAll("\\s+","") + ";" + loop.getIncrement().replaceAll("\\s+","") + ") "); + sb.append(parseElement2(nextElements.get(0), met)); //first the for-loop body + sb.append( "}" + SEQUENCE_OP ); + sb.append(parseElement2(nextElements.get(1), met)); //then the diagrams that follow the for-loop termination - TMLCPElement inLoop = nextElements.get(0); - sb.append("(" + loop.getInit().replaceAll("\\s+","") + ";" + loop.getCondition().replaceAll("\\s+","") + ";" + loop.getIncrement().replaceAll("\\s+","") + ") "); - sb.append(parseElement2(nextElements.get(0), met)); //first the for-loop body - sb.append( "}" + SEQUENCE_OP ); - sb.append(parseElement2(nextElements.get(1), met)); //then the diagrams that follow the for-loop termination - - return sb.toString(); - + return sb.toString(); } - private String parseFork2(TMLCPFork fork, ArrayList<TMLCPElement> met) { - StringBuffer sb = new StringBuffer(); - ArrayList<TMLCPElement> nextElements = fork.getNextElements(); + private String parseFork2(TMLCPFork fork, List<TMLCPElement> met) { + StringBuffer sb = new StringBuffer(); + List<TMLCPElement> nextElements = fork.getNextElements(); - TMLCPElement nextElement = null; + // TMLCPElement nextElement = null; sb.append( SP + "{" ); for(TMLCPElement elt: nextElements) { - sb.append( SP + "{" ); - sb.append(parseElement2(elt, met)); - sb = removeTrailingSymbols(sb, 2); - sb.append("}" + SP + PARALLELISM_OP); - - } + sb.append( SP + "{" ); + sb.append(parseElement2(elt, met)); + sb = removeTrailingSymbols(sb, 2); + sb.append("}" + SP + PARALLELISM_OP); + + } + sb = removeTrailingSymbol( sb ); sb.append( "}" + SEQUENCE_OP ); - // Search for the join - TMLCPElement myElt = nextElements.get(0); - while (!(myElt instanceof TMLCPJoin)) { - myElt = myElt.getNextElements().get(0); - } - // Start parsing after the join - myElt = myElt.getNextElements().get(0); + // Search for the join + TMLCPElement myElt = nextElements.get(0); + while (!(myElt instanceof TMLCPJoin)) { + myElt = myElt.getNextElements().get(0); + } + // Start parsing after the join + myElt = myElt.getNextElements().get(0); sb.append(parseElement2(myElt, met)); - return sb.toString(); + return sb.toString(); } - - - - private String makeSingleActivityDiagram( TMLCPActivityDiagram ad ) { - - StringBuffer sb = new StringBuffer( TAB + CR + TAB + "<>; " ); - TMLCPElement currentElement, nextElement; - ArrayList<TMLCPElement> nextElements; - - currentElement = getStartState( ad ).getNextElements().get(0); //get the first element after the start state - while( !(currentElement instanceof TMLCPStop) ) { - nextElements = currentElement.getNextElements(); - if( nextElements.size() > 1 ) { // currentElement is a fork node - sbFork = new StringBuffer(); - currentElement = parseFork( nextElements ); // currentElement is the closing join, use attribute sbFork - sb.append( sbFork.toString() ); - sbFork.setLength(0); - } - else { // currentElement is either a refToDiag or a junction - if( isAJunction( currentElement ) ) { - String s = ( (TMLCPRefAD) currentElement ).getName(); - sb.append( s + ";" + CR ); - } - else { - sb.append( parseSequence( currentElement ) ); - } - } - currentElement = currentElement.getNextElements().get(0); - } - - return sb.toString() + TAB + "><"; - } +// private String makeSingleActivityDiagram( TMLCPActivityDiagram ad ) { +// +// StringBuffer sb = new StringBuffer( TAB + CR + TAB + "<>; " ); +// TMLCPElement currentElement, nextElement; +// ArrayList<TMLCPElement> nextElements; +// +// currentElement = getStartState( ad ).getNextElements().get(0); //get the first element after the start state +// while( !(currentElement instanceof TMLCPStop) ) { +// nextElements = currentElement.getNextElements(); +// if( nextElements.size() > 1 ) { // currentElement is a fork node +// sbFork = new StringBuffer(); +// currentElement = parseFork( nextElements ); // currentElement is the closing join, use attribute sbFork +// sb.append( sbFork.toString() ); +// sbFork.setLength(0); +// } +// else { // currentElement is either a refToDiag or a junction +// if( isAJunction( currentElement ) ) { +// String s = ( (TMLCPRefAD) currentElement ).getName(); +// sb.append( s + ";" + CR ); +// } +// else { +// sb.append( parseSequence( currentElement ) ); +// } +// } +// currentElement = currentElement.getNextElements().get(0); +// } +// +// return sb.toString() + TAB + "><"; +// } private String parseSequence( TMLCPElement element ) { @@ -547,7 +541,7 @@ public class TMLCPTextSpecification { return ""; } - private TMLCPElement parseFork( ArrayList<TMLCPElement> elements ) { + private TMLCPElement parseFork( List<TMLCPElement> elements ) { TMLCPElement nextElement = null; @@ -576,7 +570,7 @@ public class TMLCPTextSpecification { StringBuffer sb = new StringBuffer( "<>;" + SP ); TMLCPElement currentElement, nextElement; - ArrayList<TMLCPElement> nextElements; + List<TMLCPElement> nextElements; //First parse the part from the junctionto the choice: either a fork or a sequence currentElement = getStartState( ad ); @@ -604,10 +598,10 @@ public class TMLCPTextSpecification { StringBuffer sb = new StringBuffer( /*CR + TAB + "LOOP" + SP + ad.getName()*/ ); //this LOOP is the keywork that is used to look for the junction diagram name, removing it, causing the generation not to work - ArrayList<TMLCPElement> nextElements; + List<TMLCPElement> nextElements; int index = 0; - ArrayList<TMLCPElement> branches = currentElement.getNextElements(); - ArrayList<String> guards = ( (TMLCPChoice)currentElement ).getGuards(); + List<TMLCPElement> branches = currentElement.getNextElements(); + List<String> guards = ( (TMLCPChoice)currentElement ).getGuards(); for( TMLCPElement element: branches ) { //for each of the branches go until a stop or a junction, only possible to find seq/fork sb.append( CR + TAB2 + guards.get(index) + SP ); @@ -659,17 +653,17 @@ public class TMLCPTextSpecification { } return false; } - - // Retrieves the AD corresponding to a junction from the list of junction diagrams - private TMLCPActivityDiagram getJunctionDiagram( String name, ArrayList<TMLCPActivityDiagram> junctionDiagList ) { - - for( TMLCPActivityDiagram diag: junctionDiagList ) { - if( diag.getName().equals( name ) ) { - return diag; - } - } - return junctionDiagList.get(0); - } +// +// // Retrieves the AD corresponding to a junction from the list of junction diagrams +// private TMLCPActivityDiagram getJunctionDiagram( String name, ArrayList<TMLCPActivityDiagram> junctionDiagList ) { +// +// for( TMLCPActivityDiagram diag: junctionDiagList ) { +// if( diag.getName().equals( name ) ) { +// return diag; +// } +// } +// return junctionDiagList.get(0); +// } private StringBuffer removeTrailingSymbol( StringBuffer sb ) { @@ -691,7 +685,7 @@ public class TMLCPTextSpecification { private TMLCPElement getStartState( TMLCPActivityDiagram ad ) { - ArrayList<TMLCPElement> elementsList = ad.getElements(); + List<TMLCPElement> elementsList = ad.getElements(); for( TMLCPElement elem: elementsList ) { if( elem instanceof TMLCPStart ) { return elem; @@ -1196,20 +1190,20 @@ public class TMLCPTextSpecification { // } //Look for a connector that starts from currentElem and get the endName - private String getNextElem() { - - TMLCPConnector conn; - String endName = ""; - int i; - for( i = 0; i < listTMLCPConnectors.size(); i++ ) { - conn = listTMLCPConnectors.get(i); - if( conn.getStartName().equals( currentElem ) ) { - endName = conn.getEndName(); - break; - } - } - return endName; - } +// private String getNextElem() { +// +// TMLCPConnector conn; +// String endName = ""; +// int i; +// for( i = 0; i < listTMLCPConnectors.size(); i++ ) { +// conn = listTMLCPConnectors.get(i); +// if( conn.getStartName().equals( currentElem ) ) { +// endName = conn.getEndName(); +// break; +// } +// } +// return endName; +// } /* public String makeTasks(TMLModeling tmlm) { String sb = ""; diff --git a/src/tmltranslator/TMLChoice.java b/src/tmltranslator/TMLChoice.java index f6f4344b85..ce2f4e58b3 100755 --- a/src/tmltranslator/TMLChoice.java +++ b/src/tmltranslator/TMLChoice.java @@ -140,7 +140,7 @@ public class TMLChoice extends TMLActivityElement{ } } - String guard; + //String guard; for(int i=0; i<index; i++) { if (isNonDeterministicGuard(i)) { nb ++; @@ -176,7 +176,7 @@ public class TMLChoice extends TMLActivityElement{ } } - String guard; + //String guard; for(int i=0; i<index; i++) { if (isStochasticGuard(i)) { nb ++; diff --git a/src/tmltranslator/TMLCommunicationElement.java b/src/tmltranslator/TMLCommunicationElement.java index e7301726bc..79155b7557 100755 --- a/src/tmltranslator/TMLCommunicationElement.java +++ b/src/tmltranslator/TMLCommunicationElement.java @@ -47,10 +47,8 @@ package tmltranslator; import myutil.*; - - public abstract class TMLCommunicationElement extends TMLElement { - private boolean infected; + //private boolean infected; private boolean isLossy; private int lossPercentage; diff --git a/src/tmltranslator/TMLEvent.java b/src/tmltranslator/TMLEvent.java index 67d2c7bfb0..df2d2d8053 100755 --- a/src/tmltranslator/TMLEvent.java +++ b/src/tmltranslator/TMLEvent.java @@ -50,11 +50,11 @@ import ui.tmlcompd.TMLCPrimitivePort; public class TMLEvent extends TMLCommunicationElement { // Options - protected Vector params; // List of various types of parameters + protected Vector<TMLType> params; // List of various types of parameters protected int maxEvt = -1; // maxEvt = -1 -> infinite nb of evts: default behaviour protected boolean isBlocking = false; // By default, latest events is removed when the FIFO is full protected boolean canBeNotified = false; - public ArrayList<TMLCPrimitivePort> ports; + public List<TMLCPrimitivePort> ports; // Used for 1 -> 1 protected TMLTask origin, destination; @@ -63,8 +63,8 @@ public class TMLEvent extends TMLCommunicationElement { public TMLCPrimitivePort port2; // Used for 1 -> many channel, or for many -> 1 channel - protected ArrayList<TMLTask> originTasks, destinationTasks; - protected ArrayList<TMLPort> originPorts, destinationPorts; + protected List<TMLTask> originTasks, destinationTasks; + protected List<TMLPort> originPorts, destinationPorts; // For security public int confStatus; @@ -75,16 +75,16 @@ public class TMLEvent extends TMLCommunicationElement { public TMLEvent(String name, Object reference, int _maxEvt, boolean _isBlocking) { super(name, reference); - params = new Vector(); + params = new Vector<TMLType>(); maxEvt = _maxEvt; isBlocking = _isBlocking; checkMaxEvt(); - originTasks = new ArrayList<TMLTask>(); + originTasks = new ArrayList<TMLTask>(); destinationTasks = new ArrayList<TMLTask>(); originPorts = new ArrayList<TMLPort>(); destinationPorts = new ArrayList<TMLPort>(); - ports = new ArrayList<TMLCPrimitivePort>(); - checkConf=false; + ports = new ArrayList<TMLCPrimitivePort>(); + checkConf=false; //System.out.println("New event: " + name + " max=" + _maxEvt + " blocking=" + isBlocking); } @@ -236,19 +236,19 @@ public class TMLEvent extends TMLCommunicationElement { return ((destinationTasks.size() == 1) && (originTasks.size() >= 1)); } - public ArrayList<TMLTask> getOriginTasks() { + public List<TMLTask> getOriginTasks() { return originTasks; } - public ArrayList<TMLTask> getDestinationTasks() { + public List<TMLTask> getDestinationTasks() { return destinationTasks; } - public ArrayList<TMLPort> getOriginPorts() { + public List<TMLPort> getOriginPorts() { return originPorts; } - public ArrayList<TMLPort> getDestinationPorts() { + public List<TMLPort> getDestinationPorts() { return destinationPorts; } diff --git a/src/tmltranslator/TMLModeling.java b/src/tmltranslator/TMLModeling.java index 1a0ebe81fd..c883dd23cf 100755 --- a/src/tmltranslator/TMLModeling.java +++ b/src/tmltranslator/TMLModeling.java @@ -55,8 +55,6 @@ import proverifspec.*; public class TMLModeling { - - public final String SEP1 = "_S_"; private List<TMLTask> tasks; @@ -1982,7 +1980,7 @@ public class TMLModeling { // Channels with one origin and several destinations // Add a task at sending side - // Channel is tranformed into something else ... + // Channel is transformed into something else ... public void removeForks() { // Create new basic channels and tasks ArrayList<TMLChannel> newChannels = new ArrayList<TMLChannel>(); @@ -1996,7 +1994,7 @@ public class TMLModeling { addChannel(chan); } - ArrayList<TMLEvent> newEvents = new ArrayList<TMLEvent>(); + List<TMLEvent> newEvents = new ArrayList<TMLEvent>(); for(TMLEvent event: events) { if (event.isAForkEvent()) { removeForkEvent(event, newEvents); @@ -2061,6 +2059,7 @@ public class TMLModeling { read.setNbOfSamples("1"); TMLWriteChannel []writes = new TMLWriteChannel[nb]; + for(i=0; i<nb; i++) { writes[i] = new TMLWriteChannel("WriteOfFork" + SEP1 + i, null); writes[i].addChannel(chans[i]); @@ -2072,15 +2071,15 @@ public class TMLModeling { junction.addNext(read); junction.addNext(stop2); read.addNext(writes[0]); + for(i=0; i<nb-1; i++) { writes[i].addNext(writes[i+1]); } - writes[nb-1].addNext(stop); - + writes[nb-1].addNext(stop); } - public void removeForkEvent(TMLEvent _evt, ArrayList<TMLEvent> _newEvents) { + public void removeForkEvent(TMLEvent _evt, List<TMLEvent> _newEvents) { int i, j; // Create the new task and its activity diagram @@ -2091,6 +2090,7 @@ public class TMLModeling { // Create the new (basic) events. The first branch of the fork is reused, others are created int nb = _evt.getDestinationTasks().size(); TMLEvent[] evts = new TMLEvent[nb]; + for(i=0; i<nb; i++) { evts[i] = new TMLEvent("FORKEVENT" + SEP1 + i + SEP1 + _evt.getName(), _evt.getReferenceObject(), _evt.getMaxSize(), _evt.isBlocking()); evts[i].setTasks(forkTask, _evt.getDestinationTasks().get(i)); @@ -2098,17 +2098,18 @@ public class TMLModeling { //evts[i].setType(_evt.getType()); //evts[i].setMax(_evt.getMax()); //evts[i].setSize(_evt.getSize()); - for(j=0; j<_evt.getNbOfParams(); j++) { - evts[i].addParam(_evt.getType(j)); - } - _newEvents.add(evts[i]); + for(j=0; j<_evt.getNbOfParams(); j++) { + evts[i].addParam(_evt.getType(j)); + } + + _newEvents.add(evts[i]); } // Modify the activity diagram of tasks making a wait in destination events // Modify the event of wait operators to the new events for(i=0; i<nb; i++) { _evt.getDestinationTasks().get(i).replaceWaitEventWith(_evt, evts[i]); - } + } // Transform the original event into a basic event @@ -2116,13 +2117,13 @@ public class TMLModeling { _evt.setPorts(_evt.getOriginPorts().get(0), new TMLPort("FORKPORTDESTINATION" + SEP1 + _evt.getName(), _evt.getReferenceObject())); _evt.removeComplexInformations(); - // Adding attributes to the task - for(j=0; j<_evt.getNbOfParams(); j++) { - TMLAttribute attr = new TMLAttribute("attr_" + j, _evt.getType(j)); - forkTask.addAttribute(attr); - } + // Adding attributes to the task + for(j=0; j<_evt.getNbOfParams(); j++) { + TMLAttribute attr = new TMLAttribute("attr_" + j, _evt.getType(j)); + forkTask.addAttribute(attr); + } - // Creating the AD for the fork task + // Creating the AD for the fork task TMLStartState start = new TMLStartState("startOfFork", null); forkActivity.setFirst(start); TMLStopState stop = new TMLStopState("stopOfFork", null); @@ -2139,12 +2140,13 @@ public class TMLModeling { TMLWaitEvent read = new TMLWaitEvent("WaitOfFork", null); forkActivity.addElement(read); read.setEvent(_evt); - for(j=0; j<_evt.getNbOfParams(); j++) { - read.addParam("attr_" + j); - } - + for(j=0; j<_evt.getNbOfParams(); j++) { + read.addParam("attr_" + j); + } + TMLSendEvent []writes = new TMLSendEvent[nb]; + for(i=0; i<nb; i++) { writes[i] = new TMLSendEvent("WriteEvtOfFork" + SEP1 + i, null); writes[i].setEvent(evts[i]); @@ -2158,9 +2160,11 @@ public class TMLModeling { junction.addNext(read); junction.addNext(stop2); read.addNext(writes[0]); + for(i=0; i<nb-1; i++) { writes[i].addNext(writes[i+1]); } + writes[nb-1].addNext(stop); } @@ -2170,7 +2174,7 @@ public class TMLModeling { // Same for events. public void removeJoins() { // Create new basic channels and tasks - ArrayList<TMLChannel> newChannels = new ArrayList<TMLChannel>(); + List<TMLChannel> newChannels = new ArrayList<TMLChannel>(); for(TMLChannel channel: channels) { if (channel.isAJoinChannel()) { removeJoin(channel, newChannels); @@ -2197,7 +2201,7 @@ public class TMLModeling { } - public void removeJoin(TMLChannel _ch, ArrayList<TMLChannel> _newChannels) { + public void removeJoin(TMLChannel _ch, List<TMLChannel> _newChannels) { int i; // Create the new task and its activity diagram @@ -2268,7 +2272,7 @@ public class TMLModeling { reads[nb-1].addNext(write); } - public void removeJoinEvent(TMLEvent _evt, ArrayList<TMLEvent> _newEvents) { + public void removeJoinEvent(TMLEvent _evt, List<TMLEvent> _newEvents) { int i, j; // Create the new task and its activity diagram @@ -2283,10 +2287,13 @@ public class TMLModeling { evts[i] = new TMLEvent("JOINEVENT" + SEP1 + i + SEP1 + _evt.getName(), _evt.getReferenceObject(), _evt.getMaxSize(), _evt.isBlocking()); evts[i].setTasks(_evt.getOriginTasks().get(i), joinTask); evts[i].setPorts(_evt.getOriginPorts().get(i), new TMLPort("JOINPORTDESTINATION" + SEP1 + i + SEP1 + _evt.getName(), _evt.getReferenceObject())); - for(j=0; j<_evt.getNbOfParams(); j++) { - evts[i].addParam(_evt.getType(j)); - } - _newEvents.add(evts[i]); + + for(j=0; j<_evt.getNbOfParams(); j++) { + evts[i].addParam(_evt.getType(j)); + + } + + _newEvents.add(evts[i]); } // Modify the activity diagram of tasks making a write in origin channels @@ -2300,12 +2307,12 @@ public class TMLModeling { _evt.setTasks(joinTask, _evt.getDestinationTasks().get(0)); _evt.setPorts(new TMLPort("JOINPORTORIGIN" + SEP1 + _evt.getName(), _evt.getReferenceObject()), _evt.getDestinationPorts().get(0)); _evt.removeComplexInformations(); - - // Adding attributes to the task - for(j=0; j<_evt.getNbOfParams(); j++) { - TMLAttribute attr = new TMLAttribute("attr_" + j, _evt.getType(j)); - joinTask.addAttribute(attr); - } + + // Adding attributes to the task + for(j=0; j<_evt.getNbOfParams(); j++) { + TMLAttribute attr = new TMLAttribute("attr_" + j, _evt.getType(j)); + joinTask.addAttribute(attr); + } // Make the activity diagram of the fork task TMLStartState start = new TMLStartState("startOfJoin", null); @@ -2322,19 +2329,24 @@ public class TMLModeling { joinTask.addAttribute(attr); joinActivity.addElement(junction); TMLSendEvent notify = new TMLSendEvent("NotifyOfJoin", null); - for(j=0; j<_evt.getNbOfParams(); j++) { - notify.addParam("attr_" + j); - } + + for(j=0; j<_evt.getNbOfParams(); j++) { + notify.addParam("attr_" + j); + } + joinActivity.addElement(notify); notify.setEvent(_evt); TMLWaitEvent []waits = new TMLWaitEvent[nb]; + for(i=0; i<nb; i++) { waits[i] = new TMLWaitEvent("WaitOfJoin" + SEP1 + i, null); waits[i].setEvent(evts[i]); - for(j=0; j<_evt.getNbOfParams(); j++) { - waits[i].addParam("attr_" + j); - } + + for(j=0; j<_evt.getNbOfParams(); j++) { + waits[i].addParam("attr_" + j); + } + joinActivity.addElement(waits[i]); } @@ -2343,9 +2355,11 @@ public class TMLModeling { junction.addNext(waits[0]); junction.addNext(stop2); notify.addNext(stop); + for(i=0; i<nb-1; i++) { waits[i].addNext(waits[i+1]); } + waits[nb-1].addNext(notify); } diff --git a/src/tmltranslator/TMLPort.java b/src/tmltranslator/TMLPort.java index e4bfa560eb..e01698f19e 100755 --- a/src/tmltranslator/TMLPort.java +++ b/src/tmltranslator/TMLPort.java @@ -45,8 +45,6 @@ package tmltranslator; -import ui.tmlcompd.*; - public class TMLPort extends TMLElement { private boolean prex; diff --git a/src/tmltranslator/TMLRandomSequence.java b/src/tmltranslator/TMLRandomSequence.java index e11d9f9c6b..20bcde97a2 100755 --- a/src/tmltranslator/TMLRandomSequence.java +++ b/src/tmltranslator/TMLRandomSequence.java @@ -49,53 +49,50 @@ import java.util.*; public class TMLRandomSequence extends TMLActivityElement{ - private Vector indexes; + private Vector<Integer> indexes; public TMLRandomSequence(String _name, Object _referenceObject) { super(_name, _referenceObject); - indexes = new Vector(); + indexes = new Vector<Integer>(); } public void addIndex(int index) { - indexes.add(new Integer(index)); + indexes.add(new Integer(index)); } public void sortNexts() { - if (indexes.size() == 0) { - return; - } + if (indexes.size() == 0) { + return; + } //System.out.println("Nb of indexes" + indexes.size()); //System.out.println("Nb of nexts" + nexts.size()); - Vector nextsbis = new Vector(); + Vector<TMLActivityElement> nextsbis = new Vector<TMLActivityElement>(); // Sort according to index stored in indexes // The smaller is removed at each step - Integer i0; - int index; - int i; - - while(indexes.size() > 0) { - i0 = new Integer(1000); - index = -1; - for(i=0; i<indexes.size(); i++) { - if ((((Integer)indexes.elementAt(i)).compareTo(i0))<0) { - index = i; - i0 = ((Integer)indexes.elementAt(i)); - } - } - nextsbis.addElement(nexts.elementAt(index)); - nexts.removeElementAt(index); - indexes.removeElementAt(index); - } - - nexts = nextsbis; + Integer i0; + int index; + int i; + + while(indexes.size() > 0) { + i0 = new Integer(1000); + index = -1; + for(i=0; i<indexes.size(); i++) { + if ( indexes.elementAt(i).compareTo(i0) < 0 ) { + index = i; + i0 = indexes.elementAt(i); + } + } + nextsbis.addElement(nexts.elementAt(index)); + nexts.removeElementAt(index); + indexes.removeElementAt(index); + } + + nexts = nextsbis; //for(i=0; i<nexts.size(); i++){ // System.out.println("sequence #" + i + " = " + nexts.elementAt(i)); - //} - + //} } - - } diff --git a/src/tmltranslator/TMLSDAttribute.java b/src/tmltranslator/TMLSDAttribute.java index 4adddf4746..48546947f7 100755 --- a/src/tmltranslator/TMLSDAttribute.java +++ b/src/tmltranslator/TMLSDAttribute.java @@ -80,11 +80,11 @@ public class TMLSDAttribute extends DIPLOElement { } public boolean isNat() { - return ( type.getType( "NATURAL" ) == TMLSDType.NATURAL ); + return ( TMLSDType.getType( "NATURAL" ) == TMLSDType.NATURAL ); } public boolean isArch() { - return ( type.getType( "ARCHITECTURE" ) == TMLSDType.ARCHITECTURE ); + return ( TMLSDType.getType( "ARCHITECTURE" ) == TMLSDType.ARCHITECTURE ); } public String getInitialValue() { diff --git a/src/tmltranslator/TMLSDType.java b/src/tmltranslator/TMLSDType.java index e7e85c4333..aa57e55f1d 100755 --- a/src/tmltranslator/TMLSDType.java +++ b/src/tmltranslator/TMLSDType.java @@ -48,8 +48,6 @@ package tmltranslator; -import myutil.*; - public class TMLSDType { // type diff --git a/src/tmltranslator/TMLSendRequest.java b/src/tmltranslator/TMLSendRequest.java index cf9c04aec0..53351e9e22 100755 --- a/src/tmltranslator/TMLSendRequest.java +++ b/src/tmltranslator/TMLSendRequest.java @@ -50,12 +50,12 @@ import java.util.*; public class TMLSendRequest extends TMLActivityElement { protected TMLRequest request; - protected Vector datas; + protected Vector<String> datas; public TMLSendRequest(String _name, Object _referenceObject) { super(_name, _referenceObject); - datas = new Vector(); + datas = new Vector<String>(); } public void setRequest(TMLRequest _request) { diff --git a/src/tmltranslator/TMLSequence.java b/src/tmltranslator/TMLSequence.java index ff546b74fc..4f914c4eec 100755 --- a/src/tmltranslator/TMLSequence.java +++ b/src/tmltranslator/TMLSequence.java @@ -49,53 +49,50 @@ import java.util.*; public class TMLSequence extends TMLActivityElement{ - private Vector indexes; + private Vector<Integer> indexes; public TMLSequence(String _name, Object _referenceObject) { super(_name, _referenceObject); - indexes = new Vector(); + indexes = new Vector<Integer>(); } public void addIndex(int index) { - indexes.add(new Integer(index)); + indexes.add(new Integer(index)); } public void sortNexts() { - if (indexes.size() == 0) { - return; - } + if (indexes.size() == 0) { + return; + } //System.out.println("Nb of indexes" + indexes.size()); //System.out.println("Nb of nexts" + nexts.size()); - Vector nextsbis = new Vector(); - - // Sort according to index stored in indexes - // The smaller is removed at each step - Integer i0; - int index; - int i; - - while(indexes.size() > 0) { - i0 = new Integer(1000); - index = -1; - for(i=0; i<indexes.size(); i++) { - if ((((Integer)indexes.elementAt(i)).compareTo(i0))<0) { - index = i; - i0 = ((Integer)indexes.elementAt(i)); - } - } - nextsbis.addElement(nexts.elementAt(index)); - nexts.removeElementAt(index); - indexes.removeElementAt(index); - } - - nexts = nextsbis; - - //for(i=0; i<nexts.size(); i++){ - // System.out.println("sequence #" + i + " = " + nexts.elementAt(i)); - //} - - } - + Vector<TMLActivityElement> nextsbis = new Vector<TMLActivityElement>(); + + // Sort according to index stored in indexes + // The smaller is removed at each step + Integer i0; + int index; + int i; + while(indexes.size() > 0) { + i0 = new Integer(1000); + index = -1; + for(i=0; i<indexes.size(); i++) { + if ( indexes.elementAt( i ).compareTo( i0 ) < 0 ) { + index = i; + i0 = indexes.elementAt( i ); + } + } + nextsbis.addElement(nexts.elementAt(index)); + nexts.removeElementAt(index); + indexes.removeElementAt(index); + } + + nexts = nextsbis; + + //for(i=0; i<nexts.size(); i++){ + // System.out.println("sequence #" + i + " = " + nexts.elementAt(i)); + //} + } } diff --git a/src/tmltranslator/TMLSyntaxChecking.java b/src/tmltranslator/TMLSyntaxChecking.java index 67034e5d62..8c984c437c 100755 --- a/src/tmltranslator/TMLSyntaxChecking.java +++ b/src/tmltranslator/TMLSyntaxChecking.java @@ -146,7 +146,7 @@ public class TMLSyntaxChecking { if (ch.getOriginTask() != t) { //System.out.println("Origin task=" + ch.getOriginTask().getName() + " / task = " + t.getName() + "tch=" + ch.getOriginTask() + " t=" + t); //System.out.println("tml:" + tmlm.toString()); - TMLTextSpecification tmlt = new TMLTextSpecification("toto"); + // TMLTextSpecification tmlt = new TMLTextSpecification("toto"); //System.out.println("tml:" + tmlt.toTextFormat(tmlm)); addError(t, elt, ch.getName() + ": " + WRONG_ORIGIN_CHANNEL, TMLError.ERROR_BEHAVIOR); } @@ -227,7 +227,7 @@ public class TMLSyntaxChecking { int elseg, afterg; TMLAttribute attr; - StringReader toParse; + // StringReader toParse; String action; diff --git a/src/tmltranslator/TMLTask.java b/src/tmltranslator/TMLTask.java index 7c58672855..63aa2e822f 100755 --- a/src/tmltranslator/TMLTask.java +++ b/src/tmltranslator/TMLTask.java @@ -45,22 +45,19 @@ package tmltranslator; -import myutil.*; import java.util.*; -import tmltranslator.modelcompiler.*; - public class TMLTask extends TMLElement { private TMLActivity activity; private boolean isRequested = false; private TMLRequest request; - private ArrayList<TMLAttribute> attributes; + private List<TMLAttribute> attributes; private boolean mustExit = false; private int priority; - private HashSet<TMLChannel> channelsList; - private HashSet<TMLChannel> readTMLChannelsList; - private HashSet<TMLChannel> writeTMLChannelsList; - private HashSet<TMLEvent> eventsList; + private Set<TMLChannel> channelsList; + private Set<TMLChannel> readTMLChannelsList; + private Set<TMLChannel> writeTMLChannelsList; + private Set<TMLEvent> eventsList; private int operationType; @@ -103,7 +100,7 @@ public class TMLTask extends TMLElement { attributes.add(_tmla); } - public ArrayList<TMLAttribute> getAttributes() { + public List<TMLAttribute> getAttributes() { return attributes; } @@ -149,22 +146,23 @@ public class TMLTask extends TMLElement { } //For SDR operations only 1 channel - public ArrayList<TMLReadChannel> getReadChannels() { + public List<TMLReadChannel> getReadChannels() { - ArrayList<TMLReadChannel> list = new ArrayList<TMLReadChannel>(); + List<TMLReadChannel> list = new ArrayList<TMLReadChannel>(); for( int i = 0; i < getActivityDiagram().nElements(); i++ ) { if( getActivityDiagram().get(i) instanceof TMLReadChannel ) { list.add( (TMLReadChannel) getActivityDiagram().get(i) ); //TraceManager.addDev( "Element: " + task.getActivityDiagram().get(i).toString() ); } } + return list; } //For SDR operations, only 1 channel - public ArrayList<TMLWriteChannel> getWriteChannels() { + public List<TMLWriteChannel> getWriteChannels() { - ArrayList<TMLWriteChannel> list = new ArrayList<TMLWriteChannel>(); + List<TMLWriteChannel> list = new ArrayList<TMLWriteChannel>(); for( int i = 0; i < getActivityDiagram().nElements(); i++ ) { if( getActivityDiagram().get(i) instanceof TMLWriteChannel ) { list.add( (TMLWriteChannel) getActivityDiagram().get(i) ); @@ -174,25 +172,28 @@ public class TMLTask extends TMLElement { return list; } - public ArrayList<TMLSendEvent> getSendEvents() { + public List<TMLSendEvent> getSendEvents() { - ArrayList<TMLSendEvent> list = new ArrayList<TMLSendEvent>(); + List<TMLSendEvent> list = new ArrayList<TMLSendEvent>(); + for( int i = 0; i < getActivityDiagram().nElements(); i++ ) { if( getActivityDiagram().get(i) instanceof TMLSendEvent ) { list.add( (TMLSendEvent) getActivityDiagram().get(i) ); } } + return list; } - public ArrayList<TMLWaitEvent> getWaitEvents() { - - ArrayList<TMLWaitEvent> list = new ArrayList<TMLWaitEvent>(); + public List<TMLWaitEvent> getWaitEvents() { + List<TMLWaitEvent> list = new ArrayList<TMLWaitEvent>(); + for( int i = 0; i < getActivityDiagram().nElements(); i++ ) { if( getActivityDiagram().get(i) instanceof TMLWaitEvent ) { list.add( (TMLWaitEvent) getActivityDiagram().get(i) ); } } + return list; } @@ -344,15 +345,15 @@ public class TMLTask extends TMLElement { writeTMLChannelsList.add( _ch ); } - public ArrayList<TMLChannel> getTMLChannels() { + public List<TMLChannel> getTMLChannels() { return new ArrayList<TMLChannel>( channelsList ); } - public ArrayList<TMLChannel> getReadTMLChannels() { + public List<TMLChannel> getReadTMLChannels() { return new ArrayList<TMLChannel>( readTMLChannelsList ); } - public ArrayList<TMLChannel> getWriteTMLChannels() { + public List<TMLChannel> getWriteTMLChannels() { return new ArrayList<TMLChannel>( writeTMLChannelsList ); } @@ -360,7 +361,7 @@ public class TMLTask extends TMLElement { eventsList.add( _evt ); } - public ArrayList<TMLEvent> getTMLEvents() { + public List<TMLEvent> getTMLEvents() { return new ArrayList<TMLEvent>( eventsList ); } @@ -373,7 +374,6 @@ public class TMLTask extends TMLElement { } public void removeEmptyInfiniteLoop() { - activity.removeEmptyInfiniteLoop(); - + activity.removeEmptyInfiniteLoop(); } } diff --git a/src/tmltranslator/TMLTextSpecification.java b/src/tmltranslator/TMLTextSpecification.java index 1a4b94fab7..75d86f782d 100755 --- a/src/tmltranslator/TMLTextSpecification.java +++ b/src/tmltranslator/TMLTextSpecification.java @@ -69,7 +69,7 @@ public class TMLTextSpecification { private boolean inDec = true; private boolean inTask = false; private boolean inTaskDec = false; - private boolean inTaskBehavior = false; + // private boolean inTaskBehavior = false; private TMLTask task; private TMLActivityElement tmlae; private ArrayList<TMLParserSaveElt> parses; @@ -155,7 +155,7 @@ public class TMLTextSpecification { private int nbOf(String _tmp, String[] array) { String tmp; - int size; + // int size; for(int i=0; i<array.length; i++) { if (_tmp.startsWith(array[i])) { @@ -307,12 +307,12 @@ public class TMLTextSpecification { } public String makeBehavior(TMLTask task, TMLActivityElement elt) { - String code, code1, code2; + String code,/* code1,*/ code2; TMLForLoop tmlfl; TMLActivityElementChannel tmlch; TMLActivityElementEvent tmlevt; TMLSendRequest tmlreq; - TMLEvent evt; + // TMLEvent evt; TMLRandom random; int i; String tmp1, tmp2; @@ -415,7 +415,7 @@ public class TMLTextSpecification { TMLChoice choice = (TMLChoice)elt; code = ""; if (choice.getNbGuard() !=0 ) { - code1 = ""; + // code1 = ""; int index1 = choice.getElseGuard(), index2 = choice.getAfterGuard(); int nb = Math.max(choice.nbOfNonDeterministicGuard(), choice.nbOfStochasticGuard()); if (nb > 0) { @@ -576,10 +576,10 @@ public class TMLTextSpecification { inDec = true; inTask = false; inTaskDec = false; - inTaskBehavior = false; + // inTaskBehavior = false; - String instruction; + //String instruction; parses = new ArrayList<TMLParserSaveElt>(); @@ -627,7 +627,7 @@ public class TMLTextSpecification { TMLRequest request; TMLTask t1, t2; TMLAttribute attribute; - TMLType type; + // TMLType type; TMLStopState stop; TMLRandom random; int tmp, tmp0, tmp1, i; @@ -1049,7 +1049,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = true; - inTaskBehavior = false; + // inTaskBehavior = false; if (_split.length != 2) { error = "A request must be declared with exactly 2 parameters, and not " + (_split.length - 1) ; @@ -1095,7 +1095,7 @@ public class TMLTextSpecification { inDec = true; inTask = false; inTaskDec = false; - inTaskBehavior = false; + // inTaskBehavior = false; stop = new TMLStopState("stop", null); task.getActivityDiagram().addElement(stop); @@ -1157,7 +1157,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length != 5) { error = "A RANDOM operation must be declared with exactly 4 parameters, and not " + (_split.length - 1) ; @@ -1203,7 +1203,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length != 3) { error = "A READ operation must be declared with exactly 3 parameters, and not " + (_split.length - 1) ; @@ -1253,7 +1253,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length < 3) { error = "A WRITE operation must be declared with at most 3 parameters, and not " + (_split.length - 1) ; @@ -1306,7 +1306,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length < 2) { error = "A NOTIFY operation must be declared with at least 2 parameters, and not " + (_split.length - 1) ; @@ -1352,7 +1352,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length < 2) { error = "A WAIT operation must be declared with at least 2 parameters, and not " + (_split.length - 1) ; @@ -1414,7 +1414,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length != 3) { error = "A NOTIFIED operation must be declared with exactly 2 parameters, and not " + (_split.length - 1) ; @@ -1456,7 +1456,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (_split.length < 2) { error = "A REQUEST operation must be declared with at least 1 parameter (request name), and not " + (_split.length - 1) ; @@ -1502,11 +1502,11 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the three elements of FOR String forp = _split[1]; - String forps[]; + // String forps[]; tmp0 = forp.indexOf('('); tmp1 = forp.lastIndexOf(')'); if ((tmp0 == -1) || (tmp1 == -1)) { @@ -1566,7 +1566,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1606,7 +1606,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; parseElt = new TMLParserSaveElt(); parseElt.type = TMLParserSaveElt.SELECTEVT; @@ -1633,7 +1633,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1676,7 +1676,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if(_split.length < 2) { error = "A CASE must have at least two parameters"; @@ -1729,7 +1729,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1767,7 +1767,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; parseElt = new TMLParserSaveElt(); parseElt.type = TMLParserSaveElt.RANDOMSEQ; @@ -1794,7 +1794,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1838,7 +1838,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if(_split.length >1 ) { error = "A SEQ has no parameter"; @@ -1878,7 +1878,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1916,7 +1916,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; parseElt = new TMLParserSaveElt(); parseElt.type = TMLParserSaveElt.RAND; @@ -1943,7 +1943,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -1986,7 +1986,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if(_split.length != 2) { error = "A CASERAND should have one parameter"; @@ -2029,7 +2029,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -2067,7 +2067,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; String cond = _split[1].trim(); tmp0 = cond.indexOf('('); @@ -2116,7 +2116,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; String cond = _split[1].trim(); @@ -2180,7 +2180,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if (parses.size() == 0) { error = "ELSE: badly placed instruction."; @@ -2221,7 +2221,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; // Extract the first element of the stack if (parses.size() == 0) { @@ -2256,7 +2256,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if ((_split.length < 2) ||(_split.length > 4)) { error = "An EXECI operation must be declared with 1 or 2 parameters, and not " + (_split.length - 1) ; @@ -2292,7 +2292,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if ((_split.length < 2) ||(_split.length > 4)) { error = "An EXECC operation must be declared with 1 or 2 parameters, and not " + (_split.length - 1) ; @@ -2328,7 +2328,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; if ((_split.length < 3) ||(_split.length > 5)) { error = "A DELAY operation must be declared with 2 or 3 parameters, and not " + (_split.length - 1) ; @@ -2380,7 +2380,7 @@ public class TMLTextSpecification { inDec = false; inTask = true; inTaskDec = false; - inTaskBehavior = true; + // inTaskBehavior = true; TMLActionState action = new TMLActionState(_split[0], null); action.setAction(_line); @@ -2555,7 +2555,7 @@ public class TMLTextSpecification { public String removeUndesiredWhiteSpaces(String _input, int _lineNb) { String error, tmp; - int index0, index1, index2; + int index0, index1;//, index2; if (_input.startsWith("EVENT ")) { index0 = _input.indexOf('('); diff --git a/src/tmltranslator/TMLType.java b/src/tmltranslator/TMLType.java index 05ebc000b1..812a1cffe0 100755 --- a/src/tmltranslator/TMLType.java +++ b/src/tmltranslator/TMLType.java @@ -47,8 +47,6 @@ package tmltranslator; -import myutil.*; - public class TMLType { // type diff --git a/src/tmltranslator/modelcompiler/Buffer.java b/src/tmltranslator/modelcompiler/Buffer.java index 72e522ca88..158e18172c 100755 --- a/src/tmltranslator/modelcompiler/Buffer.java +++ b/src/tmltranslator/modelcompiler/Buffer.java @@ -46,7 +46,7 @@ package tmltranslator.modelcompiler; -import java.util.ArrayList; +import java.util.List; import tmltranslator.TMLCPLibArtifact; import tmltranslator.TMLPort; @@ -82,7 +82,7 @@ public class Buffer { protected TMLCPLibArtifact artifact; protected String baseAddress = "/* USER TODO: VALUE */"; protected String endAddress = "/* USER TODO: VALUE */"; - protected ArrayList<String> bufferParameters; + protected List<String> bufferParameters; private String Context = ""; @@ -143,7 +143,7 @@ public class Buffer { return Context; } - public void setMappingParameters( ArrayList<String> params ) { + public void setMappingParameters( List<String> params ) { bufferParameters = params; } diff --git a/src/tmltranslator/modelcompiler/CPMEC.java b/src/tmltranslator/modelcompiler/CPMEC.java index 6acff1d57f..7a16abb3cc 100755 --- a/src/tmltranslator/modelcompiler/CPMEC.java +++ b/src/tmltranslator/modelcompiler/CPMEC.java @@ -46,17 +46,22 @@ package tmltranslator.modelcompiler; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + public abstract class CPMEC { - public String CR = "\n"; - public String TAB = "\t"; + protected String CR = "\n"; + protected String TAB = "\t"; - public String init_code = new String(); - public String exec_code = new String(); - public String cleanup_code = new String(); + protected String init_code = new String(); + protected String exec_code = new String(); + protected String cleanup_code = new String(); - public static final String[] cpTypes = { "Memory Copy", "Single DMA", "Double DMA" }; - public static final String[] transferTypes = { "memory to IP core", "IP core to IP core", "IP core to memory" }; + public static final String[] CP_TYPES = { "Memory Copy", "Single DMA", "Double DMA" }; + public static final String[] TRANSFER_TYPES = { "memory to IP core", "IP core to IP core", "IP core to memory" }; public static final String SingleDMA = "Single DMA"; public static final String DoubleDMA = "Double DMA"; @@ -77,6 +82,31 @@ public abstract class CPMEC { public static final String USER_TO_DO = "/* USER TO DO */"; + protected static final String DEST_ADDRESS_ATTRIBUTE_NAME = "destinationAddress"; + protected static final String SOURCE_ADDRESS_ATTRIBUTE_NAME = "sourceAddress"; + protected static final String SAMPLES_LOAD_ATTRIBUTE_NAME = "samplesToLoad"; + public static final String[] ORDERED_ATTRIBUTE_NAMES = new String[]{ DEST_ADDRESS_ATTRIBUTE_NAME, SOURCE_ADDRESS_ATTRIBUTE_NAME, SAMPLES_LOAD_ATTRIBUTE_NAME }; + + private final Map<String, String> attributes; + + protected CPMEC( final Collection<String> attributesStr ) { + attributes = initAttributes( attributesStr ); + } + + protected static Map<String, String> initAttributes( final Collection<String> attributesStr ) { + final Map<String, String> attributes = new HashMap<String, String>(); + + for ( final String assignment :attributesStr ) { + final String[] assignPair = assignment.split( " = " ); + final String key = assignPair[ 0 ].trim(); + final String value = assignPair[ 1 ].substring(0, assignPair[ 1 ].length()-1 );//remove trailing semi-colon + + attributes.put( key, value ); + } + + return attributes; + } + public String getExecCode() { return exec_code; } @@ -88,11 +118,34 @@ public abstract class CPMEC { public String getCleanupCode() { return cleanup_code; } - + + protected String getAttributeValue( final String key ) { + if ( attributes.containsKey( key ) ) { + return attributes.get( key ); + } + + return USER_TO_DO; + } // Get the value of an attribute from the TMLCP artifact string - protected static String getAttributeValue( String assignement ) { - String s = assignement.split(" = ")[1]; - return s.substring(0, s.length()-1); //remove trailing semi-colon +// protected static String getAttributeValue( String assignement ) { +// String s = assignement.split(" = ")[1]; +// return s.substring(0, s.length()-1); //remove trailing semi-colon +// } + + // Issue #38 + public static Vector<String> getSortedAttributeValues( final Collection<String> assignedAttributes, + final String[] sortedKeys ) { + final Vector<String> values = new Vector<String>(); + final Map<String, String> attributes = initAttributes( assignedAttributes ); + + for ( final String key : sortedKeys ) { + final String value = attributes.get( key ); + + if ( value != null ) { + values.add( value ); + } + } + + return values; } - } //End of class diff --git a/src/tmltranslator/modelcompiler/CpuMemoryCopyMEC.java b/src/tmltranslator/modelcompiler/CpuMemoryCopyMEC.java index 6ec8234c6b..f93d11b466 100644 --- a/src/tmltranslator/modelcompiler/CpuMemoryCopyMEC.java +++ b/src/tmltranslator/modelcompiler/CpuMemoryCopyMEC.java @@ -51,52 +51,48 @@ import java.util.Vector; public class CpuMemoryCopyMEC extends CPMEC { - public static final int MaxParameters = 3; - public static final int destinationAddressIndex = 0; - public static final int sourceAddressIndex = 1; - public static final int counterIndex = 2; - - public static final String destinationAddress = "destinationAddress"; - public static final String sourceAddress = "sourceAddress"; - public static final String counter = "samplesToLoad"; + // Issue #38 +// private static final int MaxParameters = 3; +// private static final int destinationAddressIndex = 0; +// private static final int sourceAddressIndex = 1; +// private static final int counterIndex = 2; private String memoryBaseAddress = "embb_mss"; - private String srcAddress = USER_TO_DO; - private String dataToTransfer = USER_TO_DO; + private final String srcAddress;// = USER_TO_DO; + private final String dataToTransfer;// = USER_TO_DO; - public CpuMemoryCopyMEC( String ctxName, Vector<String> attributes ) { + public CpuMemoryCopyMEC( String ctxName, Vector<String> attributes ) { + super( attributes ); - CpuMEC cpu = new CpuMEC(); - if( attributes.size() > 0 ) { - srcAddress = attributes.get( sourceAddressIndex ); - dataToTransfer = attributes.get( counterIndex ); +// if( attributes.size() > 0 ) { + srcAddress = getAttributeValue( SOURCE_ADDRESS_ATTRIBUTE_NAME );//attributes.get( sourceAddressIndex ); + dataToTransfer = getAttributeValue( SAMPLES_LOAD_ATTRIBUTE_NAME );//attributes.get( counterIndex ); // apparently there is no need to use destinationAddress - } + // } + CpuMEC cpu = new CpuMEC(); exec_code = TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", " + srcAddress + ", " + dataToTransfer + " );" + CR; init_code = TAB + cpu.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName + ", " + "(uintptr_t) " + cpu.getLocalMemoryPointer() + " );" + CR; cleanup_code = TAB + cpu.getCtxCleanupCode() + "(&" + ctxName +");"; } - - public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { - - Vector<String> newVector = new Vector<String>(); + + // Issue #38 +// public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { //temporary manual workaround - newVector.add("0"); - newVector.add("0"); - newVector.add("0"); - for( String s: assignedAttributes ) { - if( s.contains( destinationAddress ) ) { - newVector.set( destinationAddressIndex, getAttributeValue(s) ); - } - if( s.contains( sourceAddress ) ) { - newVector.set( sourceAddressIndex, getAttributeValue(s) ); - } - if( s.contains( counter ) ) { - newVector.set( counterIndex, getAttributeValue(s) ); - } - } - return newVector; - } - +// newVector.add("0"); +// newVector.add("0"); +// newVector.add("0"); +// for( String s: assignedAttributes ) { +// if( s.contains( destinationAddress ) ) { +// newVector.set( destinationAddressIndex, getAttributeValue(s) ); +// } +// if( s.contains( sourceAddress ) ) { +// newVector.set( sourceAddressIndex, getAttributeValue(s) ); +// } +// if( s.contains( counter ) ) { +// newVector.set( counterIndex, getAttributeValue(s) ); +// } +// } +// return newVector; +// } } //End of class diff --git a/src/tmltranslator/modelcompiler/DoubleDmaMEC.java b/src/tmltranslator/modelcompiler/DoubleDmaMEC.java index 3cdea78673..b13263ffbd 100755 --- a/src/tmltranslator/modelcompiler/DoubleDmaMEC.java +++ b/src/tmltranslator/modelcompiler/DoubleDmaMEC.java @@ -51,20 +51,22 @@ import java.util.Vector; public class DoubleDmaMEC extends CPMEC { - public static final int MaxParameters = 6; - public static final int destinationAddress1Index = 0; - public static final int sourceAddress1Index = 1; - public static final int counter1Index = 2; - public static final int destinationAddress2Index = 3; - public static final int sourceAddress2Index = 4; - public static final int counter2Index = 5; - - public static final String destinationAddress1 = "destinationAddress1"; - public static final String sourceAddress1 = "sourceAddress1"; - public static final String counter1 = "counter1"; - public static final String destinationAddress2 = "destinationAddress2"; - public static final String sourceAddress2 = "sourceAddress2"; - public static final String counter2 = "counter2"; +// public static final int MaxParameters = 6; +// public static final int destinationAddress1Index = 0; +// public static final int sourceAddress1Index = 1; +// public static final int counter1Index = 2; +// public static final int destinationAddress2Index = 3; +// public static final int sourceAddress2Index = 4; +// public static final int counter2Index = 5; + + private static final String destinationAddress1 = "destinationAddress1"; + private static final String sourceAddress1 = "sourceAddress1"; + private static final String counter1 = "counter1"; + private static final String destinationAddress2 = "destinationAddress2"; + private static final String sourceAddress2 = "sourceAddress2"; + private static final String counter2 = "counter2"; + + public static final String[] ORDERED_ATTRIBUTE_NAMES = new String[]{ destinationAddress1, sourceAddress1, counter1, destinationAddress2, sourceAddress2, counter2 }; private Vector<String> memoryBaseAddress = new Vector<String>(); private String dataToTransfer1 = USER_TO_DO; @@ -79,6 +81,8 @@ public class DoubleDmaMEC extends CPMEC { private String ctxName2 = USER_TO_DO; public DoubleDmaMEC( String ctxName, Vector<ArchUnitMEC> archMECs, Vector<Integer> srcMemoryTypes, Vector<Integer> dstMemoryTypes, List<Integer> transferTypes, Vector<String> attributes ) { + super( attributes ); + int numSrcMemories = srcMemoryTypes.size(); for( int i = 0; i < numSrcMemories; i++ ) { @@ -108,12 +112,12 @@ public class DoubleDmaMEC extends CPMEC { ArchUnitMEC archMEC = archMECs.get(0); if( attributes.size() > 0 ) { - dataToTransfer1 = attributes.get( counter1Index ); - dataToTransfer2 = attributes.get( counter2Index ); - dstAddress1 = attributes.get( destinationAddress1Index ); - srcAddress1 = attributes.get( sourceAddress1Index ); - dstAddress2 = attributes.get( destinationAddress2Index ); - srcAddress2 = attributes.get( sourceAddress2Index ); + dataToTransfer1 = getAttributeValue( counter1 );//attributes.get( counter1Index ); + dataToTransfer2 = getAttributeValue( counter2 );//attributes.get( counter2Index ); + dstAddress1 = getAttributeValue( destinationAddress1 );//attributes.get( destinationAddress1Index ); + srcAddress1 = getAttributeValue( sourceAddress1 );//attributes.get( sourceAddress1Index ); + dstAddress2 = getAttributeValue( destinationAddress2 );//attributes.get( destinationAddress2Index ); + srcAddress2 = getAttributeValue( sourceAddress2 );//attributes.get( sourceAddress2Index ); ctxName1 = ctxName + "_1"; ctxName2 = ctxName + "_2"; } @@ -156,30 +160,30 @@ public class DoubleDmaMEC extends CPMEC { break; } } - - public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { - - Vector<String> newVector = new Vector<String>( assignedAttributes ); - for( String s: assignedAttributes ) { - if( s.contains( destinationAddress1 ) ) { - newVector.set( destinationAddress1Index, getAttributeValue(s) ); - } - if( s.contains( sourceAddress1 ) ) { - newVector.set( sourceAddress1Index, getAttributeValue(s) ); - } - if( s.contains( counter1 ) ) { - newVector.set( counter1Index, getAttributeValue(s) ); - } - if( s.contains( destinationAddress2 ) ) { - newVector.set( destinationAddress2Index, getAttributeValue(s) ); - } - if( s.contains( sourceAddress2 ) ) { - newVector.set( sourceAddress2Index, getAttributeValue(s) ); - } - if( s.contains( counter2 ) ) { - newVector.set( counter2Index, getAttributeValue(s) ); - } - } - return newVector; - } +// +// public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { +// +// Vector<String> newVector = new Vector<String>( assignedAttributes ); +// for( String s: assignedAttributes ) { +// if( s.contains( destinationAddress1 ) ) { +// newVector.set( destinationAddress1Index, getAttributeValue(s) ); +// } +// if( s.contains( sourceAddress1 ) ) { +// newVector.set( sourceAddress1Index, getAttributeValue(s) ); +// } +// if( s.contains( counter1 ) ) { +// newVector.set( counter1Index, getAttributeValue(s) ); +// } +// if( s.contains( destinationAddress2 ) ) { +// newVector.set( destinationAddress2Index, getAttributeValue(s) ); +// } +// if( s.contains( sourceAddress2 ) ) { +// newVector.set( sourceAddress2Index, getAttributeValue(s) ); +// } +// if( s.contains( counter2 ) ) { +// newVector.set( counter2Index, getAttributeValue(s) ); +// } +// } +// return newVector; +// } } //End of class diff --git a/src/tmltranslator/modelcompiler/FepBuffer.java b/src/tmltranslator/modelcompiler/FepBuffer.java index b397407f59..cc990d56b4 100755 --- a/src/tmltranslator/modelcompiler/FepBuffer.java +++ b/src/tmltranslator/modelcompiler/FepBuffer.java @@ -99,8 +99,8 @@ public class FepBuffer extends Buffer { private static JTextField numSamplesTF = new JTextField( "", 5 ); private static JTextField baseAddressTF = new JTextField( "", 5 ); - private static JComboBox bankCB = new JComboBox( new Vector<String>( Arrays.asList( banksList ) ) ); - private static JComboBox dataTypeCB = new JComboBox( new Vector<String>( Arrays.asList( dataTypeList ) ) ); + private static JComboBox<String> bankCB = new JComboBox<String>( new Vector<String>( Arrays.asList( banksList ) ) ); + private static JComboBox<String> dataTypeCB = new JComboBox<String>( new Vector<String>( Arrays.asList( dataTypeList ) ) ); public FepBuffer( String _name, TMLTask _task ) { type = "FEP_BUFFER_TYPE"; @@ -185,7 +185,7 @@ public class FepBuffer extends Buffer { public static ArrayList<JPanel> makePanel( GridBagConstraints c1, GridBagConstraints c2 ) { - String baseAddress = "", numSamples = "", bank = "", dataType = ""; + String baseAddress = "", numSamples = "";//, bank = "", dataType = ""; GridBagLayout gridbag2 = new GridBagLayout(); diff --git a/src/tmltranslator/modelcompiler/FepOperationMEC.java b/src/tmltranslator/modelcompiler/FepOperationMEC.java index 035240f16f..6407855544 100755 --- a/src/tmltranslator/modelcompiler/FepOperationMEC.java +++ b/src/tmltranslator/modelcompiler/FepOperationMEC.java @@ -46,10 +46,6 @@ package tmltranslator.modelcompiler; -import java.util.*; -import java.nio.*; -import myutil.*; - public abstract class FepOperationMEC extends OperationMEC { public FepOperationMEC() { diff --git a/src/tmltranslator/modelcompiler/InterleaverBuffer.java b/src/tmltranslator/modelcompiler/InterleaverBuffer.java index 2301749884..95f3f393ec 100644 --- a/src/tmltranslator/modelcompiler/InterleaverBuffer.java +++ b/src/tmltranslator/modelcompiler/InterleaverBuffer.java @@ -133,11 +133,11 @@ public class InterleaverBuffer extends Buffer { //Intl Data In private static JTextField width_TF, bitInOffset_TF, inputOffset_TF; private static String width = "", bitInOffset = "", inputOffset = "", packedBinaryIn = ""; - private static JComboBox packedBinaryIn_CB; + private static JComboBox<String> packedBinaryIn_CB; // Data Out private static JTextField bitOutOffset_TF, outputOffset_TF; - private static JComboBox packedBinaryOut_CB; + private static JComboBox<String> packedBinaryOut_CB; private static String packedBinaryOut = "", bitOutOffset = "", outputOffset = ""; // Perm @@ -299,7 +299,7 @@ public class InterleaverBuffer extends Buffer { //Data In panel c2.anchor = GridBagConstraints.LINE_START; - packedBinaryIn_CB = new JComboBox( Buffer.onOffVector ); + packedBinaryIn_CB = new JComboBox<String>( Buffer.onOffVector ); panel3.add( new JLabel( "Packed binary input mode = "), c2 ); c1.gridwidth = GridBagConstraints.REMAINDER; panel3.add( packedBinaryIn_CB, c1 ); @@ -322,7 +322,7 @@ public class InterleaverBuffer extends Buffer { //Data Out panel c2.anchor = GridBagConstraints.LINE_START; - packedBinaryOut_CB = new JComboBox( Buffer.onOffVector ); + packedBinaryOut_CB = new JComboBox<String>( Buffer.onOffVector ); panel4.add( new JLabel( "Packed binary output mode = "), c2 ); c1.gridwidth = GridBagConstraints.REMAINDER; panel4.add( packedBinaryOut_CB, c1 ); diff --git a/src/tmltranslator/modelcompiler/MapperBuffer.java b/src/tmltranslator/modelcompiler/MapperBuffer.java index af6fb8843a..5a4f48c09a 100644 --- a/src/tmltranslator/modelcompiler/MapperBuffer.java +++ b/src/tmltranslator/modelcompiler/MapperBuffer.java @@ -103,7 +103,7 @@ public class MapperBuffer extends Buffer { //Mapper Data In private static JTextField baseAddressDataIn_TF, numSamplesDataIn_TF, bitsPerSymbolDataIn_TF; private static String baseAddressDataIn = "", numSamplesDataIn = "", bitsPerSymbolDataIn = "", symmetricalValueDataIn = ""; - private static JComboBox symmetricalValueDataIn_CB; + private static JComboBox<String> symmetricalValueDataIn_CB; //Mapper Data Out private static JTextField baseAddressDataOut_TF; private static String baseAddressDataOut = ""; @@ -262,7 +262,7 @@ public class MapperBuffer extends Buffer { c1.gridwidth = GridBagConstraints.REMAINDER; panel3.add( bitsPerSymbolDataIn_TF, c1 ); // - symmetricalValueDataIn_CB = new JComboBox( new Vector<String>( Arrays.asList( symmetricalValues ) ) ); + symmetricalValueDataIn_CB = new JComboBox<String>( new Vector<String>( Arrays.asList( symmetricalValues ) ) ); panel3.add( new JLabel( "Symmetrical value = "), c2 ); c1.gridwidth = GridBagConstraints.REMAINDER; panel3.add( symmetricalValueDataIn_CB, c1 ); diff --git a/src/tmltranslator/modelcompiler/OperationMEC.java b/src/tmltranslator/modelcompiler/OperationMEC.java index 7a752dcf67..ea88e0cec5 100755 --- a/src/tmltranslator/modelcompiler/OperationMEC.java +++ b/src/tmltranslator/modelcompiler/OperationMEC.java @@ -47,8 +47,6 @@ package tmltranslator.modelcompiler; import java.util.*; -import java.nio.*; -import myutil.*; public abstract class OperationMEC { @@ -65,7 +63,7 @@ public abstract class OperationMEC { public static final int FftMEC = FepOperationMEC + 6; private static final String[] contextArray = { "MAPPER_CONTEXT", "INTL_CONTEXT", "ADAIF_CONTEXT", "EMBB_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT", "FEP_CONTEXT" }; - public static final ArrayList<String> ContextList = new ArrayList( Arrays.asList( contextArray ) ); + public static final List<String> ContextList = new ArrayList<String>( Arrays.asList( contextArray ) ); protected String CR = "\n"; protected String TAB = "\t"; diff --git a/src/tmltranslator/modelcompiler/SingleDmaMEC.java b/src/tmltranslator/modelcompiler/SingleDmaMEC.java index 29bd978cef..f433a8c6cb 100755 --- a/src/tmltranslator/modelcompiler/SingleDmaMEC.java +++ b/src/tmltranslator/modelcompiler/SingleDmaMEC.java @@ -50,22 +50,24 @@ import java.util.Vector; public class SingleDmaMEC extends CPMEC { - public static final int MaxParameters = 3; - public static final int destinationAddressIndex = 0; - public static final int sourceAddressIndex = 1; - public static final int counterIndex = 2; + //private static final int MaxParameters = 3; +// private static final int destinationAddressIndex = 0; +// private static final int sourceAddressIndex = 1; +// private static final int counterIndex = 2; - public static final String destinationAddress = "destinationAddress"; - public static final String sourceAddress = "sourceAddress"; - public static final String counter = "counter"; +// private static final String destinationAddress = "destinationAddress"; +// private static final String sourceAddress = "sourceAddress"; +// private static final String counter = "counter"; - private String memoryBaseAddress = "0"; - private String dataToTransfer = USER_TO_DO; - private static String dstAddress = USER_TO_DO; - private static String srcAddress = USER_TO_DO; + // Issue #38: default handled in super class + private final String memoryBaseAddress;// = "0"; + private final String dataToTransfer;// = USER_TO_DO; + private final String dstAddress;// = USER_TO_DO; + private final String srcAddress;// = USER_TO_DO; public SingleDmaMEC( String ctxName, ArchUnitMEC archMEC, int srcMemoryType, int dstMemoryType, int transferType, Vector<String> attributes ) { - + super( attributes ); + switch( srcMemoryType ) { case Buffer.FEP_BUFFER: memoryBaseAddress = "fep_mss"; @@ -87,11 +89,11 @@ public class SingleDmaMEC extends CPMEC { break; } - if( attributes.size() > 0 ) { - dataToTransfer = attributes.get( counterIndex ); - srcAddress = attributes.get( sourceAddressIndex ); - dstAddress = attributes.get( destinationAddressIndex ); - } + //if( attributes.size() > 0 ) { + dataToTransfer = getAttributeValue( SAMPLES_LOAD_ATTRIBUTE_NAME );//attributes.get( counterIndex ); + srcAddress = getAttributeValue( SOURCE_ADDRESS_ATTRIBUTE_NAME );//attributes.get( sourceAddressIndex ); + dstAddress = getAttributeValue( DEST_ADDRESS_ATTRIBUTE_NAME );//attributes.get( destinationAddressIndex ); + //} switch( transferType ) { case CPMEC.mem2IP: @@ -116,22 +118,29 @@ public class SingleDmaMEC extends CPMEC { break; } } - - public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { - - Vector<String> newVector = new Vector<String>( assignedAttributes ); - for( String s: assignedAttributes ) { - if( s.contains( destinationAddress ) ) { - newVector.set( destinationAddressIndex, getAttributeValue(s) ); - } - if( s.contains( sourceAddress ) ) { - newVector.set( sourceAddressIndex, getAttributeValue(s) ); - } - if( s.contains( counter ) ) { - newVector.set( counterIndex, getAttributeValue(s) ); - } - } - return newVector; - } - +// +// public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { +// Vector<String> newVector = new Vector<String>( assignedAttributes ); +// +// for( String s: assignedAttributes ) { +// if( s.contains( destinationAddress ) ) { +// newVector.set( destinationAddressIndex, getAttributeValue(s) ); +// } +// +// if( s.contains( sourceAddress ) ) { +// newVector.set( sourceAddressIndex, getAttributeValue(s) ); +// } +// +// if( s.contains( counter ) ) { +// // try { +// newVector.set( counterIndex, getAttributeValue(s) ); +//// } +//// catch (IndexOutOfBoundsException ex) { +//// ex.printStackTrace(); +//// } +// } +// } +// +// return newVector; +// } } //End of class diff --git a/src/tmltranslator/modelcompiler/TMLModelCompiler.java b/src/tmltranslator/modelcompiler/TMLModelCompiler.java index 6f51450951..6e6d4e8f1a 100755 --- a/src/tmltranslator/modelcompiler/TMLModelCompiler.java +++ b/src/tmltranslator/modelcompiler/TMLModelCompiler.java @@ -493,7 +493,7 @@ public class TMLModelCompiler { private void setMappingParametersToBuffers() { for( TMLCPLib tmlcplib: mappedCPLibs ) { - ArrayList<String> bufferParameters = tmlcplib.getArtifacts().get(0).getBufferParameters(); + List<String> bufferParameters = tmlcplib.getArtifacts().get(0).getBufferParameters(); String portName = tmlcplib.getArtifacts().get(0).getPortName(); for( Buffer buff: buffersList ) { if( buff.getName().equals( "buff_" + portName ) ) { diff --git a/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java b/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java index 55a9b2dddc..b1f52d7677 100755 --- a/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java +++ b/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java @@ -48,20 +48,18 @@ package tmltranslator.tmlcp; import java.util.*; import tmltranslator.*; -import myutil.*; -//import compiler.tmlCPparser.myexceptions.*; public class TMLCPActivityDiagram extends TMLElement { private TMLCPStart start; - private ArrayList<TMLCPElement> elements; // Including the start element + private List<TMLCPElement> elements; // Including the start element //private ArrayList<TMLAttribute> globalVariables; - private ArrayList<String> ads; //a list of the activity diagrams declared in a section (for parsing of text) - private ArrayList<String> sds; //a list of the sequence diagrams declated in a section (for parsing of text) + private List<String> ads; //a list of the activity diagrams declared in a section (for parsing of text) + private List<String> sds; //a list of the sequence diagrams declated in a section (for parsing of text) - private int hashCode; - private boolean hashCodeComputed = false; +// private int hashCode; +// private boolean hashCodeComputed = false; /*private boolean definedVariable( TMLAttribute _var ) { @@ -179,13 +177,13 @@ public class TMLCPActivityDiagram extends TMLElement { //The variable trying to be initialized was not declared }*/ - public ArrayList<TMLCPElement> getElements() { + public List<TMLCPElement> getElements() { return elements; } - public void addElements( ArrayList<TMLCPElement> _nexts ) { - elements = new ArrayList<TMLCPElement>( _nexts ); - } + public void addElements( List<TMLCPElement> _nexts ) { + elements = new ArrayList<TMLCPElement>( _nexts ); + } /*public void addElement( TMLCPElement _elem ) { elements.add( _elem ); @@ -208,11 +206,11 @@ public class TMLCPActivityDiagram extends TMLElement { return globalVariables; }*/ - public ArrayList<String> getADlist() { + public List<String> getADlist() { return ads; } - public ArrayList<String> getSDlist() { + public List<String> getSDlist() { return sds; } @@ -248,8 +246,8 @@ public class TMLCPActivityDiagram extends TMLElement { String tempString; - ArrayList<TMLCPActivityDiagram> activityList = _refTopCP.getCPActivityDiagrams(); - ArrayList<TMLCPSequenceDiagram> sequenceList = _refTopCP.getCPSequenceDiagrams(); + List<TMLCPActivityDiagram> activityList = _refTopCP.getCPActivityDiagrams(); + List<TMLCPSequenceDiagram> sequenceList = _refTopCP.getCPSequenceDiagrams(); for(TMLCPElement tempElem: elements) { @@ -348,7 +346,7 @@ public class TMLCPActivityDiagram extends TMLElement { // Replacing next to junction by new refs int index; - int ID = 0; + // int ID = 0; for(TMLCPElement elt: elements) { while(((index = elt.getNextElements().indexOf(junction)) != -1)) { //TMLCPRefAD ref = new TMLCPRefAD(toAD, toAD.getName() + "_" + ID, junction.getReferenceObject()); @@ -376,7 +374,7 @@ public class TMLCPActivityDiagram extends TMLElement { } // Moving elements from old AD to split ADs - int cpt = 0; + //int cpt = 0; for(TMLCPJunction junction: junctions) { diag = refs.get(junction); //TMLCPRefAD refAD = refsAD.get(cpt); @@ -398,7 +396,7 @@ public class TMLCPActivityDiagram extends TMLElement { return refs.values(); } - private void addElementsFromJunction(TMLCPElement originInOld, TMLCPElement originInNew, TMLCPActivityDiagram newDiag, HashMap<TMLCPJunction, TMLCPActivityDiagram> refs, ArrayList<TMLCPElement> toBeRemoved) { + private void addElementsFromJunction(TMLCPElement originInOld, TMLCPElement originInNew, TMLCPActivityDiagram newDiag, Map<TMLCPJunction, TMLCPActivityDiagram> refs, List<TMLCPElement> toBeRemoved) { if (originInOld.getNextElements() == null) { return; } @@ -427,82 +425,84 @@ public class TMLCPActivityDiagram extends TMLElement { public TMLCPElement getNonConnectedElement() { - // Starting from Start state ... reaching all elements - // Then, see elements which are not in the reachable ones - if (start == null) { - return null; - } - - ArrayList<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + // Starting from Start state ... reaching all elements + // Then, see elements which are not in the reachable ones + if (start == null) { + return null; + } - computeReachableElements(start, reached); - - // Find elements which were not reached - for(TMLCPElement elt: elements) { - if (!(reached.contains(elt))) { - return elt; - } - } - return null; + List<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + + computeReachableElements(start, reached); + + // Find elements which were not reached + for(TMLCPElement elt: elements) { + if (!(reached.contains(elt))) { + return elt; + } + } + return null; } - public LinkedList<TMLCPElement> getAllNonConnectedElements() { - // Starting from Start state ... reaching all elements - // Then, see elements which are not in the reachable ones - if (start == null) { - return null; - } - - LinkedList<TMLCPElement> list = new LinkedList<TMLCPElement>(); - ArrayList<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + public List<TMLCPElement> getAllNonConnectedElements() { + // Starting from Start state ... reaching all elements + // Then, see elements which are not in the reachable ones + if (start == null) { + return null; + } - computeReachableElements(start, reached); - - // Find elements which were not reached - for(TMLCPElement elt: elements) { - if (!(reached.contains(elt))) { - list.add(elt); - } - } - return list; + LinkedList<TMLCPElement> list = new LinkedList<TMLCPElement>(); + ArrayList<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + + computeReachableElements(start, reached); + + // Find elements which were not reached + for(TMLCPElement elt: elements) { + if (!(reached.contains(elt))) { + list.add(elt); + } + } + return list; } - public LinkedList<TMLCPElement> removeAllNonConnectedElements() { - // Starting from Start state ... reaching all elements - // Then, see elements which are not in the reachable ones - if (start == null) { - return null; - } - - LinkedList<TMLCPElement> list = new LinkedList<TMLCPElement>(); - ArrayList<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + public List<TMLCPElement> removeAllNonConnectedElements() { + // Starting from Start state ... reaching all elements + // Then, see elements which are not in the reachable ones + if (start == null) { + return null; + } - computeReachableElements(start, reached); - - // Find elements which were not reached - for(TMLCPElement elt: elements) { - if (!(reached.contains(elt))) { - list.add(elt); - } - } - - for(TMLCPElement elt: list) { - elements.remove(elt); - } + List<TMLCPElement> list = new LinkedList<TMLCPElement>(); + List<TMLCPElement> reached = new ArrayList<TMLCPElement>(); + + computeReachableElements(start, reached); + + // Find elements which were not reached + for(TMLCPElement elt: elements) { + if (!(reached.contains(elt))) { + list.add(elt); + } + } - return list; + for(TMLCPElement elt: list) { + elements.remove(elt); + } + + return list; } - private void computeReachableElements(TMLCPElement _elt, ArrayList<TMLCPElement> _reached) { - if (_reached.contains(_elt)) { - return; - } - - _reached.add(_elt); - - for(TMLCPElement elt: _elt.getNextElements()) { - computeReachableElements(_elt, _reached); - } + private void computeReachableElements(TMLCPElement _elt, List<TMLCPElement> _reached) { + if (_reached.contains(_elt)) { + return; + } + + _reached.add(_elt); + + // Issue #38 found while cleaning code + for(TMLCPElement elt : _elt.getNextElements()) { + computeReachableElements( elt, _reached ); +// computeReachableElements(_elt, _reached); + } } public String toString() { diff --git a/src/tmltranslator/tmlcp/TMLCPChoice.java b/src/tmltranslator/tmlcp/TMLCPChoice.java index 699d6cb6d7..9f09bf8cc6 100755 --- a/src/tmltranslator/tmlcp/TMLCPChoice.java +++ b/src/tmltranslator/tmlcp/TMLCPChoice.java @@ -48,9 +48,6 @@ package tmltranslator.tmlcp; import java.util.*; - -import myutil.*; - //The method is not very suited for the language, I should come back later... public class TMLCPChoice extends TMLCPElement { private ArrayList<String> guards; diff --git a/src/tmltranslator/tmlcp/TMLCPConnector.java b/src/tmltranslator/tmlcp/TMLCPConnector.java index 424c4c81af..56a6cd2945 100755 --- a/src/tmltranslator/tmlcp/TMLCPConnector.java +++ b/src/tmltranslator/tmlcp/TMLCPConnector.java @@ -46,10 +46,6 @@ package tmltranslator.tmlcp; -import java.util.*; - -import myutil.*; - public class TMLCPConnector extends TMLCPElement implements Comparable<TMLCPConnector> { private String startName; diff --git a/src/tmltranslator/tmlcp/TMLCPElement.java b/src/tmltranslator/tmlcp/TMLCPElement.java index 55b2f6c1cf..8229ed122e 100755 --- a/src/tmltranslator/tmlcp/TMLCPElement.java +++ b/src/tmltranslator/tmlcp/TMLCPElement.java @@ -49,11 +49,8 @@ package tmltranslator.tmlcp; import tmltranslator.*; import java.util.*; - -import myutil.*; - public abstract class TMLCPElement extends TMLElement { - protected ArrayList<TMLCPElement> nexts; + protected List<TMLCPElement> nexts; public TMLCPElement(String _name, Object _referenceObject) { super(_name, _referenceObject); @@ -87,11 +84,11 @@ public abstract class TMLCPElement extends TMLElement { nexts.clear(); } - public ArrayList<TMLCPElement> getNextElements() { + public List<TMLCPElement> getNextElements() { return nexts; } - public void setNexts(ArrayList<TMLCPElement> _nexts) { + public void setNexts( List<TMLCPElement> _nexts) { nexts = _nexts; } diff --git a/src/tmltranslator/tmlcp/TMLCPEndGroup.java b/src/tmltranslator/tmlcp/TMLCPEndGroup.java index 76f3abc2c6..64bd880585 100755 --- a/src/tmltranslator/tmlcp/TMLCPEndGroup.java +++ b/src/tmltranslator/tmlcp/TMLCPEndGroup.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPEndGroup extends TMLCPElement { diff --git a/src/tmltranslator/tmlcp/TMLCPFork.java b/src/tmltranslator/tmlcp/TMLCPFork.java index 2df41cb5e8..f7af8b8dba 100755 --- a/src/tmltranslator/tmlcp/TMLCPFork.java +++ b/src/tmltranslator/tmlcp/TMLCPFork.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPFork extends TMLCPElement { diff --git a/src/tmltranslator/tmlcp/TMLCPJoin.java b/src/tmltranslator/tmlcp/TMLCPJoin.java index 881ab8cda1..52e4feceb5 100755 --- a/src/tmltranslator/tmlcp/TMLCPJoin.java +++ b/src/tmltranslator/tmlcp/TMLCPJoin.java @@ -45,27 +45,23 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - import java.util.ArrayList; - -import myutil.*; +import java.util.List; public class TMLCPJoin extends TMLCPElement { //they can be either CPSections (AD) or SDSections (SD) - private ArrayList<String> listElements = new ArrayList<String>(); + private List<String> listElements = new ArrayList<String>(); public TMLCPJoin(String _name, Object _referenceObject) { super(_name, _referenceObject); } - public void addElementName( String elementName ) { - listElements.add( elementName ); - } + public void addElementName( String elementName ) { + listElements.add( elementName ); + } - public ArrayList<String> getElementsName() { - return listElements; - } - + public List<String> getElementsName() { + return listElements; + } } diff --git a/src/tmltranslator/tmlcp/TMLCPJunction.java b/src/tmltranslator/tmlcp/TMLCPJunction.java index 2ed75dba13..f8d189fe33 100755 --- a/src/tmltranslator/tmlcp/TMLCPJunction.java +++ b/src/tmltranslator/tmlcp/TMLCPJunction.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPJunction extends TMLCPElement { public TMLCPJunction(String _name, Object _referenceObject) { diff --git a/src/tmltranslator/tmlcp/TMLCPRefAD.java b/src/tmltranslator/tmlcp/TMLCPRefAD.java index 4221d70ebc..bfe4117c92 100755 --- a/src/tmltranslator/tmlcp/TMLCPRefAD.java +++ b/src/tmltranslator/tmlcp/TMLCPRefAD.java @@ -46,10 +46,6 @@ package tmltranslator.tmlcp; -import java.util.*; - -import myutil.*; - public class TMLCPRefAD extends TMLCPElement { private TMLCPActivityDiagram reference; diff --git a/src/tmltranslator/tmlcp/TMLCPRefSD.java b/src/tmltranslator/tmlcp/TMLCPRefSD.java index 00757fd04e..baaa39a0bf 100755 --- a/src/tmltranslator/tmlcp/TMLCPRefSD.java +++ b/src/tmltranslator/tmlcp/TMLCPRefSD.java @@ -46,10 +46,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - -import myutil.*; - public class TMLCPRefSD extends TMLCPElement { private TMLCPSequenceDiagram reference; diff --git a/src/tmltranslator/tmlcp/TMLCPSequence.java b/src/tmltranslator/tmlcp/TMLCPSequence.java index 921c6a905c..d81ff53dcc 100755 --- a/src/tmltranslator/tmlcp/TMLCPSequence.java +++ b/src/tmltranslator/tmlcp/TMLCPSequence.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPSequence extends TMLCPElement { diff --git a/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java b/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java index b5024efb68..e04dd29206 100755 --- a/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java +++ b/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java @@ -50,14 +50,13 @@ package tmltranslator.tmlcp; import java.util.*; import tmltranslator.*; -import myutil.*; public class TMLCPSequenceDiagram extends TMLElement { - private ArrayList<TMLSDInstance> instancesList; + private List<TMLSDInstance> instancesList; - private int hashCode; - private boolean hashCodeComputed = false; +// private int hashCode; +// private boolean hashCodeComputed = false; public TMLCPSequenceDiagram( String _name, Object _referenceObject ) { @@ -83,7 +82,7 @@ public class TMLCPSequenceDiagram extends TMLElement { instancesList.add( _inst ); } - public ArrayList<TMLSDInstance> getInstances() { + public List<TMLSDInstance> getInstances() { return instancesList; } diff --git a/src/tmltranslator/tmlcp/TMLCPStart.java b/src/tmltranslator/tmlcp/TMLCPStart.java index 7c1b437a7e..ab3e8371b6 100755 --- a/src/tmltranslator/tmlcp/TMLCPStart.java +++ b/src/tmltranslator/tmlcp/TMLCPStart.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPStart extends TMLCPElement { public TMLCPStart(String _name, Object _referenceObject) { diff --git a/src/tmltranslator/tmlcp/TMLCPStartGroup.java b/src/tmltranslator/tmlcp/TMLCPStartGroup.java index dde17644de..c9afbb9ec2 100755 --- a/src/tmltranslator/tmlcp/TMLCPStartGroup.java +++ b/src/tmltranslator/tmlcp/TMLCPStartGroup.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPStartGroup extends TMLCPElement { diff --git a/src/tmltranslator/tmlcp/TMLCPStop.java b/src/tmltranslator/tmlcp/TMLCPStop.java index 214ce1a103..25c5d1cd82 100755 --- a/src/tmltranslator/tmlcp/TMLCPStop.java +++ b/src/tmltranslator/tmlcp/TMLCPStop.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLCPStop extends TMLCPElement { diff --git a/src/tmltranslator/tmlcp/TMLSDAction.java b/src/tmltranslator/tmlcp/TMLSDAction.java index 705281984d..1c3356f5f0 100755 --- a/src/tmltranslator/tmlcp/TMLSDAction.java +++ b/src/tmltranslator/tmlcp/TMLSDAction.java @@ -46,35 +46,32 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLSDAction extends TMLSDElement { private String action; private String instanceName; private int yCoord; - - public TMLSDAction( String _action, String _instanceName, Object _referenceObject, int _yCoord ) { + + public TMLSDAction( String _action, String _instanceName, Object _referenceObject, int _yCoord ) { super( "action", _referenceObject); - action = _action; + + action = _action; instanceName = _instanceName; this.yCoord = _yCoord; - } + } // Constructor used for the TMLCPparser where in the TMLCP code there is no notion of yCoord and no notion of referenceObject - public TMLSDAction( String _action, String _instanceName ) { + public TMLSDAction( String _action, String _instanceName ) { super( "action", null ); - action = _action; + + action = _action; instanceName = _instanceName; this.yCoord = -1; - } - - public int getYCoord() { - return this.yCoord; - } + } + + public int getYCoord() { + return this.yCoord; + } public String getInstanceName() { return instanceName; @@ -83,5 +80,5 @@ public class TMLSDAction extends TMLSDElement { public String toString() { return action; } - + } diff --git a/src/tmltranslator/tmlcp/TMLSDElement.java b/src/tmltranslator/tmlcp/TMLSDElement.java index 94092b1746..fc37a9370a 100755 --- a/src/tmltranslator/tmlcp/TMLSDElement.java +++ b/src/tmltranslator/tmlcp/TMLSDElement.java @@ -45,10 +45,7 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - import tmltranslator.*; -import myutil.*; public abstract class TMLSDElement extends TMLElement { diff --git a/src/tmltranslator/tmlcp/TMLSDEvent.java b/src/tmltranslator/tmlcp/TMLSDEvent.java index e862e74da4..daec2c7df3 100755 --- a/src/tmltranslator/tmlcp/TMLSDEvent.java +++ b/src/tmltranslator/tmlcp/TMLSDEvent.java @@ -47,11 +47,6 @@ package tmltranslator.tmlcp; -import java.util.*; - -import tmltranslator.*; -import myutil.*; - public class TMLSDEvent implements Comparable<TMLSDEvent> { public final static int SEND_MESSAGE_EVENT = 0; diff --git a/src/tmltranslator/tmlcp/TMLSDInstance.java b/src/tmltranslator/tmlcp/TMLSDInstance.java index 8aa54d0c6d..e7b7720155 100755 --- a/src/tmltranslator/tmlcp/TMLSDInstance.java +++ b/src/tmltranslator/tmlcp/TMLSDInstance.java @@ -53,8 +53,6 @@ import java.util.*; import ui.tmlsd.*; -import myutil.*; - public class TMLSDInstance extends TMLElement { private String type; diff --git a/src/tmltranslator/tmlcp/TMLSDMessage.java b/src/tmltranslator/tmlcp/TMLSDMessage.java index f31d935e34..c68750857e 100755 --- a/src/tmltranslator/tmlcp/TMLSDMessage.java +++ b/src/tmltranslator/tmlcp/TMLSDMessage.java @@ -49,7 +49,6 @@ package tmltranslator.tmlcp; import java.util.*; import tmltranslator.*; -import myutil.*; public class TMLSDMessage extends TMLElement { diff --git a/src/tmltranslator/tmlcp/TMLSDMessageManipulation.java b/src/tmltranslator/tmlcp/TMLSDMessageManipulation.java index a462912a06..87ab61135b 100755 --- a/src/tmltranslator/tmlcp/TMLSDMessageManipulation.java +++ b/src/tmltranslator/tmlcp/TMLSDMessageManipulation.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLSDMessageManipulation extends TMLSDElement { private TMLSDMessage msg; diff --git a/src/tmltranslator/tmlcp/TMLSDReceiveMessage.java b/src/tmltranslator/tmlcp/TMLSDReceiveMessage.java index 19e4975682..7e2b9c4450 100755 --- a/src/tmltranslator/tmlcp/TMLSDReceiveMessage.java +++ b/src/tmltranslator/tmlcp/TMLSDReceiveMessage.java @@ -46,11 +46,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLSDReceiveMessage extends TMLSDMessageManipulation { public TMLSDReceiveMessage(TMLSDMessage _msg, String _name, Object _referenceObject) { diff --git a/src/tmltranslator/tmlcp/TMLSDSendMessage.java b/src/tmltranslator/tmlcp/TMLSDSendMessage.java index 6b069d02cf..3256a29fac 100755 --- a/src/tmltranslator/tmlcp/TMLSDSendMessage.java +++ b/src/tmltranslator/tmlcp/TMLSDSendMessage.java @@ -45,11 +45,6 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp; -import java.util.*; - - -import myutil.*; - public class TMLSDSendMessage extends TMLSDMessageManipulation { public TMLSDSendMessage(TMLSDMessage _msg, String _name, Object _referenceObject) { diff --git a/src/tmltranslator/tmlcp/UndeclaredDiagramException.java b/src/tmltranslator/tmlcp/UndeclaredDiagramException.java index 90a9720257..69eb7be006 100644 --- a/src/tmltranslator/tmlcp/UndeclaredDiagramException.java +++ b/src/tmltranslator/tmlcp/UndeclaredDiagramException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UndeclaredDiagramException extends Exception -{ +public class UndeclaredDiagramException extends Exception { public UndeclaredDiagramException() { super( "TMLCP COMPILER ERROR: undeclared diagram" ); } public UndeclaredDiagramException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tmlcp/UndeclaredInstanceException.java b/src/tmltranslator/tmlcp/UndeclaredInstanceException.java index 679e6a65c2..7ab4cfa18b 100644 --- a/src/tmltranslator/tmlcp/UndeclaredInstanceException.java +++ b/src/tmltranslator/tmlcp/UndeclaredInstanceException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UndeclaredInstanceException extends Exception -{ +public class UndeclaredInstanceException extends Exception { public UndeclaredInstanceException() { super( "TMLCP COMPILER ERROR: undeclared instance" ); } public UndeclaredInstanceException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tmlcp/UndeclaredVariableException.java b/src/tmltranslator/tmlcp/UndeclaredVariableException.java index 4badb7c4a6..7bd6e717c1 100644 --- a/src/tmltranslator/tmlcp/UndeclaredVariableException.java +++ b/src/tmltranslator/tmlcp/UndeclaredVariableException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UndeclaredVariableException extends Exception -{ +public class UndeclaredVariableException extends Exception { public UndeclaredVariableException() { super( "TMLCP COMPILER ERROR: undeclared variable" ); } public UndeclaredVariableException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tmlcp/UndefinedDiagramException.java b/src/tmltranslator/tmlcp/UndefinedDiagramException.java index 8c38dd0a84..fe271c3181 100644 --- a/src/tmltranslator/tmlcp/UndefinedDiagramException.java +++ b/src/tmltranslator/tmlcp/UndefinedDiagramException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UndefinedDiagramException extends Exception -{ +public class UndefinedDiagramException extends Exception { public UndefinedDiagramException() { super( "TMLCP COMPILER ERROR: undeclared diagram" ); } public UndefinedDiagramException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tmlcp/UndefinedVariableException.java b/src/tmltranslator/tmlcp/UndefinedVariableException.java index bf852a9a4f..ed2b261576 100644 --- a/src/tmltranslator/tmlcp/UndefinedVariableException.java +++ b/src/tmltranslator/tmlcp/UndefinedVariableException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UndefinedVariableException extends Exception -{ +public class UndefinedVariableException extends Exception { public UndefinedVariableException() { super( "TMLCP COMPILER ERROR: undefined variable" ); } public UndefinedVariableException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tmlcp/UninitializedVariableException.java b/src/tmltranslator/tmlcp/UninitializedVariableException.java index acea485cac..6fa7269e49 100644 --- a/src/tmltranslator/tmlcp/UninitializedVariableException.java +++ b/src/tmltranslator/tmlcp/UninitializedVariableException.java @@ -45,14 +45,13 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator.tmlcp;; -public class UninitializedVariableException extends Exception -{ +public class UninitializedVariableException extends Exception { public UninitializedVariableException() { super( "TMLCP COMPILER ERROR: uninitialized variable" ); } public UninitializedVariableException( String message ) { - super( message ); + super( message ); } } diff --git a/src/tmltranslator/tomappingsystemc2/DiploSimulatorCodeGenerator.java b/src/tmltranslator/tomappingsystemc2/DiploSimulatorCodeGenerator.java index 0e3b1f90c2..6607206caa 100644 --- a/src/tmltranslator/tomappingsystemc2/DiploSimulatorCodeGenerator.java +++ b/src/tmltranslator/tomappingsystemc2/DiploSimulatorCodeGenerator.java @@ -108,9 +108,11 @@ public class DiploSimulatorCodeGenerator implements IDiploSimulatorCodeGenerator DiploSimulatorCodeGenerator(TMLMapping _tmlmapping, List<EBRDD> _ebrdds, List<TEPE> _tepes) { tmlmapping = _tmlmapping; - if (tmlmapping == null) { - TraceManager.addDev("null mapping"); - } + + if ( tmlmapping == null ) { + throw new IllegalArgumentException( "TML Mapping is NULL." ); + } + tmlmapping.handleCPs(); tmlmapping.removeForksAndJoins(); tmlmapping.makeMinimumMapping(); diff --git a/src/ui/ad/TActivityDiagramPanel.java b/src/ui/ad/TActivityDiagramPanel.java index f02e8928f3..3de459a5f7 100755 --- a/src/ui/ad/TActivityDiagramPanel.java +++ b/src/ui/ad/TActivityDiagramPanel.java @@ -56,6 +56,7 @@ public class TActivityDiagramPanel extends TDiagramPanel implements ActivityDiag public TActivityDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); + addComponent(400, 50, TGComponentManager.TAD_START_STATE, false); } diff --git a/src/ui/avatardd/ADDConnector.java b/src/ui/avatardd/ADDConnector.java index 628b436323..f6c95c0f56 100755 --- a/src/ui/avatardd/ADDConnector.java +++ b/src/ui/avatardd/ADDConnector.java @@ -153,7 +153,6 @@ public class ADDConnector extends TGConnector { return true; } - protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); @@ -161,7 +160,6 @@ public class ADDConnector extends TGConnector { sb.append("</extraparam>\n"); return new String(sb); } - @Override public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ diff --git a/src/ui/ncdd/NCConnectorNode.java b/src/ui/ncdd/NCConnectorNode.java index 173ec68838..29b87c14a9 100755 --- a/src/ui/ncdd/NCConnectorNode.java +++ b/src/ui/ncdd/NCConnectorNode.java @@ -46,8 +46,6 @@ knowledge of the CeCILL license and that you accept its terms. package ui.ncdd; - - import java.awt.*; import javax.swing.*; import java.util.*; @@ -72,7 +70,7 @@ public class NCConnectorNode extends TGConnector implements WithAttributes { protected String interfaceName; - public NCConnectorNode(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) { + public NCConnectorNode(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; diff --git a/src/ui/tmldd/TMLArchiCPNode.java b/src/ui/tmldd/TMLArchiCPNode.java index 5917fddc61..9f8861642a 100755 --- a/src/ui/tmldd/TMLArchiCPNode.java +++ b/src/ui/tmldd/TMLArchiCPNode.java @@ -209,22 +209,29 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow GraphicLib.centerOnParent( dialog, 750, 500 ); dialog.setVisible( true ); // blocked until dialog has been closed //setJDialogOptions(jdab); + + // Issue #36 + if( dialog.hasBeenCancelled() ) { + return false; + } + name = dialog.getNodeName(); mappedUnits = dialog.getMappedUnits(); cpMEC = dialog.getCPMEC(); transferType1 = dialog.getTransferTypes().get(0); transferType2 = dialog.getTransferTypes().get(1); assignedAttributes = dialog.getAssignedAttributes(); - TraceManager.addDev( "name " + name ); - TraceManager.addDev( "mappedUnits " + mappedUnits ); - TraceManager.addDev( "cpMEC " + cpMEC ); - TraceManager.addDev( "transferType1 " + transferType1 ); - TraceManager.addDev( "transferType2 " + transferType2 ); - TraceManager.addDev( "assignedAttributes " + assignedAttributes.toString() ); - - if( !dialog.isRegularClose() ) { - return false; - } +// TraceManager.addDev( "name " + name ); +// TraceManager.addDev( "mappedUnits " + mappedUnits ); +// TraceManager.addDev( "cpMEC " + cpMEC ); +// TraceManager.addDev( "transferType1 " + transferType1 ); +// TraceManager.addDev( "transferType2 " + transferType2 ); +// TraceManager.addDev( "assignedAttributes " + assignedAttributes.toString() ); + + // Issue #36 +// if( !dialog.isRegularClose() ) { +// return false; +// } if( dialog.getNodeName().length() != 0 ) { tmpName = dialog.getNodeName(); @@ -429,25 +436,32 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow return completeName; } - public Vector<String> getAssignedAttributes() { - + public Vector<String> getAssignedAttributes() { Vector<String> vectorToReturn; switch( cpMEC ) { case CPMEC.MemoryCopy: - TraceManager.addDev( "**** ASSIGNED ATTRIBUTES ****\\" + assignedAttributes ); - vectorToReturn = CpuMemoryCopyMEC.sortAttributes( assignedAttributes ); + //TraceManager.addDev( "**** ASSIGNED ATTRIBUTES ****\\" + assignedAttributes ); + vectorToReturn = CPMEC.getSortedAttributeValues( assignedAttributes, CpuMemoryCopyMEC.ORDERED_ATTRIBUTE_NAMES ); + break; case CPMEC.SingleDMA: - vectorToReturn = SingleDmaMEC.sortAttributes( assignedAttributes ); + vectorToReturn = CPMEC.getSortedAttributeValues( assignedAttributes, SingleDmaMEC.ORDERED_ATTRIBUTE_NAMES ); + //vectorToReturn = SingleDmaMEC.sortAttributes( assignedAttributes ); + break; case CPMEC.DoubleDMA: - vectorToReturn = DoubleDmaMEC.sortAttributes( assignedAttributes ); + vectorToReturn = CPMEC.getSortedAttributeValues( assignedAttributes, DoubleDmaMEC.ORDERED_ATTRIBUTE_NAMES ); + //vectorToReturn = DoubleDmaMEC.sortAttributes( assignedAttributes ); + break; default: - TraceManager.addDev( "ERROR in returning assignedAttributes" ); - vectorToReturn = assignedAttributes; - break; + throw new IllegalArgumentException( "Unknown communication pattern " + cpMEC + "." ); + //TraceManager.addDev( "ERROR in returning assignedAttributes" ); + //vectorToReturn = assignedAttributes; + + //break; } + return vectorToReturn; } diff --git a/src/ui/window/JDialogCommPatternMapping.java b/src/ui/window/JDialogCommPatternMapping.java index 52bfbc0b3b..812dd6b991 100644 --- a/src/ui/window/JDialogCommPatternMapping.java +++ b/src/ui/window/JDialogCommPatternMapping.java @@ -72,7 +72,8 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe private final static String EMPTY_CPS_LIST = "No CPs to reference"; private final static String EMPTY_INSTANCES_LIST = "No instances to map"; - private boolean regularClose; + // Issue #36 only the cancel boolean is needed + //private boolean regularClose; private Frame frame; private TMLArchiCPNode cp; @@ -689,13 +690,13 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe c5.anchor = GridBagConstraints.LINE_START; c5.insets = lblInsets; pnlCodeGen.add( new JLabel( "Extension Construct:" ), c5 ); - cpMECsCB = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.cpTypes ) ) ); + cpMECsCB = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.CP_TYPES ) ) ); if( cpMEC.equals( "VOID" ) || cpMEC.equals( "" ) ) { cpMECsCB.setSelectedIndex( 0 ); } else { - cpMECsCB.setSelectedIndex( new Vector<String>( Arrays.asList( CPMEC.cpTypes ) ).indexOf( cpMEC ) ); + cpMECsCB.setSelectedIndex( new Vector<String>( Arrays.asList( CPMEC.CP_TYPES ) ).indexOf( cpMEC ) ); } cpMECsCB.addActionListener( new ActionListener() { @@ -717,7 +718,7 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe // c5.weightx = 1.0; // c5.fill = GridBagConstraints.HORIZONTAL; pnlCodeGen.add( new JLabel( "Type of DMA Transfer n.1:" ), c5 ); - transferTypeCB1 = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.transferTypes ) ) ); + transferTypeCB1 = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.TRANSFER_TYPES ) ) ); if( transferType1 == -1 ) { transferTypeCB1.setSelectedIndex( 0 ); @@ -749,7 +750,7 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe // c5.anchor = GridBagConstraints.LINE_START; c5.gridwidth = 1; pnlCodeGen.add( new JLabel( "Type of DMA Transfer n.2:" ), c5 ); - transferTypeCB2 = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.transferTypes ) ) ); + transferTypeCB2 = new JComboBox<String>( new Vector<String>( Arrays.asList( CPMEC.TRANSFER_TYPES ) ) ); if( transferType2 == -1 ) { transferTypeCB2.setSelectedIndex( 0 ); @@ -1460,12 +1461,12 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe } public void closeDialog() { - regularClose = true; + //regularClose = true; cancelled = false; name = nameOfCP.getText(); cpMEC = (String)cpMECsCB.getSelectedItem(); - transferType1 = Arrays.asList( CPMEC.transferTypes ).indexOf( (String)transferTypeCB1.getSelectedItem() ); - transferType2 = Arrays.asList( CPMEC.transferTypes ).indexOf( (String)transferTypeCB2.getSelectedItem() ); + transferType1 = Arrays.asList( CPMEC.TRANSFER_TYPES ).indexOf( (String)transferTypeCB1.getSelectedItem() ); + transferType2 = Arrays.asList( CPMEC.TRANSFER_TYPES ).indexOf( (String)transferTypeCB2.getSelectedItem() ); dispose(); } @@ -1551,10 +1552,10 @@ public class JDialogCommPatternMapping extends JDialog /* implements ActionListe } return (String)( communicationPatternsCB.getSelectedItem() ); } - - public boolean isRegularClose() { - return regularClose; - } +// +// public boolean isRegularClose() { +// return regularClose; +// } public Vector<String> getMappedUnits() { return mappedUnitsSL; -- GitLab