From bc3a03ab8e595e260a540f1cc7c171a049912521 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Mon, 23 May 2016 10:14:48 +0000 Subject: [PATCH] Update on simulation diplo --- .../JFrameInteractiveSimulation.java | 32 ++-- .../JPanelTransactions.java | 172 ++++++++++++++++++ 2 files changed, 193 insertions(+), 11 deletions(-) create mode 100755 src/ui/interactivesimulation/JPanelTransactions.java diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 0e93e96a31..80a0d4334c 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -72,6 +72,8 @@ import javax.xml.parsers.*; public class JFrameInteractiveSimulation extends JFrame implements ActionListener, Runnable, MouseListener, ItemListener, ChangeListener/*, StoppableGUIElement, SteppedAlgorithm, ExternalCall*/ { + protected static final int NB_OF_TRANSACTIONS = 10; + protected static final String SIMULATION_HEADER = "siminfo"; protected static final String SIMULATION_GLOBAL = "global"; protected static final String SIMULATION_TASK = "task"; @@ -123,7 +125,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen // Commands - JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel, transactionPanel; // from MGUI + JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel; + protected JPanelTransactions transactionPanel; JCheckBox latex, debug, animate, diploids, update, openDiagram, animateWithInfo; JTabbedPane commandTab, infoTab; protected JTextField paramMainCommand; @@ -145,9 +148,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen private JScrollPane jspTaskVariableInfo; // Last transactions elements - TransactionTableModel ttm; - JButton updateTransactionInformationButton; - private JScrollPane jspTransactionInfo; + //private TransactionTableModel ttm; + //JButton updateTransactionInformationButton; + //private JScrollPane jspTransactionInfo; private Vector<SimulationTransaction> trans; // Breakpoints @@ -806,10 +809,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen variablePanel.add(updateTaskVariableInformationButton, BorderLayout.SOUTH); // Transactions - transactionPanel = new JPanel(); - transactionPanel.setLayout(new BorderLayout()); + transactionPanel = new JPanelTransactions(this, NB_OF_TRANSACTIONS); + //transactionPanel.setLayout(new BorderLayout()); infoTab.addTab("Transactions", null, transactionPanel, "Recent transactions"); - ttm = new TransactionTableModel(this); + /*ttm = new TransactionTableModel(this); sorterPI = new TableSorter(ttm); jtablePI = new JTable(sorterPI); sorterPI.setTableHeader(jtablePI.getTableHeader()); @@ -825,7 +828,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen jspTransactionInfo.setPreferredSize(new Dimension(500, 300)); transactionPanel.add(jspTransactionInfo, BorderLayout.NORTH); updateTransactionInformationButton = new JButton(actions[InteractiveSimulationActions.ACT_UPDATE_TRANSACTIONS]); - transactionPanel.add(updateTransactionInformationButton, BorderLayout.SOUTH); + transactionPanel.add(updateTransactionInformationButton, BorderLayout.SOUTH);*/ // CPUs cpuPanel = new JPanel(); @@ -1578,7 +1581,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen st.deviceName = elt.getAttribute("devicename"); String commandT = elt.getAttribute("command"); - //TraceManager.addDev("command found: " + commandT); + TraceManager.addDev("command found: " + commandT); if (commandT != null) { int index = commandT.indexOf(": "); if (index == -1){ @@ -1694,7 +1697,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen trans = new Vector<SimulationTransaction>(); } //TraceManager.addDev("Transinfo -> " + trans.size()); - ttm.setData(trans); + if (transactionPanel != null) { + transactionPanel.setData(trans); + } + //ttm.setData(trans); } } catch (Exception e) { TraceManager.addError("Exception in xml parsing " + e.getMessage() + " node= " + node1); @@ -2133,7 +2139,11 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListen } trans = null; - sendCommand("lt 10"); + int nb = NB_OF_TRANSACTIONS; + if (transactionPanel != null) { + nb = transactionPanel.getNbOfTransactions(); + } + sendCommand("lt " + nb); } private void updateTaskCommands() { diff --git a/src/ui/interactivesimulation/JPanelTransactions.java b/src/ui/interactivesimulation/JPanelTransactions.java new file mode 100755 index 0000000000..b81e86d202 --- /dev/null +++ b/src/ui/interactivesimulation/JPanelTransactions.java @@ -0,0 +1,172 @@ +/**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 JPanelTransactions + * Creation: 23/05/2016 + * version 1.0 23/05/2016 + * @author Ludovic APVRILLE + * @see + */ + +package ui.interactivesimulation; + +//import java.io.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; + + +import myutil.*; +import ui.*; +import ui.file.*; + +import tmltranslator.*; + +import launcher.*; +import remotesimulation.*; + +import org.w3c.dom.*; +import org.xml.sax.*; +import javax.xml.parsers.*; + + +public class JPanelTransactions extends JPanel { + + + private JFrameInteractiveSimulation jfis; + private TransactionTableModel ttm; + private JButton updateTransactionInformationButton; + private JScrollPane jspTransactionInfo; + + + private JTextField nbOfTransactions; + private int defaultNbOfTransactions; + + + + public JPanelTransactions(JFrameInteractiveSimulation _jfis, int _defaultNbOfTransactions) { + super(); + + jfis = _jfis; + defaultNbOfTransactions = _defaultNbOfTransactions; + + makeComponents(); + setComponents(); + } + + public void makeComponents() { + TableSorter sorterPI; + JTable jtablePI; + + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c2 = new GridBagConstraints(); + setLayout(gridbag2); + setBorder(new javax.swing.border.TitledBorder("Managing transactions")); + + ttm = new TransactionTableModel(jfis); + sorterPI = new TableSorter(ttm); + jtablePI = new JTable(sorterPI); + sorterPI.setTableHeader(jtablePI.getTableHeader()); + ((jtablePI.getColumnModel()).getColumn(0)).setPreferredWidth(100); + ((jtablePI.getColumnModel()).getColumn(1)).setPreferredWidth(100); + ((jtablePI.getColumnModel()).getColumn(2)).setPreferredWidth(150); + ((jtablePI.getColumnModel()).getColumn(3)).setPreferredWidth(100); + ((jtablePI.getColumnModel()).getColumn(4)).setPreferredWidth(100); + jtablePI.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jspTransactionInfo = new JScrollPane(jtablePI); + jspTransactionInfo.setWheelScrollingEnabled(true); + jspTransactionInfo.getVerticalScrollBar().setUnitIncrement(10); + jspTransactionInfo.setPreferredSize(new Dimension(500, 300)); + + + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 5; + c2.weighty = 10.0; + c2.weightx = 10.0; + add(jspTransactionInfo, c2); + + // 2nd line panel2 + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 1; + add(new JLabel(""), c2); + add(new JLabel("# of transactions per node:"), c2); + + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c2.fill = GridBagConstraints.HORIZONTAL; + + nbOfTransactions = new JTextField(defaultNbOfTransactions); + add(nbOfTransactions, c2); + + add(new JLabel(" "), c2); + + updateTransactionInformationButton = new JButton(jfis.actions[InteractiveSimulationActions.ACT_UPDATE_TRANSACTIONS]); + add(updateTransactionInformationButton, c2); + + } + + public void setComponents() { + + } + + public TransactionTableModel getTableModel() { + return ttm; + } + + public int getNbOfTransactions() { + try { + defaultNbOfTransactions = Integer.decode(nbOfTransactions.getText()).intValue(); + } catch (Exception e) { + TraceManager.addDev("Invalid default transaction"); + } + return defaultNbOfTransactions; + } + + public void setData(Vector<SimulationTransaction> _trans) { + if (ttm != null) { + ttm.setData(_trans); + } + } + +} // Class -- GitLab