diff --git a/src/myutil/BrowserControl.java b/src/myutil/BrowserControl.java index 14cc9a4ecc9dfec41087db019d511ede451f1fd1..49516d50c764b51afdb35c1f40cdc0fb79a77332 100755 --- a/src/myutil/BrowserControl.java +++ b/src/myutil/BrowserControl.java @@ -65,9 +65,15 @@ public class BrowserControl { else return false; } - + public static void startBrowerToURL(String url) { - Process p; + try { + java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); + } catch(Exception e) { + TraceManager.addError("Error: couldn't start browser because: " + e.getMessage()); + } + + /*Process p; boolean underWindows = underWindows(); String cmd = null; @@ -91,7 +97,7 @@ public class BrowserControl { } } } catch(Exception e) { - System.err.println("Error: couldn't start browser with command=" + cmd + "with Exception=" + e.getMessage()); - } + TraceManager.addError("Error: couldn't start browser because: " + e.getMessage()); + } */ } } \ No newline at end of file diff --git a/src/myutil/TraceManager.java b/src/myutil/TraceManager.java index af02502282814f849452937ca08ec0395efe311e..e2d71cf80cd0173215a0235ee46108161b203c61 100644 --- a/src/myutil/TraceManager.java +++ b/src/myutil/TraceManager.java @@ -63,8 +63,9 @@ public class TraceManager { case TO_CONSOLE: System.out.println(_s); break; + case TO_DEVNULL: + break; default: - System.out.println(_s); } } diff --git a/src/ui/LoadInfo.java b/src/ui/LoadInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..8f6c51d257398458b217336d88d53d54dde0e901 --- /dev/null +++ b/src/ui/LoadInfo.java @@ -0,0 +1,60 @@ +/**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 LoadInfo + * Load information for HW elements. Used for simulation purpose + * Creation: 11/05/2010 + * @version 1.0 11/05/2010 + * @author Ludovic APVRILLE + * @see + */ + + +package ui; + + + +public class LoadInfo { + + + public int id; + public double load; + + public LoadInfo() { + } +} \ No newline at end of file diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 7bca1ef97e28dc73c6bfbefb33f9771a4674a6b2..674f3b34b70e0bee0d9d68a1506343fa7718f735 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -256,8 +256,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { //private int selectedAction = -1; // Interaction with simulators - ArrayList<RunningInfo> runningIDs; - JFrameInteractiveSimulation jfis; + private ArrayList<RunningInfo> runningIDs; + private ArrayList<LoadInfo> loadIDs; + private JFrameInteractiveSimulation jfis; public MainGUI(boolean _systemcOn, boolean _lotosOn, boolean _proactiveOn, boolean _tpnOn, boolean _osOn, boolean _uppaalOn, boolean _ncOn, boolean _avatarOn) { systemcOn = _systemcOn; @@ -5435,6 +5436,18 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { setDiploIDs(!TDiagramPanel.DIPLO_ID_ON); } + public void toggleDiploAnimate() { + setDiploAnimate(!TDiagramPanel.DIPLO_ANIMATE_ON); + } + + public void setDiploAnimate(boolean b) { + TDiagramPanel.DIPLO_ANIMATE_ON = b; + TDiagramPanel tdp = getCurrentTDiagramPanel(); + if (tdp != null) { + tdp.repaint(); + } + } + public void setDiploIDs(boolean b) { TDiagramPanel.DIPLO_ID_ON = b; TDiagramPanel tdp = getCurrentTDiagramPanel(); @@ -5465,6 +5478,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return null; } + public synchronized LoadInfo isLoadID(int id) { + if (loadIDs == null) { + return null; + } + + for(LoadInfo li: loadIDs) { + if (li.id == id) { + return li; + } + } + + return null; + } + public synchronized void resetRunningID() { if (runningIDs != null) { runningIDs.clear(); @@ -5476,6 +5503,17 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } + public synchronized void resetLoadID() { + if (loadIDs != null) { + loadIDs.clear(); + } + loadIDs = null; + TDiagramPanel tdp = getCurrentTDiagramPanel(); + if (tdp != null) { + tdp.repaint(); + } + } + public synchronized void addRunningID(int _id, int _nextCommand, String _progression, String _startTime, String _finishTime, String _transStartTime, String _transFinishTime) { if (runningIDs == null) { runningIDs = new ArrayList<RunningInfo>(); @@ -5496,6 +5534,23 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } + public synchronized void addLoadInfo(int _id, double _load) { + if (loadIDs == null) { + loadIDs = new ArrayList<LoadInfo>(); + } + + removeLoadId(_id); + LoadInfo li = new LoadInfo(); + li.id = _id; + li.load = _load; + loadIDs.add(li); + //System.out.println("Running id " + id + " added"); + TDiagramPanel tdp = getCurrentTDiagramPanel(); + if (tdp != null) { + tdp.repaint(); + } + } + public synchronized void removeRunningId(Integer id) { if (runningIDs == null) { return ; @@ -5510,6 +5565,21 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } getCurrentTDiagramPanel().repaint(); } + + public synchronized void removeLoadId(int _id) { + if (loadIDs == null) { + return ; + } + + for(LoadInfo li: loadIDs) { + if (li.id == _id) { + loadIDs.remove(li); + //System.out.println("Running id " + i + " removed"); + return; + } + } + getCurrentTDiagramPanel().repaint(); + } public void toggleGates() { TDiagramPanel tdp = getCurrentTDiagramPanel(); diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index 6ceb138e60d569e96c7570abbe96e4ebd747420e..70f3cd5ae03cb07f0f9bd38e4fc8f329720a2162 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -190,6 +190,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { int adjustMode = 0; // DIPLO ID -> for simulation purpose + public static boolean DIPLO_ANIMATE_ON; public static boolean DIPLO_ID_ON; public static boolean DIPLO_TRANSACTION_PROGRESSION_ON; diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index 3abf176f18bdfb783cd2c026aa54ddaebc5ed6f8..749d5e6ac3cd5cf5b67285553d72b0a77d41d041 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -515,8 +515,26 @@ public abstract class TGComponent implements CDElement, GenericTree { } + public void drawLoadDiploID(Graphics g, LoadInfo li) { + //TraceManager.addDev("Drawing diplo ID id=" + li.id); + int sizeRect = 6; + int sizeOval = 8; + Color c = g.getColor(); + Color myCol = new Color(135, Math.min(255, Math.max(0, (int)(255-(li.load*255)))), 0); + g.setColor(myCol); + g.fillRect(x, y, width, sizeRect); + g.fillRect(x, y, sizeRect, height); + g.fillRect(x+width-sizeRect, y, sizeRect, height); + g.fillRect(x, y + height-sizeRect, width, sizeRect); + + g.fillOval(x+width, y+((sizeRect-sizeOval)/2), sizeOval, sizeOval); + g.drawLine(x+width+sizeOval, y+(sizeRect/2), x+width+sizeOval+(sizeOval), y+(sizeRect/2)); + g.drawString("" + (int)(li.load*100) + "%", x+width+sizeOval+(sizeOval) + 1, y+(sizeOval/2)); + } + public void draw(Graphics g) { RunningInfo ri; + LoadInfo li; ColorManager.setColor(g, state, 0); internalDrawing(g); repaint = false; @@ -540,7 +558,7 @@ public abstract class TGComponent implements CDElement, GenericTree { GraphicLib.setNormalStroke(g); } - if (tdp.DIPLO_ID_ON) { + if (tdp.DIPLO_ANIMATE_ON) { if (breakpoint) { //System.out.println("breakpoint"); g.setColor(ColorManager.BREAKPOINT); @@ -552,7 +570,9 @@ public abstract class TGComponent implements CDElement, GenericTree { if (! ((this instanceof TGConnector) || (this instanceof TGCNote))) { if (tdp instanceof TMLActivityDiagramPanel) { if (getFather() == null) { - drawDiploID(g); + if (tdp.DIPLO_ID_ON) { + drawDiploID(g); + } ri = tdp.getMGUI().isRunningID(getDIPLOID()); if (ri != null) { drawRunningDiploID(g, ri); @@ -560,11 +580,15 @@ public abstract class TGComponent implements CDElement, GenericTree { } } else if (tdp instanceof TMLComponentTaskDiagramPanel) { if (this instanceof TMLCPrimitiveComponent) { - drawDiploID(g); + if (tdp.DIPLO_ID_ON) { + drawDiploID(g); + } } } else if (tdp instanceof TMLTaskDiagramPanel) { if (getDIPLOID() != -1) { - drawDiploID(g); + if (tdp.DIPLO_ID_ON) { + drawDiploID(g); + } } /*if (this instanceof TMLTaskOperator) { drawDiploID(g); @@ -580,7 +604,13 @@ public abstract class TGComponent implements CDElement, GenericTree { }*/ } else if (tdp instanceof TMLArchiDiagramPanel) { if (getDIPLOID() != -1) { - drawDiploID(g); + if (tdp.DIPLO_ID_ON) { + drawDiploID(g); + } + li = tdp.getMGUI().isLoadID(getDIPLOID()); + if (li != null) { + drawLoadDiploID(g, li); + } } /*if (this instanceof TMLArchiCPUNode) { diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 6cd358b72c8afb35eb4bf37a332fb39ee7448f7c..f416866481f2da0834fa6b2411361b34da4899b4 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -119,7 +119,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Commands JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel; // from MGUI - JCheckBox latex, debug, animate, update, openDiagram, animateWithInfo; + JCheckBox latex, debug, animate, diploids, update, openDiagram, animateWithInfo; JTabbedPane commandTab, infoTab; protected JTextField paramMainCommand; protected JTextField saveFileName; @@ -223,6 +223,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene mgui.resetRunningID(); + mgui.resetLoadID(); setBackground(new Color(50, 40, 40, 200)); @@ -595,19 +596,24 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene jp01.add(debug, c01); animate = new JCheckBox("Animate UML diagrams"); jp01.add(animate, c01); - animate.addItemListener(this); - animate.setSelected(true); + 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); + openDiagram = new JCheckBox("Automatically open active task diagram"); + jp01.add(openDiagram, c01); + openDiagram.setSelected(true); update = new JCheckBox("Automatically update information (task, CPU, etc.)"); jp01.add(update, c01); update.addItemListener(this); update.setSelected(true); - openDiagram = new JCheckBox("Automatically open active task diagram"); - jp01.add(openDiagram, c01); - openDiagram.setSelected(true); + + animate.addItemListener(this); + animate.setSelected(true); TableSorter sorterPI; @@ -678,7 +684,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene sorterPI.setTableHeader(jtablePI.getTableHeader()); ((jtablePI.getColumnModel()).getColumn(0)).setPreferredWidth(100); ((jtablePI.getColumnModel()).getColumn(1)).setPreferredWidth(75); - ((jtablePI.getColumnModel()).getColumn(2)).setPreferredWidth(300); + ((jtablePI.getColumnModel()).getColumn(2)).setPreferredWidth(700); jtablePI.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jspCPUInfo = new JScrollPane(jtablePI); jspCPUInfo.setWheelScrollingEnabled(true); @@ -797,6 +803,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } mgui.resetRunningID(); + mgui.resetLoadID(); + mgui.setDiploAnimate(false); dispose(); setVisible(false); @@ -847,7 +855,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void run() { String s; - System.out.println("mode=" + threadMode); + TraceManager.addDev("mode=" + threadMode); try { if (threadMode == 0) { @@ -1109,11 +1117,11 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } catch (IOException e) { - System.err.println("Error when parsing server info:" + e.getMessage()); + TraceManager.addError("Error when parsing server info:" + e.getMessage()); return false; } catch (SAXException saxe) { - System.err.println("Error when parsing server info:" + saxe.getMessage()); - System.err.println("xml:" + xmldata); + TraceManager.addError("Error when parsing server info:" + saxe.getMessage()); + TraceManager.addError("xml:" + xmldata); return false; } return true; @@ -1161,7 +1169,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene node = diagramNl.item(j); if (node == null) { - System.out.println("null node"); + TraceManager.addDev("null node"); return false; } @@ -1382,7 +1390,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } } catch (Exception e) { - System.err.println("Exception in xml parsing " + e.getMessage() + " node= " + node1); + TraceManager.addError("Exception in xml parsing " + e.getMessage() + " node= " + node1); return false; } @@ -1417,6 +1425,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene hashOK = true; animate.setSelected(true); animate.setEnabled(true); + diploids.setEnabled(true); animateWithInfo.setSelected(true); animateWithInfo.setEnabled(true); openDiagram.setEnabled(true); @@ -1434,14 +1443,16 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } private void wrongHashCode() { - System.out.println("Wrong hash code"); + TraceManager.addDev("Wrong hash code"); cpuPanel.setVisible(false); variablePanel.setVisible(false); openDiagram.setSelected(false); openDiagram.setEnabled(false); animate.setEnabled(false); + diploids.setEnabled(false); animate.setSelected(false); + diploids.setSelected(false); animateWithInfo.setSelected(false); animateWithInfo.setEnabled(false); update.setEnabled(false); @@ -1493,7 +1504,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } public synchronized void threadStarted() { - System.out.println("thread started"); + TraceManager.addDev("thread started"); threadStarted = true; notify(); } @@ -1829,7 +1840,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //System.out.println("Adding running command: " +c); mgui.addRunningID(c, nc, progression, startTime, finishTime, transStartTime, transFinishTime); } catch (Exception e) { - System.out.println("Exception updateRunningCommand: " + e.getMessage()); + TraceManager.addDev("Exception updateRunningCommand: " + e.getMessage()); } } @@ -1984,7 +1995,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene row = (Integer)(rowTable.get(i)).intValue(); tvtm.fireTableCellUpdated(row, 4); } catch (Exception e) { - System.out.println("Exception updateVariableState: " + e.getMessage() + " idvar=" + _idvar + " val=" + _value); + TraceManager.addDev("Exception updateVariableState: " + e.getMessage() + " idvar=" + _idvar + " val=" + _value); } } @@ -2003,7 +2014,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene row = rowTable.get(i).intValue(); tasktm.fireTableCellUpdated(row, 2); } catch (Exception e) { - System.out.println("Exception updateTaskState: " + e.getMessage()); + TraceManager.addDev("Exception updateTaskState: " + e.getMessage()); } } @@ -2025,8 +2036,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //System.out.println("Searching for old row"); row = (Integer)(rowTable.get(i)).intValue(); cputm.fireTableCellUpdated(row, 2); + mgui.addLoadInfo(i, getDouble(_utilization).doubleValue()); } catch (Exception e) { - System.out.println("Exception updateCPUState: " + e.getMessage() + " id=" + _id + " util=" + _utilization); + TraceManager.addDev("Exception updateCPUState: " + e.getMessage() + " id=" + _id + " util=" + _utilization); } } } @@ -2039,9 +2051,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene try { valueTable.remove(i); valueTable.put(i, "Utilization: " + _utilization); - //System.out.println("Searching for old row"); + //TraceManager.addDev("Searching for old row"); row = rowTable.get(i).intValue(); bustm.fireTableCellUpdated(row, 2); + mgui.addLoadInfo(i, getDouble(_utilization).doubleValue()); } catch (Exception e) { System.err.println("Exception updateBusState: " + e.getMessage()); } @@ -2065,27 +2078,32 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void itemStateChanged(ItemEvent e) { if (e.getSource() == animate) { - mgui.setDiploIDs(animate.isSelected()); - } else if (e.getSource() == animateWithInfo) { + 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) { mgui.setTransationProgression(animateWithInfo.isSelected()); } } public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); - //System.out.println("Command:" + command); + //TraceManager.addDev("Command:" + command); if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand())) { close(); } else if (command.equals(actions[InteractiveSimulationActions.ACT_START_ALL].getActionCommand())) { setComponents(); startSimulation(); - //System.out.println("Start simulation!"); + //TraceManager.addDev("Start simulation!"); } else if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_AND_CLOSE_ALL].getActionCommand())) { killSimulator(); close(); return; - //System.out.println("Start simulation!"); + //TraceManager.addDev("Start simulation!"); } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_SIMU].getActionCommand())) { sendCommand("run-to-next-breakpoint"); } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_X_TIME_UNITS].getActionCommand())) { @@ -2124,6 +2142,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene sendSaveBenchmarkCommand(); } else if (command.equals(actions[InteractiveSimulationActions.ACT_RESET_SIMU].getActionCommand())) { mgui.resetRunningID(); + mgui.resetLoadID(); sendCommand("reset"); askForUpdate(); } else if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_SIMU].getActionCommand())) { @@ -2170,6 +2189,14 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + public Double getDouble(String s) { + try { + return new Double(s); + } catch (Exception e) { + return null; + } + } + public void toNextBusTransfer() { int id = getIDFromString(busIDs[busses.getSelectedIndex()]); if (id != -1) { @@ -2228,7 +2255,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void addBreakPoint(int _commandID) { - //System.out.println("Add breakpoint: " + _commandID); + //TraceManager.addDev("Add breakpoint: " + _commandID); // Check whether that breakpoint is already listed or not for(Point p: points) { if (p.y == _commandID) { @@ -2238,9 +2265,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene if (tmap != null) { TMLTask task = tmap.getTMLTaskByCommandID(_commandID); - //System.out.println("Got task: " + task); + //TraceManager.addDev("Got task: " + task); if (task != null) { - //System.out.println("Adding bkp"); + //TraceManager.addDev("Adding bkp"); sendCommand("add-breakpoint " + task.getID() + " " + _commandID + "\n"); jpbp.addExternalBreakpoint(task.getID(), _commandID); } @@ -2248,7 +2275,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } public void removeBreakPoint(int _commandID) { - System.out.println("remove breakpoint"); + TraceManager.addDev("remove breakpoint"); int cpt = 0; for(Point p: points) { if (p.y == _commandID) {