From d056c6668e9c738fbfb52dac3f2072bc3f11bd58 Mon Sep 17 00:00:00 2001 From: Letitia Li <letitia.li@telecom-paristech.fr> Date: Mon, 20 Aug 2018 16:02:11 +0200 Subject: [PATCH] Allow selection of tasks for sim traces --- src/main/java/ui/GTMLModeling.java | 1 - .../JFrameInteractiveSimulation.java | 20 +- .../JFrameTMLSimulationPanel.java | 2 + .../JSimulationSDPanel.java | 13 +- .../JSimulationTMLPanel.java | 12 +- .../java/ui/window/JDialogSelectTasks.java | 367 ++++++++++++++++++ 6 files changed, 406 insertions(+), 9 deletions(-) create mode 100644 src/main/java/ui/window/JDialogSelectTasks.java diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index 5d3d860747..7e3836f882 100755 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -2959,7 +2959,6 @@ public class GTMLModeling { memory.byteDataSize = memorynode.getByteDataSize(); memory.clockRatio = memorynode.getClockRatio(); memory.bufferType = memorynode.getBufferType(); - System.out.println("ADDING memory " + memorynode.getName() + " " + memorynode + " " + memory); listE.addCor(memory, memorynode); archi.addHwNode(memory); //TraceManager.addDev("Memory node added:" + memory.getName()); diff --git a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java index ec11c83c40..37627a2d46 100755 --- a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -53,6 +53,7 @@ import remotesimulation.RemoteConnection; import remotesimulation.RemoteConnectionException; import tmltranslator.*; import ui.*; +import ui.window.JDialogSelectTasks; import ui.util.IconManager; import javax.swing.*; @@ -103,7 +104,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene private static int STARTED_NOT_CONNECTED = 2; private static int STARTED_AND_CONNECTED = 3; - //private Frame f; + private Frame f; private MainGUI mgui; // private String title; private String hostSystemC; @@ -256,7 +257,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute, TMLMapping<TGComponent> _tmap, List<Point> _points) { super(_title); - // f = _f; + f = _f; mgui = _mgui; //title = _title; hostSystemC = _hostSystemC; @@ -1403,13 +1404,24 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene try { tmlSimPanel = new JFrameTMLSimulationPanel(new Frame(), mgui, "Simulation Transactions"); + //Make a popup to select which tasks + Vector<String> tmlComponentsToValidate = new Vector<String>(); + List<String> tasks = new ArrayList<String>(); + for (TMLTask task: tmap.getTMLModeling().getTasks()){ + tasks.add(task.getName()); + } + JDialogSelectTasks jdstmlc = new JDialogSelectTasks(f, tmlComponentsToValidate, tasks, "Select tasks to show in trace"); + + GraphicLib.centerOnParent(jdstmlc); + jdstmlc.setVisible(true); + HashMap<String, ArrayList<String>> deviceTaskMap = new HashMap<String, ArrayList<String>>(); for (HwNode node : tmap.getTMLArchitecture().getHwNodes()){ deviceTaskMap.put(node.getName(), new ArrayList<String>()); } for (TMLTask task: tmap.getTMLModeling().getTasks()){ HwNode node = tmap.getHwNodeOf(task); - if (node!=null){ + if (node!=null && tmlComponentsToValidate.contains(task.getName())){ deviceTaskMap.get(node.getName()).add(task.getName()); } } @@ -1424,7 +1436,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene simIndex++; }*/ for (TMLTask task : tmap.getTMLModeling().getTasks()){ - if (!simtraces.contains("time=0 block="+ task.getName()+" type=state_entering state=startState")){ + if (!simtraces.contains("time=0 block="+ task.getName()+" type=state_entering state=startState") && tmlComponentsToValidate.contains(task.getName())){ simtraces.add("time=0 block="+ task.getName()+" type=state_entering state=startState"); simIndex++; } diff --git a/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanel.java b/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanel.java index ff8e2a9772..eef0ee7604 100644 --- a/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanel.java +++ b/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanel.java @@ -115,6 +115,7 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { topPanel.add(buttonSVG); JButton buttonPNG = new JButton(actions[InteractiveSimulationActions.ACT_SAVE_SD_PNG]); topPanel.add(buttonPNG); + /*topPanel.add(new JLabel(" time unit:")); units = new JComboBox<>(unitTab); units.setSelectedIndex(1); @@ -221,6 +222,7 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { //TraceManager.addDev("Command:" + command); if (command.equals(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW].getActionCommand())) { + sdpanel=null; close(); } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_SD_SVG].getActionCommand())) { saveSVG(); diff --git a/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java b/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java index 736d3d809a..012201621f 100644 --- a/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java +++ b/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java @@ -1017,6 +1017,7 @@ public class JSimulationSDPanel extends JPanel implements MouseMotionListener, R long value; int value1, value2; + if (!(trans.startsWith("#"))) { return; } @@ -1078,8 +1079,11 @@ public class JSimulationSDPanel extends JPanel implements MouseMotionListener, R //TraceManager.addDev("4"); - addEntityNameIfApplicable(tmp); +// addEntityNameIfApplicable(tmp); gt.entityName = tmp; + if (!entityNames.contains(tmp)){ + return; + } // Type of the transaction tmp = extract(trans, "type"); @@ -1139,7 +1143,12 @@ public class JSimulationSDPanel extends JPanel implements MouseMotionListener, R tmp = extract(trans, "blockdestination"); if (tmp != null) { gt.otherEntityName = tmp; - addEntityNameIfApplicable(tmp); + // addEntityNameIfApplicable(tmp); + } + + + if (!entityNames.contains(tmp)){ + return; } // Channel of the transaction? diff --git a/src/main/java/ui/interactivesimulation/JSimulationTMLPanel.java b/src/main/java/ui/interactivesimulation/JSimulationTMLPanel.java index 90c463d819..ea2b45a77e 100644 --- a/src/main/java/ui/interactivesimulation/JSimulationTMLPanel.java +++ b/src/main/java/ui/interactivesimulation/JSimulationTMLPanel.java @@ -1041,6 +1041,8 @@ public class JSimulationTMLPanel extends JPanel implements MouseMotionListener, } private void addGenericTransaction(String trans) { + + // int index0; String tmp, tmp1, tmp2; @@ -1108,8 +1110,11 @@ public class JSimulationTMLPanel extends JPanel implements MouseMotionListener, //TraceManager.addDev("4"); - addEntityNameIfApplicable(tmp); + //addEntityNameIfApplicable(tmp); gt.entityName = tmp; + if (!entityNames.contains(tmp)){ + return; + } // Type of the transaction tmp = extract(trans, "type"); @@ -1170,9 +1175,12 @@ public class JSimulationTMLPanel extends JPanel implements MouseMotionListener, tmp = extract(trans, "blockdestination"); if (tmp != null) { gt.otherEntityName = tmp; - addEntityNameIfApplicable(tmp); + // addEntityNameIfApplicable(tmp); } + if (!entityNames.contains(tmp)){ + return; + } // Channel of the transaction? tmp = extract(trans, "channel"); if (tmp != null) { diff --git a/src/main/java/ui/window/JDialogSelectTasks.java b/src/main/java/ui/window/JDialogSelectTasks.java new file mode 100644 index 0000000000..e4e2cabd54 --- /dev/null +++ b/src/main/java/ui/window/JDialogSelectTasks.java @@ -0,0 +1,367 @@ +/* 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.window; + + +import ui.util.IconManager; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; +import java.util.List; +import java.util.Vector; + + +/** + * Class JDialogSelectStrings + * Dialog for managing tasks in sim trace panel + * Creation: 28/03/2008 + * + * @author Ludovic APVRILLE + * @version 1.0 28/03/2008 + */ +public class JDialogSelectTasks extends JDialogBase implements ActionListener, ListSelectionListener { + public static Vector<String> validated, ignored; + + + private Vector<String> val; + private Vector<String> ign, back; + + //subpanels + private JPanel panel1, panel2, panel3, panel4, panel5, panel6; + private JList<String> listIgnored; + private JList<String> listValidated; + private JButton allValidated; + private JButton addOneValidated; + private JButton addOneIgnored; + private JButton allIgnored; + + /** + * Creates new form + */ + public JDialogSelectTasks(Frame f, Vector<String> _back, List<String> componentList, String title) { + super(f, title, true); + + back = _back; + + + + if ((validated == null) || (ignored == null)) { + val = makeNewVal(componentList); + ign = new Vector<String>(); + } else { + val = validated; + ign = ignored; + checkTask(val, componentList); + checkTask(ign, componentList); + addNewTask(val, componentList, ign); + } + + initComponents(); + myInitComponents(); + pack(); + } + + + + private Vector<String> makeNewVal(List<String> list) { + Vector<String> v = new Vector<String>(); + String tgc; + + for (int i = 0; i < list.size(); i++) { + tgc = list.get(i); + // + + v.addElement(tgc); + + } + return v; + } + + private void checkTask(Vector<? extends String> tobeChecked, List<String> source) { + String t; + + for (int i = 0; i < tobeChecked.size(); i++) { + t = tobeChecked.elementAt(i); + + if (!source.contains(t)) { + tobeChecked.removeElementAt(i); + i--; + } + } + } + + public void addNewTask(Vector<String> added, List<String> source, Vector<String> notSource) { + String tgc; + + for (int i = 0; i < source.size(); i++) { + tgc = source.get(i); + + if ((!added.contains(tgc)) && (!notSource.contains(tgc))) { + added.addElement(tgc); + // + } + } + } + + private void myInitComponents() { + setButtons(); + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagConstraints c1 = new GridBagConstraints(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c2 = new GridBagConstraints(); + setFont(new Font("Helvetica", Font.PLAIN, 14)); + + c.setLayout(gridbag2); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.gridwidth = 1; + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 1; + + // ignored list + panel1 = new JPanel(); + panel1.setLayout(new BorderLayout()); + panel1.setBorder(new javax.swing.border.TitledBorder("Ignored components")); + listIgnored = new JList<String>(ign); + //listIgnored.setPreferredSize(new Dimension(200, 250)); + listIgnored.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + listIgnored.addListSelectionListener(this); + JScrollPane scrollPane1 = new JScrollPane(listIgnored); + panel1.add(scrollPane1, BorderLayout.CENTER); + panel1.setPreferredSize(new Dimension(200, 250)); + c.add(panel1, c2); + + + // central buttons + panel3 = new JPanel(); + panel3.setLayout(gridbag1); + + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.HORIZONTAL; + c1.gridheight = 1; + + allValidated = new JButton(IconManager.imgic50); + allValidated.setPreferredSize(new Dimension(50, 25)); + allValidated.addActionListener(this); + allValidated.setActionCommand("allValidated"); + panel3.add(allValidated, c1); + + addOneValidated = new JButton(IconManager.imgic48); + addOneValidated.setPreferredSize(new Dimension(50, 25)); + addOneValidated.addActionListener(this); + addOneValidated.setActionCommand("addOneValidated"); + panel3.add(addOneValidated, c1); + + panel3.add(new JLabel(" "), c1); + + addOneIgnored = new JButton(IconManager.imgic46); + addOneIgnored.addActionListener(this); + addOneIgnored.setPreferredSize(new Dimension(50, 25)); + addOneIgnored.setActionCommand("addOneIgnored"); + panel3.add(addOneIgnored, c1); + + allIgnored = new JButton(IconManager.imgic44); + allIgnored.addActionListener(this); + allIgnored.setPreferredSize(new Dimension(50, 25)); + allIgnored.setActionCommand("allIgnored"); + panel3.add(allIgnored, c1); + + c.add(panel3, c2); + + // validated list + panel2 = new JPanel(); + panel2.setLayout(new BorderLayout()); + panel2.setBorder(new javax.swing.border.TitledBorder("Used components")); + listValidated = new JList<String>(val); + //listValidated.setPreferredSize(new Dimension(200, 250)); + listValidated.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + listValidated.addListSelectionListener(this); + JScrollPane scrollPane2 = new JScrollPane(listValidated); + panel2.add(scrollPane2, BorderLayout.CENTER); + panel2.setPreferredSize(new Dimension(200, 250)); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c2); + + c2.fill = GridBagConstraints.HORIZONTAL; + c2.gridwidth = 1; //end row + initMainButtons(c2, c, this, false, "Show trace", "Cancel"); + + + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + + if (evt.getSource() == closeButton) { + closeDialog(); + return; + } else if (evt.getSource() == cancelButton) { + cancelDialog(); + return; + } + + // Compare the action command to the known actions. + if (command.equals("addOneIgnored")) { + addOneIgnored(); + } else if (command.equals("addOneValidated")) { + addOneValidated(); + } else if (command.equals("allValidated")) { + allValidated(); + } else if (command.equals("allIgnored")) { + allIgnored(); + } + } + + + private void addOneIgnored() { + int[] list = listValidated.getSelectedIndices(); + Vector<String> v = new Vector<String>(); + String o; + for (int i = 0; i < list.length; i++) { + o = val.elementAt(list[i]); + ign.addElement(o); + v.addElement(o); + } + + val.removeAll(v); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void addOneValidated() { + int[] list = listIgnored.getSelectedIndices(); + Vector<String> v = new Vector<String>(); + String o; + for (int i = 0; i < list.length; i++) { + o = ign.elementAt(list[i]); + val.addElement(o); + v.addElement(o); + } + + ign.removeAll(v); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void allValidated() { + val.addAll(ign); + ign.removeAllElements(); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void allIgnored() { + ign.addAll(val); + val.removeAllElements(); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + + public void closeDialog() { + back.removeAllElements(); + for (int i = 0; i < val.size(); i++) { + back.addElement(val.elementAt(i)); + } + validated = val; + ignored = ign; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + private void setButtons() { + int i1 = listIgnored.getSelectedIndex(); + int i2 = listValidated.getSelectedIndex(); + + if (i1 == -1) { + addOneValidated.setEnabled(false); + } else { + addOneValidated.setEnabled(true); + //listValidated.clearSelection(); + } + + if (i2 == -1) { + addOneIgnored.setEnabled(false); + } else { + addOneIgnored.setEnabled(true); + //listIgnored.clearSelection(); + } + + if (ign.size() == 0) { + allValidated.setEnabled(false); + } else { + allValidated.setEnabled(true); + } + + if (val.size() == 0) { + allIgnored.setEnabled(false); + closeButton.setEnabled(false); + } else { + allIgnored.setEnabled(true); + closeButton.setEnabled(true); + } + } + + + public void valueChanged(ListSelectionEvent e) { + setButtons(); + } + +} -- GitLab