diff --git a/src/tmltranslator/TMLArchiTextSpecification.java b/src/tmltranslator/TMLArchiTextSpecification.java index b852ee9183e2a70dc0d002a18901f7baf903e9f6..bb7e728cf822aa081c8ce0fd0de5d15ec5153883 100755 --- a/src/tmltranslator/TMLArchiTextSpecification.java +++ b/src/tmltranslator/TMLArchiTextSpecification.java @@ -208,9 +208,9 @@ public class TMLArchiTextSpecification { String set; ArrayList<HwLink> hwlinks = tmla.getHwLinks(); - System.out.println("Making links"); + //System.out.println("Making links"); for(HwLink link: hwlinks) { - System.out.println("Link"); + //System.out.println("Link"); if (link instanceof HwLink) { if ((link.hwnode != null) && (link.bus != null)) { name = prepareString(link.getName()); @@ -222,7 +222,7 @@ public class TMLArchiTextSpecification { } } } - System.out.println("Links:done"); + //System.out.println("Links:done"); return code; } diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 6135be5edabaa6a79c1c84bd093663ec7412609e..2cf5f827dded83b067da22d3878749fb3aa23e35 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -249,7 +249,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { //private int selectedAction = -1; // Interaction with simulators - ArrayList<Integer> runningIDs; + ArrayList<RunningInfo> runningIDs; JFrameInteractiveSimulation jfis; public MainGUI(boolean _systemcOn, boolean _lotosOn, boolean _proactiveOn, boolean _tpnOn, boolean _osOn, boolean _uppaalOn, boolean _ncOn) { @@ -5157,18 +5157,18 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } - public synchronized boolean isRunningID(int id) { + public synchronized RunningInfo isRunningID(int id) { if (runningIDs == null) { - return false; + return null; } - for(Integer i: runningIDs) { - if (i.intValue() == id) { - return true; + for(RunningInfo ri: runningIDs) { + if (ri.id == id) { + return ri; } } - return false; + return null; } public synchronized void resetRunningID() { @@ -5182,12 +5182,17 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } - public synchronized void addRunningID(Integer id) { + public synchronized void addRunningID(int _id, int _nextCommand, String _progression, String _startTime, String _finishTime) { if (runningIDs == null) { - runningIDs = new ArrayList<Integer>(); + runningIDs = new ArrayList<RunningInfo>(); } - - runningIDs.add(id); + RunningInfo ri = new RunningInfo(); + ri.id = _id; + ri.nextCommand = _nextCommand; + ri.progression = _progression; + ri.startTime = _startTime; + ri.finishTime = _finishTime; + runningIDs.add(ri); //System.out.println("Running id " + id + " added"); TDiagramPanel tdp = getCurrentTDiagramPanel(); if (tdp != null) { @@ -5200,9 +5205,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return ; } - for(Integer i: runningIDs) { - if (i.intValue() == id.intValue()) { - runningIDs.remove(i); + for(RunningInfo ri: runningIDs) { + if (ri.id == id.intValue()) { + runningIDs.remove(ri); //System.out.println("Running id " + i + " removed"); return; } diff --git a/src/ui/RunningInfo.java b/src/ui/RunningInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..b982f89c1e055d4232af3957e6c0bc9366d89a47 --- /dev/null +++ b/src/ui/RunningInfo.java @@ -0,0 +1,63 @@ +/**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 RunningInfo + * running information for actions. Used for simulation purpose + * Creation: 30/03/2010 + * @version 1.0 30/03/2010 + * @author Ludovic APVRILLE + * @see + */ + + +package ui; + + + +public class RunningInfo { + + + public int id; + public int nextCommand; + public String progression; + public String startTime; + public String finishTime; + + public RunningInfo() { + } +} \ No newline at end of file diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index 73ce893598b494240e1e5833d0e4d5b47d0dbdcb..9827a82d9446eb39c70b7a85c45a8ce4f8d9bcff 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -433,7 +433,7 @@ public abstract class TGComponent implements CDElement, GenericTree { } } - public void drawRunningDiploID(Graphics g) { + public void drawRunningDiploID(Graphics g, RunningInfo ri) { //System.out.println("Drawing running DIPLO"); int wb = 30; int hb = 10; @@ -468,9 +468,26 @@ public abstract class TGComponent implements CDElement, GenericTree { g.setColor(ColorManager.CURRENT_COMMAND); g.fillPolygon(xp, yp, 7); + String s; + if (ri.progression != null) { + s = ri.progression + "%"; + } else { + s = ""; + } + int ww = g.getFontMetrics().stringWidth(s); + + if (ri.startTime != null) { + g.drawString(ri.startTime, x - sep - wb -wh, y + ((height-hb) / 2) - 1); + } + g.drawString(s, x - sep - wb -wh -ww, y + 4 + ((height) / 2)); + if (ri.finishTime != null) { + g.drawString(ri.finishTime, x - sep - wb -wh, y + ((height+hb) / 2) + 10); + } + } public void draw(Graphics g) { + RunningInfo ri; ColorManager.setColor(g, state, 0); internalDrawing(g); repaint = false; @@ -507,8 +524,9 @@ public abstract class TGComponent implements CDElement, GenericTree { if (tdp instanceof TMLActivityDiagramPanel) { if (getFather() == null) { drawDiploID(g); - if (tdp.getMGUI().isRunningID(getDIPLOID())) { - drawRunningDiploID(g); + ri = tdp.getMGUI().isRunningID(getDIPLOID()); + if (ri != null) { + drawRunningDiploID(g, ri); } } } else if (tdp instanceof TMLComponentTaskDiagramPanel) { diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 81fbf9b292e0580c6fe362e07fd1c6b3781b4001..50b6bde56a36e45c77fc924f00e35d257a30fc7c 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -1137,6 +1137,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene String id, idvar; String name; String command; + String startTime="", finishTime=""; + String progression="", nextCommand=""; String util = null; String value; String extime; @@ -1146,12 +1148,15 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene int k; + //System.out.println("toto0"); + try { for(int j=0; j<diagramNl.getLength(); j++) { //System.out.println("Ndes: " + j); node = diagramNl.item(j); if (node == null) { + System.out.println("null node"); return false; } @@ -1162,7 +1167,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene if (elt.getTagName().compareTo(SIMULATION_GLOBAL) == 0) { nl = elt.getElementsByTagName("status"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); @@ -1170,7 +1175,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } nl = elt.getElementsByTagName("brkreason"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); @@ -1178,7 +1183,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } nl = elt.getElementsByTagName("simtime"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { gotTimeAnswerFromServer = true; node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); @@ -1186,19 +1191,19 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } nl = elt.getElementsByTagName("msg"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); msg = node0.getTextContent(); } nl = elt.getElementsByTagName("error"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); error = node0.getTextContent(); } nl = elt.getElementsByTagName("hashval"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); hash = node0.getTextContent(); } @@ -1210,21 +1215,52 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene id = null; name = null; command = null; + nextCommand = null; + progression = null; + startTime = null; finishTime = null; id = elt.getAttribute("id"); name = elt.getAttribute("name"); nl = elt.getElementsByTagName("currcmd"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); if (node0.getNodeType() == Node.ELEMENT_NODE) { elt0 = (Element)node0; command = elt0.getAttribute("id"); } + nl = elt.getElementsByTagName("progr"); + if ((nl != null) && (nl.getLength() > 0)) { + node0 = nl.item(0); + progression = node0.getTextContent(); + //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); + } + nl = elt.getElementsByTagName("starttime"); + if ((nl != null) && (nl.getLength() > 0)) { + node0 = nl.item(0); + startTime = node0.getTextContent(); + //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); + } + nl = elt.getElementsByTagName("finishtime"); + if ((nl != null) && (nl.getLength() > 0)) { + node0 = nl.item(0); + finishTime = node0.getTextContent(); + //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); + } + nl = elt.getElementsByTagName("nextcmd"); + if ((nl != null) && (nl.getLength() > 0)) { + node0 = nl.item(0); + nextCommand = node0.getTextContent(); + //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); + } + } //System.out.println("Got info on task " + id + " command=" + command); if ((id != null) && (command != null)) { - updateRunningCommand(id, command); + if (nextCommand ==null) { + nextCommand = "-1"; + } + updateRunningCommand(id, command, progression, startTime, finishTime, nextCommand); } if (openDiagram.isEnabled() && openDiagram.isSelected() && (name != null) && (command != null)) { @@ -1233,7 +1269,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene extime = null; nl = elt.getElementsByTagName("extime"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); extime = node0.getTextContent(); @@ -1246,22 +1282,26 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene nl = elt.getElementsByTagName("var"); - idvar = null; - value = null; - for(k=0; k<nl.getLength(); k++) { - node0 = nl.item(k); - value = node0.getTextContent(); - if (node0.getNodeType() == Node.ELEMENT_NODE) { - elt0 = (Element)node0; - idvar = elt0.getAttribute("id"); - } - if ((value != null) && (idvar != null)) { - updateVariableState(idvar, value); - jpsv.updateOnVariableValue(idvar); + if ((nl != null) && (nl.getLength() > 0)) { + idvar = null; + value = null; + for(k=0; k<nl.getLength(); k++) { + node0 = nl.item(k); + value = node0.getTextContent(); + if (node0.getNodeType() == Node.ELEMENT_NODE) { + elt0 = (Element)node0; + idvar = elt0.getAttribute("id"); + } + if ((value != null) && (idvar != null)) { + updateVariableState(idvar, value); + jpsv.updateOnVariableValue(idvar); + } } } } + //System.out.println("toto1"); + if (elt.getTagName().compareTo(SIMULATION_CPU) == 0) { id = null; name = null; @@ -1273,23 +1313,15 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene id = elt.getAttribute("id"); name = elt.getAttribute("name"); nl = elt.getElementsByTagName("util"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); util = node0.getTextContent(); } - //System.out.println("Got info on cpu " + id + " util=" + util); - - nl = elt.getElementsByTagName("util"); - if (nl.getLength() > 0) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - util = node0.getTextContent(); - } - - - if (nl.getLength() > 0) { + //System.out.println("toto12"); + nl = elt.getElementsByTagName("contdel"); + if ((nl != null) && (nl.getLength() > 0)) { nl = elt.getElementsByTagName("contdel"); node0 = nl.item(0); elt0 = (Element)node0; @@ -1307,6 +1339,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + //System.out.println("toto2"); + if (elt.getTagName().compareTo(SIMULATION_BUS) == 0) { id = null; name = null; @@ -1314,7 +1348,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene id = elt.getAttribute("id"); name = elt.getAttribute("name"); nl = elt.getElementsByTagName("util"); - if (nl.getLength() > 0) { + if ((nl != null) && (nl.getLength() > 0)) { node0 = nl.item(0); //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); util = node0.getTextContent(); @@ -1755,9 +1789,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene }*/ } - private void updateRunningCommand(String id, String command) { + private void updateRunningCommand(String id, String command, String progression, String startTime, String finishTime, String nextCommand) { Integer i = getInteger(id); Integer c = getInteger(command); + Integer nc = getInteger(nextCommand); if ((i != null) && (c != null)) { try { @@ -1769,8 +1804,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } runningTable.put(i, c); - //System.out.println("Adding running command"); - mgui.addRunningID(c); + //System.out.println("Adding running command: " +c); + mgui.addRunningID(c, nc, progression, startTime, finishTime); } catch (Exception e) { System.out.println("Exception updateRunningCommand: " + e.getMessage()); } @@ -1779,6 +1814,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } private void updateOpenDiagram(String name, String command) { + //System.out.println("UpdateOpenDiagram name=" + name + " for command:" + command); if (tmap == null) { return; } @@ -1786,10 +1822,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene String cmd = diagramTable.get(name); if (cmd == null) { diagramTable.put(name, command); - return; + //return; } - if (!(cmd.equals(command))) { + if ((cmd == null) || (!(cmd.equals(command)))) { diagramTable.remove(name); diagramTable.put(name, command); @@ -1800,7 +1836,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene diag = tab.substring(0, index); tab = tab.substring(index+2, tab.length()); } - //System.out.println("Opening diagram " + tab); + //System.out.println("Opening diagram " + tab + " for command:" + command); mgui.openTMLTaskActivityDiagram(diag, tab); }