diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 7ce18a7625899d2a4a51314c3de0ead7d0b5de73..e110c0671aefc96662b0a4b5f49b77f107baf215 100644 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -3718,7 +3718,7 @@ public class GTURTLEModeling { private String header() { String head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING version=\"" + DefaultText.getVersion() + "\""; - //head += ModelParameter.toXML(); + head += ModelParameters.toXML(); head += ">\n\n"; return head; @@ -5519,6 +5519,16 @@ public class GTURTLEModeling { return; } + + // Loading header + + try { + TraceManager.addDev("Loading model parameters"); + ModelParameters.loadValuesFromXML(doc.getElementsByTagName("TURTLEGMODELING").item(0)); + } catch (Exception e) { + TraceManager.addDev("Exception when loading model parameters:" + e.getMessage()); + } + //designPanelNl = doc.getElementsByTagName("Design"); //analysisNl = doc.getElementsByTagName("Analysis"); diff --git a/src/main/java/ui/ModelParameters.java b/src/main/java/ui/ModelParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..5b1d4659c7d58516403d653c43b074695e579d33 --- /dev/null +++ b/src/main/java/ui/ModelParameters.java @@ -0,0 +1,120 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + + + + +package ui; + + +import myutil.TraceManager; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.tmlad.TMLActivityDiagramPanel; + +/** + * Class ModelParameters + * Used as an abstraction of TMLTask and TMLTaskObject + * Creation: 19/06/2019 + * @version 1.0 19/06/2019 + * @author Ludovic APVRILLE + */ +public class ModelParameters { + private static String[] ids = {"ANIMATE_INTERACTIVE_SIMULATION", // Diplodocus animate simulation + "ACTIVATE_PENALTIES", // Diplodocus penalties in C++ simulation + "UPDATE_INFORMATION_DIPLO_SIM", // Diplo simulator + "ANIMATE_WITH_INFO_DIPLO_SIM", // Diplo simulator + "OPEN_DIAG_DIPLO_SIM" // Diplo simulator + }; + private static String[] values = {"true", "true", "true", "true", "false"}; + + public static boolean getBooleanValueFromID(String value) { + for(int i=0; i<ids.length; i++) { + if (ids[i].compareTo(value) == 0) { + return values[i].compareTo("true") == 0; + } + } + return false; + } + + public static String toXML() { + String ret = ""; + for(int i=0; i<ids.length; i++) { + ret += " " + ids[i] + "=\"" + values[i] + "\""; + } + return ret; + } + + public static void loadValuesFromXML(org.w3c.dom.Node node) { + String tmp; + Element elt; + + TraceManager.addDev("Loading parameters from XML"); + + if (node.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) node; + for(int i=0; i<ids.length; i++) { + try { + tmp = elt.getAttribute(ids[i]); + if ((tmp != null) && (tmp.length() > 0)){ + TraceManager.addDev("Setting value " + tmp + " to id " + ids[i]); + values[i] = tmp; + } + } catch (Exception e) { + + } + } + } + + } + + public static void setValueForID(String id, String value) { + //TraceManager.addDev("Trying to set value " + value + " to " + id); + + for(int i=0; i<ids.length; i++) { + if (ids[i].compareTo(id) == 0) { + //TraceManager.addDev("Setting value " + value + " to " + id); + values[i] = value; + return; + } + } + return; + } +} \ No newline at end of file diff --git a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java index e039db8b94d9e39323c65a5f473084556a0b0f32..1acd9ad54dccfa5cbab7b0b50d9c36eafc1cfcbc 100755 --- a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -40,7 +40,6 @@ package ui.interactivesimulation; import common.ConfigurationTTool; import common.SpecConfigTTool; -import ddtranslatorSoclib.toTopCell.Simulation; import launcher.LauncherException; import launcher.RshClient; import myutil.*; @@ -770,28 +769,35 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene jp01.add(new JLabel(" "), c01); latex = new JCheckBox("Generate info in Latex format"); jp01.add(latex, c01); + debug = new JCheckBox("Print messages received from server"); jp01.add(debug, c01); + animate = new JCheckBox("Animate UML diagrams"); jp01.add(animate, c01); + diploids = new JCheckBox("Show DIPLO IDs on UML diagrams"); jp01.add(diploids, c01); diploids.addItemListener(this); diploids.setSelected(false); + animateWithInfo = new JCheckBox("Show transaction progression on UML diagrams"); jp01.add(animateWithInfo, c01); animateWithInfo.addItemListener(this); - animateWithInfo.setSelected(true); + animateWithInfo.setSelected(ModelParameters.getBooleanValueFromID("ANIMATE_WITH_INFO_DIPLO_SIM")); + openDiagram = new JCheckBox("Automatically open active task diagram"); jp01.add(openDiagram, c01); - openDiagram.setSelected(false); + openDiagram.setSelected(ModelParameters.getBooleanValueFromID("OPEN_DIAG_DIPLO_SIM")); + openDiagram.addItemListener(this); + update = new JCheckBox("Automatically update information (task, CPU, etc.)"); jp01.add(update, c01); update.addItemListener(this); - update.setSelected(true); + update.setSelected(ModelParameters.getBooleanValueFromID("UPDATE_INFORMATION_DIPLO_SIM")); animate.addItemListener(this); - animate.setSelected(true); + animate.setSelected(ModelParameters.getBooleanValueFromID("ANIMATE_INTERACTIVE_SIMULATION")); TableSorter sorterPI; @@ -3303,14 +3309,20 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void itemStateChanged(ItemEvent e) { if (e.getSource() == animate) { + ModelParameters.setValueForID("ANIMATE_INTERACTIVE_SIMULATION", "" + animate.isSelected()); mgui.setDiploAnimate(animate.isSelected()); diploids.setEnabled(animate.isSelected()); animateWithInfo.setEnabled(animate.isSelected()); openDiagram.setEnabled(animate.isSelected()); } else if (e.getSource() == diploids) { mgui.setDiploIDs(diploids.isSelected()); - }else if (e.getSource() == animateWithInfo) { + } else if (e.getSource() == animateWithInfo) { mgui.setTransationProgression(animateWithInfo.isSelected()); + ModelParameters.setValueForID("ANIMATE_WITH_INFO_DIPLO_SIM", "" + animateWithInfo.isSelected()); + } else if (e.getSource() == update) { + ModelParameters.setValueForID("UPDATE_INFORMATION_DIPLO_SIM", "" + update.isSelected()); + } else if (e.getSource() == debug) { + ModelParameters.setValueForID("OPEN_DIAG_DIPLO_SIM", "" + debug.isSelected()); } } diff --git a/src/main/java/ui/window/JDialogSystemCGeneration.java b/src/main/java/ui/window/JDialogSystemCGeneration.java index 35ac2fd9ea9036d466bd9c0bf3c81a99121a9acc..ab7e8f51c7e250ef975870961714e62a9de390a0 100644 --- a/src/main/java/ui/window/JDialogSystemCGeneration.java +++ b/src/main/java/ui/window/JDialogSystemCGeneration.java @@ -51,6 +51,7 @@ import tmltranslator.tomappingsystemc2.Penalties; import ui.AvatarRequirementPanelTranslator; import ui.JTextAreaWriter; import ui.MainGUI; +import ui.ModelParameters; import ui.avatarpd.AvatarPDPanel; import ui.util.IconManager; @@ -59,7 +60,6 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.text.BadLocationException; import java.awt.*; import java.awt.event.*; import java.io.File; @@ -111,7 +111,6 @@ public class JDialogSystemCGeneration extends JDialog implements ActionListener, protected static boolean interactiveSimulationSelected = true; protected static boolean optimizeModeSelected = true; - protected static boolean activatePenaltiesSelected = true; protected final static int NOT_STARTED = 1; protected final static int STARTED = 2; @@ -347,7 +346,7 @@ public class JDialogSystemCGeneration extends JDialog implements ActionListener, help.setPreferredSize(new Dimension(30, 30)); activatePenalties = new JCheckBox("Activate penalties (task switching time, cache miss, miss branching prediction)"); - activatePenalties.setSelected(activatePenaltiesSelected); + activatePenalties.setSelected(ModelParameters.getBooleanValueFromID("ACTIVATE_PENALTIES")); jp01.add(activatePenalties, c01); jp01.add(new JLabel("Simulator used:"), c01); @@ -600,7 +599,7 @@ public class JDialogSystemCGeneration extends JDialog implements ActionListener, updateStaticList(); optimizeModeSelected = optimizemode.isSelected(); - activatePenaltiesSelected = activatePenalties.isSelected(); + ModelParameters.setValueForID("ACTIVATE_PENALTIES", "" + activatePenalties.isSelected()); // wasClosed = true; dispose(); } @@ -973,7 +972,7 @@ public class JDialogSystemCGeneration extends JDialog implements ActionListener, case ANIMATION: updateStaticList(); optimizeModeSelected = optimizemode.isSelected(); - activatePenaltiesSelected = activatePenalties.isSelected(); + ModelParameters.setValueForID("ACTIVATE_PENALTIES", "" + activatePenalties.isSelected()); dispose(); mgui.interactiveSimulationSystemC(getPathInteractiveExecute()); break;