diff --git a/modeling/DIPLODOCUS/SmartCardProtocol.xml b/modeling/DIPLODOCUS/SmartCardProtocol.xml index 2ad884699d398f1e5fe572490e2cff4642c78f54..7aae6f40a7ffee8116cac0e9e077637600f350f8 100755 --- a/modeling/DIPLODOCUS/SmartCardProtocol.xml +++ b/modeling/DIPLODOCUS/SmartCardProtocol.xml @@ -8,8 +8,8 @@ <cdparam x="522" y="390" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="522" y="390" id="60" /> -<P2 x="468" y="336" id="39" /> +<P1 x="535" y="377" id="60" /> +<P2 x="455" y="323" id="39" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="2" > @@ -24,16 +24,16 @@ <cdparam x="652" y="444" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="816" y="554" id="89" /> -<P2 x="971" y="502" id="152" /> +<P1 x="805" y="544" id="89" /> +<P2 x="971" y="481" id="152" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="4" > <cdparam x="652" y="418" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="816" y="522" id="87" /> -<P2 x="922" y="482" id="154" /> +<P1 x="805" y="512" id="87" /> +<P2 x="932" y="472" id="154" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="5" > @@ -41,134 +41,134 @@ <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> <P1 x="752" y="408" id="79" /> -<P2 x="831" y="376" id="103" /> +<P2 x="844" y="363" id="103" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="6" > <cdparam x="685" y="310" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="857" y="376" id="107" /> -<P2 x="922" y="368" id="144" /> +<P1 x="844" y="389" id="107" /> +<P2 x="932" y="358" id="144" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="7" > <cdparam x="652" y="395" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="816" y="493" id="83" /> -<P2 x="922" y="459" id="146" /> +<P1 x="805" y="483" id="83" /> +<P2 x="932" y="449" id="146" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="8" > <cdparam x="652" y="369" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="816" y="461" id="85" /> -<P2 x="922" y="432" id="148" /> +<P1 x="805" y="451" id="85" /> +<P2 x="932" y="422" id="148" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="9" > <cdparam x="737" y="314" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="922" y="403" id="150" /> -<P2 x="816" y="432" id="81" /> +<P1 x="932" y="393" id="150" /> +<P2 x="805" y="422" id="81" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="10" > <cdparam x="735" y="260" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="919" y="336" id="142" /> -<P2 x="749" y="284" id="198" /> +<P1 x="932" y="323" id="142" /> +<P2 x="736" y="271" id="198" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="11" > <cdparam x="641" y="230" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="749" y="248" id="200" /> -<P2 x="919" y="297" id="140" /> +<P1 x="736" y="235" id="200" /> +<P2 x="932" y="284" id="140" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="12" > <cdparam x="641" y="195" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="749" y="204" id="202" /> -<P2 x="919" y="254" id="138" /> +<P1 x="736" y="191" id="202" /> +<P2 x="932" y="241" id="138" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="13" > <cdparam x="740" y="353" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="831" y="376" id="102" /> -<P2 x="749" y="315" id="204" /> +<P1 x="844" y="363" id="102" /> +<P2 x="736" y="302" id="204" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="14" > <cdparam x="460" y="270" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="522" y="304" id="194" /> -<P2 x="468" y="304" id="45" /> +<P1 x="535" y="291" id="194" /> +<P2 x="455" y="291" id="45" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="15" > <cdparam x="387" y="129" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="466" y="127" id="49" /> -<P2 x="525" y="127" id="206" /> +<P1 x="455" y="117" id="49" /> +<P2 x="535" y="117" id="206" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="16" > <cdparam x="389" y="200" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="468" y="216" id="43" /> -<P2 x="522" y="216" id="192" /> +<P1 x="455" y="203" id="43" /> +<P2 x="535" y="203" id="192" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="17" > <cdparam x="460" y="236" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="522" y="261" id="190" /> -<P2 x="468" y="261" id="41" /> +<P1 x="535" y="248" id="190" /> +<P2 x="455" y="248" id="41" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="18" > <cdparam x="460" y="296" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="536" y="349" id="188" /> -<P2 x="548" y="390" id="65" /> +<P1 x="536" y="323" id="188" /> +<P2 x="535" y="403" id="65" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="19" > <cdparam x="389" y="163" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="468" y="170" id="47" /> -<P2 x="522" y="170" id="196" /> +<P1 x="455" y="157" id="47" /> +<P2 x="535" y="157" id="196" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="20" > <cdparam x="967" y="190" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="919" y="204" id="136" /> -<P2 x="749" y="125" id="184" /> +<P1 x="932" y="191" id="136" /> +<P2 x="736" y="112" id="184" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="21" > <cdparam x="1028" y="535" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="630" y="347" id="208" /> +<P1 x="630" y="326" id="208" /> <P2 x="671" y="408" id="91" /> <AutomaticDrawing data="true" /> </CONNECTOR> @@ -176,24 +176,24 @@ <cdparam x="1304" y="321" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="1224" y="379" id="121" /> -<P2 x="1180" y="386" id="156" /> +<P1 x="1234" y="369" id="121" /> +<P2 x="1169" y="376" id="156" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="23" > <cdparam x="1168" y="455" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="1180" y="421" id="158" /> -<P2 x="1224" y="414" id="123" /> +<P1 x="1169" y="411" id="158" /> +<P2 x="1234" y="404" id="123" /> <AutomaticDrawing data="true" /> </CONNECTOR> <CONNECTOR type="126" id="26" > <cdparam x="1037" y="180" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="1180" y="214" id="160" /> -<P2 x="1180" y="282" id="162" /> +<P1 x="1169" y="204" id="160" /> +<P2 x="1169" y="272" id="162" /> <Point x="1224" y="226" /> <Point x="1224" y="266" /> <AutomaticDrawing data="true" /> @@ -218,8 +218,8 @@ <cdparam x="873" y="361" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="1000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector from TGComponent to TGComponent" value="Connector between ports" /> -<P1 x="1180" y="461" id="164" /> -<P2 x="1224" y="442" id="125" /> +<P1 x="1169" y="451" id="164" /> +<P2 x="1234" y="432" id="125" /> <AutomaticDrawing data="true" /> </CONNECTOR> <COMPONENT type="1205" id="36" > diff --git a/src/main/java/dseengine/DSEConfiguration.java b/src/main/java/dseengine/DSEConfiguration.java index 763e683bda4a91c1a5fdf8952f9165ffe38d5274..c6fbcacc4ca59c53a7ff8d201fadc1d1e102cf1d 100755 --- a/src/main/java/dseengine/DSEConfiguration.java +++ b/src/main/java/dseengine/DSEConfiguration.java @@ -157,7 +157,7 @@ public class DSEConfiguration implements Runnable { // private TMLModeling secModel = null; private Vector<TMLMapping<TGComponent>> mappings; private DSEMappingSimulationResults dsemapresults; - List<Integer[]> latencyIds =new ArrayList<Integer[]>(); + private List<Integer[]> latencyIds =new ArrayList<Integer[]>(); public MainGUI mainGUI; // Taps private static String[] taps = {"MinSimulationDuration", "AverageSimulationDuration", @@ -227,6 +227,14 @@ public class DSEConfiguration implements Runnable { return 0; } + public void setMappingModel(TMLMapping<TGComponent> _tmap) { + tmap = _tmap; + } + + public void setTaskModel(TMLModeling<TGComponent> _tmlm) { + tmlm = _tmlm; + } + public int setTaskModelFile(String _fileName) { // Trying to read the file taskModelFile = new File(modelPath + _fileName); @@ -545,46 +553,56 @@ public class DSEConfiguration implements Runnable { private boolean loadTaskModel(boolean _optimize) { boolean ret = false; //System.out.println("load"); - String inputData = FileUtils.loadFileData(taskModelFile); - TMLTextSpecification<TGComponent> tmlts = new TMLTextSpecification<>("LoadedTaskModel"); - ret = tmlts.makeTMLModeling(inputData); - TraceManager.addDev("Load of task model done"); List<TMLError> warnings; + if (tmlm == null) { + String inputData = FileUtils.loadFileData(taskModelFile); + TMLTextSpecification<TGComponent> tmlts = new TMLTextSpecification<>("LoadedTaskModel"); + ret = tmlts.makeTMLModeling(inputData); + TraceManager.addDev("Load of task model done"); - if (!ret) { - TraceManager.addDev("Compilation:\n" + tmlts.printSummary()); - } - if (ret) { - //System.out.println("Format OK"); - taskModel = tmlts.getTMLModeling(); - //System.out.println("\n\n*** TML Modeling *** \n"); - //TMLTextSpecification textspec = new TMLTextSpecification("toto"); - //String s = textspec.toTextFormat(tmlm); - //System.out.println(s); - - // Checking syntax - TraceManager.addDev("--- Checking syntax of the whole specification (TML, TARCHI, TMAP)---"); - TMLSyntaxChecking syntax = new TMLSyntaxChecking(taskModel); - syntax.checkSyntax(); - if (syntax.hasErrors() > 0) { - TraceManager.addDev("Printing errors:"); - TraceManager.addDev(syntax.printErrors()); - return false; + if (!ret) { + TraceManager.addDev("Compilation:\n" + tmlts.printSummary()); } + if (ret) { + //System.out.println("Format OK"); + taskModel = tmlts.getTMLModeling(); + //System.out.println("\n\n*** TML Modeling *** \n"); + //TMLTextSpecification textspec = new TMLTextSpecification("toto"); + //String s = textspec.toTextFormat(tmlm); + //System.out.println(s); + + // Checking syntax + TraceManager.addDev("--- Checking syntax of the whole specification (TML, TARCHI, TMAP)---"); + TMLSyntaxChecking syntax = new TMLSyntaxChecking(taskModel); + syntax.checkSyntax(); + if (syntax.hasErrors() > 0) { + TraceManager.addDev("Printing errors:"); + TraceManager.addDev(syntax.printErrors()); + return false; + } - TraceManager.addDev("Compilation:\n" + syntax.printSummary()); - TraceManager.addDev("Compilation:\n" + tmlts.printSummary()); + //TraceManager.addDev("Compilation:\n" + syntax.printSummary()); + + //TraceManager.addDev("Compilation:\n" + tmlts.printSummary()); + if (_optimize) { + warnings = tmlm.optimize(); + TraceManager.addDev(taskModel.printSummary(warnings)); + } + //spec.toTextFormat(tmlm); + //System.out.println("TMLModeling=" + spec); + } + } else { + taskModel = tmlm; if (_optimize) { warnings = tmlm.optimize(); TraceManager.addDev(taskModel.printSummary(warnings)); } - //spec.toTextFormat(tmlm); - //System.out.println("TMLModeling=" + spec); + TraceManager.addDev("No need to make the TMLModeling from file: we use the current model"); } return true; @@ -675,7 +693,7 @@ public class DSEConfiguration implements Runnable { return -1; } - if (mappingFile == null) { + if ((mappingFile == null) && (tmap == null)) { errorMessage = PATH_TO_SOURCE; return -1; } @@ -701,11 +719,13 @@ public class DSEConfiguration implements Runnable { public int loadingModel(boolean _debug, boolean _optimize) { if (optionChanged) { - TraceManager.addDev("Loading mapping"); - if (!loadMapping(_optimize)) { - errorMessage = LOAD_MAPPING_FAILED; - TraceManager.addDev("Loading of the mapping failed!!!!"); - return -1; + if (tmap == null) { + TraceManager.addDev("Loading mapping"); + if (!loadMapping(_optimize)) { + errorMessage = LOAD_MAPPING_FAILED; + TraceManager.addDev("Loading of the mapping failed!!!!"); + return -1; + } } // Generating code @@ -730,8 +750,8 @@ public class DSEConfiguration implements Runnable { return 0; } - public int loadingTaskModel(boolean _debug, boolean _optimize) { - if (optionChanged) { + /*public int loadingTaskModel(boolean _debug, boolean _optimize) { + if ((optionChanged) && (tmlm != null)){ TraceManager.addDev("Loading mapping"); if (!loadTaskModel(_optimize)) { errorMessage = LOAD_TASKMODEL_FAILED; @@ -740,10 +760,12 @@ public class DSEConfiguration implements Runnable { } } return 0; - } - public int generateSecMapping(){ + }*/ + + /*public int generateSecMapping(){ return 0; - } + }*/ + public int generateAndCompileMappingCode(TMLMapping<TGComponent> _tmlmap, boolean _debug, boolean _optimize) { // Generating code @@ -1421,7 +1443,7 @@ public class DSEConfiguration implements Runnable { } if (addSecurity){ - System.out.println("ADDING SECURITY TO MAPPING " +(cpt-1)); + TraceManager.addDev("ADDING SECURITY TO MAPPING " +(cpt-1)); TMLArchiPanel newArch = drawMapping(tmla, "securedMapping"+(cpt-1)); GTMLModeling gtml =new GTMLModeling(newArch, true); @@ -1436,7 +1458,7 @@ public class DSEConfiguration implements Runnable { //Run simulations on this mapping if (generateAndCompileMappingCode(secMapping, _debug, _optimize) >= 0) { - System.out.println("GENERATING>>>"); + TraceManager.addDev("GENERATING>>>"); if (recordResults) { results = new DSESimulationResult(); resultsID ++; @@ -1472,6 +1494,7 @@ public class DSEConfiguration implements Runnable { } return 0; } + public TMLArchiPanel drawMapping(TMLMapping<TGComponent> map, String name){ //Map<HwNode, TGConnectingPoint> connectMap; Map<HwNode, TMLArchiNode> objMap = new HashMap<HwNode, TMLArchiNode>(); diff --git a/src/main/java/tmltranslator/TMLSyntaxChecking.java b/src/main/java/tmltranslator/TMLSyntaxChecking.java index 4d579b16dcfb1d89f6bd1c00af94274ef2a97a2c..14f2b4ab61a6659f4a2ddf04344c4652b35043d9 100755 --- a/src/main/java/tmltranslator/TMLSyntaxChecking.java +++ b/src/main/java/tmltranslator/TMLSyntaxChecking.java @@ -204,16 +204,16 @@ public class TMLSyntaxChecking { if (elt instanceof TMLWaitEvent) { evt = ((TMLWaitEvent)elt).getEvent(); if (evt.isBasicEvent()) { - try { + /*try { TraceManager.addDev("wait evt= " + evt.getName()); } catch (Exception e) { TraceManager.addDev("Error on evt = " + evt); } if (evt.getDestinationTask() == null) { TraceManager.addDev("Null destination task"); - } + }*/ - TraceManager.addDev("wait evt= " + evt.getName() + " task=" + t.getName() + " destination=" + evt.getDestinationTask().getName()); + //TraceManager.addDev("wait evt= " + evt.getName() + " task=" + t.getName() + " destination=" + evt.getDestinationTask().getName()); if (evt.getDestinationTask() != t) { addError(t, elt, evt.getName() + ": " + WRONG_DESTINATION_EVENT, TMLError.ERROR_BEHAVIOR); } diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 5412c0ac764afd6e0739da0cc0bf0009860f3052..7eae596af38359480e29b6f0838811434b6e879f 100755 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -9094,8 +9094,8 @@ public class GTURTLEModeling { gtmlm.setTasks(tasksToTakeIntoAccount); tmlm = gtmlm.translateToTMLModeling(true); //tmlm.removeAllRandomSequences(); - TraceManager.addDev("New TML Modeling:" + tmlm.toString()); - mgui.generateTMLTxt(); + //TraceManager.addDev("New TML Modeling:" + tmlm.toString()); + //mgui.generateTMLTxt(); artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gtmlm.getCorrespondanceTable(); @@ -9147,7 +9147,7 @@ public class GTURTLEModeling { gctmlm.putPrefixName(true); gctmlm.setComponents(componentsToTakeIntoAccount); tmlm = gctmlm.translateToTMLModeling(true); - mgui.generateTMLTxt(); + //mgui.generateTMLTxt(); artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gctmlm.getCorrespondanceTable(); diff --git a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java index 99b5368e486888cbdbb175152fa0d9d7df5c43c0..84285ea558d8462ff0a198de1fd484132c570d35 100755 --- a/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java +++ b/src/main/java/ui/tmlcompd/TMLComponentTaskDiagramPanel.java @@ -294,7 +294,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi // if (p.getFather() != null) { if (p.getFather() instanceof TMLCPrimitiveComponent) { if (componentsToTakeIntoAccount.contains(p.getFather())) { - TraceManager.addDev("-> port " + _port + " is connected to " + o); + //TraceManager.addDev("-> port " + _port + " is connected to " + o); ret.add( p ); } } diff --git a/src/main/java/ui/window/JDialogDSE.java b/src/main/java/ui/window/JDialogDSE.java index 24004eb63df86bed4646405b033d6a809f122237..e5d99618a44e274544c9e5fbb6326f70be8ce86d 100644 --- a/src/main/java/ui/window/JDialogDSE.java +++ b/src/main/java/ui/window/JDialogDSE.java @@ -638,7 +638,7 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection dseButtonFromFile.addActionListener(this); jp03.add(dseButtonFromFile, c03); - simButton = new JRadioButton("Run Lots of Simulations"); + simButton = new JRadioButton("Run Lots of Simulations from current model"); if (!isFunctionalModel) { simButton.addActionListener(this); jp03.add(simButton, c03); @@ -915,6 +915,29 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection mode = STOPPED; setButtons(); go = false; + + } + + public void stopErrorProcess() { + TraceManager.addDev("Stop error process (1)"); + + if (rshc != null) { + try { + rshc.stopCommand(); + } catch (LauncherException le) { + } + } + TraceManager.addDev("Stop error process (2)"); + rshc = null; + outputText.append("\n\n" + output + "\n"); + + checkMode(); + setButtons(); + //TraceManager.addDev("Unselecting radio buttons"); + group.clearSelection(); + handleStartButton(); + + go = false; } public void startProcess() { @@ -973,52 +996,70 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection if (config.setRandomness(useRandomMappings, randomMappingsSelected) != 0) { TraceManager.addDev("Randomness error " + randomMappingsSelected + " error"); output += "Randomness error " + randomMappingsSelected + "\n"; - checkMode(); + stopErrorProcess(); return; } else { TraceManager.addDev("Randomness set to " + randomMappingsSelected); } - if (simButton.isSelected() || dseButton.isSelected()) { + /*if (simButton.isSelected() || dseButton.isSelected()) { mgui.generateTMLTxt(); tmlDir = SpecConfigTTool.TMLCodeDirectory; mapFile = "spec.tmap"; modFile = "spec.tml"; + }*/ + + if (simButton.isSelected()) { + config.setMappingModel(mgui.gtm.getTMLMapping()); } + if (dseButton.isSelected()) { + if (mgui.gtm.getTMLModeling() == null) + TraceManager.addDev("Null Modeling ..."); + config.setTaskModel(mgui.gtm.getTMLModeling()); + } - if (config.setModelPath(tmlDir) != 0) { - TraceManager.addDev("TML Directory file at " + tmlDir + " error"); - output += "TML Directory file at " + tmlDir + " error \n"; - checkMode(); - return; - } else { - TraceManager.addDev("Set directory to " + tmlDir); + if (simButtonFromFile.isSelected() || dseButtonFromFile.isSelected()) { + if (config.setModelPath(tmlDir) != 0) { + TraceManager.addDev("TML Directory file at " + tmlDir + " error"); + output += "Error with the Directory: " + tmlDir + "\n"; + stopErrorProcess(); + return; + } else { + TraceManager.addDev("Set directory to " + tmlDir); + } } - if (!mapFile.isEmpty()) { - if (config.setMappingFile(mapFile) < 0) { - TraceManager.addDev("Mapping at " + mapFile + " error"); - output += "Mapping at " + mapFile + " error"; - mode = STOPPED; + if (simButtonFromFile.isSelected()) { + if (!mapFile.isEmpty()) { + if (config.setMappingFile(mapFile) < 0) { + TraceManager.addDev("Mapping at " + mapFile + " error (file is not present?)"); + output += "Error: mapping file " + mapFile + " could not be loaded"; + stopErrorProcess(); + return; + } else { + TraceManager.addDev("Set mapping file to " + mapFile); + } + } + } + + if (dseButtonFromFile.isSelected()) { + if (config.setTaskModelFile(modFile) != 0) { + TraceManager.addDev("Model File " + modFile + " error"); + output += "Model File " + modFile + " error \n"; + stopErrorProcess(); return; } else { - TraceManager.addDev("Set mapping file to " + mapFile); + TraceManager.addDev("Set model file to " + modFile); } } - if (config.setTaskModelFile(modFile) != 0) { - TraceManager.addDev("Model File " + modFile + " error"); - output += "Model File " + modFile + " error \n"; - checkMode(); - return; - } else { - TraceManager.addDev("Set model file to " + modFile); - } + if (config.setPathToSimulator(simulator) != 0) { TraceManager.addDev("Simulator at " + mapFile + " error"); output += "Simulator at " + mapFile + " error \n"; - checkMode(); + stopErrorProcess(); + return; } else { TraceManager.addDev("Simulator set"); @@ -1027,6 +1068,7 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection if (config.setPathToResults(resDirect) != 0) { TraceManager.addDev("Results Directory at " + resDirect + " error"); output += "Results Directory at " + resDirect + " error \n"; + stopErrorProcess(); return; } else { TraceManager.addDev("Results Directory set"); @@ -1034,12 +1076,14 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection if (config.setNbOfSimulationThreads(simThreads) != 0) { TraceManager.addDev("Simulation threads error: " + simThreads); + stopErrorProcess(); output += "Simulation threads error: " + simThreads + "\n"; return; } if (config.setNbOfSimulationsPerMapping(nbSim) != 0) { TraceManager.addDev("Simulations per mapping error: " + nbSim); + stopErrorProcess(); output += "Simulation per mapping error: " + nbSim + "\n"; return; } @@ -1047,11 +1091,13 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection if (config.setSimulationCompilationCommand("make -j9 -C") != 0) { TraceManager.addDev("Simulation compilation error"); output += "Simulation compilation error" + "\n"; + stopErrorProcess(); return; } if (config.setSimulationExecutionCommand("run.x") != 0) { TraceManager.addDev("Simulation execution error"); output += "Simulation execution error \n"; + stopErrorProcess(); return; } @@ -1059,12 +1105,16 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection if (config.setMinNbOfCPUs(nbMinCPU) != 0) { TraceManager.addDev("Can't set Min # CPUS to " + nbMinCPU); output += "Can't set Min # CPUS to " + nbMinCPU + "\n"; + stopErrorProcess(); + return; } TraceManager.addDev("Setting max nb of CPUs to:" + nbMaxCPU); if (config.setMaxNbOfCPUs(nbMaxCPU) != 0) { TraceManager.addDev("Can't set Max # CPUS to " + nbMaxCPU); output += "Can't set Max # CPUS to " + nbMaxCPU + "\n"; + stopErrorProcess(); + return; } config.setOutputTXT(outputTXT.isSelected() ? "true" : "false"); @@ -1074,22 +1124,24 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection // Simulations - if (simButton.isSelected()) { + if (simButton.isSelected() || simButtonFromFile.isSelected()) { if (config.runParallelSimulation(nbSim, true, true) != 0) { output += "Simulation Failed:\n" + config.getErrorMessage() + " \n"; outputText.setText(output); - checkMode(); + stopErrorProcess(); return; + } else { output += "Simulation Succeeded"; outputText.setText(output); } // DSE - } else if (dseButton.isSelected()) { + } else if (dseButton.isSelected() || (dseButtonFromFile.isSelected())) { if (config.runDSE("", false, false) != 0) { TraceManager.addDev("Can't run DSE"); - + stopErrorProcess(); + return; } TraceManager.addDev("DSE run"); } @@ -1120,6 +1172,7 @@ public class JDialogDSE extends JDialog implements ActionListener, ListSelection } if (config.replaceTapValues(tap) < 0) { output += "Error changing values"; + } //System.out.println(tap[0]); if (config.printResultsSummary("", true, true) != 0) { diff --git a/tmltranslator/src/main/java/TMLTranslator.java b/tmltranslator/src/main/java/TMLTranslator.java index 61b4fbb8d7307e0296e623b454eceda8f3c49e95..79be8aa3e921b611450108ab9501f7f5abd3005e 100755 --- a/tmltranslator/src/main/java/TMLTranslator.java +++ b/tmltranslator/src/main/java/TMLTranslator.java @@ -485,25 +485,25 @@ public class TMLTranslator { System.out.println("toto=" + s);*/ switch(conversionType) { - case 0: - if (tmap == null) { - convert = convertToLOTOS(); - } else { - convert = convertToLOTOSFromMapping(); - } - break; - case 1: - convert = convertToUPPAAL(); - break; - case 2: - convert = convertToSystemC(); - break; - case 3: - convert = convertToSystemC2(); - break; - case 4: - convert = convertToTML(); - break; + case 0: + if (tmap == null) { + convert = convertToLOTOS(); + } else { + convert = convertToLOTOSFromMapping(); + } + break; + case 1: + convert = convertToUPPAAL(); + break; + case 2: + convert = convertToSystemC(); + break; + case 3: + convert = convertToSystemC2(); + break; + case 4: + convert = convertToTML(); + break; /*case 5: convert = convertToSystemC3();*/ }