diff --git a/src/TMLTranslator.java b/src/TMLTranslator.java index fcea25fe76332a74c40c473e9c19b8e1350c4663..734e86ddab1d7c1cbea81eb7d442806ee2d0b9e6 100755 --- a/src/TMLTranslator.java +++ b/src/TMLTranslator.java @@ -252,6 +252,41 @@ public class TMLTranslator { return ret; } + public static boolean convertToLOTOSFromMapping() { + Mapping2TIF m2tif = new Mapping2TIF(tmap); + m2tif.setShowSampleChannels(false); + m2tif.setShowChannels(true); + m2tif.setShowEvents(true); + m2tif.setShowRequests(true); + m2tif.setShowExecs(false); + m2tif.setShowBusTransfers(false); + m2tif.setShowScheduling(false); + m2tif.setIsClocked(false); + m2tif.setTickValue("10"); + m2tif.setIsEndClocked(false); + m2tif.setIsCountTick(true); + m2tif.hasMaxCountTick(false); + m2tif.setShowTaskState(false); + m2tif.setShowChannelState(false); + m2tif.setShowBlockedCPU(false); + m2tif.setShowTerminateCPUs(true); + m2tif.setShowBranching(false); + m2tif.setRandomTasks(false); + TURTLEModeling tm = m2tif.generateTURTLEModeling(); + + TURTLETranslator tt = new TURTLETranslator(tm); + outputData = tt.generateLOTOS(true); + try { + FileOutputStream fos = new FileOutputStream(outputFile); + fos.write(outputData.getBytes()); + fos.close(); + } catch (Exception e) { + System.out.println("Error when writing LOTOS file"); + return false; + } + return true; + } + public static boolean convertToLOTOS() { TML2TURTLE totif = new TML2TURTLE(tmlm); TURTLEModeling tm = totif.generateTURTLEModeling(); @@ -422,8 +457,12 @@ public class TMLTranslator { switch(conversionType) { case 0: - convert = convertToLOTOS(); - break; + if (tmap == null) { + convert = convertToLOTOS(); + } else { + convert = convertToLOTOSFromMapping(); + } + break; case 1: convert = convertToUPPAAL(); break; diff --git a/src/compiler/tmlgrammar/JJTTMLExprParserState.java b/src/compiler/tmlgrammar/JJTTMLExprParserState.java index c74715f1ae77b560ab812ef8946f493a3099ef7b..8efd22737493180c179c0735e4142c47e9587887 100755 --- a/src/compiler/tmlgrammar/JJTTMLExprParserState.java +++ b/src/compiler/tmlgrammar/JJTTMLExprParserState.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree: Do not edit this line. ./JJTTMLExprParserState.java */ class JJTTMLExprParserState { diff --git a/src/compiler/tmlgrammar/Node.java b/src/compiler/tmlgrammar/Node.java index 49ee9c6a827c082b675c4f9cb2972979f9d25756..3e3aa7e9c16aca150a0137568a6c43980ac14ee9 100755 --- a/src/compiler/tmlgrammar/Node.java +++ b/src/compiler/tmlgrammar/Node.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree: Do not edit this line. Node.java */ /* All AST nodes must implement this interface. It provides basic diff --git a/src/compiler/tmlgrammar/ParseException.java b/src/compiler/tmlgrammar/ParseException.java index 9a00bdf4c94394c52a6dc6c72af71c9e3533441d..0720de8b433c6dfd269684123975e323d9b5ad52 100755 --- a/src/compiler/tmlgrammar/ParseException.java +++ b/src/compiler/tmlgrammar/ParseException.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ /** * This exception is thrown when parse errors are encountered. diff --git a/src/compiler/tmlgrammar/SimpleCharStream.java b/src/compiler/tmlgrammar/SimpleCharStream.java index 02b1bc85b9f5894a5e01a8816481a85335691a8c..85392c2d3289417152ed6530f6a3a12de8a87ba6 100755 --- a/src/compiler/tmlgrammar/SimpleCharStream.java +++ b/src/compiler/tmlgrammar/SimpleCharStream.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */ /** * An implementation of interface CharStream, where the stream is assumed to diff --git a/src/compiler/tmlgrammar/SimpleNode.java b/src/compiler/tmlgrammar/SimpleNode.java index 5d9b3fa994edc0b1b68300ed0a1a6500e1f6b809..9e350500ff8974020893be746a9592518af888df 100755 --- a/src/compiler/tmlgrammar/SimpleNode.java +++ b/src/compiler/tmlgrammar/SimpleNode.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille ludovic.apvrille AT enst.fr diff --git a/src/compiler/tmlgrammar/TMLExprParser.java b/src/compiler/tmlgrammar/TMLExprParser.java index 43f4f3fed69210fc5dede5bcc393dc09f2abadfb..7a9bb9c2f7b0af81b25d8739863b62a0a0b13c82 100755 --- a/src/compiler/tmlgrammar/TMLExprParser.java +++ b/src/compiler/tmlgrammar/TMLExprParser.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree&JavaCC: Do not edit this line. TMLExprParser.java */ public class TMLExprParser/*@bgen(jjtree)*/implements TMLExprParserTreeConstants, TMLExprParserConstants {/*@bgen(jjtree)*/ protected JJTTMLExprParserState jjtree = new JJTTMLExprParserState();private int x; diff --git a/src/compiler/tmlgrammar/TMLExprParserConstants.java b/src/compiler/tmlgrammar/TMLExprParserConstants.java index e375c0bd8866e7216e0accfc08f9ffabc0ea5199..8ff7476b927269a768dd5a259536cc676c97ac86 100755 --- a/src/compiler/tmlgrammar/TMLExprParserConstants.java +++ b/src/compiler/tmlgrammar/TMLExprParserConstants.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree&JavaCC: Do not edit this line. TMLExprParserConstants.java */ public interface TMLExprParserConstants { diff --git a/src/compiler/tmlgrammar/TMLExprParserTokenManager.java b/src/compiler/tmlgrammar/TMLExprParserTokenManager.java index 866629fe53528829f2281f216027882ee8e0835d..be783ec4611a352e605da7dfd12a815b889d704c 100755 --- a/src/compiler/tmlgrammar/TMLExprParserTokenManager.java +++ b/src/compiler/tmlgrammar/TMLExprParserTokenManager.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree&JavaCC: Do not edit this line. TMLExprParserTokenManager.java */ public class TMLExprParserTokenManager implements TMLExprParserConstants diff --git a/src/compiler/tmlgrammar/TMLExprParserTreeConstants.java b/src/compiler/tmlgrammar/TMLExprParserTreeConstants.java index 8efbc784625707ffac5dcb73049001774fb0dad4..4b13b1f8ff4c4c0f7e00359fc80617ed5b65b9d5 100755 --- a/src/compiler/tmlgrammar/TMLExprParserTreeConstants.java +++ b/src/compiler/tmlgrammar/TMLExprParserTreeConstants.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JJTree: Do not edit this line. ./TMLExprParserTreeConstants.java */ public interface TMLExprParserTreeConstants diff --git a/src/compiler/tmlgrammar/Token.java b/src/compiler/tmlgrammar/Token.java index ba9eb4e77d7b9ea20b789ff992c1d0e45d7d6e62..7767a998c204699b5317ba6cd73f71aaa445a9a7 100755 --- a/src/compiler/tmlgrammar/Token.java +++ b/src/compiler/tmlgrammar/Token.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ /** * Describes the input token stream. diff --git a/src/compiler/tmlgrammar/TokenMgrError.java b/src/compiler/tmlgrammar/TokenMgrError.java index 2322ddd1ed280947bcdcdbbadffa79feff3c3963..e679c28dbfa7b524cb7106a4fac7304cb6e041bd 100755 --- a/src/compiler/tmlgrammar/TokenMgrError.java +++ b/src/compiler/tmlgrammar/TokenMgrError.java @@ -1,39 +1,3 @@ -/**Copyright GET / ENST / Ludovic Apvrille - -ludovic.apvrille at enst.fr - -This software is a computer program whose purpose is to edit TURTLE -diagrams, generate RT-LOTOS code from these TURTLE diagrams, and at -last to analyse results provided from externalm formal validation tools. - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms.*/ - -package compiler.tmlparser; - /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ public class TokenMgrError extends Error { diff --git a/src/tmltranslator/TMLArchiTextSpecification.java b/src/tmltranslator/TMLArchiTextSpecification.java index 811f6a342868423283fb3a9c449ecf29e0416da2..b852ee9183e2a70dc0d002a18901f7baf903e9f6 100755 --- a/src/tmltranslator/TMLArchiTextSpecification.java +++ b/src/tmltranslator/TMLArchiTextSpecification.java @@ -64,7 +64,7 @@ public class TMLArchiTextSpecification { private ArrayList<TMLTXTError> errors; private ArrayList<TMLTXTError> warnings; - private String keywords[] = {"NODE", "CPU", "SET", "BUS", "LINK", "BRIDGE", "MEMORY"}; + private String keywords[] = {"NODE", "CPU", "SET", "BUS", "LINK", "BRIDGE", "MEMORY", "MASTERCLOCKFREQUENCY"}; private String nodetypes[] = {"CPU", "BUS", "LINK", "BRIDGE", "MEMORY", "HWA"}; private String cpuparameters[] = {"byteDataSize", "pipelineSize", "goIdleTime", "taskSwitchingTime", "branchingPredictionPenalty", "schedulingPolicy", "execiTime"}; private String linkparameters[] = {"bus", "node", "priority"}; @@ -111,60 +111,6 @@ public class TMLArchiTextSpecification { return warnings; } - /*public void indent() { - indent(4); - } - - public void indent(int _nbDec) { - int dec = 0; - int indexEnd; - String output = ""; - String tmp; - int nbOpen = 0; - int nbClose = 0; - - while ( (indexEnd = spec.indexOf('\n')) > -1) { - tmp = spec.substring(0, indexEnd+1); - try { - spec = spec.substring(indexEnd+1, spec.length()); - } catch (Exception e) { - spec = ""; - } - nbOpen = nbOfOpen(tmp); - nbClose = nbOfClose(tmp); - dec -= nbClose * _nbDec; - tmp = Conversion.addHead(tmp.trim(), ' ', dec); - dec += nbOpen * _nbDec; - //System.out.println("dec=" + dec); - output += tmp + "\n"; - } - spec = output; - }*/ - - /*private int nbOfOpen(String tmp) { - return nbOf(tmp, beginArray); - } - - private int nbOfClose(String tmp) { - return nbOf(tmp, endArray); - }*/ - - /*private int nbOf(String _tmp, String[] array) { - String tmp; - int size; - - for(int i=0; i<array.length; i++) { - if (_tmp.startsWith(array[i])) { - tmp = _tmp.substring(array[i].length(), _tmp.length()); - //System.out.println("tmp=" + tmp + " _tmp" + _tmp + " array=" + array[i]); - if ((tmp.length() == 0) || (tmp.charAt(0) == ' ') || (tmp.charAt(0) == '(') || (tmp.charAt(0) == '\n')) { - //System.out.println("Returning 1!!"); - return 1; - } - } - } - return 0; - }*/ public String toString() { return spec; @@ -172,7 +118,11 @@ public class TMLArchiTextSpecification { public String toTextFormat(TMLArchitecture _tmla) { tmla = _tmla; - spec = makeNodes(tmla); + + spec = "// Master clock frequency - in MHz" + CR; + spec += "MASTERCLOCKFREQUENCY " + tmla.getMasterClockFrequency() + CR + CR; + + spec += makeNodes(tmla); spec += makeLinks(tmla); return spec; //indent(); @@ -246,6 +196,8 @@ public class TMLArchiTextSpecification { code += set + "byteDataSize " + memory.byteDataSize + CR; } + code += CR; + } return code; } @@ -383,9 +335,43 @@ public class TMLArchiTextSpecification { String error; String params; String id; + int value; + + // Master clock frequency + if(isInstruction("MASTERCLOCKFREQUENCY", _split[0])) { + + if (_split.length != 2) { + error = "A master clock frequency must be declared with 1 parameter, and not " + (_split.length - 1) ; + addError(0, _lineNb, 0, error); + return -1; + } + + if (!checkParameter("NODE", _split, 1, 1, _lineNb)) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + try { + value = Integer.decode(_split[1]).intValue(); + } catch (Exception e) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + if (value < 0) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + System.out.println("Master clock frequency = " + value); + tmla.setMasterClockFrequency(value); + // NODE - if(isInstruction("NODE", _split[0])) { + } else if(isInstruction("NODE", _split[0])) { if (_split.length != 3) { error = "A node must be declared with 3 parameters, and not " + (_split.length - 1) ; @@ -604,8 +590,9 @@ public class TMLArchiTextSpecification { } // SET // Other command + //System.out.println("ERROR hm hm"); if((_split[0].length() > 0) && (!(isInstruction(_split[0])))) { - error = "Syntax error: unrecognized instruction."; + error = "Syntax error: unrecognized instruction: " + _split[0]; addError(0, _lineNb, 0, error); return -1; diff --git a/src/tmltranslator/TMLArchitecture.java b/src/tmltranslator/TMLArchitecture.java index 0a05b40baa1df312fbb513da4e4f40c7356f01dd..85279aebb03d8fe1a66b0605b15b8622bb8b90d8 100755 --- a/src/tmltranslator/TMLArchitecture.java +++ b/src/tmltranslator/TMLArchitecture.java @@ -51,6 +51,7 @@ import java.util.*; public class TMLArchitecture { private ArrayList<HwNode> hwnodes; private ArrayList<HwLink> hwlinks; // Between buses and other component + private int masterClockFrequency = 200; // in MHz public TMLArchitecture() { @@ -61,6 +62,14 @@ public class TMLArchitecture { hwnodes = new ArrayList<HwNode>(); hwlinks = new ArrayList<HwLink>(); } + + public void setMasterClockFrequency(int value) { + masterClockFrequency = value; + } + + public int getMasterClockFrequency() { + return masterClockFrequency; + } public void addHwNode(HwNode _node) { hwnodes.add(_node); @@ -107,13 +116,12 @@ public class TMLArchitecture { return null; } - public HwLink getLinkByHwNode(HwNode node){ + public ArrayList<HwLink> getLinkByHwNode(HwNode node){ + ArrayList<HwLink> tempList=new ArrayList<HwLink>(); for(HwLink link: hwlinks) { - if (link.hwnode==node) { - return link; - } + if (link.hwnode==node) tempList.add(link); } - return null; + return tempList; } public HwLink getHwLinkByHwNode(HwNode node){ diff --git a/src/tmltranslator/TMLAttribute.java b/src/tmltranslator/TMLAttribute.java index 07b0d3172ba25efe4e7a78e415c5ec265dce14b7..5857740efd7e6bdad0e6b232764f864544742e8a 100755 --- a/src/tmltranslator/TMLAttribute.java +++ b/src/tmltranslator/TMLAttribute.java @@ -81,7 +81,7 @@ public class TMLAttribute { } public String getInitialValue() { - return initialValue; + return initialValue; } diff --git a/src/tmltranslator/TMLMappingTextSpecification.java b/src/tmltranslator/TMLMappingTextSpecification.java index 18267a6c3913b12260489f2b711ce7ed4b0494fd..037487348db2f817f04d747cce49721c4d45061f 100755 --- a/src/tmltranslator/TMLMappingTextSpecification.java +++ b/src/tmltranslator/TMLMappingTextSpecification.java @@ -654,7 +654,7 @@ public class TMLMappingTextSpecification { // Other command if((_split[0].length() > 0) && (!(isInstruction(_split[0])))) { - error = "Syntax error: unrecognized instruction."; + error = "Syntax error in mapping information: unrecognized instruction: " + _split[0]; addError(0, _lineNb, 0, error, _line); return -1; diff --git a/src/tmltranslator/TMLModeling.java b/src/tmltranslator/TMLModeling.java index 47e8d8c02e1b7bd68ae658f58ed1f0db32d6ff35..614b37151f9d6140c394a14564d3eb34c0d92a62 100755 --- a/src/tmltranslator/TMLModeling.java +++ b/src/tmltranslator/TMLModeling.java @@ -535,6 +535,7 @@ public class TMLModeling { TMLActivity activity = task.getActivityDiagram(); optimizeVariables(task, activity, warnings); optimizeMergeEXECs(activity); + optimizeMergeDELAYSs(activity); } /** @@ -603,6 +604,7 @@ public class TMLModeling { TMLForLoop tmlloop; TMLActivityElementChannel tmlaec; TMLSendRequest tmlasr; + TMLSendEvent tmlne; TMLRandom tmlrandom; int i, j; int usage = 0; @@ -739,6 +741,13 @@ public class TMLModeling { usage = analyzeStringWithParam(tmlasr.getParam(j), name); } } + } else if (element instanceof TMLSendEvent) { + tmlne = (TMLSendEvent)element; + for(j=0; j<tmlne.getNbOfParams(); j++) { + if (usage == 0) { + usage = analyzeStringWithParam(tmlne.getParam(j), name); + } + } } } //System.out.println("After element: " + element + " usage=" + usage); @@ -979,6 +988,42 @@ public class TMLModeling { } } + + /** + * Concatenate Delay operations + */ + public void optimizeMergeDELAYSs(TMLActivity activity) { + TMLActivityElement elt0, elt1; + String action0, action1; + TMLDelay del0, del1; + + + for(int i=0; i<activity.nElements(); i++) { + elt0 = activity.get(i); + if ((elt0 instanceof TMLDelay) && (elt0.getNbNext() == 1)) { + elt1 = elt0.getNextElement(0); + if (elt1 instanceof TMLDelay) { + del1 = (TMLDelay)elt1; + del0 = (TMLDelay)elt0; + + if (del1.getUnit().equals(del0.getUnit())) { + // We delete the second i.e. elt1 + activity.removeElement(elt1); + + // We link the first one to the nexts of the second one + elt0.setNexts(elt1.getNexts()); + + // We modify the value of elt0 + del0.setMinDelay(addActions(del0.getMinDelay(), del1.getMinDelay())); + del0.setMaxDelay(addActions(del0.getMaxDelay(), del1.getMaxDelay())); + + i = -1; + } + } + } + } + } + public void setNewNexts(TMLActivity activity, TMLActivityElement elt0, TMLActivityElement elt1) { if (elt0 == elt1) { diff --git a/src/tmltranslator/TMLSyntaxChecking.java b/src/tmltranslator/TMLSyntaxChecking.java index bb989070d29fec8aadb098e4f58d27371300374a..c4807bf0855389479955a859af2579ab9f629ecd 100755 --- a/src/tmltranslator/TMLSyntaxChecking.java +++ b/src/tmltranslator/TMLSyntaxChecking.java @@ -64,6 +64,7 @@ public class TMLSyntaxChecking { private final String VARIABLE_ERROR = "variable is not used according to its type"; private final String UNDECLARED_VARIABLE = "unknown variable"; private final String SYNTAX_ERROR_VARIABLE_EXPECTED = "syntax error (variable expected)"; + private final String TIME_UNIT_ERROR = "unknown time unit"; private ArrayList<TMLError> errors; @@ -222,11 +223,20 @@ public class TMLSyntaxChecking { parsing(t, elt, "actionnat", action); } else if (elt instanceof TMLActivityElementWithIntervalAction) { + //System.out.println("Parsing TMLActivityElementWithIntervalAction"); action = ((TMLActivityElementWithIntervalAction)elt).getMinDelay(); parsing(t, elt, "actionnat", action); action = ((TMLActivityElementWithIntervalAction)elt).getMaxDelay(); parsing(t, elt, "actionnat", action); + if (elt instanceof TMLDelay) { + action = ((TMLDelay)elt).getUnit().trim(); + + if (!(TMLDelay.isAValidUnit(action))) { + addError(t, elt, TIME_UNIT_ERROR + "in expression " + action, TMLError.ERROR_BEHAVIOR); + } + } + } else if (elt instanceof TMLActivityElementChannel) { action = ((TMLActivityElementChannel)elt).getNbOfSamples(); parsing(t, elt, "actionnat", action); diff --git a/src/tmltranslator/TMLTextSpecification.java b/src/tmltranslator/TMLTextSpecification.java index 5b5cd981e7624caf522ad7bcd2c45ab38a7900e5..e6935cd90083133f452089c18f4dd51cd3bdc100 100755 --- a/src/tmltranslator/TMLTextSpecification.java +++ b/src/tmltranslator/TMLTextSpecification.java @@ -76,7 +76,7 @@ public class TMLTextSpecification { private String keywords[] = {"BOOL", "INT", "NAT", "CHANNEL", "EVENT", "REQUEST", "BRBW", "NBRNBW", "BRNBW", "INF", "NIB", "NINB", "TASK", "ENDTASK", "IF", "ELSE", "ELSEIF", "ENDIF", "FOR", "ENDFOR", - "SELECTEVT", "CASE", "ENDSELECTEVT", "ENDCASE", "WRITE", "READ", "WAIT", "NOTIFY", "NOTIFIED", "RAND", "CASERAND", "ENDRAND", "ENDCASERAND", "EXECI", "EXECC", "RANDOM"}; + "SELECTEVT", "CASE", "ENDSELECTEVT", "ENDCASE", "WRITE", "READ", "WAIT", "NOTIFY", "NOTIFIED", "RAND", "CASERAND", "ENDRAND", "ENDCASERAND", "EXECI", "EXECC", "DELAY", "RANDOM"}; private String channeltypes[] = {"BRBW", "NBRNBW", "BRNBW"}; private String eventtypes[] = {"INF", "NIB", "NINB"}; @@ -271,6 +271,7 @@ public class TMLTextSpecification { TMLEvent evt; TMLRandom random; int i; + String tmp1, tmp2; if (elt instanceof TMLStartState) { return makeBehavior(task, elt.getNextElement(0)); @@ -294,6 +295,16 @@ public class TMLTextSpecification { code = "EXECC" + SP + modifyString(((TMLExecCInterval)elt).getMinDelay()) + SP + modifyString(((TMLExecCInterval)elt).getMaxDelay()) + CR; return code + makeBehavior(task, elt.getNextElement(0)); + } else if (elt instanceof TMLDelay) { + tmp1 = ((TMLDelay)elt).getMinDelay(); + tmp2 = ((TMLDelay)elt).getMaxDelay(); + if (tmp1.compareTo(tmp2) == 0) { + code = "DELAY" + SP + modifyString(((TMLDelay)elt).getMinDelay()) + SP + modifyString(((TMLDelay)elt).getUnit()) + CR; + } else { + code = "DELAY" + SP + modifyString(((TMLDelay)elt).getMinDelay()) + SP + modifyString(((TMLDelay)elt).getMaxDelay()) + SP + modifyString(((TMLDelay)elt).getUnit()) + CR; + } + return code + makeBehavior(task, elt.getNextElement(0)); + } else if (elt instanceof TMLForLoop) { tmlfl = (TMLForLoop)elt; code = "FOR(" + tmlfl.getInit() + SC + SP; @@ -920,6 +931,8 @@ public class TMLTextSpecification { TMLAttribute ta = new TMLAttribute(_split[1], new TMLType(TMLType.getType(_split[0]))); if (_split.length > 2) { ta.initialValue = _split[3]; + } else { + ta.initialValue = ta.getDefaultInitialValue(); } task.addAttribute(ta); } // Attribute declaration @@ -1923,10 +1936,63 @@ public class TMLTextSpecification { } } // EXECC + // DELAY + if((isInstruction("DELAY", _split[0]))) { + + if (!inTask) { + error = "A DELAY operation may only be performed in a task body"; + addError(0, _lineNb, 0, error); + return -1; + } + + inDec = false; + inTask = true; + inTaskDec = false; + 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) ; + addError(0, _lineNb, 0, error); + return -1; + } + + if (_split.length == 3) { + if (!checkParameter("DELAY", _split, 2, 0, _lineNb)) { + error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))" ; + addError(0, _lineNb, 0, error); + return -1; + } + } + + if (_split.length == 4) { + if (!checkParameter("DELAY", _split, 3, 0, _lineNb)) { + error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))" ; + addError(0, _lineNb, 0, error); + return -1; + } + } + + TMLDelay delay = new TMLDelay("delay", null); + delay.setMinDelay(_split[1]); + if (_split.length == 3) { + delay.setMaxDelay(_split[1]); + delay.setUnit(_split[2]); + } else { + delay.setMaxDelay(_split[2]); + delay.setUnit(_split[3]); + } + + + tmlae.addNext(delay); + task.getActivityDiagram().addElement(delay); + tmlae = delay; + + } // EXECC + // Other command if((_split[0].length() > 0) && (!(isInstruction(_split[0])))) { if (!inTask) { - error = "Syntax error: unrecognized instruction."; + error = "Syntax error in TML modeling: unrecognized instruction:" + _split[0]; addError(0, _lineNb, 0, error); return -1; } @@ -1955,6 +2021,7 @@ public class TMLTextSpecification { // Type 5: '=' // Type 6: attribute value // Type 7: id or numeral + // Type 8:unit public boolean checkParameter(String _inst, String[] _split, int _parameter, int _type, int _lineNb) { boolean err = false; @@ -2014,6 +2081,11 @@ public class TMLTextSpecification { err = true; } break; + case 8: + if (!isAValidUnit(_split[_parameter])) { + err = true; + } + break; } } else { err = true; @@ -2050,6 +2122,20 @@ public class TMLTextSpecification { return _num.matches("\\d*"); } + public boolean isAValidUnit(String s) { + if (s.compareTo("ns") == 0) { + return true; + } else if (s.compareTo("us") == 0) { + return true; + } else if (s.compareTo("ms") == 0) { + return true; + } else if (s.compareTo("s") == 0) { + return true; + } + + return false; + } + public boolean checkKeywords(String _id) { String id = _id.toUpperCase(); for(int i=0; i<keywords.length; i++) { diff --git a/src/tmltranslator/tomappingsystemc2/MappedSystemCTask.java b/src/tmltranslator/tomappingsystemc2/MappedSystemCTask.java index 051c82bad16b5409b487d5d7e30918e6744e2c7b..9b0ec47bbd34fd73b9f8cedf6288b13ee41777c8 100755 --- a/src/tmltranslator/tomappingsystemc2/MappedSystemCTask.java +++ b/src/tmltranslator/tomappingsystemc2/MappedSystemCTask.java @@ -1,781 +1,772 @@ -/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille - * - * ludovic.apvrille AT enst.fr - * - * This software is a computer program whose purpose is to allow the - * edition of TURTLE analysis, design and deployment diagrams, to - * allow the generation of RT-LOTOS or Java code from this diagram, - * and at last to allow the analysis of formal validation traces - * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP - * from INRIA Rhone-Alpes. - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - * - * /** - * Class MappedSystemCTask - * Creation: 24/11/2005 - * @version 1.0 24/11/2005 - * @author Ludovic APVRILLE - * @see - */ - -package tmltranslator.tomappingsystemc2; - -import java.util.*; - -import tmltranslator.*; -import myutil.*; - - -public class MappedSystemCTask { - //private TMLModeling tmlm; - private TMLTask task; - private String reference, cppcode, hcode, initCommand, functions, functionSig, chaining, firstCommand, commentText; - private ArrayList<TMLChannel> channels; - private ArrayList<TMLEvent> events; - private ArrayList<TMLRequest> requests; - private int commentNum; - - - private boolean debug; - - private final static String DOTH = ".h"; - private final static String DOTCPP = ".cpp"; - private final static String SYSTEM_INCLUDE = "#include \"systemc.h\""; - private final static String CR = "\n"; - private final static String CR2 = "\n\n"; - private final static String SCCR = ";\n"; - private final static String EFCR = "}\n"; - private final static String EFCR2 = "}\n\n"; - private final static String EF = "}"; - - - public MappedSystemCTask(TMLTask _task, ArrayList<TMLChannel> _channels, ArrayList<TMLEvent> _events, ArrayList<TMLRequest> _requests) { - task = _task; - channels = _channels; - events = _events; - requests = _requests; - reference = task.getName(); - cppcode = ""; - hcode = ""; - initCommand=""; - functions=""; - chaining=""; - firstCommand=""; - functionSig=""; - commentText=""; - commentNum=0; - } - - public void saveInFiles(String path) throws FileException { - FileUtils.saveFile(path + reference + DOTH, getHCode()); - FileUtils.saveFile(path + reference + DOTCPP, getCPPCode()); - } - - public TMLTask getTMLTask() { - return task; - } - - - public void generateSystemC(boolean _debug) { - debug = _debug; - //basicHCode(); - basicCPPCode(); - makeClassCode(); - } - - public void print() { - System.out.println("task: " + reference + DOTH + hcode); - System.out.println("task: " + reference + DOTCPP + cppcode); - } - - - public String getCPPCode() { - return cppcode; - } - - public String getHCode() { - return hcode; - } - - public String getReference() { - return reference; - } - - - // H Code - // - public String basicHCode() { - String code=""; - code += "#ifndef " + reference.toUpperCase() + "__H" + CR; - code += "#define " + reference.toUpperCase() + "__H" + CR2; - code += "#include <TMLTask.h>\n#include <definitions.h>\n\n"; - code += "#include <TMLbrbwChannel.h>\n#include <TMLbrnbwChannel.h>\n#include <TMLnbrnbwChannel.h>\n\n"; - code += "#include <TMLEventBChannel.h>\n#include <TMLEventFChannel.h>\n#include <TMLEventFBChannel.h>\n\n"; - code += "#include <TMLActionCommand.h>\n#include <TMLChoiceCommand.h>\n#include <TMLExeciCommand.h>\n"; - code += "#include <TMLSelectCommand.h>\n#include <TMLReadCommand.h>\n#include <TMLNotifiedCommand.h>\n"; - code += "#include <TMLRequestCommand.h>\n#include <TMLSendCommand.h>\n#include <TMLWaitCommand.h>\n"; - code += "#include <TMLWriteCommand.h>\n\n"; - return code; - } - - - public void classHCode() { - } - - - // CPP Code - // - public void basicCPPCode() { - cppcode += "#include <" + reference + DOTH + ">" + CR2; - } - - public void makeClassCode(){ - makeHeaderClassH(); - makeEndClassH(); - - cppcode+=reference+ "::" + makeConstructorSignature()+":TMLTask(iPriority,iName,iCPU)"+ CR + makeAttributesCode(); - cppcode+=initCommand + CR2 + "{" + CR + "_comment = new std::string[" + commentNum + "]" + SCCR + commentText; - - cppcode+="//set blocked read task/set blocked write task"+ CR; - for(TMLChannel ch: channels) { - if (ch.getOriginTask()==task) - cppcode+=ch.getExtendedName() + "->setBlockedWriteTask(this)"+SCCR; - else - cppcode+=ch.getExtendedName() + "->setBlockedReadTask(this)"+SCCR; - } - for(TMLEvent evt: events) { - if (evt.getOriginTask()==task) - cppcode+=evt.getExtendedName() + "->setBlockedWriteTask(this)"+SCCR; - else - cppcode+=evt.getExtendedName() + "->setBlockedReadTask(this)"+SCCR; - } - if (task.isRequested()) cppcode+="requestChannel->setBlockedReadTask(this)" +SCCR; - for(TMLRequest req: requests) { - if (req.isAnOriginTask(task)) cppcode+=req.getExtendedName() + "->setBlockedWriteTask(this)" +SCCR; - } - cppcode+=CR + "//command chaining"+ CR; - cppcode+= chaining + "_currCommand=" + firstCommand + SCCR + "_currCommand->prepare()"+SCCR+"}"; - cppcode+=CR2+functions; - hcode = Conversion.indentString(hcode, 4); - cppcode = Conversion.indentString(cppcode, 4); - //System.out.println(CR2+ "************HCODE************\n"+hcode); - //System.out.println(CR+ "************CPPCODE************\n" + cppcode); - } - - private String makeConstructorSignature(){ - String constSig=reference+ "(unsigned int iPriority, std::string iName, CPU* iCPU"+CR; - for(TMLChannel ch: channels) { - constSig+=", TMLChannel* "+ ch.getExtendedName() + CR; - } - for(TMLEvent evt: events) { - constSig+=", TMLEventChannel* "+ evt.getExtendedName() +CR; - } - for(TMLRequest req: requests) { - if (req.isAnOriginTask(task)) constSig+=", TMLEventBChannel* " + req.getExtendedName() + CR; - } - if (task.isRequested()){ - constSig+=", TMLEventBChannel* requestChannel"+CR; - } - return constSig+")"; - } - - public void makeHeaderClassH() { - String hcodeBegin=""; - // Common dec - hcodeBegin = "class " + reference + ": public TMLTask {" + CR; - hcodeBegin += "private:" + CR; - - // Attributes - hcodeBegin += "// Attributes" + CR; - //hcodeBegin += makeAttributesDeclaration() + CR; - - if (task.isRequested()) { - int params = task.getRequest().getNbOfParams(); - firstCommand="_waitOnRequest"; - hcode+="TMLWaitCommand " + firstCommand + SCCR; - initCommand+= "," + firstCommand + "(this,requestChannel,"; - if (params==0){ - initCommand+= "0)" + CR; - }else{ - initCommand+= "new Parameter<ParamType>(arg1__req,"; - if (params>1) initCommand+= "arg2__req,"; else initCommand+= "0,"; - if (params>2) initCommand+= "arg3__req))\n"; else initCommand+= "0))\n"; - } - //"arg2__req,arg3__req))" + CR; - String xx = firstCommand + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(task.getActivityDiagram().getFirst(),false,"&"+firstCommand,null,null,null) + "))"+ SCCR; - firstCommand="&"+firstCommand; - chaining+=xx; - }else{ - firstCommand=makeCommands(task.getActivityDiagram().getFirst(),false,"0",null,null,null); - } - - hcode = basicHCode() + hcodeBegin + makeAttributesDeclaration() + CR + hcode; - // public dec - hcode += CR + functionSig + CR + "public:" + CR; - // Simulation - hcode += makeConstructorSignature() + SCCR; - } - - public String makeCommands(TMLActivityElement currElem, boolean skip, String retElement, strwrap nextCommandCont, strwrap functionCont, TMLActivityElement lastSequence){ - String nextCommand="",cmdName=""; - //strwrap nextCommandCollection, functionCollection; - - if (skip) return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); - - if (currElem==null){ - System.out.println("Checking null\n"); - //if (nextCommandCont!=null){ - //nextCommandCont.str += ",(TMLCommand*)" + retElement; - //nextCommandCont.num++; - //} - //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); - return retElement; - } - - //System.out.println("Checking " + currElem.getName() + CR); - - if (currElem instanceof TMLStartState) { - System.out.println("Checking Start\n"); - return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); - - } else if (currElem instanceof TMLStopState){ - System.out.println("Checking Stop\n"); - //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); - return retElement; - - } else if (currElem instanceof TMLActionState || currElem instanceof TMLRandom){ - String action; - if (currElem instanceof TMLActionState){ - action = ((TMLActionState)currElem).getAction(); - System.out.println("Checking Action\n"); - }else{ - TMLRandom random = (TMLRandom)currElem; - action = random.getVariable() + "=myrand("+ random.getMinValue() + "," + random.getMaxValue() + ")"; - System.out.println("Checking Random\n"); - } - cmdName= "_action" + currElem.getID(); - if (nextCommandCont==null){ - System.out.println("nextCommandCont==null in ActionState "+ action +CR); - hcode+="TMLActionCommand " + cmdName + SCCR; - strwrap nextCommandCollection = new strwrap(""), functionCollection = new strwrap(""); - //nextCommandCollection = new strwrap(""); functionCollection = new strwrap(""); - initCommand+= "," + cmdName + "(this,(ActionFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; - String MKResult = makeCommands(currElem.getNextElement(0),false,retElement,nextCommandCollection,functionCollection,lastSequence); - if(nextCommandCollection.num==0){ - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + MKResult + "));\n"; - }else{ - nextCommand= cmdName + ".setNextCommand(array(" + nextCommandCollection.num + nextCommandCollection.str + "));\n"; - } - functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + modifyString(addSemicolonIfNecessary(action)) + CR + functionCollection.str + "}" + CR2; - commentText+="_comment[" + commentNum + "]=std::string(\"Action " + action + "\");\n"; - commentNum++; - functionSig+="unsigned int " + cmdName + "_func()" + SCCR; - System.out.println("action no append: "+ MKResult); - }else{ - System.out.println("nextCommandCont!=null in ActionState "+ action +CR); - functionCont.str += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + modifyString(addSemicolonIfNecessary(action)) + CR; - commentText+="_comment[" + commentNum + "]=std::string(\"Action " + action + "\");\n"; - commentNum++; - //String MKResult = makeCommands(currElem.getNextElement(0),false,retElement,nextCommandCont,functionCont,lastSequence); - //System.out.println("action append: "+ MKResult); - //return MKResult; - return makeCommands(currElem.getNextElement(0),false,retElement,nextCommandCont,functionCont,lastSequence); - } - - - } else if (currElem instanceof TMLExecI){ - System.out.println("Checking Execi\n"); - cmdName= "_execi" + currElem.getID(); - hcode+="TMLExeciCommand " + cmdName + SCCR; - //initCommand+= "," + cmdName + "(this,"+ ((TMLExecI)currElem).getAction() + ",0,0)"+CR; - initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, ((TMLExecI)currElem).getAction(), null) + ",0)" + CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLExecC){ - System.out.println("Checking ExecC\n"); - cmdName= "_execc" + currElem.getID(); - hcode+="TMLExeciCommand " + cmdName + SCCR; - //initCommand+= "," + cmdName + "(this,"+ ((TMLExecI)currElem).getAction() + ",1)"+CR; - initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecI)currElem).getAction(), null) + ",1)"+CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLExecIInterval){ - System.out.println("Checking ExeciInterv\n"); - cmdName= "_execi" + currElem.getID(); - hcode+="TMLExeciCommand " + cmdName + SCCR; - //initCommand+= "," + cmdName + "(this,"+ ((TMLExecIInterval)currElem).getMinDelay()+ "," + ((TMLExecIInterval)currElem).getMaxDelay() + ",0)"+CR; - initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecIInterval)currElem).getMinDelay(), ((TMLExecIInterval)currElem).getMaxDelay()) + ",0)"+CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLExecCInterval){ - System.out.println("Checking ExecCInterv\n"); - cmdName= "_execc" + currElem.getID(); - hcode+="TMLExeciCommand " + cmdName + SCCR; - //initCommand+= "," + cmdName + "(this,"+ ((TMLExecIInterval)currElem).getMinDelay()+ "," + ((TMLExecIInterval)currElem).getMaxDelay() + ",1)"+CR; - initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecIInterval)currElem).getMinDelay(), ((TMLExecIInterval)currElem).getMaxDelay()) + ",1)"+CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - - } else if (currElem instanceof TMLForLoop){ - System.out.println("Checking Loop\n"); - TMLForLoop fl = (TMLForLoop)currElem; - cmdName="_choice" + currElem.getID(); - hcode+="TMLChoiceCommand " + cmdName + SCCR; - initCommand+= "," + cmdName + "(this,(CondFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; - functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nstatic bool firstTime=true;\nif(firstTime){\nfirstTime=false;\n" + addSemicolonIfNecessary(((TMLForLoop)currElem).getInit()) + "\n}else{\n" + addSemicolonIfNecessary(((TMLForLoop)currElem).getIncrement()) + "\n}\nif(" + ((TMLForLoop)currElem).getCondition() + "){\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn 0;\n}else{\naddComment(new Comment(_endLastTransaction,0," + (commentNum+1) + "));\nfirstTime=true;\nreturn 1;\n}\n}\n\n"; - commentText+="_comment[" + commentNum + "]=std::string(\"" + ((TMLForLoop)currElem).getCondition() + "=true\");\n"; - commentNum++; - commentText+="_comment[" + commentNum + "]=std::string(\"Exit loop: " + ((TMLForLoop)currElem).getCondition() + "=false\");\n"; - commentNum++; - functionSig+="unsigned int " + cmdName + "_func()" + SCCR; - nextCommand= cmdName + ".setNextCommand(array(2,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,"&"+cmdName,null,null,null) + ",(TMLCommand*)" + makeCommands(currElem.getNextElement(1),false,retElement,null,null,lastSequence) + "))"+ SCCR; - //initCommand+="LOOP!!!" + CR; - //nextCommand= cmdName + ".setNextCommand(array(2,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,cmdName,null,null,null) + ",(TMLCommand*)" + makeCommands(currElem.getNextElement(1),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLReadChannel){ - System.out.println("Checking Read\n"); - cmdName= "_read" + currElem.getID(); - hcode+="TMLReadCommand " + cmdName + SCCR; - TMLReadChannel rCommand=(TMLReadChannel)currElem; - //initCommand+= "," + cmdName + "(this," + rCommand.getNbOfSamples() + "*" + rCommand.getChannel().getSize() + "," + rCommand.getChannel().getExtendedName() + ")"+CR; - initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, rCommand.getChannel().getSize() + "*(" + rCommand.getNbOfSamples()+")",null) + "," + rCommand.getChannel().getExtendedName() + ")"+CR; - //initCommand+= "," + cmdName + "(this," + rCommand.getNbOfSamples() + "," + rCommand.getChannel().getExtendedName() + ")"+CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLWriteChannel){ - System.out.println("Checking Write\n"); - cmdName= "_write" + currElem.getID(); - hcode+="TMLWriteCommand " + cmdName + SCCR; - TMLWriteChannel wCommand=(TMLWriteChannel)currElem; - //initCommand+= "," + cmdName + "(this," + wCommand.getNbOfSamples() + "*" + wCommand.getChannel().getSize() + "," + wCommand.getChannel().getExtendedName() + ")"+CR; - initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, wCommand.getChannel().getSize() + "*(" + wCommand.getNbOfSamples() + ")", null) + "," + wCommand.getChannel().getExtendedName() + ")"+CR; - //initCommand+= "," + cmdName + "(this," + wCommand.getNbOfSamples() + "," + wCommand.getChannel().getExtendedName() + ")"+CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLSendEvent){ - System.out.println("Checking Send\n"); - cmdName= "_send" + currElem.getID(); - hcode+="TMLSendCommand " + cmdName + SCCR; - if (((TMLSendEvent)currElem).getNbOfParams()==0){ - initCommand+= "," + cmdName + "(this," + ((TMLSendEvent)currElem).getEvent().getExtendedName() + ",0)"+CR; - }else{ - initCommand+= "," + cmdName + "(this," + ((TMLSendEvent)currElem).getEvent().getExtendedName() + ",new Parameter<ParamType>("; - for(int i=0; i<3; i++) { - if (i!=0) initCommand += ","; - if (((TMLSendEvent)currElem).getParam(i) == null) { - initCommand += "0"; - } else { - if (((TMLSendEvent)currElem).getParam(i).length() > 0) { - initCommand += ((TMLSendEvent)currElem).getParam(i); - } else { - initCommand += "0"; - } - } - } - initCommand+="))"+CR; - } - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLSendRequest){ - System.out.println("Checking Request\n"); - cmdName= "_request" + currElem.getID(); - hcode+="TMLRequestCommand " + cmdName + SCCR; - if (((TMLSendRequest)currElem).getNbOfParams()==0){ - initCommand+= "," + cmdName + "(this," + ((TMLSendRequest)currElem).getRequest().getExtendedName() + ",0)"+CR; - }else{ - initCommand+= "," + cmdName + "(this," + ((TMLSendRequest)currElem).getRequest().getExtendedName() + ",new Parameter<ParamType>("; - for(int i=0; i<3; i++) { - if (i!=0) initCommand += ","; - if (((TMLSendRequest)currElem).getParam(i) == null) { - initCommand += "0"; - } else { - if (((TMLSendRequest)currElem).getParam(i).length() > 0) { - initCommand += ((TMLSendRequest)currElem).getParam(i); - } else { - initCommand += "0"; - } - } - } - initCommand+="))"+CR; - } - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLWaitEvent){ - System.out.println("Checking Wait\n"); - cmdName= "_wait" + currElem.getID(); - hcode+="TMLWaitCommand " + cmdName + SCCR; - if (((TMLWaitEvent)currElem).getNbOfParams()==0){ - initCommand+= "," + cmdName + "(this," + ((TMLWaitEvent)currElem).getEvent().getExtendedName() + ",0)"+CR; - }else{ - initCommand+= "," + cmdName + "(this," + ((TMLWaitEvent)currElem).getEvent().getExtendedName() + ",new Parameter<ParamType>("; - for(int i=0; i<3; i++) { - if (i!=0) initCommand += ","; - if (((TMLWaitEvent)currElem).getParam(i) == null) { - initCommand += "0"; - } else { - if (((TMLWaitEvent)currElem).getParam(i).length() > 0) { - initCommand += ((TMLWaitEvent)currElem).getParam(i); - } else { - initCommand += "0"; - } - } - } - initCommand+="))"+CR; - } - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLNotifiedEvent){ - System.out.println("Checking Notified\n"); - cmdName= "_notified" + currElem.getID(); - hcode+="TMLNotifiedCommand " + cmdName + SCCR; - initCommand+= "," + cmdName + "(this," + ((TMLNotifiedEvent)currElem).getEvent().getExtendedName() + ",(TMLLength*)&" + ((TMLNotifiedEvent)currElem).getVariable() +",\"" + ((TMLNotifiedEvent)currElem).getVariable() + "\")" + CR; - nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; - - } else if (currElem instanceof TMLSequence){ - TMLSequence tmlseq = (TMLSequence)currElem; - System.out.println("Checking Sequence with "+ tmlseq.getNbNext()+ " elements."); - if (tmlseq.getNbNext() == 0) { - //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); - return retElement; - } else { - if (tmlseq.getNbNext() == 1) { - return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); - } else { - String nextBranch; - tmlseq.sortNexts(); - System.out.println("Checking Sequence branch "+ (tmlseq.getNbNext()-1)); - nextBranch= makeCommands(currElem.getNextElement(currElem.getNbNext() - 1),false,retElement,null,null,null); - for(int i=currElem.getNbNext() - 2; i>=0; i--) { - System.out.println("Checking Sequence branch "+ i); - nextBranch=makeCommands(currElem.getNextElement(i),false,nextBranch,null,null,null); - } - //nextBranch=makeCommands(currElem.getNextElement(0),false,nextBranch,nextCommandCont,functionCont,null); - return nextBranch; - //int index = tmlseq.getCurrIndex(lastSequence); - //if (index==tmlseq.getNbNext()-1) return makeCommands(currElem.getNextElement(index), false,retElement,nextCommandCont,functionCont,tmlseq.getLastSequence()); - //return makeCommands(currElem.getNextElement(index), false,retElement,nextCommandCont,functionCont,currElem); - } - } - - } else if (currElem instanceof TMLChoice){ - int returnIndex=0; - cmdName= "_choice" + currElem.getID(); - TMLChoice choice = (TMLChoice)currElem; - String code = "", nextCommandTemp="", MCResult=""; - System.out.println("Checking Choicet\n"); - if (choice.getNbGuard() !=0 ) { - - String guardS = "",code2; - int index1 = choice.getElseGuard(), index2 = choice.getAfterGuard(); - int nb = choice.nbOfNonDeterministicGuard(); - int nbS = choice.nbOfStochasticGuard(); - if ((nb > 0) || (nbS > 0)){ - code += "rnd__0 = myrand(0, 99)" + SCCR; - } - nb = 0; - for(int i=0; i<choice.getNbGuard(); i++) { - if (choice.isNonDeterministicGuard(i)) { - code2 = "(rnd__0 < " + Math.floor(100/choice.getNbGuard())*(nb+1) + ")"; - nb ++; - } else if (choice.isStochasticGuard(i)) { - if (guardS.length() == 0) { - guardS = choice.getStochasticGuard(i); - } else { - guardS = "(" + guardS + ")+(" + choice.getStochasticGuard(i) + ")"; - } - code2 = "(rnd__0 < (" + guardS + "))"; - nbS ++; - } else { - code2 = choice.getGuard(i); - code2 = Conversion.replaceAllChar(code2, '[', "("); - code2 = Conversion.replaceAllChar(code2, ']', ")"); - } - //System.out.println("guard = " + code1 + " i=" + i); - if (i != index2) { - if (i==0) { - code += "if " + code2; - } else { - code += " else "; - if (i != index1) { - code += "if " + code2; - } - } - if (nextCommandCont==null){ - strwrap nextCommandCollection = new strwrap("",returnIndex), functionCollection = new strwrap(""); - //nextCommandCollection = new strwrap("",returnIndex); functionCollection = new strwrap(""); - //System.out.println("Call makeCommands, task: "+reference); - if (nextCommandCollection==null) System.out.println("Choice: nextCommandCollection==0"); - MCResult = makeCommands(currElem.getNextElement(i), false, retElement,nextCommandCollection,functionCollection,lastSequence); - if (functionCollection.str.isEmpty()){ - //System.out.println("NO content has been added to "+ code2); - code += "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + returnIndex + SCCR +"}" + CR; - commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; - commentNum++; - //System.out.println("RETURN, aaINC NUM "+ returnIndex); - returnIndex++; - nextCommandTemp+= ",(TMLCommand*)" + MCResult; - System.out.println("no append to old, no content in new: "+ MCResult); - }else{ - //System.out.println("OLD RETURN INDEX "+ returnIndex); - returnIndex = nextCommandCollection.num; - //System.out.println("Returned index: "+ returnIndex); - //System.out.println("Choice: Content has been added to "+ code2); - code += "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + functionCollection.str + "return " + returnIndex + ";\n}" + CR; - commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; - commentNum++; - //returnIndex = nextCommandCollection.num; - //System.out.println("RETURN, bbINC NUM "+ returnIndex); - returnIndex++; - nextCommandTemp+= nextCommandCollection.str+ ",(TMLCommand*)" + MCResult; - System.out.println("no append to old, content in new: "+ MCResult); - } - }else{ - //System.out.println("Choice: Next command!=0 "+ code2); - int oldReturnIndex=nextCommandCont.num; - functionCont.str += code + "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n"; - commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; - commentNum++; - MCResult = makeCommands(currElem.getNextElement(i), false, retElement, nextCommandCont,functionCont,lastSequence); - if (oldReturnIndex==nextCommandCont.num){ - //System.out.println("RETURN, ccINC NUM "+ nextCommandCont.num); - functionCont.str+= "return " + nextCommandCont.num + SCCR; - nextCommandCont.num++; - nextCommandCont.str += ",(TMLCommand*)" + MCResult; - } - functionCont.str+= "}\n"; - code=""; - System.out.println("append to old: "+ MCResult); - } - } - } - // If there was no else, do a terminate - if (nextCommandCont==null){ - //System.out.println("Choice: finalization, add new command\n"); - if (index1 == -1){ - code += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + returnIndex + SCCR; - commentText+="_comment[" + commentNum + "]=std::string(\"Exit branch taken\");\n"; - commentNum++; - nextCommand= cmdName + ".setNextCommand(array(" + (returnIndex+1) + nextCommandTemp + ",(TMLCommand*)0))" + SCCR; - }else{ - nextCommand= cmdName + ".setNextCommand(array(" + returnIndex + nextCommandTemp + "))" + SCCR; - } - hcode+="TMLChoiceCommand " + cmdName + SCCR; - initCommand+= "," + cmdName + "(this,(CondFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; - functions+="unsigned int "+ reference + "::" + cmdName + "_func(){" + CR + code +CR+ "}" + CR2; - functionSig+="unsigned int " + cmdName + "_func()" + SCCR; - }else{ - //System.out.println("Choice: finalization, No new command\n"); - if (index1 == -1){ - functionCont.str += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + nextCommandCont.num + SCCR; - commentText+="_comment[" + commentNum + "]=std::string(\"Exit branch taken\");\n"; - commentNum++; - nextCommandCont.str += ",(TMLCommand*)0"; - //System.out.println("RETURN, ddINC NUM "+ nextCommandCont.num); - nextCommandCont.num++; - } - cmdName=MCResult; - } - } - - } else if (currElem instanceof TMLSelectEvt){ - TMLEvent evt; - Integer nbevt=0; - String evtList="",paramList=""; - System.out.println("Checking SelectEvt\n"); - cmdName= "_select" + currElem.getID(); - for(int i=0; i<currElem.getNbNext(); i++) { - evt=((TMLSelectEvt)currElem).getEvent(i); - if (evt!=null){ - nbevt++; - evtList += ",(TMLEventChannel*)"+ evt.getExtendedName(); - //paramList+=",0"; - if (evt.getNbOfParams()==0) { - paramList+=",(Parameter<ParamType>*)0"; - }else{ - paramList+=",new Parameter<ParamType>("; - for(int j=0; j<3; j++) { - if (j!=0) paramList += ","; - if (((TMLSelectEvt)currElem).getParam(i,j) == null) { - paramList += "0"; - } else { - if (((TMLSelectEvt)currElem).getParam(i,j).length() > 0) { - paramList += ((TMLSelectEvt)currElem).getParam(i,j); - } else { - paramList += "0"; - } - } - } - paramList+=")"; - } - nextCommand+= ",(TMLCommand*)" + makeCommands(currElem.getNextElement(i), true, retElement,null,null,lastSequence); - } - } - hcode+="TMLSelectCommand " + cmdName + SCCR; - //initCommand+= "," + cmdName + "(this,array("+ nbevt + evtList + "),"+ nbevt + ",0)"+CR; - initCommand+= "," + cmdName + "(this,array("+ nbevt + evtList + "),"+ nbevt + ",array("+ nbevt + paramList + "))"+CR; - nextCommand=cmdName + ".setNextCommand(array(" + nbevt + nextCommand + "))" + SCCR; - - } else { - System.out.println("Operator: " + currElem + " is not managed in SystemC" + "))" + SCCR); - } - chaining+=nextCommand; - return (cmdName.equals("0") || cmdName.charAt(0)=='&')? cmdName : "&"+cmdName; - } - - - public String makeCommandLenFunc(String cmdName, String lowerLimit, String upperLimit){ - if (upperLimit==null) - functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nreturn (unsigned int)(" + lowerLimit + ");\n}" + CR2; - else - functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nreturn (unsigned int)myrand(" + lowerLimit + "," + upperLimit + ");\n}" + CR2; - functionSig+="unsigned int " + cmdName + "_func()" + SCCR; - return "(LengthFuncPointer)&" + reference + "::" + cmdName + "_func"; - } - - -/*public String makeChoice(TMLActivityElement currElem){ - TMLChoice choice = (TMLChoice)currElem; - //System.out.println("nb of guards = " + choice.getNbGuard() + " nb of nexts =" + choice.getNbNext()); - String code = ""; - if (choice.getNbGuard() !=0 ) { - String code1 = "",guardS = "",code2; - int index1 = choice.getElseGuard(), index2 = choice.getAfterGuard(); - int nb = choice.nbOfNonDeterministicGuard(); - int nbS = choice.nbOfStochasticGuard(); - if ((nb > 0) || (nbS > 0)){ - code += "rnd__0 = myrand(0, 99)" + SCCR; - } - nb = 0; - for(int i=0; i<choice.getNbGuard(); i++) { - if (choice.isNonDeterministicGuard(i)) { - code2 = "(rnd__0 < " + Math.floor(100/choice.getNbGuard())*(nb+1) + ")"; - nb ++; - } else if (choice.isStochasticGuard(i)) { - if (guardS.length() == 0) { - guardS = choice.getStochasticGuard(i); - } else { - guardS = "(" + guardS + ")+(" + choice.getStochasticGuard(i) + ")"; - } - code2 = "(rnd__0 < (" + guardS + "))"; - nbS ++; - } else { - code2 = choice.getGuard(i); - code2 = Conversion.replaceAllChar(code2, '[', "("); - code2 = Conversion.replaceAllChar(code2, ']', ")"); - } - //System.out.println("guard = " + code1 + " i=" + i); - if (i != index2) { - if (i==0) { - code += "if " + code2; - } else { - code += " else "; - if (i != index1) { - code += "if " + code2; - } - } - code += "{\naddComment(new Comment(_endLastTransaction,\"Branch taken: " + code2 + "\"));\nreturn "+ i + SCCR +"}" + CR; - } - } - // If there was no else, do a terminate - if (index1 == -1) code += "addComment(new Comment(_endLastTransaction,\"Exit branch taken\"));\nreturn " + choice.getNbGuard() + SCCR; - code += code1; - } - return code; - }*/ - - public void makeEndClassH() { - hcode += "};" + CR + "#endif" + CR; - } - - - private String makeAttributesCode() { - String code = ""; - TMLAttribute att; - int i; - - ListIterator iterator = task.getAttributes().listIterator(); - - while(iterator.hasNext()) { - att = (TMLAttribute)(iterator.next()); - if (att.hasInitialValue()) - code += ","+ att.name + "(" + att.initialValue + ")"+CR; - else - code += ","+ att.name + "(0)"+CR; - } - return code; - } - - private String makeAttributesDeclaration() { - String code = ""; - TMLAttribute att; - int i; - - ListIterator iterator = task.getAttributes().listIterator(); - - while(iterator.hasNext()) { - att = (TMLAttribute)(iterator.next()); - //code += TMLType.getStringType(att.type.getType()) + " " + att.name; - code += "int " + att.name; - code += ";\n"; - } - - // Attributes for events - //code += "unsigned int arg__evt0" + SCCR; - //code += "unsigned int arg__evt1" + SCCR; - //code += "unsigned int arg__evt2" + SCCR; - - //Adding request arguments - //if (task.isRequested()) { - // code += "unsigned int arg1__req" + SCCR; - // code += "unsigned int arg2__req" + SCCR; - // code += "unsigned int arg3__req" + SCCR; - //} - - code += "int rnd__0" + SCCR; - //if (commentNum!=0) code+= "std::string _comment[" + commentNum + "]" + SCCR; - return code; - } - - - public String addSemicolonIfNecessary(String _input) { - String code1 = _input.trim(); - if (!(code1.endsWith(";"))) { - code1 += ";"; - } - return code1; - } - - public String modifyString(String _input) { - //System.out.println("Modify string=" + _input); - _input = Conversion.changeBinaryOperatorWithUnary(_input, "div", "/"); - _input = Conversion.changeBinaryOperatorWithUnary(_input, "mod", "%"); - //System.out.println("Modified string=" + _input); - return _input; - } - -} +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class MappedSystemCTask + * Creation: 24/11/2005 + * @version 1.0 24/11/2005 + * @author Ludovic APVRILLE + * @see + */ + +package tmltranslator.tomappingsystemc2; + +import java.util.*; + +import tmltranslator.*; +import myutil.*; + + +public class MappedSystemCTask { + //private TMLModeling tmlm; + private TMLTask task; + private String reference, cppcode, hcode, initCommand, functions, functionSig, chaining, firstCommand, commentText; + private ArrayList<TMLChannel> channels; + private ArrayList<TMLEvent> events; + private ArrayList<TMLRequest> requests; + private int commentNum; + + + private boolean debug; + + private final static String DOTH = ".h"; + private final static String DOTCPP = ".cpp"; + private final static String SYSTEM_INCLUDE = "#include \"systemc.h\""; + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; + private final static String SCCR = ";\n"; + private final static String EFCR = "}\n"; + private final static String EFCR2 = "}\n\n"; + private final static String EF = "}"; + + + public MappedSystemCTask(TMLTask _task, ArrayList<TMLChannel> _channels, ArrayList<TMLEvent> _events, ArrayList<TMLRequest> _requests) { + task = _task; + channels = _channels; + events = _events; + requests = _requests; + reference = task.getName(); + cppcode = ""; + hcode = ""; + initCommand=""; + functions=""; + chaining=""; + firstCommand=""; + functionSig=""; + commentText=""; + commentNum=0; + } + + public void saveInFiles(String path) throws FileException { + FileUtils.saveFile(path + reference + DOTH, getHCode()); + FileUtils.saveFile(path + reference + DOTCPP, getCPPCode()); + } + + public TMLTask getTMLTask() { + return task; + } + + + public void generateSystemC(boolean _debug) { + debug = _debug; + //basicHCode(); + basicCPPCode(); + makeClassCode(); + } + + public void print() { + System.out.println("task: " + reference + DOTH + hcode); + System.out.println("task: " + reference + DOTCPP + cppcode); + } + + + public String getCPPCode() { + return cppcode; + } + + public String getHCode() { + return hcode; + } + + public String getReference() { + return reference; + } + + + // H Code + // + public String basicHCode() { + String code=""; + code += "#ifndef " + reference.toUpperCase() + "__H" + CR; + code += "#define " + reference.toUpperCase() + "__H" + CR2; + code += "#include <TMLTask.h>\n#include <definitions.h>\n\n"; + code += "#include <TMLbrbwChannel.h>\n#include <TMLbrnbwChannel.h>\n#include <TMLnbrnbwChannel.h>\n\n"; + code += "#include <TMLEventBChannel.h>\n#include <TMLEventFChannel.h>\n#include <TMLEventFBChannel.h>\n\n"; + code += "#include <TMLActionCommand.h>\n#include <TMLChoiceCommand.h>\n#include <TMLExeciCommand.h>\n"; + code += "#include <TMLSelectCommand.h>\n#include <TMLReadCommand.h>\n#include <TMLNotifiedCommand.h>\n"; + code += "#include <TMLRequestCommand.h>\n#include <TMLSendCommand.h>\n#include <TMLWaitCommand.h>\n"; + code += "#include <TMLWriteCommand.h>\n\n"; + return code; + } + + + public void classHCode() { + } + + + // CPP Code + // + public void basicCPPCode() { + cppcode += "#include <" + reference + DOTH + ">" + CR2; + } + + public void makeClassCode(){ + makeHeaderClassH(); + makeEndClassH(); + + cppcode+=reference+ "::" + makeConstructorSignature()+":TMLTask(iPriority,iName,iCPU)"+ CR + makeAttributesCode(); + cppcode+=initCommand + CR2 + "{" + CR + "_comment = new std::string[" + commentNum + "]" + SCCR + commentText; + + cppcode+="//set blocked read task/set blocked write task"+ CR; + for(TMLChannel ch: channels) { + if (ch.getOriginTask()==task) + cppcode+=ch.getExtendedName() + "->setBlockedWriteTask(this)"+SCCR; + else + cppcode+=ch.getExtendedName() + "->setBlockedReadTask(this)"+SCCR; + } + for(TMLEvent evt: events) { + if (evt.getOriginTask()==task) + cppcode+=evt.getExtendedName() + "->setBlockedWriteTask(this)"+SCCR; + else + cppcode+=evt.getExtendedName() + "->setBlockedReadTask(this)"+SCCR; + } + if (task.isRequested()) cppcode+="requestChannel->setBlockedReadTask(this)" +SCCR; + for(TMLRequest req: requests) { + if (req.isAnOriginTask(task)) cppcode+=req.getExtendedName() + "->setBlockedWriteTask(this)" +SCCR; + } + cppcode+=CR + "//command chaining"+ CR; + cppcode+= chaining + "_currCommand=" + firstCommand + SCCR + "_currCommand->prepare()"+SCCR+"}"; + cppcode+=CR2+functions; + hcode = Conversion.indentString(hcode, 4); + cppcode = Conversion.indentString(cppcode, 4); + //System.out.println(CR2+ "************HCODE************\n"+hcode); + //System.out.println(CR+ "************CPPCODE************\n" + cppcode); + } + + private String makeConstructorSignature(){ + String constSig=reference+ "(unsigned int iPriority, std::string iName, CPU* iCPU"+CR; + for(TMLChannel ch: channels) { + constSig+=", TMLChannel* "+ ch.getExtendedName() + CR; + } + for(TMLEvent evt: events) { + constSig+=", TMLEventChannel* "+ evt.getExtendedName() +CR; + } + for(TMLRequest req: requests) { + if (req.isAnOriginTask(task)) constSig+=", TMLEventBChannel* " + req.getExtendedName() + CR; + } + if (task.isRequested()){ + constSig+=", TMLEventBChannel* requestChannel"+CR; + } + return constSig+")"; + } + + public void makeHeaderClassH() { + String hcodeBegin=""; + // Common dec + hcodeBegin = "class " + reference + ": public TMLTask {" + CR; + hcodeBegin += "private:" + CR; + + // Attributes + hcodeBegin += "// Attributes" + CR; + //hcodeBegin += makeAttributesDeclaration() + CR; + + if (task.isRequested()) { + int params = task.getRequest().getNbOfParams(); + firstCommand="_waitOnRequest"; + hcode+="TMLWaitCommand " + firstCommand + SCCR; + initCommand+= "," + firstCommand + "(this,requestChannel,"; + if (params==0){ + initCommand+= "0)" + CR; + }else{ + initCommand+= "new Parameter<ParamType>(arg1__req,"; + if (params>1) initCommand+= "arg2__req,"; else initCommand+= "0,"; + if (params>2) initCommand+= "arg3__req))\n"; else initCommand+= "0))\n"; + } + //"arg2__req,arg3__req))" + CR; + String xx = firstCommand + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(task.getActivityDiagram().getFirst(),false,"&"+firstCommand,null,null,null) + "))"+ SCCR; + firstCommand="&"+firstCommand; + chaining+=xx; + }else{ + firstCommand=makeCommands(task.getActivityDiagram().getFirst(),false,"0",null,null,null); + } + + hcode = basicHCode() + hcodeBegin + makeAttributesDeclaration() + CR + hcode; + // public dec + hcode += CR + functionSig + CR + "public:" + CR; + // Simulation + hcode += makeConstructorSignature() + SCCR; + } + + public String makeCommands(TMLActivityElement currElem, boolean skip, String retElement, strwrap nextCommandCont, strwrap functionCont, TMLActivityElement lastSequence){ + String nextCommand="",cmdName=""; + //strwrap nextCommandCollection, functionCollection; + + if (skip) return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); + + if (currElem==null){ + System.out.println("Checking null\n"); + //if (nextCommandCont!=null){ + //nextCommandCont.str += ",(TMLCommand*)" + retElement; + //nextCommandCont.num++; + //} + //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); + return retElement; + } + + //System.out.println("Checking " + currElem.getName() + CR); + + if (currElem instanceof TMLStartState) { + System.out.println("Checking Start\n"); + return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); + + } else if (currElem instanceof TMLStopState){ + System.out.println("Checking Stop\n"); + //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); + return retElement; + + } else if (currElem instanceof TMLActionState || currElem instanceof TMLRandom){ + String action; + if (currElem instanceof TMLActionState){ + action = ((TMLActionState)currElem).getAction(); + System.out.println("Checking Action\n"); + }else{ + TMLRandom random = (TMLRandom)currElem; + action = random.getVariable() + "=myrand("+ random.getMinValue() + "," + random.getMaxValue() + ")"; + System.out.println("Checking Random\n"); + } + cmdName= "_action" + currElem.getID(); + if (nextCommandCont==null){ + System.out.println("nextCommandCont==null in ActionState "+ action +CR); + hcode+="TMLActionCommand " + cmdName + SCCR; + strwrap nextCommandCollection = new strwrap(""), functionCollection = new strwrap(""); + //nextCommandCollection = new strwrap(""); functionCollection = new strwrap(""); + initCommand+= "," + cmdName + "(this,(ActionFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; + String MKResult = makeCommands(currElem.getNextElement(0),false,retElement,nextCommandCollection,functionCollection,lastSequence); + if(nextCommandCollection.num==0){ + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + MKResult + "));\n"; + }else{ + nextCommand= cmdName + ".setNextCommand(array(" + nextCommandCollection.num + nextCommandCollection.str + "));\n"; + } + functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + modifyString(addSemicolonIfNecessary(action)) + CR + functionCollection.str + "}" + CR2; + commentText+="_comment[" + commentNum + "]=std::string(\"Action " + action + "\");\n"; + commentNum++; + functionSig+="unsigned int " + cmdName + "_func()" + SCCR; + }else{ + System.out.println("nextCommandCont!=null in ActionState "+ action +CR); + functionCont.str += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + modifyString(addSemicolonIfNecessary(action)) + CR; + commentText+="_comment[" + commentNum + "]=std::string(\"Action " + action + "\");\n"; + commentNum++; + return makeCommands(currElem.getNextElement(0),false,retElement,nextCommandCont,functionCont,lastSequence); + } + + + } else if (currElem instanceof TMLExecI){ + System.out.println("Checking Execi\n"); + cmdName= "_execi" + currElem.getID(); + hcode+="TMLExeciCommand " + cmdName + SCCR; + //initCommand+= "," + cmdName + "(this,"+ ((TMLExecI)currElem).getAction() + ",0,0)"+CR; + initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, ((TMLExecI)currElem).getAction(), null) + ",0)" + CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLExecC){ + System.out.println("Checking ExecC\n"); + cmdName= "_execc" + currElem.getID(); + hcode+="TMLExeciCommand " + cmdName + SCCR; + //initCommand+= "," + cmdName + "(this,"+ ((TMLExecI)currElem).getAction() + ",1)"+CR; + initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecI)currElem).getAction(), null) + ",1)"+CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLExecIInterval){ + System.out.println("Checking ExeciInterv\n"); + cmdName= "_execi" + currElem.getID(); + hcode+="TMLExeciCommand " + cmdName + SCCR; + //initCommand+= "," + cmdName + "(this,"+ ((TMLExecIInterval)currElem).getMinDelay()+ "," + ((TMLExecIInterval)currElem).getMaxDelay() + ",0)"+CR; + initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecIInterval)currElem).getMinDelay(), ((TMLExecIInterval)currElem).getMaxDelay()) + ",0)"+CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLExecCInterval){ + System.out.println("Checking ExecCInterv\n"); + cmdName= "_execc" + currElem.getID(); + hcode+="TMLExeciCommand " + cmdName + SCCR; + //initCommand+= "," + cmdName + "(this,"+ ((TMLExecIInterval)currElem).getMinDelay()+ "," + ((TMLExecIInterval)currElem).getMaxDelay() + ",1)"+CR; + initCommand+= "," + cmdName + "(this,"+ makeCommandLenFunc(cmdName, ((TMLExecIInterval)currElem).getMinDelay(), ((TMLExecIInterval)currElem).getMaxDelay()) + ",1)"+CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + + } else if (currElem instanceof TMLForLoop){ + System.out.println("Checking Loop\n"); + TMLForLoop fl = (TMLForLoop)currElem; + cmdName="_choice" + currElem.getID(); + hcode+="TMLChoiceCommand " + cmdName + SCCR; + initCommand+= "," + cmdName + "(this,(CondFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; + functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nstatic bool firstTime=true;\nif(firstTime){\nfirstTime=false;\n" + addSemicolonIfNecessary(((TMLForLoop)currElem).getInit()) + "\n}else{\n" + addSemicolonIfNecessary(((TMLForLoop)currElem).getIncrement()) + "\n}\nif(" + ((TMLForLoop)currElem).getCondition() + "){\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn 0;\n}else{\naddComment(new Comment(_endLastTransaction,0," + (commentNum+1) + "));\nfirstTime=true;\nreturn 1;\n}\n}\n\n"; + commentText+="_comment[" + commentNum + "]=std::string(\"" + ((TMLForLoop)currElem).getCondition() + "=true\");\n"; + commentNum++; + commentText+="_comment[" + commentNum + "]=std::string(\"Exit loop: " + ((TMLForLoop)currElem).getCondition() + "=false\");\n"; + commentNum++; + functionSig+="unsigned int " + cmdName + "_func()" + SCCR; + nextCommand= cmdName + ".setNextCommand(array(2,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,"&"+cmdName,null,null,null) + ",(TMLCommand*)" + makeCommands(currElem.getNextElement(1),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLReadChannel){ + System.out.println("Checking Read\n"); + cmdName= "_read" + currElem.getID(); + hcode+="TMLReadCommand " + cmdName + SCCR; + TMLReadChannel rCommand=(TMLReadChannel)currElem; + //initCommand+= "," + cmdName + "(this," + rCommand.getNbOfSamples() + "*" + rCommand.getChannel().getSize() + "," + rCommand.getChannel().getExtendedName() + ")"+CR; + initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, rCommand.getChannel().getSize() + "*(" + rCommand.getNbOfSamples()+")",null) + "," + rCommand.getChannel().getExtendedName() + ")"+CR; + //initCommand+= "," + cmdName + "(this," + rCommand.getNbOfSamples() + "," + rCommand.getChannel().getExtendedName() + ")"+CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLWriteChannel){ + System.out.println("Checking Write\n"); + cmdName= "_write" + currElem.getID(); + hcode+="TMLWriteCommand " + cmdName + SCCR; + TMLWriteChannel wCommand=(TMLWriteChannel)currElem; + //initCommand+= "," + cmdName + "(this," + wCommand.getNbOfSamples() + "*" + wCommand.getChannel().getSize() + "," + wCommand.getChannel().getExtendedName() + ")"+CR; + initCommand+= "," + cmdName + "(this," + makeCommandLenFunc(cmdName, wCommand.getChannel().getSize() + "*(" + wCommand.getNbOfSamples() + ")", null) + "," + wCommand.getChannel().getExtendedName() + ")"+CR; + //initCommand+= "," + cmdName + "(this," + wCommand.getNbOfSamples() + "," + wCommand.getChannel().getExtendedName() + ")"+CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLSendEvent){ + System.out.println("Checking Send\n"); + cmdName= "_send" + currElem.getID(); + hcode+="TMLSendCommand " + cmdName + SCCR; + if (((TMLSendEvent)currElem).getNbOfParams()==0){ + initCommand+= "," + cmdName + "(this," + ((TMLSendEvent)currElem).getEvent().getExtendedName() + ",0)"+CR; + }else{ + initCommand+= "," + cmdName + "(this," + ((TMLSendEvent)currElem).getEvent().getExtendedName() + ",new Parameter<ParamType>("; + for(int i=0; i<3; i++) { + if (i!=0) initCommand += ","; + if (((TMLSendEvent)currElem).getParam(i) == null) { + initCommand += "0"; + } else { + if (((TMLSendEvent)currElem).getParam(i).length() > 0) { + initCommand += ((TMLSendEvent)currElem).getParam(i); + } else { + initCommand += "0"; + } + } + } + initCommand+="))"+CR; + } + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLSendRequest){ + System.out.println("Checking Request\n"); + cmdName= "_request" + currElem.getID(); + hcode+="TMLRequestCommand " + cmdName + SCCR; + if (((TMLSendRequest)currElem).getNbOfParams()==0){ + initCommand+= "," + cmdName + "(this," + ((TMLSendRequest)currElem).getRequest().getExtendedName() + ",0)"+CR; + }else{ + initCommand+= "," + cmdName + "(this," + ((TMLSendRequest)currElem).getRequest().getExtendedName() + ",new Parameter<ParamType>("; + for(int i=0; i<3; i++) { + if (i!=0) initCommand += ","; + if (((TMLSendRequest)currElem).getParam(i) == null) { + initCommand += "0"; + } else { + if (((TMLSendRequest)currElem).getParam(i).length() > 0) { + initCommand += ((TMLSendRequest)currElem).getParam(i); + } else { + initCommand += "0"; + } + } + } + initCommand+="))"+CR; + } + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLWaitEvent){ + System.out.println("Checking Wait\n"); + cmdName= "_wait" + currElem.getID(); + hcode+="TMLWaitCommand " + cmdName + SCCR; + if (((TMLWaitEvent)currElem).getNbOfParams()==0){ + initCommand+= "," + cmdName + "(this," + ((TMLWaitEvent)currElem).getEvent().getExtendedName() + ",0)"+CR; + }else{ + initCommand+= "," + cmdName + "(this," + ((TMLWaitEvent)currElem).getEvent().getExtendedName() + ",new Parameter<ParamType>("; + for(int i=0; i<3; i++) { + if (i!=0) initCommand += ","; + if (((TMLWaitEvent)currElem).getParam(i) == null) { + initCommand += "0"; + } else { + if (((TMLWaitEvent)currElem).getParam(i).length() > 0) { + initCommand += ((TMLWaitEvent)currElem).getParam(i); + } else { + initCommand += "0"; + } + } + } + initCommand+="))"+CR; + } + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLNotifiedEvent){ + System.out.println("Checking Notified\n"); + cmdName= "_notified" + currElem.getID(); + hcode+="TMLNotifiedCommand " + cmdName + SCCR; + initCommand+= "," + cmdName + "(this," + ((TMLNotifiedEvent)currElem).getEvent().getExtendedName() + ",(TMLLength*)&" + ((TMLNotifiedEvent)currElem).getVariable() +",\"" + ((TMLNotifiedEvent)currElem).getVariable() + "\")" + CR; + nextCommand= cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0),false,retElement,null,null,lastSequence) + "))"+ SCCR; + + } else if (currElem instanceof TMLSequence){ + TMLSequence tmlseq = (TMLSequence)currElem; + System.out.println("Checking Sequence with "+ tmlseq.getNbNext()+ " elements."); + if (tmlseq.getNbNext() == 0) { + //if (lastSequence!=null) return makeCommands(lastSequence, false,retElement,nextCommandCont,functionCont,null); + return retElement; + } else { + if (tmlseq.getNbNext() == 1) { + return makeCommands(currElem.getNextElement(0), false,retElement,nextCommandCont,functionCont,lastSequence); + } else { + String nextBranch; + tmlseq.sortNexts(); + System.out.println("Checking Sequence branch "+ (tmlseq.getNbNext()-1)); + nextBranch= makeCommands(currElem.getNextElement(currElem.getNbNext() - 1),false,retElement,null,null,null); + for(int i=currElem.getNbNext() - 2; i>=0; i--) { + System.out.println("Checking Sequence branch "+ i); + nextBranch=makeCommands(currElem.getNextElement(i),false,nextBranch,null,null,null); + } + //nextBranch=makeCommands(currElem.getNextElement(0),false,nextBranch,nextCommandCont,functionCont,null); + return nextBranch; + //int index = tmlseq.getCurrIndex(lastSequence); + //if (index==tmlseq.getNbNext()-1) return makeCommands(currElem.getNextElement(index), false,retElement,nextCommandCont,functionCont,tmlseq.getLastSequence()); + //return makeCommands(currElem.getNextElement(index), false,retElement,nextCommandCont,functionCont,currElem); + } + } + + } else if (currElem instanceof TMLChoice){ + int returnIndex=0; + cmdName= "_choice" + currElem.getID(); + TMLChoice choice = (TMLChoice)currElem; + String code = "", nextCommandTemp="", MCResult=""; + System.out.println("Checking Choicet\n"); + if (choice.getNbGuard() !=0 ) { + + String guardS = "",code2; + int index1 = choice.getElseGuard(), index2 = choice.getAfterGuard(); + int nb = choice.nbOfNonDeterministicGuard(); + int nbS = choice.nbOfStochasticGuard(); + if ((nb > 0) || (nbS > 0)){ + code += "rnd__0 = myrand(0, 99)" + SCCR; + } + nb = 0; + for(int i=0; i<choice.getNbGuard(); i++) { + if (choice.isNonDeterministicGuard(i)) { + code2 = "(rnd__0 < " + Math.floor(100/choice.getNbGuard())*(nb+1) + ")"; + nb ++; + } else if (choice.isStochasticGuard(i)) { + if (guardS.length() == 0) { + guardS = choice.getStochasticGuard(i); + } else { + guardS = "(" + guardS + ")+(" + choice.getStochasticGuard(i) + ")"; + } + code2 = "(rnd__0 < (" + guardS + "))"; + nbS ++; + } else { + code2 = choice.getGuard(i); + code2 = Conversion.replaceAllChar(code2, '[', "("); + code2 = Conversion.replaceAllChar(code2, ']', ")"); + } + //System.out.println("guard = " + code1 + " i=" + i); + if (i != index2) { + if (i==0) { + code += "if " + code2; + } else { + code += " else "; + if (i != index1) { + code += "if " + code2; + } + } + if (nextCommandCont==null){ + strwrap nextCommandCollection = new strwrap("",returnIndex), functionCollection = new strwrap(""); + //nextCommandCollection = new strwrap("",returnIndex); functionCollection = new strwrap(""); + //System.out.println("Call makeCommands, task: "+reference); + if (nextCommandCollection==null) System.out.println("Choice: nextCommandCollection==0"); + MCResult = makeCommands(currElem.getNextElement(i), false, retElement,nextCommandCollection,functionCollection,lastSequence); + if (functionCollection.str.isEmpty()){ + System.out.println("NO content has been added to "+ code2); + code += "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + returnIndex + SCCR +"}" + CR; + commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; + commentNum++; + System.out.println("RETURN, aaINC NUM "+ returnIndex); + returnIndex++; + nextCommandTemp+= ",(TMLCommand*)" + MCResult; + }else{ + System.out.println("OLD RETURN INDEX "+ returnIndex); + returnIndex = nextCommandCollection.num; + //System.out.println("Returned index: "+ returnIndex); + System.out.println("Choice: Content has been added to "+ code2); + code += "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n" + functionCollection.str + "return " + returnIndex + ";\n}" + CR; + commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; + commentNum++; + //returnIndex = nextCommandCollection.num; + System.out.println("RETURN, bbINC NUM "+ returnIndex); + returnIndex++; + nextCommandTemp+= nextCommandCollection.str+ ",(TMLCommand*)" + MCResult; + } + }else{ + System.out.println("Choice: Next command!=0 "+ code2); + int oldReturnIndex=nextCommandCont.num; + functionCont.str += code + "{\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n"; + commentText+="_comment[" + commentNum + "]=std::string(\"Branch taken: " + code2 + "\");\n"; + commentNum++; + MCResult = makeCommands(currElem.getNextElement(i), false, retElement, nextCommandCont,functionCont,lastSequence); + if (oldReturnIndex==nextCommandCont.num){ + System.out.println("RETURN, ccINC NUM "+ nextCommandCont.num); + functionCont.str+= "return " + nextCommandCont.num + SCCR; + nextCommandCont.num++; + nextCommandCont.str += ",(TMLCommand*)" + MCResult; + } + functionCont.str+= "}\n"; + code=""; + } + } + } + // If there was no else, do a terminate + if (nextCommandCont==null){ + System.out.println("Choice: finalization, add new command\n"); + if (index1 == -1){ + code += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + returnIndex + SCCR; + commentText+="_comment[" + commentNum + "]=std::string(\"Exit branch taken\");\n"; + commentNum++; + nextCommand= cmdName + ".setNextCommand(array(" + (returnIndex+1) + nextCommandTemp + ",(TMLCommand*)0))" + SCCR; + }else{ + nextCommand= cmdName + ".setNextCommand(array(" + returnIndex + nextCommandTemp + "))" + SCCR; + } + hcode+="TMLChoiceCommand " + cmdName + SCCR; + initCommand+= "," + cmdName + "(this,(CondFuncPointer)&" + reference + "::" + cmdName + "_func)"+CR; + functions+="unsigned int "+ reference + "::" + cmdName + "_func(){" + CR + code +CR+ "}" + CR2; + functionSig+="unsigned int " + cmdName + "_func()" + SCCR; + }else{ + System.out.println("Choice: finalization, No new command\n"); + if (index1 == -1){ + functionCont.str += "addComment(new Comment(_endLastTransaction,0," + commentNum + "));\nreturn " + nextCommandCont.num + SCCR; + commentText+="_comment[" + commentNum + "]=std::string(\"Exit branch taken\");\n"; + commentNum++; + nextCommandCont.str += ",(TMLCommand*)0"; + System.out.println("RETURN, ddINC NUM "+ nextCommandCont.num); + nextCommandCont.num++; + } + cmdName=MCResult; + } + } + + } else if (currElem instanceof TMLSelectEvt){ + TMLEvent evt; + Integer nbevt=0; + String evtList="",paramList=""; + System.out.println("Checking SelectEvt\n"); + cmdName= "_select" + currElem.getID(); + for(int i=0; i<currElem.getNbNext(); i++) { + evt=((TMLSelectEvt)currElem).getEvent(i); + if (evt!=null){ + nbevt++; + evtList += ",(TMLEventChannel*)"+ evt.getExtendedName(); + //paramList+=",0"; + if (evt.getNbOfParams()==0) { + paramList+=",(Parameter<ParamType>*)0"; + }else{ + paramList+=",new Parameter<ParamType>("; + for(int j=0; j<3; j++) { + if (j!=0) paramList += ","; + if (((TMLSelectEvt)currElem).getParam(i,j) == null) { + paramList += "0"; + } else { + if (((TMLSelectEvt)currElem).getParam(i,j).length() > 0) { + paramList += ((TMLSelectEvt)currElem).getParam(i,j); + } else { + paramList += "0"; + } + } + } + paramList+=")"; + } + nextCommand+= ",(TMLCommand*)" + makeCommands(currElem.getNextElement(i), true, retElement,null,null,lastSequence); + } + } + hcode+="TMLSelectCommand " + cmdName + SCCR; + //initCommand+= "," + cmdName + "(this,array("+ nbevt + evtList + "),"+ nbevt + ",0)"+CR; + initCommand+= "," + cmdName + "(this,array("+ nbevt + evtList + "),"+ nbevt + ",array("+ nbevt + paramList + "))"+CR; + nextCommand=cmdName + ".setNextCommand(array(" + nbevt + nextCommand + "))" + SCCR; + + } else { + System.out.println("Operator: " + currElem + " is not managed in SystemC" + "))" + SCCR); + } + chaining+=nextCommand; + return (cmdName.equals("0") || cmdName.charAt(0)=='&')? cmdName : "&"+cmdName; + } + + + public String makeCommandLenFunc(String cmdName, String lowerLimit, String upperLimit){ + if (upperLimit==null) + functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nreturn (unsigned int)(" + lowerLimit + ");\n}" + CR2; + else + functions+="unsigned int "+ reference + "::" + cmdName + "_func(){\nreturn (unsigned int)myrand(" + lowerLimit + "," + upperLimit + ");\n}" + CR2; + functionSig+="unsigned int " + cmdName + "_func()" + SCCR; + return "(LengthFuncPointer)&" + reference + "::" + cmdName + "_func"; + } + + +/*public String makeChoice(TMLActivityElement currElem){ + TMLChoice choice = (TMLChoice)currElem; + //System.out.println("nb of guards = " + choice.getNbGuard() + " nb of nexts =" + choice.getNbNext()); + String code = ""; + if (choice.getNbGuard() !=0 ) { + String code1 = "",guardS = "",code2; + int index1 = choice.getElseGuard(), index2 = choice.getAfterGuard(); + int nb = choice.nbOfNonDeterministicGuard(); + int nbS = choice.nbOfStochasticGuard(); + if ((nb > 0) || (nbS > 0)){ + code += "rnd__0 = myrand(0, 99)" + SCCR; + } + nb = 0; + for(int i=0; i<choice.getNbGuard(); i++) { + if (choice.isNonDeterministicGuard(i)) { + code2 = "(rnd__0 < " + Math.floor(100/choice.getNbGuard())*(nb+1) + ")"; + nb ++; + } else if (choice.isStochasticGuard(i)) { + if (guardS.length() == 0) { + guardS = choice.getStochasticGuard(i); + } else { + guardS = "(" + guardS + ")+(" + choice.getStochasticGuard(i) + ")"; + } + code2 = "(rnd__0 < (" + guardS + "))"; + nbS ++; + } else { + code2 = choice.getGuard(i); + code2 = Conversion.replaceAllChar(code2, '[', "("); + code2 = Conversion.replaceAllChar(code2, ']', ")"); + } + //System.out.println("guard = " + code1 + " i=" + i); + if (i != index2) { + if (i==0) { + code += "if " + code2; + } else { + code += " else "; + if (i != index1) { + code += "if " + code2; + } + } + code += "{\naddComment(new Comment(_endLastTransaction,\"Branch taken: " + code2 + "\"));\nreturn "+ i + SCCR +"}" + CR; + } + } + // If there was no else, do a terminate + if (index1 == -1) code += "addComment(new Comment(_endLastTransaction,\"Exit branch taken\"));\nreturn " + choice.getNbGuard() + SCCR; + code += code1; + } + return code; + }*/ + + public void makeEndClassH() { + hcode += "};" + CR + "#endif" + CR; + } + + + private String makeAttributesCode() { + String code = ""; + TMLAttribute att; + int i; + + ListIterator iterator = task.getAttributes().listIterator(); + + while(iterator.hasNext()) { + att = (TMLAttribute)(iterator.next()); + if (att.hasInitialValue()) + code += ","+ att.name + "(" + att.initialValue + ")"+CR; + else + code += ","+ att.name + "(0)"+CR; + } + return code; + } + + private String makeAttributesDeclaration() { + String code = ""; + TMLAttribute att; + int i; + + ListIterator iterator = task.getAttributes().listIterator(); + + while(iterator.hasNext()) { + att = (TMLAttribute)(iterator.next()); + //code += TMLType.getStringType(att.type.getType()) + " " + att.name; + code += "int " + att.name; + code += ";\n"; + } + + // Attributes for events + //code += "unsigned int arg__evt0" + SCCR; + //code += "unsigned int arg__evt1" + SCCR; + //code += "unsigned int arg__evt2" + SCCR; + + //Adding request arguments + //if (task.isRequested()) { + // code += "unsigned int arg1__req" + SCCR; + // code += "unsigned int arg2__req" + SCCR; + // code += "unsigned int arg3__req" + SCCR; + //} + + code += "int rnd__0" + SCCR; + //if (commentNum!=0) code+= "std::string _comment[" + commentNum + "]" + SCCR; + return code; + } + + + public String addSemicolonIfNecessary(String _input) { + String code1 = _input.trim(); + if (!(code1.endsWith(";"))) { + code1 += ";"; + } + return code1; + } + + public String modifyString(String _input) { + //System.out.println("Modify string=" + _input); + _input = Conversion.changeBinaryOperatorWithUnary(_input, "div", "/"); + _input = Conversion.changeBinaryOperatorWithUnary(_input, "mod", "%"); + //System.out.println("Modified string=" + _input); + return _input; + } + +} diff --git a/src/tmltranslator/tomappingsystemc2/TML2MappingSystemC.java b/src/tmltranslator/tomappingsystemc2/TML2MappingSystemC.java index 03180e6f17c276559ed792b7a80224740af65fb0..5631c66e0ecbef6e9fe84fbd21273f750e96b72f 100755 --- a/src/tmltranslator/tomappingsystemc2/TML2MappingSystemC.java +++ b/src/tmltranslator/tomappingsystemc2/TML2MappingSystemC.java @@ -251,7 +251,7 @@ public class TML2MappingSystemC { declaration += CR; //Registration of CPUs - HwLink link; + //HwLink link; declaration += "//Registration of CPUs" + CR; //iterator=tmlmapping.getTMLArchitecture().getHwNodes().listIterator(); //for(HwLink link: tmlmapping.getTMLArchitecture().getHwLinks()){ @@ -260,16 +260,34 @@ public class TML2MappingSystemC { PriorityQueue<HwLink> pq=new PriorityQueue<HwLink>(20); for(HwNode node: tmlmapping.getTMLArchitecture().getHwNodes()){ if (node instanceof HwExecutionNode){ - //getPriority - link = tmlmapping.getTMLArchitecture().getLinkByHwNode(node); - if (link==null){ + ArrayList<HwLink> nodeLinks= tmlmapping.getTMLArchitecture().getLinkByHwNode(node); + if (nodeLinks.isEmpty()) declaration+= "defaultBus.registerMasterDevice(&" + node.getName() + ")" + SCCR; - }else{ - pq.add(link); - //declaration+=link.bus.getName() + ".registerMasterDevice(&" + node.getName() + ")" + SCCR; - } + else + pq.addAll(nodeLinks); + //getPriority + //for(HwLink link: tmlmapping.getTMLArchitecture().getLinkByHwNode(node)){ + // if (link==null){ + // declaration+= "defaultBus.registerMasterDevice(&" + node.getName() + ")" + SCCR; + // }else{ + // pq.add(link); + // //declaration+=link.bus.getName() + ".registerMasterDevice(&" + node.getName() + ")" + SCCR; + // } + //} } } + //for(HwLink link: tmlmapping.getTMLArchitecture().getHwLinks()){ + //if (node instanceof HwExecutionNode){ + //link = tmlmapping.getTMLArchitecture().getLinkByHwNode(node); + //if (link==null){ + // declaration+= "defaultBus.registerMasterDevice(&" + node.getName() + ")" + SCCR; + //}else{ + //pq.add(link); + //declaration+=link.bus.getName() + ".registerMasterDevice(&" + node.getName() + ")" + SCCR; + //} + //} + //} + HwLink link; while (!pq.isEmpty()){ link = pq.remove(); declaration+=link.bus.getName() + ".registerMasterDevice(&" + link.hwnode.getName() + ")" + SCCR; @@ -310,7 +328,7 @@ public class TML2MappingSystemC { } declaration += CR;*/ - declaration+="gettimeofday(&end,NULL);\nstd::cout << \"The preparation took \" << getTimeDiff(begin,end) << \"usec.\\n\";\nsimulate(cpulist,buslist);\nschedule2HTML(cpulist,buslist,len,args);\nschedule2VCD(vcdlist,len,args);\nschedule2Graph(cpulist, len, args);\nreturn 0;\n}\n"; + declaration+="gettimeofday(&end,NULL);\nstd::cout << \"The preparation took \" << getTimeDiff(begin,end) << \"usec.\\n\";\nsimulate(cpulist,buslist);\nschedule2HTML(cpulist,buslist,len,args);\nschedule2VCD(vcdlist,len,args);\nschedule2Graph(cpulist, len, args);\nschedule2TXT(cpulist, len, args);\nreturn 0;\n}\n"; } diff --git a/src/tmltranslator/toturtle/Mapping2TIF.java b/src/tmltranslator/toturtle/Mapping2TIF.java index f93f8356fb078cb8a46fdcf6c33df8e8ab6bc47a..a48964acd16effcd2d8100fd1e904a4b89256173 100755 --- a/src/tmltranslator/toturtle/Mapping2TIF.java +++ b/src/tmltranslator/toturtle/Mapping2TIF.java @@ -1193,24 +1193,33 @@ public class Mapping2TIF { } - private void makeTaskAttributes(TClass tcpu, ArrayList<TMLTask> tasks) { + private void makeTaskAttributes(TClass tcpu, ArrayList<TMLTask> tasks) { + int i; + String init; + for(TMLTask task: tasks) { tcpu.addNewParamIfApplicable(task.getName() + "__state", "nat", "0"); tcpu.addNewParamIfApplicable(task.getName() + "__istate", "nat", "0"); //tcpu.addNewParamIfApplicable(task.getName() + "__blockedOn", "nat", "0"); for(TMLAttribute attribute:task.getAttributes()) { + init = attribute.initialValue; + if ((init == null) || (init.length() == 0)) { + init = attribute.getDefaultInitialValue(); + } switch(attribute.type.getType()) { case TMLType.NATURAL: - //System.out.println("Adding nat attribute:" + modifyString(tmla.name)); + //System.out.println("Adding nat attribute:" + attribute.name+ " init=" + attribute.initialValue); if (attribute.name.equals("i")) { - tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name + "_0", "nat", modifyString(attribute.initialValue, task)); + tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name + "_0", "nat", modifyString(init, task)); } else { - tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name, "nat", modifyString(attribute.initialValue, task)); + tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name, "nat", modifyString(init, task)); } + break; default: - tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name, "bool", modifyString(attribute.initialValue, task)); + //System.out.println("Adding other attribute:" + attribute.name + " init=" + init); + tcpu.addNewParamIfApplicable(task.getName() + "__" + attribute.name, "bool", modifyString(init, task)); } } } @@ -1282,7 +1291,7 @@ public class Mapping2TIF { tcpu.addNewParamIfApplicable("n__" + request.getName() + "__tmp", "nat", "0"); for(int i=0; i<request.getNbOfParams(); i++) { tcpu.addNewParamIfApplicable("fifo" + (i+1) + "__" + request.getName(), "Queue_nat", "nil"); - tcpu.addNewParamIfApplicable(modifyString("arg" + (i+1) + "__" + request.getName(), request.getDestinationTask()), "nat", "0"); + tcpu.addNewParamIfApplicable(modifyString("arg" + (i+1) + "__req", request.getDestinationTask()), "nat", "0"); } } } @@ -3335,11 +3344,14 @@ public class Mapping2TIF { if (i==index1) { /* else guard */ guard0 = modifyString(tmlchoice.getValueOfElse(), task); + //System.out.println("modified else guard=" + guard0); } else { if (tmlchoice.isStochasticGuard(i)) { guard0 = "[ ]"; } else { + //System.out.println("guard=" + tmlchoice.getGuard(i)); guard0 = modifyString(tmlchoice.getGuard(i), task); + //System.out.println("modified guard=" + guard0); } } actionp1 = getStateIdActionState(tcpu, ad, task, stateId); @@ -3505,7 +3517,7 @@ public class Mapping2TIF { } private ADActionStateWithParam getReqFirstActionStateWithParam(TClass tcpu, ActivityDiagram ad, TMLTask task, TMLRequest req, int index) { - Param p = tcpu.getParamByName(modifyString("arg" + index + "__" + req.getName(), task)); + Param p = tcpu.getParamByName(modifyString("arg" + index + "__req", task)); ADActionStateWithParam actionp = new ADActionStateWithParam(p); actionp.setActionValue("First(fifo" + index + "__" + req.getName() + ")"); ad.add(actionp); diff --git a/src/tmltranslator/toturtle/TML2TURTLE.java b/src/tmltranslator/toturtle/TML2TURTLE.java index b12ddcca33d6606d019ea1303a2202cef6e1840d..f397614f4eb3643bcccb1edd6418f5c361d1d5ac 100755 --- a/src/tmltranslator/toturtle/TML2TURTLE.java +++ b/src/tmltranslator/toturtle/TML2TURTLE.java @@ -449,7 +449,17 @@ public class TML2TURTLE { adinterval.addNext(adc1); return adinterval; - + // DELAY + } else if (tmle instanceof TMLDelay) { + adinterval = new ADTimeInterval(); + newElements.add(adinterval); + baseElements.add(tmle); + tclass.getActivityDiagram().add(adinterval); + adc1 = translateAD(newElements, baseElements, tclass, task, tmle.getNextElement(0), adinterval, adjunc); + adinterval.setValue(modifyString(((TMLDelay)tmle).getMinDelay()), modifyString(((TMLDelay)tmle).getMaxDelay())); + adinterval.addNext(adc1); + return adinterval; + // TMLRandom } else if (tmle instanceof TMLRandom) { tmlrandom = (TMLRandom)tmle; diff --git a/src/tmltranslator/touppaal/TML2UPPAAL.java b/src/tmltranslator/touppaal/TML2UPPAAL.java index f636ac44184a11e40f598a32d44f289b4154602e..1e2d0a4354a074eeb5f104f1f6ca540cb350ac7c 100755 --- a/src/tmltranslator/touppaal/TML2UPPAAL.java +++ b/src/tmltranslator/touppaal/TML2UPPAAL.java @@ -471,7 +471,7 @@ public class TML2UPPAAL { makeElementBehavior(task, template, elt.getNextElement(0), loc1, end); // EXEC operations -> ignored - } else if ((elt instanceof TMLExecI) || (elt instanceof TMLExecC) ||(elt instanceof TMLExecIInterval)|| (elt instanceof TMLExecCInterval)) { + } else if ((elt instanceof TMLExecI) || (elt instanceof TMLExecC) ||(elt instanceof TMLExecIInterval)|| (elt instanceof TMLExecCInterval)|| (elt instanceof TMLDelay)) { rtu.addTMLActivityElementLocation(elt, previous, previous); makeElementBehavior(task, template, elt.getNextElement(0), previous, end); diff --git a/src/translator/TClass.java b/src/translator/TClass.java index 3b420e4861ff1824c0635ed8b660202838b14d06..3bde60338ab305f3d9b37ffdc6cf208738a4a4e6 100755 --- a/src/translator/TClass.java +++ b/src/translator/TClass.java @@ -536,6 +536,28 @@ public class TClass { } + } + + public void printParamsValues() { + Param p; + + for(int i=0; i<paramList.size(); i++) { + p = (Param)(paramList.elementAt(i)); + System.out.println("Param #" + i + "= |" + p.getName() + "=" + p.getValue() + "|"); + + } + + } + + public void printGates() { + Gate g; + + for(int i=0; i<gateList.size(); i++) { + g = (Gate)(gateList.elementAt(i)); + System.out.println("Gate #" + i + "= |" + g.getName() + "|"); + + } + } public void setPackageName(String _name) { diff --git a/src/translator/TURTLEModelChecker.java b/src/translator/TURTLEModelChecker.java index c790347a50fca7f85e3fdc45e497efbfae024a4d..76381067732a8acee2d694b885ba1096f531d0cf 100755 --- a/src/translator/TURTLEModelChecker.java +++ b/src/translator/TURTLEModelChecker.java @@ -480,7 +480,7 @@ public class TURTLEModelChecker { /** * Parsing in two steps: - * 1. Parsing the expression with no varaible checking + * 1. Parsing the expression with no variable checking * 2. Parsing the expression with variables values to see whether variables are well-placed or not * The second parsing is performed iff the first one succeeds */ @@ -558,9 +558,13 @@ public class TURTLEModelChecker { // Tree analysis: if the tree contains a variable, then, this variable has not been declared ArrayList<String> vars = root.getVariables(); for(String s: vars) { - CheckingError error = new CheckingError(CheckingError.BEHAVIOR_ERROR, s + ": " + ERROR_AD_009_2 + " in expression " + action + " of tclass " + t.getName()); - error.setTClass(t); - errors.add(error); + // is that string a variable? + if ((s.compareTo("true") != 0) && (s.compareTo("false") != 0) && (s.compareTo("nil") != 0)) { + System.out.println("Variable not declared: " +s); + CheckingError error = new CheckingError(CheckingError.BEHAVIOR_ERROR, s + ": " + ERROR_AD_009_2 + " in expression " + action + " of tclass " + t.getName()); + error.setTClass(t); + errors.add(error); + } } } diff --git a/src/translator/TURTLEModeling.java b/src/translator/TURTLEModeling.java index 81f995ad0d531d0b0ebf4103a389af88ba618fd7..87e5e3f6c3e25537cd803dfff9162fecb9001303 100755 --- a/src/translator/TURTLEModeling.java +++ b/src/translator/TURTLEModeling.java @@ -1572,7 +1572,9 @@ public class TURTLEModeling { for(i=0; i<tclass.size(); i++) { t = (TClass)(tclass.elementAt(i)); System.out.println("\nTClass " + t.getName()); - // t.getActivityDiagram().print(); + t.printParamsValues(); + t.printGates(); + //t.getActivityDiagram().print(); } for(i=0; i<relation.size(); i++) { diff --git a/src/translator/TURTLETranslator.java b/src/translator/TURTLETranslator.java index 88ec6c08ce1e169c2e37d36df6921682065bca1a..eb904023fb6fb01d8efeb7b4f7e0f75c0427b341 100755 --- a/src/translator/TURTLETranslator.java +++ b/src/translator/TURTLETranslator.java @@ -130,6 +130,12 @@ public class TURTLETranslator { } public String generateLOTOS(boolean xtendedNatural) { + + //System.out.println("Printing TM"); + //System.out.println("null? generate"); + //tm.print(); + //System.out.println("end null?"); + buildLOTOS(xtendedNatural); int i; @@ -153,8 +159,21 @@ public class TURTLETranslator { tm.translateInvocationIntoSynchronization(); tm.translateActionStatesWithMultipleParams(); + //System.out.println("null? generate 1"); + //tm.print(); + //System.out.println("end null?"); + tm.removeUselessVariables(); - tm.removeUselessGates(); + + //System.out.println("null? generate 12"); + //tm.print(); + //System.out.println("end null?"); + + //tm.removeUselessGates(); + + //System.out.println("null? generate 2"); + //tm.print(); + //System.out.println("end null?"); mgm = new MasterGateManager(tm, false); mgm.sort(); @@ -1288,9 +1307,11 @@ public class TURTLETranslator { } private String translateADChoice(ADChoice ad) { + if (ad.realNbOfNext() < 1) return ""; + //System.out.println("GUARD=" + ad.getGuard(0)); if (ad.realNbOfNext() == 1) { if (Conversion.replaceAllString(ad.getGuard(0), " ", "").compareTo("[]") == 0) { translateActivity(ad.getNext(0), ad); diff --git a/src/ui/DefaultText.java b/src/ui/DefaultText.java index 0ad5cd6a3138202d8cd3884afdbfb92215877700..e89110010095cdebc4a6475efe11d02141a526b1 100755 --- a/src/ui/DefaultText.java +++ b/src/ui/DefaultText.java @@ -58,7 +58,7 @@ public class DefaultText { } public static String getVersion() { - return "0.91-beta5"; /* Set new release September, 19th, 2008 */ + return "0.91-beta6"; /* Set new release November, 10th, 2008 */ } public static String getFullVersion() { diff --git a/src/ui/DesignPanelTranslator.java b/src/ui/DesignPanelTranslator.java index 395b38303243fc2b2db40fe9065cde9b1615ed60..00e17cafb192fcf7d4fc72d888b5f7d1a75a578b 100755 --- a/src/ui/DesignPanelTranslator.java +++ b/src/ui/DesignPanelTranslator.java @@ -164,6 +164,13 @@ public class DesignPanelTranslator { p.setAccess(a.getAccessString()); t.addParameter(p); } + + if (a.getType() == TAttribute.QUEUE_NAT) { + p = new Param(a.getId(), Param.QUEUE_NAT, a.getInitialValue()); + p.setAccess(a.getAccessString()); + t.addParameter(p); + //System.out.println("Adding queuenat parameter"); + } if (a.getType() == TAttribute.OTHER) { addTDataAttributes(a, t, tdp, tm); @@ -231,6 +238,12 @@ public class DesignPanelTranslator { p.setAccess(a.getAccessString()); t.addParameter(p); } + + if (b.getType() == TAttribute.QUEUE_NAT) { + p = new Param(a.getId() + "__" + b.getId(), Param.QUEUE_NAT, b.getInitialValue()); + p.setAccess(a.getAccessString()); + t.addParameter(p); + } } } @@ -391,7 +404,7 @@ public class DesignPanelTranslator { for(j=0; j<nbActions; j++) { sTmp = TURTLEModeling.manageDataStructures(t,((TADActionState)(tgc)).getAction(j)); if (sTmp == null) { - ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (" + s + "): \"" + s + "\" is not a correct expression"); + ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (0) (" + s + "): \"" + s + "\" is not a correct expression"); ce.setTClass(t); ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); @@ -400,7 +413,7 @@ public class DesignPanelTranslator { p = t.getParamFromActionState(sTmp); if (p == null) { - ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state(" + s + "): \"" + sTmp + "\" is not a correct expression"); + ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (1) (" + s + "): \"" + sTmp + "\" is not a correct expression"); ce.setTClass(t); ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); @@ -413,7 +426,7 @@ public class DesignPanelTranslator { adamp.setActionValue(TURTLEModeling.manageDataStructures(t, s)); listE.addCor(adamp, tgc); } else { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (" + s + "): \"" + s + "\" is not a correct expression"); + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (2) (" + s + "): \"" + s + "\" is not a correct expression"); ce.setTClass(t); ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); diff --git a/src/ui/DocumentationGenerator.java b/src/ui/DocumentationGenerator.java index fa173f09e86cb814e489a287d62639cf619844a9..f07f6078c6fa8ad75c93e5a76ee59a3c83c78280 100644 --- a/src/ui/DocumentationGenerator.java +++ b/src/ui/DocumentationGenerator.java @@ -52,26 +52,47 @@ import java.util.*; import java.io.*; import java.awt.image.*; import javax.imageio.*; +import java.text.*; import myutil.*; +import ui.ad.*; +import ui.dd.*; +import ui.tmlad.*; +import ui.tmlcd.*; +import ui.tmldd.*; -public class DocumentationGenerator { +public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIElement { // type private Vector panels; // TURTLEPanels private JTabbedPane mainTabbedPane; private int firstHeadingNumber = 1; - private String title = "TTTool project"; + private String title = "TTool project:"; private String fileName = "doc.html"; private String path; + private String projectName; + + private int cpt, total; // For loops -> to know at which point it is of its algorithm + private boolean finished = false; + private boolean go = true; + private boolean stopped = false; + private String panelName = ""; + private String doc; - public DocumentationGenerator(Vector _panels, JTabbedPane _mainTabbedPane, String _path) { + public DocumentationGenerator(Vector _panels, JTabbedPane _mainTabbedPane, String _path, String _projectName) { panels = _panels; mainTabbedPane = _mainTabbedPane; path = _path + "/"; + projectName = _projectName; + + int i,j; + for(i=0; i<panels.size(); i++) { + TURTLEPanel tp = (TURTLEPanel)(panels.elementAt(i)); + total += tp.panels.size(); + } } public void setFirstHeadingNumber(int _firstHeadingNumber) { @@ -90,34 +111,115 @@ public class DocumentationGenerator { return title; } + public void goElement() { + finished = false; + go = true; + } + + public void stopElement(){ + go = false; + } + + public boolean hasFinished() { + return (finished == true); + } + + public void setFinished() { + finished = true; + go = false; + } + + public boolean hasBeenStopped() { + return (stopped == true); + } + + public String getCurrentActivity() { + return "Generating documentation for " + panelName; + } + public boolean generateDocumentation() { - int i, j; + int i,j; + cpt = 0; BufferedImage image; TURTLEPanel tp; TDiagramPanel tdp; File file1; + String tmp; doc = ""; doc += "<html>\n"; doc += getDocumentationHeader(); doc += "<body>\n"; + doc +="<center><h1>" + title + "</h1></center>\n"; + doc +="<center><b><h1>" + projectName + "</h1></b></center>\n<br><br>\n"; + for(i=0; i<panels.size(); i++) { tp = (TURTLEPanel)(panels.elementAt(i)); - doc += "<h" + firstHeadingNumber + ">" + mainTabbedPane.getTitleAt(i) + "</h" + firstHeadingNumber + ">\n"; + + tmp = mainTabbedPane.getTitleAt(i); + panelName = tmp; + + if (tp instanceof TMLDesignPanel) { + tmp = "DIPLODOCUS Application Modeling: " + tmp; + } + if (tp instanceof TMLComponentDesignPanel) { + tmp = "DIPLODOCUS Component-based Application Modeling: " + tmp; + } + if (tp instanceof TMLArchiPanel) { + tmp = "DIPLODOCUS Architecture / Mapping Modeling: " + tmp; + } + if (tp instanceof DesignPanel) { + tmp = "TURTLE Design"; + } + if (tp instanceof AnalysisPanel) { + tmp = "TURTLE Analysis"; + } + if (tp instanceof DeploymentPanel) { + tmp = "TURTLE Deployment"; + } + + doc += "<br>\n<h" + firstHeadingNumber + ">" + tmp + "</h" + firstHeadingNumber + ">\n"; for(j=0; j<tp.panels.size(); j++) { + if (go == false) { + return false; + } tdp = (TDiagramPanel)(tp.panels.elementAt(j)); - doc += "<h" + (firstHeadingNumber+1) + ">" + tp.tabbedPane.getTitleAt(j) + "</h" + (firstHeadingNumber+1) + ">\n"; + + tmp = tp.tabbedPane.getTitleAt(j); + + if (tdp instanceof TMLActivityDiagramPanel) { + tmp = "Behavior of Task: " + tmp; + } + + if (tdp instanceof TActivityDiagramPanel) { + tmp = "Behavior of TClass: " + tmp; + } + + if (tdp instanceof TMLTaskDiagramPanel) { + tmp = "Task and communications between tasks"; + } + + if (tdp instanceof TMLArchiDiagramPanel) { + tmp = ""; + } + + if (tdp instanceof TDeploymentDiagramPanel) { + tmp = ""; + } + + doc += "<h" + (firstHeadingNumber+1) + ">" + tmp + "</h" + (firstHeadingNumber+1) + ">\n"; image = tdp.performMinimalCapture(); file1 = new File(path + "img_" + i + "_" + j + ".png"); //frame.paint(frame.getGraphics()); try { // save captured image to PNG file ImageIO.write(image, "png", file1); - doc += "<img src=\"img_" + i + "_" + j + "\" align=center>\n"; + doc += "<center><img src=\"img_" + i + "_" + j + ".png\" align=\"middle\" title=\"" + tmp + "\"></center>\n"; } catch (Exception e) { System.out.println("Image (" + i + ", " + j + ") could not be captured"); } + cpt ++; } } @@ -126,20 +228,32 @@ public class DocumentationGenerator { try { FileUtils.saveFile(path+fileName, doc); } catch (FileException fe) { - System.out.println("HTML file couldnot be saved"); + System.out.println("HTML file could not be saved"); return false; } + finished = true; + return true; } + public int getPercentage() { + return (int)((cpt*100) / total); + } + public String getDocumentationHeader() { + GregorianCalendar calendar = (GregorianCalendar)GregorianCalendar.getInstance(); + Date date = calendar.getTime(); + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm"); + String formattedDate = formatter.format(date); + String tmpdoc=""; - tmpdoc += "<!----- Automatically generated by TTool "; - tmpdoc += DefaultText.getFullVersion(); + tmpdoc += "<!----- Automatically generated by TTool version "; + tmpdoc += DefaultText.getVersion(); + tmpdoc += " generation date: " + formattedDate; tmpdoc += "---->\n"; tmpdoc += "\n<head>\n<title>"; - tmpdoc += getTitle(); + tmpdoc += getTitle() + ": " +projectName; tmpdoc += "</title>\n</head>\n"; return tmpdoc; } diff --git a/src/ui/GCTMLModeling.java b/src/ui/GCTMLModeling.java index 088422b7d8055bc227be40086c3762a7c9e923b6..16b4952c72e6e59c36dfa6ee226e5a3da410d8b9 100755 --- a/src/ui/GCTMLModeling.java +++ b/src/ui/GCTMLModeling.java @@ -466,6 +466,7 @@ public class GCTMLModeling { TMLExecIInterval tmlexecii; TMLExecC tmlexecc; TMLExecCInterval tmlexecci; + TMLDelay tmldelay; TMLForLoop tmlforloop; TMLReadChannel tmlreadchannel; TMLSendEvent tmlsendevent; @@ -535,6 +536,20 @@ public class GCTMLModeling { tmlexecci.setMaxDelay(((TMLADExecCInterval)tgc).getMaxDelayValue()); activity.addElement(tmlexecci); listE.addCor(tmlexecci, tgc); + } else if (tgc instanceof TMLADDelay) { + tmldelay = new TMLDelay("d-delay", tgc); + tmldelay.setMinDelay(((TMLADDelay)tgc).getDelayValue()); + tmldelay.setMaxDelay(((TMLADDelay)tgc).getDelayValue()); + tmldelay.setUnit(((TMLADDelay)tgc).getUnit()); + activity.addElement(tmldelay); + listE.addCor(tmldelay, tgc); + } else if (tgc instanceof TMLADDelayInterval) { + tmldelay = new TMLDelay("nd-delay", tgc); + tmldelay.setMinDelay(((TMLADDelayInterval)tgc).getMinDelayValue()); + tmldelay.setMaxDelay(((TMLADDelayInterval)tgc).getMaxDelayValue()); + tmldelay.setUnit(((TMLADDelayInterval)tgc).getUnit()); + activity.addElement(tmldelay); + listE.addCor(tmldelay, tgc); } else if (tgc instanceof TMLADForLoop) { tmlforloop = new TMLForLoop("loop", tgc); tmlforloop.setInit(((TMLADForLoop)tgc).getInit()); diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index 3a6bdb0fbd895f607987c15968b50af52f132c31..41439777dfb4f6ef3465bac7b98083781b1b230d 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -414,7 +414,8 @@ public class GTMLModeling { for(int j=0; j<request.getNbOfParams(); j++) { tmltt = new TMLType(request.getType(j).getType()); tmlattr = new TMLAttribute("arg" + (j + 1) + "__req", tmltt); - System.out.println("Adding " + tmlattr.getName() + " to " + task.getName()); + tmlattr.initialValue = tmlattr.getDefaultInitialValue(); + System.out.println("Adding " + tmlattr.getName() + " to " + task.getName() + "with value =" + tmlattr.initialValue); task.addAttribute(tmlattr); } @@ -773,6 +774,7 @@ public class GTMLModeling { } tmlt = new TMLAttribute(ta.getId(), tt); tmlt.initialValue = ta.getInitialValue(); + //System.out.println("ta =" + ta.getId() + " value=" + ta.getInitialValue()); tmltask.addAttribute(tmlt); } @@ -884,6 +886,7 @@ public class GTMLModeling { TMLWriteChannel tmlwritechannel; TMLSequence tmlsequence; TMLSelectEvt tmlselectevt; + TMLDelay tmldelay; int staticLoopIndex = 0; String sl = "", tmp; TMLType tt; @@ -945,6 +948,20 @@ public class GTMLModeling { tmlexecci.setMaxDelay(((TMLADExecCInterval)tgc).getMaxDelayValue()); activity.addElement(tmlexecci); listE.addCor(tmlexecci, tgc); + } else if (tgc instanceof TMLADDelay) { + tmldelay = new TMLDelay("d-delay", tgc); + tmldelay.setMinDelay(((TMLADDelay)tgc).getDelayValue()); + tmldelay.setMaxDelay(((TMLADDelay)tgc).getDelayValue()); + tmldelay.setUnit(((TMLADDelay)tgc).getUnit()); + activity.addElement(tmldelay); + listE.addCor(tmldelay, tgc); + } else if (tgc instanceof TMLADDelayInterval) { + tmldelay = new TMLDelay("nd-delay", tgc); + tmldelay.setMinDelay(((TMLADDelayInterval)tgc).getMinDelayValue()); + tmldelay.setMaxDelay(((TMLADDelayInterval)tgc).getMaxDelayValue()); + tmldelay.setUnit(((TMLADDelayInterval)tgc).getUnit()); + activity.addElement(tmldelay); + listE.addCor(tmldelay, tgc); } else if (tgc instanceof TMLADForLoop) { tmlforloop = new TMLForLoop("loop", tgc); tmlforloop.setInit(((TMLADForLoop)tgc).getInit()); @@ -1326,6 +1343,8 @@ public class GTMLModeling { } private void makeArchitecture() { + archi.setMasterClockFrequency(tmlap.tmlap.getMasterClockFrequency()); + if (nodesToTakeIntoAccount == null) { components = tmlap.tmlap.getComponentList(); } else { diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index fb40cdee42545bd72b93acb24ced7a9a4144fb40..95e5aa44ce162050657ab88b0e974e2ef75a24cb 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -4861,6 +4861,7 @@ public class GTURTLEModeling { } public boolean translateTMLMapping(boolean _sample, boolean _channel, boolean _event, boolean _request, boolean _exec, boolean _busTransfers, boolean _scheduling, boolean _taskState, boolean _channelState, boolean _branching, boolean _terminateCPU, boolean _terminateCPUs, boolean _clocked, String _tickValue, boolean _endClocked, boolean _countTick, boolean _maxCountTick, String _maxCountTickValue, boolean _randomTask) { + //System.out.println("TML=" + tmap.toString()); Mapping2TIF m2tif = new Mapping2TIF(tmap); m2tif.setShowSampleChannels(_sample); m2tif.setShowChannels(_channel); @@ -4884,7 +4885,13 @@ public class GTURTLEModeling { m2tif.setShowBranching(_branching); m2tif.setRandomTasks(_randomTask); tm = m2tif.generateTURTLEModeling(); - tmState = 1; + //StringBuffer sb = tm.printToStringBuffer(); + //System.out.println("tm=" + sb); + + + + return true; + /*tmState = 1; System.out.println("tm generated from TMAP"); checkingErrors = m2tif.getCheckingErrors(); if ((checkingErrors != null) && (checkingErrors.size() > 0)){ @@ -4892,7 +4899,8 @@ public class GTURTLEModeling { } else { // Optimize System.out.println("Optimize TIF"); - //tm.optimize(); + return true; + /*tm.optimize(); //System.out.println("Optimize done"); //tm.print(); TURTLEModelChecker tmc = new TURTLEModelChecker(tm); @@ -4905,7 +4913,7 @@ public class GTURTLEModeling { System.out.println("false"); return false; } - } + }*/ } //Added by Solange diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 457e2bc936c4dfbe49fd880e741242bbc56f4232..40c101a4d3d8207ba903c16ba3892c4ed5872357 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -2323,13 +2323,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { JDialogSelectTMLNodes.validated = tmlap.validated; JDialogSelectTMLNodes.ignored = tmlap.ignored; Vector tmlNodesToValidate = new Vector(); - JDialogSelectTMLNodes jdstmln = new JDialogSelectTMLNodes(frame, tmlNodesToValidate, tmlap.tmlap.getComponentList(), "Choosing Nodes to validate"); + JDialogSelectTMLNodes jdstmln = new JDialogSelectTMLNodes(frame, tmlNodesToValidate, tmlap.tmlap.getComponentList(), "Choosing Nodes to validate", tmlap.tmlap.getMasterClockFrequency()); if (!automatic) { GraphicLib.centerOnParent(jdstmln); jdstmln.setVisible(true); // Blocked until dialog has been closed } else { jdstmln.closeDialog(); } + tmlap.tmlap.setMasterClockFrequency(jdstmln.getClock()); + if (tmlNodesToValidate.size() > 0) { tmlap.validated = JDialogSelectTMLNodes.validated; tmlap.ignored = JDialogSelectTMLNodes.ignored; @@ -3366,10 +3368,23 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } public void generateDocumentation() { - System.out.println("Documentation"); - DocumentationGenerator docgen = new DocumentationGenerator(tabs, mainTabbedPane, ConfigurationTTool.IMGPath); - docgen.generateDocumentation(); - System.out.println("Documentation=" + docgen.getDocumentation()); + //System.out.println("Documentation"); + ThreadGUIElement t = new ThreadGUIElement(frame, 1, tabs, mainTabbedPane, ConfigurationTTool.IMGPath, file.getName(),"Documentation", "Generating documentation ... Please wait"); + t.go(); + /*DocumentationGenerator docgen = new DocumentationGenerator(tabs, mainTabbedPane, ConfigurationTTool.IMGPath, file.getName()); + docgen.setFirstHeadingNumber(2); + if (docgen.generateDocumentation()) { + JOptionPane.showMessageDialog(frame, + "All done!", + "Documentation generation", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(frame, + "The documentation generation could not be performed", + "Error", + JOptionPane.INFORMATION_MESSAGE); + }*/ + //System.out.println("Documentation=" + docgen.getDocumentation()); } public int getTypeButtonSelected() { @@ -4480,14 +4495,35 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void requestRenameTab(int index) { + String oldName = mainTabbedPane.getTitleAt(index); String s = (String)JOptionPane.showInputDialog(frame, "TURTLE modeling:", "Name=", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, null, mainTabbedPane.getTitleAt(index)); if ((s != null) && (s.length() > 0)){ // name already in use? - mainTabbedPane.setTitleAt(index, s); - changeMade(getCurrentTDiagramPanel(), ((TURTLEPanel)(tabs.elementAt(index))).tdp.MOVE_COMPONENT); + if (s.compareTo(oldName) != 0) { + mainTabbedPane.setTitleAt(index, s); + changeMade(getCurrentTDiagramPanel(), ((TURTLEPanel)(tabs.elementAt(index))).tdp.MOVE_COMPONENT); + + TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index)); + if ((tp instanceof TMLDesignPanel) || (tp instanceof TMLComponentDesignPanel)) { + renameMapping(oldName, s); + } + + } } changeMade(null, -1); } + + public void renameMapping(String oldName, String newName) { + TURTLEPanel tp; + + for(int i = 0; i<mainTabbedPane.getTabCount(); i++) { + tp = (TURTLEPanel)(tabs.elementAt(i)); + if (tp instanceof TMLArchiPanel) { + ((TMLArchiPanel)tp).renameMapping(oldName, newName); + } + } + + } public boolean selectTDiagramPanel(TDiagramPanel tdp) { return (selectTab(getPoint(tdp)) == tdp); @@ -5111,6 +5147,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_EXECC); } else if (command.equals(actions[TGUIAction.TMLAD_EXECC_INTERVAL].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_EXECC_INTERVAL); + } else if (command.equals(actions[TGUIAction.TMLAD_DELAY].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_DELAY); + } else if (command.equals(actions[TGUIAction.TMLAD_INTERVAL_DELAY].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_INTERVAL_DELAY); } else if (command.equals(actions[TGUIAction.TMLAD_FOR_LOOP].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_FOR_LOOP); } else if (command.equals(actions[TGUIAction.TMLAD_FOR_STATIC_LOOP].getActionCommand())) { diff --git a/src/ui/TAttribute.java b/src/ui/TAttribute.java index 6480961cc2c4630194928cc810ed47209c935be6..3d79f205f2807e742d8ceb2ac3be7162d6d9fa66 100755 --- a/src/ui/TAttribute.java +++ b/src/ui/TAttribute.java @@ -179,6 +179,8 @@ public class TAttribute { return ((value == null) ||(value.equals(""))); case OTHER: return ((value == null) ||(value.equals(""))); + case QUEUE_NAT: + return ((value == null) ||(value.equals("")) || (value.equals("nil"))); default: return false; } @@ -224,7 +226,7 @@ public class TAttribute { } else if (s.equals("InGate")) { return INGATE; } else if (s.equals("Queue_nat")) { - return INGATE; + return QUEUE_NAT; } else if (!s.equals("")) { return OTHER; } diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index 9d030758cca1a797caea4eacd0d86b8d4d1a40dd..157329513e964c36861ebd84dfcc828d23f867df 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -2408,6 +2408,30 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } return name; } + + public String findNodeName(String name) { + boolean ok; + int i; + int index = 0; + TGComponent tgc; + Iterator iterator; + + while(index >= 0) { + ok = true; + iterator = componentList.listIterator(); + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc.getName().equals(name + index)) { + ok = false; + } + } + if (ok) { + return name + index; + } + index ++; + } + return name; + } public boolean isTClassNameUnique(String s) { Object o; diff --git a/src/ui/TGCAttributeBox.java b/src/ui/TGCAttributeBox.java index 39eaaca30552da615047b70379512f1681501e79..5fe03fc622f8585193214b1c33bc8dfd228db3d7 100755 --- a/src/ui/TGCAttributeBox.java +++ b/src/ui/TGCAttributeBox.java @@ -288,6 +288,8 @@ public abstract class TGCAttributeBox extends TGCWithoutInternalComponent { if (valueAtt.equals("null")) { valueAtt = ""; } + + //System.out.println("Studying attribute " + id); if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) { //System.out.println("Adding attribute " + id + " typeOther=" + typeOther); TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther); diff --git a/src/ui/TGCTimeDelay.java b/src/ui/TGCTimeDelay.java new file mode 100644 index 0000000000000000000000000000000000000000..b735c328a5fa21ccf52f28293665c3c9e3ed4fdc --- /dev/null +++ b/src/ui/TGCTimeDelay.java @@ -0,0 +1,251 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class TGCTimeDelay +* Internal component that is a time interval / or a single time with a unit +* Creation: 10/11/2008 +* @version 1.0 10/11/2008 +* @author Ludovic APVRILLE +* @see +*/ + +package ui; + +import java.awt.*; +//import java.awt.geom.*; +import javax.swing.*; +import org.w3c.dom.*; + +import myutil.*; +import ui.window.*; + +public class TGCTimeDelay extends TGCWithoutInternalComponent{ + protected int minWidth = 10; + private String minDelay = ""; + private String maxDelay = ""; + private String unit = "ns"; // can be "ns" or "us" or "ms" or "s"; + private boolean hasMaxDelay; + + public TGCTimeDelay(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + nbConnectingPoint = 0; + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = false; + + name = ""; + value = "interval value"; + + myImageIcon = IconManager.imgic302; + } + + public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 1); + if ((w1 != width) && (!tdp.isScaled())) { + //System.out.println("x=" + x + " y=" + y + " width=" + width + " height=" + height); + //setCd(x + width/2 - w1/2, g.getFontMetrics().getHeight()); + width = w1; + height = g.getFontMetrics().getHeight(); + //updateConnectingPoints(); + } + + if (value.equals("")) { + g.drawString("unspecified value", x, y); + if (!tdp.isScaled()) + width = g.getFontMetrics().stringWidth("unspecified value"); + } else { + g.drawString(value, x, y); + } + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y - height, Math.max(width, minWidth), height)) { + return this; + } + return null; + } + + public void makeValue() { + if (hasMaxDelay) { + if (minDelay.equals("") && maxDelay.equals("")) { + value = ""; + return; + } + if ((minDelay.equals("")) && (!maxDelay.equals(""))){ + minDelay = "0"; + } + + value = "[" + minDelay + ", " + maxDelay + "] " + getUnit(); + } else { + if (minDelay.equals("")) { + value = ""; + return; + } + + value = minDelay + " " + getUnit(); + } + } + + public boolean editOndoubleClick(JFrame frame) { + String oldMin = getMinDelay(); + String oldMax = getMaxDelay(); + String oldUnit = getUnit(); + String[] array = new String[3]; + String ind; + if (hasMaxDelay) { + ind = "min"; + } else { + ind = "value"; + } + array[0] = getMinDelay(); array[1] = getMaxDelay(); array[2] = getUnit(); + + JDialogTimeIntervalUnit jdti = new JDialogTimeIntervalUnit(frame, array, hasMaxDelay, "Setting time parameters", ind, "max"); + jdti.setSize(350, 250); + GraphicLib.centerOnParent(jdti); + jdti.show(); // blocked until dialog has been closed + + minDelay = array[0]; maxDelay = array[1]; unit = array[2]; + + if (hasMaxDelay) { + if ((minDelay != null) && (maxDelay != null) && (unit != null) && ((!minDelay.equals(oldMin)) || (!maxDelay.equals(oldMax) || (!unit.equals(oldUnit))))){ + makeValue(); + return true; + } + } else { + if ((minDelay != null) && (unit != null) && ((!minDelay.equals(oldMin)) || (!unit.equals(oldUnit)))){ + makeValue(); + return true; + } + } + + minDelay = oldMin; + maxDelay = oldMax; + unit = oldUnit; + return false; + } + + public String getMinDelay() { + return minDelay; + } + + public String getMaxDelay() { + return maxDelay; + } + + public void setHasMaxValue(boolean b) { + hasMaxDelay = b; + } + + public void setMinDelay(String del) { + minDelay = del; + makeValue(); + } + + public void setMaxDelay(String del) { + maxDelay = del; + makeValue(); + } + + public void setUnit(String _unit) { + unit = _unit; + } + + public String getUnit() { + return unit; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<TimeDelay minDelay=\""); + sb.append(getMinDelay()); + sb.append("\" maxDelay=\""); + sb.append(getMaxDelay()); + sb.append("\" hasMaxDelay=\""); + sb.append(hasMaxDelay); + sb.append("\" unit=\""); + sb.append(getUnit()); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + NodeList nli; + Node n1, n2; + Element elt; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("TimeDelay")) { + minDelay = elt.getAttribute("minDelay"); + maxDelay = elt.getAttribute("maxDelay"); + if (elt.getAttribute("hasMaxDelay") != null) { + if (elt.getAttribute("hasMaxDelay").compareTo("true") == 0) { + hasMaxDelay = true; + } else { + hasMaxDelay = false; + } + } + unit = elt.getAttribute("unit"); + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + makeValue(); + } +} \ No newline at end of file diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index 0b3363bff45105ca527bd1a2d6c394ebfd0c3457..28001dfc9bd22f96ade8f1e6c480e578f96bf889 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -181,6 +181,8 @@ public class TGComponentManager { public static final int TMLAD_EXECC = 1021; public static final int TMLAD_EXECC_INTERVAL = 1022; public static final int TMLAD_RANDOM = 1024; + public static final int TMLAD_DELAY = 1026; + public static final int TMLAD_INTERVAL_DELAY = 1028; public static final int TMLARCHI_CPUNODE = 1100; public static final int TMLARCHI_ARTIFACT = 1101; @@ -438,6 +440,12 @@ public class TGComponentManager { break; case TMLAD_EXECC_INTERVAL: tgc = new TMLADExecCInterval(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case TMLAD_DELAY: + tgc = new TMLADDelay(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case TMLAD_INTERVAL_DELAY: + tgc = new TMLADDelayInterval(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; case TMLAD_FOR_LOOP: tgc = new TMLADForLoop(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -726,6 +734,10 @@ public class TGComponentManager { return TMLAD_EXECC; } else if (tgc instanceof TMLADExecCInterval) { return TMLAD_EXECC_INTERVAL; + } else if (tgc instanceof TMLADDelay) { + return TMLAD_DELAY; + } else if (tgc instanceof TMLADDelayInterval) { + return TMLAD_INTERVAL_DELAY; } else if (tgc instanceof TMLADForLoop) { return TMLAD_FOR_LOOP; } else if (tgc instanceof TMLADForStaticLoop) { diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index f6c66fbae6bb18d992a3e87b35cd1d2d2433de00..e6947caad17dd002c0f80f902a19b23ce93837d6 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -178,6 +178,8 @@ public class TGUIAction extends AbstractAction { public static final int TMLAD_EXECI_INTERVAL = 152; public static final int TMLAD_EXECC = 243; public static final int TMLAD_EXECC_INTERVAL = 244; + public static final int TMLAD_DELAY = 248; + public static final int TMLAD_INTERVAL_DELAY = 249; public static final int TMLAD_WRITE_CHANNEL = 142; public static final int TMLAD_SEND_REQUEST = 143; public static final int TMLAD_SEND_EVENT = 144; @@ -352,7 +354,7 @@ public class TGUIAction extends AbstractAction { public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 248; + public static final int NB_ACTION = 250; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -605,6 +607,8 @@ public class TGUIAction extends AbstractAction { actions[TMLAD_EXECI_INTERVAL] = new TAction("add-tmlad-execi-int", "EXECI (time interval)", IconManager.imgic914, IconManager.imgic914, "EXECI (time interval)", "Add an EXECI time interval to the currently opened TML task activity diagram", 0); actions[TMLAD_EXECC] = new TAction("add-tmlad-execc", "EXECC", IconManager.imgic920, IconManager.imgic920, "EXECC", "Add an EXECC delay to the currently opened TML task activity diagram", 0); actions[TMLAD_EXECC_INTERVAL] = new TAction("add-tmlad-execc-int", "EXECC (time interval)", IconManager.imgic922, IconManager.imgic922, "EXECC (time interval)", "Add an EXECC time interval to the currently opened TML task activity diagram", 0); + actions[TMLAD_DELAY] = new TAction("add-tmlad-delay", "DELAY[]", IconManager.imgic214, IconManager.imgic214, "DELAY[]", "Add a physical delay to the currently opened TML task activity diagram", 0); + actions[TMLAD_INTERVAL_DELAY] = new TAction("add-tmlad-interval-delay", "DELAY[,]", IconManager.imgic224, IconManager.imgic224, "DELAY[,]", "Add a physical interval delay to the currently opened TML task activity diagram", 0); actions[TMLAD_WRITE_CHANNEL] = new TAction("add-tmladd-write-channel", "Write in channel", IconManager.imgic900, IconManager.imgic900, "Write in channel", "Add a write to channel operator opened TML activity diagram", 0); actions[TMLAD_SEND_REQUEST] = new TAction("add-tmladd-send-request", "Send request", IconManager.imgic902, IconManager.imgic902, "Send request", "Add a send request operator to the currently opened TML activity diagram", 0); actions[TMLAD_SEND_EVENT] = new TAction("add-tmladd-send-event", "Send event", IconManager.imgic904, IconManager.imgic904, "Send event", "Add a send event operator to the currently opened TML activity diagram", 0); diff --git a/src/ui/TMLArchiPanel.java b/src/ui/TMLArchiPanel.java index 50780ff4feedfc959452174a598ed79676ceb001..9d2e47b322ca4b3e6ee4a931ad804daa1c0b9ac9 100755 --- a/src/ui/TMLArchiPanel.java +++ b/src/ui/TMLArchiPanel.java @@ -79,7 +79,7 @@ public class TMLArchiPanel extends TURTLEPanel { //Class diagram tmlap = new TMLArchiDiagramPanel(mgui, toolBarTML); - tmlap.setName("TML Architecture Diagram"); + tmlap.setName("DIPLODOCUS architecture and mapping Diagram"); tmlap.tp = this; tdp = tmlap; panels.add(tmlap); // Always first in list @@ -89,7 +89,7 @@ public class TMLArchiPanel extends TURTLEPanel { jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); toolBarPanel.add(toolBarTML, BorderLayout.NORTH); toolBarPanel.add(jsp, BorderLayout.CENTER); - tabbedPane.addTab("DIPLODOCUS Architecture Diagram", IconManager.imgic60, toolBarPanel, "Opens DIPLODOCUS architecture diagram"); + tabbedPane.addTab("DIPLODOCUS architecture and mapping Diagram", IconManager.imgic60, toolBarPanel, "Opens DIPLODOCUS architecture diagram"); tabbedPane.setSelectedIndex(0); //jsp.setVisible(true); @@ -107,5 +107,11 @@ public class TMLArchiPanel extends TURTLEPanel { public String toString() { return "DIPLODOCUS Architecture: " + mgui.getTitleAt(this); } + + public void renameMapping(String oldName, String newName) { + if (tmlap != null) { + tmlap.renameMapping(oldName, newName); + } + } } \ No newline at end of file diff --git a/src/ui/ThreadGUIElement.java b/src/ui/ThreadGUIElement.java index 9dc8270f8ed4443fe08766dcf4876556238b6cce..621701997f561a65d6f8e3ea14f23765e419b077 100755 --- a/src/ui/ThreadGUIElement.java +++ b/src/ui/ThreadGUIElement.java @@ -48,8 +48,8 @@ package ui; import java.awt.*; -//import java.awt.event.*; -//import javax.swing.*; +import java.util.*; +import javax.swing.*; import myutil.*; import ui.window.*; @@ -57,9 +57,11 @@ import ui.window.*; public class ThreadGUIElement extends Thread { private String param0, param1, param2; + private Object obj0, obj1, obj2, obj3; private int function; private StoppableGUIElement sge; private JFrameStatistics jfs; + private DocumentationGenerator docgen; private JDialogCancel jdc; private Frame frame; private ExternalCall ec; @@ -72,6 +74,17 @@ public class ThreadGUIElement extends Thread { param2 = _param2; } + public ThreadGUIElement (Frame _frame, int _function, Object _obj0, Object _obj1, Object _obj2, Object _obj3, String _param0, String _param2) { + frame = _frame; + function = _function; + obj0 = _obj0; + obj1 = _obj1; + obj2 = _obj2; + obj3 = _obj3; + param0 = _param0; + param2 = _param2; + } + public void setExternalCall(ExternalCall _ec) { ec = _ec; } @@ -90,6 +103,11 @@ public class ThreadGUIElement extends Thread { jdc = null; } else { switch(function) { + case 1: + docgen = new DocumentationGenerator((Vector)obj0, (JTabbedPane)obj1, (String)obj2, (String)obj3); + docgen.setFirstHeadingNumber(2); + sge = (StoppableGUIElement)docgen; + break; case 0: default: jfs = new JFrameStatistics(param0, param1); @@ -97,8 +115,8 @@ public class ThreadGUIElement extends Thread { } start(); jdc = new JDialogCancel(frame, param0, param2, sge); + jdc.setSize(400, 200); GraphicLib.centerOnParent(jdc); - jdc.setSize(300, 200); jdc.setVisible(true); jdc = null; } @@ -115,6 +133,23 @@ public class ThreadGUIElement extends Thread { } } else { switch(function) { + case 1: + boolean res = docgen.generateDocumentation(); + if (jdc != null) { + jdc.stopAll(); + } + if (res && !docgen.hasBeenStopped()) { + JOptionPane.showMessageDialog(frame, + "All done!", + "Documentation generation", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(frame, + "The documentation generation could not be performed", + " Error", + JOptionPane.INFORMATION_MESSAGE); + } + break; case 0: default: jfs.goElement(); diff --git a/src/ui/tmlad/TMLADDelay.java b/src/ui/tmlad/TMLADDelay.java new file mode 100755 index 0000000000000000000000000000000000000000..8c6f4f5c71fa74679a6eb5f34578eb864c3eaaf6 --- /dev/null +++ b/src/ui/tmlad/TMLADDelay.java @@ -0,0 +1,134 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class TMLADDelay + * Fixed physical duration operator. To be used in TML activity diagrams + * Creation: 20/11/2008 + * @version 1.0 10/11/2008 + * @author Ludovic APVRILLE + * @see + */ + +package ui.tmlad; + +import java.awt.*; +import java.awt.geom.*; + +import ui.*; +import myutil.*; + +public class TMLADDelay extends TGCWithInternalComponent implements EmbeddedComment { + private int lineLength = 5; + private int textX, textY; + private int ilength = 10; + private int lineLength1 = 2; + + public TMLADDelay(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 10; + height = 30; + textX = width + 5; + textY = height/2 + 5; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCTimeDelay tgc = new TGCTimeDelay(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); + tgc.setMinDelay("10"); + tgc.setMaxDelay("nope"); + tgc.setHasMaxValue(false); + tgc.setUnit("ms"); + tgc.setName("value of the delay"); + tgc.makeValue(); + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "delay"; + + myImageIcon = IconManager.imgic214; + } + + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { + return this; + } + + return null; + } + + public String getDelayValue() { + return ((TGCTimeDelay)tgcomponent[0]).getMinDelay(); + } + + public void setDelayValue(String value) { + ((TGCTimeDelay)tgcomponent[0]).setMinDelay(value); + } + + public String getUnit() { + return ((TGCTimeDelay)tgcomponent[0]).getUnit(); + } + + public int getType() { + return TGComponentManager.TMLAD_DELAY; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_TMLAD; + } + +} + diff --git a/src/ui/tmlad/TMLADDelayInterval.java b/src/ui/tmlad/TMLADDelayInterval.java new file mode 100755 index 0000000000000000000000000000000000000000..3a5e4dfdd72efb2f89993cbf1b47f4e0176c51aa --- /dev/null +++ b/src/ui/tmlad/TMLADDelayInterval.java @@ -0,0 +1,154 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille +* +* ludovic.apvrille AT enst.fr +* +* This software is a computer program whose purpose is to allow the +* edition of TURTLE analysis, design and deployment diagrams, to +* allow the generation of RT-LOTOS or Java code from this diagram, +* and at last to allow the analysis of formal validation traces +* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +* from INRIA Rhone-Alpes. +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* /** +* Class TMLADDelayInterval +* Non deterministic physical duration operator. To be used in TML activity diagrams +* Creation: 10/11/2008 +* @version 1.0 10/11/2008 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.tmlad; + +import java.awt.*; +import java.awt.geom.*; + +import ui.*; +import myutil.*; + +public class TMLADDelayInterval extends TGCWithInternalComponent implements EmbeddedComment { + private int lineLength = 5; + private int textX, textY; + private int ilength = 10; + private int lineLength1 = 2; + private int incrementY = 3; + private int segment = 4; + + public TMLADDelayInterval(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 10; + height = 30; + textX = width + 5; + textY = height/2 + 5; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointTMLAD(this, 0, + lineLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCTimeDelay tgc = new TGCTimeDelay(x+textX, y+textY, -75, 30, textY - 10, textY + 10, true, this, _tdp); + tgc.setMinDelay("10"); + tgc.setMaxDelay("20"); + tgc.setHasMaxValue(true); + tgc.setUnit("ms"); + tgc.setName("value of the interval delay"); + tgc.makeValue(); + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "delayInterval"; + + myImageIcon = IconManager.imgic214; + } + + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + + int y1 = y + 4; + int x1 = x + 2; + int width1 = width - 4; + + for (int i=0; i<segment; i++) { + g.drawLine(x1, y1, x1+width1, y1+incrementY); + y1 += incrementY; + g.drawLine(x1+width1, y1, x1, y1+incrementY); + y1 += incrementY; + } + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { + return this; + } + + return null; + } + + public String getMinDelayValue() { + return ((TGCTimeDelay)(tgcomponent[0])).getMinDelay(); + } + + public String getMaxDelayValue() { + return ((TGCTimeDelay)(tgcomponent[0])).getMaxDelay(); + } + + public void setMinValue(String val) { + ((TGCTimeDelay)(tgcomponent[0])).setMinDelay(val); + } + + public void setMaxValue(String val) { + ((TGCTimeDelay)(tgcomponent[0])).setMaxDelay(val); + } + + public int getType() { + return TGComponentManager.TMLAD_INTERVAL_DELAY; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_TMLAD; + } + + public String getUnit() { + return ((TGCTimeDelay)tgcomponent[0]).getUnit(); + } + +} diff --git a/src/ui/tmlad/TMLActivityDiagramToolBar.java b/src/ui/tmlad/TMLActivityDiagramToolBar.java index f0dafb321e67682abd79231ecc68fd0a9d16e7b3..f6a2ca44bf8c7a356cefcedf80cc46ed9f89ebc6 100755 --- a/src/ui/tmlad/TMLActivityDiagramToolBar.java +++ b/src/ui/tmlad/TMLActivityDiagramToolBar.java @@ -74,6 +74,8 @@ public class TMLActivityDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.TMLAD_EXECI_INTERVAL].setEnabled(b); mgui.actions[TGUIAction.TMLAD_EXECC].setEnabled(b); mgui.actions[TGUIAction.TMLAD_EXECC_INTERVAL].setEnabled(b); + mgui.actions[TGUIAction.TMLAD_DELAY].setEnabled(b); + mgui.actions[TGUIAction.TMLAD_INTERVAL_DELAY].setEnabled(b); mgui.actions[TGUIAction.TMLAD_WRITE_CHANNEL].setEnabled(b); mgui.actions[TGUIAction.TMLAD_READ_CHANNEL].setEnabled(b); mgui.actions[TGUIAction.TMLAD_SEND_REQUEST].setEnabled(b); @@ -170,6 +172,13 @@ public class TMLActivityDiagramToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.TMLAD_EXECC]); button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLAD_EXECC_INTERVAL]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.TMLAD_DELAY]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLAD_INTERVAL_DELAY]); button.addMouseListener(mgui.mouseHandler); this.addSeparator(); diff --git a/src/ui/tmlcd/TMLTaskOperator.java b/src/ui/tmlcd/TMLTaskOperator.java index 76e3169e50c2987c7b60fa19b26528d017a98bff..f140da80295afec5e507e828e27d68f1a57b894c 100755 --- a/src/ui/tmlcd/TMLTaskOperator.java +++ b/src/ui/tmlcd/TMLTaskOperator.java @@ -357,5 +357,7 @@ public class TMLTaskOperator extends TGCWithInternalComponent implements TMLTask public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TML_ASSOCIATION_NAV; } + + } diff --git a/src/ui/tmldd/TMLArchiArtifact.java b/src/ui/tmldd/TMLArchiArtifact.java index 9c8b90e9e4605403c9bb4657297a4df782ae2d71..4d759f245099653697f4cb5f76fcd36bea19b9ad 100755 --- a/src/ui/tmldd/TMLArchiArtifact.java +++ b/src/ui/tmldd/TMLArchiArtifact.java @@ -282,6 +282,11 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa public String getReferenceTaskName() { return referenceTaskName; } + + public void setReferenceTaskName(String _referenceTaskName) { + referenceTaskName = _referenceTaskName; + makeFullValue(); + } public String getTaskName() { return taskName; diff --git a/src/ui/tmldd/TMLArchiBUSNode.java b/src/ui/tmldd/TMLArchiBUSNode.java index 13bb93737cd3b0661a4e15ea5bdf455164e9ebf2..4aa8836be944581dc22608e7a4da09820450f848 100755 --- a/src/ui/tmldd/TMLArchiBUSNode.java +++ b/src/ui/tmldd/TMLArchiBUSNode.java @@ -107,7 +107,7 @@ public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements Swallo removable = true; userResizable = true; - name = "NodeName"; + name = tdp.findNodeName("Bus"); value = "name"; myImageIcon = IconManager.imgic700; diff --git a/src/ui/tmldd/TMLArchiBridgeNode.java b/src/ui/tmldd/TMLArchiBridgeNode.java index cdd1fe64bc2d2070bacd97ff54b2c795c01d824d..4f9c2a9746541c42684dae6117492617cd801a03 100755 --- a/src/ui/tmldd/TMLArchiBridgeNode.java +++ b/src/ui/tmldd/TMLArchiBridgeNode.java @@ -105,7 +105,7 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa removable = true; userResizable = true; - name = "NodeName"; + name = tdp.findNodeName("Bridge"); value = "name"; myImageIcon = IconManager.imgic700; diff --git a/src/ui/tmldd/TMLArchiCPUNode.java b/src/ui/tmldd/TMLArchiCPUNode.java index 5ffa64f797cf033d3dbf274cc4ac15c6700afc65..6a5a7d72e25cd164da1ccc47c14b47067db54d91 100755 --- a/src/ui/tmldd/TMLArchiCPUNode.java +++ b/src/ui/tmldd/TMLArchiCPUNode.java @@ -114,7 +114,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, removable = true; userResizable = true; - name = "NodeName"; + name = tdp.findNodeName("CPU"); value = "name"; myImageIcon = IconManager.imgic700; diff --git a/src/ui/tmldd/TMLArchiCommunicationArtifact.java b/src/ui/tmldd/TMLArchiCommunicationArtifact.java index e7e6350c4c11b647bab6931e43d9aa085d88c657..ef6ef998c4c44924d092e44c5493d52d549e2738 100755 --- a/src/ui/tmldd/TMLArchiCommunicationArtifact.java +++ b/src/ui/tmldd/TMLArchiCommunicationArtifact.java @@ -276,6 +276,11 @@ public class TMLArchiCommunicationArtifact extends TGCWithoutInternalComponent i public String getReferenceCommunicationName() { return referenceCommunicationName; } + + public void setReferenceCommunicationName(String _referenceCommunicationName) { + referenceCommunicationName = _referenceCommunicationName; + makeFullValue(); + } public String getCommunicationName() { return communicationName; diff --git a/src/ui/tmldd/TMLArchiDiagramPanel.java b/src/ui/tmldd/TMLArchiDiagramPanel.java index 4df5b46a762d7d3f70674172d1f4affcd189ac77..3ed0318a16ea4cf4e0b1338b484cd0d32d6e609b 100755 --- a/src/ui/tmldd/TMLArchiDiagramPanel.java +++ b/src/ui/tmldd/TMLArchiDiagramPanel.java @@ -53,7 +53,8 @@ import java.util.*; import ui.*; public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttributes { - + private int masterClockFrequency = 200; // in MHz + public TMLArchiDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); TDiagramMouseManager tdmm = new TDiagramMouseManager(this); @@ -107,9 +108,17 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib }*/ return false; } + + public int getMasterClockFrequency() { + return masterClockFrequency; + } + + public void setMasterClockFrequency(int _masterClockFrequency) { + masterClockFrequency = _masterClockFrequency; + } public String getXMLHead() { - return "<TMLArchiDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + " >"; + return "<TMLArchiDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + displayClock() + " >"; } public String getXMLTail() { @@ -138,6 +147,13 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib s += "\""; return s; } + + public String displayClock() { + String s = " masterClockFrequency=\""; + s += masterClockFrequency; + s += "\""; + return s; + } public void loadExtraParameters(Element elt) { String s; @@ -147,11 +163,20 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib //System.out.println("S=" + s); int attr = Integer.decode(s).intValue(); setAttributes(attr % 3); - } catch (Exception e) { // Model was saved in an older version of TTool //System.out.println("older format"); setAttributes(0); + } + + try { + s = elt.getAttribute("masterClockFrequency"); + //System.out.println("S=" + s); + masterClockFrequency = Math.abs(Integer.decode(s).intValue()); + } catch (Exception e) { + // Model was saved in an older version of TTool + //System.out.println("older format"); + masterClockFrequency = 200; } } @@ -183,6 +208,14 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib if (tgc instanceof TMLArchiCPUNode) { ll.add(tgc); } + + if (tgc instanceof TMLArchiHWANode) { + ll.add(tgc); + } + + if (tgc instanceof TMLArchiCommunicationNode) { + ll.add(tgc); + } } return ll; @@ -226,6 +259,49 @@ public class TMLArchiDiagramPanel extends TDiagramPanel implements TDPWithAttrib return false; } + + public void renameMapping(String oldName, String newName) { + ListIterator iterator = getListOfNodes().listIterator(); + TMLArchiNode node; + Vector v; + TMLArchiArtifact artifact; + ArrayList<TMLArchiCommunicationArtifact> list; + int i; + + while(iterator.hasNext()) { + node = (TMLArchiNode)(iterator.next()); + + // Task mapping + + if ((node instanceof TMLArchiCPUNode) || (node instanceof TMLArchiHWANode)) { + if (node instanceof TMLArchiCPUNode) { + v = ((TMLArchiCPUNode)(node)).getArtifactList(); + //System.out.println("CPU:" + node.getName() + " v:" + v.size()); + } else { + v = ((TMLArchiHWANode)(node)).getArtifactList(); + //System.out.println("HWA:" + node.getName() + " v:" + v.size()); + } + + for(i=0; i<v.size(); i++) { + artifact = (TMLArchiArtifact)(v.get(i)); + if (artifact.getReferenceTaskName().compareTo(oldName) == 0) { + artifact.setReferenceTaskName(newName); + } + } + } + + // Channel, event, request mapping + if (node instanceof TMLArchiCommunicationNode) { + list = ((TMLArchiCommunicationNode)node).getArtifactList(); + + for(TMLArchiCommunicationArtifact arti: list) { + if (arti.getReferenceCommunicationName().compareTo(oldName) == 0) { + arti.setReferenceCommunicationName(newName); + } + } + } + } + } } \ No newline at end of file diff --git a/src/ui/tmldd/TMLArchiHWANode.java b/src/ui/tmldd/TMLArchiHWANode.java index 2e91ace19b792538486c9627d850f5477565117b..f7e820b28f72b6de091feebd4a5f36ed953a5d79 100755 --- a/src/ui/tmldd/TMLArchiHWANode.java +++ b/src/ui/tmldd/TMLArchiHWANode.java @@ -106,7 +106,7 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, removable = true; userResizable = true; - name = "NodeName"; + name = tdp.findNodeName("HWA"); value = "name"; myImageIcon = IconManager.imgic700; diff --git a/src/ui/tmldd/TMLArchiMemoryNode.java b/src/ui/tmldd/TMLArchiMemoryNode.java index 886d15dff54eebf8fb50069bf19a82508a7f3400..f916bfaddadaa79bd94745da072b1b533fb9e872 100755 --- a/src/ui/tmldd/TMLArchiMemoryNode.java +++ b/src/ui/tmldd/TMLArchiMemoryNode.java @@ -105,7 +105,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa removable = true; userResizable = true; - name = "NodeName"; + name = tdp.findNodeName("Memory"); value = "name"; myImageIcon = IconManager.imgic700; diff --git a/src/ui/window/JDialogScheduling.java b/src/ui/window/JDialogScheduling.java index 14d6780b1b6d8590e0f233569ed21ee77cf916ba..256393b50e56b768e93ecbf5552d20acfbc04287 100755 --- a/src/ui/window/JDialogScheduling.java +++ b/src/ui/window/JDialogScheduling.java @@ -241,6 +241,7 @@ public class JDialogScheduling extends javax.swing.JDialog implements ActionList jta.setEditable(false); jta.setMargin(new Insets(10, 10, 10, 10)); jta.setTabSize(3); + jta.setRows(10); if (generator == MainGUI.LOTOS) { jta.append("Select options and then, click on 'start' for generating a LOTOS specification\n"); } else { diff --git a/src/ui/window/JDialogSelectTMLNodes.java b/src/ui/window/JDialogSelectTMLNodes.java index 1e0698870a051653c4e3239338bfd45de0191b64..f892dc76fd569616a9cf04f91e66961b222bd1a5 100755 --- a/src/ui/window/JDialogSelectTMLNodes.java +++ b/src/ui/window/JDialogSelectTMLNodes.java @@ -59,6 +59,8 @@ import ui.tmldd.*; public class JDialogSelectTMLNodes extends javax.swing.JDialog implements ActionListener, ListSelectionListener { public static Vector validated, ignored; private static boolean optimized = true; + + private int clock; private Vector val, ign, back; @@ -71,16 +73,19 @@ public class JDialogSelectTMLNodes extends javax.swing.JDialog implements Action private JButton addOneIgnored; private JButton allIgnored; protected JCheckBox optimize; + protected JTextField clockField; // Main Panel private JButton closeButton; private JButton cancelButton; /** Creates new form */ - public JDialogSelectTMLNodes(Frame f, Vector _back, LinkedList componentList, String title) { + public JDialogSelectTMLNodes(Frame f, Vector _back, LinkedList componentList, String title, int _clock) { super(f, title, true); back = _back; + + clock = _clock; if ((validated == null) || (ignored == null)) { val = makeNewVal(componentList); @@ -217,11 +222,25 @@ public class JDialogSelectTMLNodes extends javax.swing.JDialog implements Action panel6.setLayout(new BorderLayout()); panel5 = new JPanel(); - panel5.setLayout(new FlowLayout()); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c2 = new GridBagConstraints(); + panel5.setLayout(gridbag2); + + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + c2.gridheight = 1; + c2.gridwidth = GridBagConstraints.REMAINDER; //end row optimize = new JCheckBox("Optimize TML specification"); optimize.setSelected(optimized); - panel5.add(optimize); + panel5.add(optimize, c2); + + c2.gridwidth = 1; //end row + panel5.add(new JLabel("Master clock (in MHz)"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + clockField = new JTextField("" + clock); + panel5.add(clockField, c2); panel4 = new JPanel(); panel4.setLayout(new FlowLayout()); @@ -360,6 +379,16 @@ public class JDialogSelectTMLNodes extends javax.swing.JDialog implements Action } } + public int getClock() { + try { + int c = Integer.decode(clockField.getText()).intValue(); + if (c > 0) { + return c; + } + } catch (Exception e) { + } + return clock; + } public void valueChanged(ListSelectionEvent e) { setButtons(); diff --git a/src/ui/window/JDialogSystemCGeneration.java b/src/ui/window/JDialogSystemCGeneration.java index 9780c510f184cfc479a4b8a1a86749982d7d3941..e576045904fdcec95bd749d400e2173e715089e5 100755 --- a/src/ui/window/JDialogSystemCGeneration.java +++ b/src/ui/window/JDialogSystemCGeneration.java @@ -71,7 +71,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act private static String unitCycle = "1"; private static String[] simus = {"SystemC Simulator - LabSoC version", "C++ Simulator - LabSoc version"}; - private static int selectedItem = 0; + private static int selectedItem = 1; protected static String pathCode; protected static String pathCompiler; @@ -208,8 +208,11 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act jp01.add(new JLabel("Simulator used:"), c01); versionSimulator = new JComboBox(simus); - versionSimulator.setSelectedItem(selectedItem); + versionSimulator.setSelectedIndex(selectedItem); + versionSimulator.addActionListener(this); jp01.add(versionSimulator, c01); + //System.out.println("selectedItem=" + selectedItem); + //devmode = new JCheckBox("Development version of the simulator"); //devmode.setSelected(true); //jp01.add(devmode, c01); @@ -305,7 +308,9 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act stopProcess(); } else if (command.equals("Close")) { closeDialog(); - } + } else if (evt.getSource() == versionSimulator) { + selectedItem = versionSimulator.getSelectedIndex(); + } } public void closeDialog() { @@ -384,7 +389,8 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act testGo(); try { - cycle = Integer.valueOf(unitcycle.getText()).intValue(); + unitCycle = unitcycle.getText(); + cycle = Integer.valueOf(unitCycle).intValue(); } catch (Exception e) { jta.append("Wrong number of cycles: " + unitcycle.getText()); jta.append("Aborting"); @@ -410,6 +416,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act }*/ selectedItem = versionSimulator.getSelectedIndex(); + //System.out.println("Selected item=" + selectedItem); if (selectedItem == 0) { tmltranslator.tomappingsystemc.TML2MappingSystemC tml2systc; if (mgui.gtm.getTMLMapping() == null) { @@ -519,6 +526,8 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act checkMode(); setButtons(); + + //System.out.println("Selected item=" + selectedItem); } protected String processCmd(String cmd) throws LauncherException {