diff --git a/src/avatartranslator/directsimulation/AvatarSimulationInteraction.java b/src/avatartranslator/directsimulation/AvatarSimulationInteraction.java index 2ba7c22cf135953da92ae847db2bc3966a8787c5..9ae865762c4a9913470d5743aeb41ceda16d9186 100644 --- a/src/avatartranslator/directsimulation/AvatarSimulationInteraction.java +++ b/src/avatartranslator/directsimulation/AvatarSimulationInteraction.java @@ -51,4 +51,6 @@ package avatartranslator.directsimulation; public interface AvatarSimulationInteraction { public void setMode(int _mode); + + public void updateTransactionAndTime(int _nbOfTransactions, long clockValue); } \ No newline at end of file diff --git a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java index d611c259067e65fe23c5379942b02bc1635b50ae..86f67a6b738f586b9912141bda061518d1235617 100644 --- a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java +++ b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java @@ -185,6 +185,9 @@ public class AvatarSpecificationSimulation { go = performSelectedTransactions(selectedTransactions); //TraceManager.addDev("NbOfcommands=" + nbOfCommands); nbOfCommands --; + if (asi != null) { + asi.updateTransactionAndTime(allTransactions.size(), clockValue); + } //TraceManager.addDev("------------- new NbOfcommands=" + nbOfCommands); } } @@ -206,7 +209,7 @@ public class AvatarSpecificationSimulation { pendingTransactions.addAll(asb.getPendingTransactions(allTransactions, clockValue, MAX_TRANSACTION_IN_A_ROW)); } - TraceManager.addDev("# of pending transactions before selection: " + pendingTransactions.size()); + //TraceManager.addDev("# of pending transactions before selection: " + pendingTransactions.size()); Vector<AvatarSimulationPendingTransaction> ll = new Vector<AvatarSimulationPendingTransaction>(); @@ -223,7 +226,7 @@ public class AvatarSpecificationSimulation { // It has in fact no delay! aspt.hasDelay = false; } else { - TraceManager.addDev("min Duration = " + aspt.myMinDuration + " max duration=" + aspt.myMaxDuration); + //TraceManager.addDev("min Duration = " + aspt.myMinDuration + " max duration=" + aspt.myMaxDuration); } } } diff --git a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java index f9cdfe2ebdf50081b4660a2a9ddc10a3cf8775c9..87ded8b915d071d517ae16401bd86b8362b9e0b3 100755 --- a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java +++ b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java @@ -72,6 +72,8 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS private static int NOT_STARTED = 0; private static int STARTED = 1; + private static long SPACE_UPDATE_TIME = 100; + private Frame f; private MainGUI mgui; private String title; @@ -167,6 +169,8 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS private LinkedList<TGComponent> runningTGComponents; private int nbOfAllExecutedElements = 0; + private long previousTime; + public JFrameAvatarInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, AvatarSpecification _avspec) { super(_title); @@ -209,6 +213,8 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS resetThread = false; killThread = false; + previousTime = System.currentTimeMillis(); + ass.runSimulation(); if (killThread) { return; @@ -226,6 +232,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS nbOfAllExecutedElements = 0; resetMetElements(); ass.reset(); + previousTime = System.currentTimeMillis(); run(); } TraceManager.addDev("Simulation thread ended"); @@ -238,7 +245,6 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS wait(); } catch (Exception e) {} } - TraceManager.addDev("EndWaitForResetOrKillThread"); } @@ -671,6 +677,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } public void runSimulation() { + previousTime = System.currentTimeMillis(); ass.unstop(); } @@ -683,6 +690,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS nb = 1; } ass.setNbOfCommands(nb); + previousTime = System.currentTimeMillis(); ass.unstop(); } @@ -745,6 +753,14 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } + public void updateTransactionAndTime(int _nbOfTransactions, long clockValue) { + long timeNow = System.currentTimeMillis(); + if (timeNow - previousTime > SPACE_UPDATE_TIME) { + previousTime = timeNow; + setLabelColors(); + } + } + public void setAll() { boolean b= true; @@ -1062,1022 +1078,4 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } - /*private void printCPUs() { - if (latex.isSelected()) { - String name; - String tmp, tmp1; - int index, index1; - jta.append("\\begin{tabular}{|l|c|c|}\n"); - jta.append("\\hline\n"); - jta.append("\\texbf{CPU} & \\textbf{Load} & \\textbf{Contention delay}\n"); - jta.append("\\hline\n"); - for(int i=0; i<cputm.getRowCount(); i++) { - name = (String)(cputm.getValueAt(i, 0)); - tmp = (String)(cputm.getValueAt(i, 2)); - jta.append(Conversion.toLatex(name) + " &"); - index = tmp.indexOf(';'); - if (index == -1) { - jta.append(" - & - \\\\\n"); - } else { - - - tmp1 = tmp.substring(0, index); - index1 = tmp1.indexOf(':'); - if (index1 != -1) { - tmp1 = tmp1.substring(index1 + 2, tmp1.length()); - } - jta.append("" + tmp1 + " &"); - tmp1 = tmp.substring(index+1, tmp.length()); - index1 = tmp1.indexOf(':'); - if (index1 != -1) { - tmp1 = tmp1.substring(index1 + 2, tmp1.length()); - } - jta.append("" + tmp1 + "\\\\\n"); - } - } - jta.append("\\hline\n"); - } else { - String name; - String tmp, tmp1; - int index, index1; - jta.append("\nCPUs:\n"); - for(int i=0; i<cputm.getRowCount(); i++) { - name = (String)(cputm.getValueAt(i, 0)); - tmp = (String)(cputm.getValueAt(i, 2)); - jta.append("* " + name + "\n"); - index = tmp.indexOf(';'); - if (index == -1) { - jta.append("\t - \n"); - } else { - jta.append("\t" + tmp.substring(0, index) + "\n"); - jta.append("\t" + tmp.substring(index+1, tmp.length()) + "\n"); - } - } - } - } - - private void printBuses() { - if (latex.isSelected()) { - String name; - String tmp, tmp1; - int index, index1; - jta.append("\\begin{tabular}{|l|c|c|}\n"); - jta.append("\\hline\n"); - jta.append("\\texbf{CPU} & \\textbf{Load} & \\textbf{Contention delay}\n"); - jta.append("\\hline\n"); - for(int i=0; i<bustm.getRowCount(); i++) { - name = (String)(bustm.getValueAt(i, 0)); - tmp = (String)(bustm.getValueAt(i, 2)); - jta.append(Conversion.toLatex(name) + " &"); - index = tmp.indexOf(':'); - if (index == -1) { - jta.append(" - \\\\\n"); - } else { - tmp1 = tmp.substring(index+2, tmp.length()); - jta.append("" + tmp1 + "\\\\\n"); - } - } - jta.append("\\hline\n"); - } else { - String name; - String tmp; - jta.append("\nBuses:\n"); - for(int i=0; i<bustm.getRowCount(); i++) { - name = (String)(bustm.getValueAt(i, 0)); - tmp = (String)(bustm.getValueAt(i, 2)); - jta.append("* " + name + "\n"); - jta.append("\t" + tmp + "\n"); - } - } - }*/ - - /*private void updateVariableState(String _idvar, String _value) { - Integer i = getInteger(_idvar); - int row; - - if (i != null) { - try { - valueTable.remove(i); - valueTable.put(i, _value); - //System.out.println("Searching for old row"); - row = (Integer)(rowTable.get(i)).intValue(); - tvtm.fireTableCellUpdated(row, 4); - } catch (Exception e) { - TraceManager.addDev("Exception updateVariableState: " + e.getMessage() + " idvar=" + _idvar + " val=" + _value); - } - } - - } - - private void updateTaskCyclesAndState(String _id, String _extime, String _state) { - Integer i = getInteger(_id); - Integer ex = getInteger(_extime); - int row; - - String s = ""; - if (_state != null) { - s += _state; - } - s += ";"; - if (_extime != null) { - s+= _extime; - } - - - - if ((i != null) && (ex != null)) { - try { - valueTable.remove(i); - valueTable.put(i, s); - //System.out.println("Searching for old row"); - row = rowTable.get(i).intValue(); - if (_state != null) { - tasktm.fireTableCellUpdated(row, 2); - } - if (_extime != null) { - tasktm.fireTableCellUpdated(row, 3); - } - - Integer c = runningTable.get(i); - if (c != null) { - mgui.addRunningIDTaskState(c, _state); - } - } catch (Exception e) { - TraceManager.addDev("Exception updateTaskCyclesAndStates: " + e.getMessage()); - } - } - - } - - private void updateCPUState(String _id, String _utilization, String contdel, String busName, String busID) { - Integer i = getInteger(_id); - int row; - String info; - - if (i != null) { - try { - valueTable.remove(i); - info = "Utilization: " + _utilization; - if ((contdel != null) && (busName != null) && (busID != null)) { - info += "; Cont. delay on " + busName + " (" + busID + "): " + contdel; - } - valueTable.put(i, info); - //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) { - TraceManager.addDev("Exception updateCPUState: " + e.getMessage() + " id=" + _id + " util=" + _utilization); - } - } - } - - private void updateBusState(String _id, String _utilization) { - Integer i = getInteger(_id); - int row; - - if (i != null) { - try { - valueTable.remove(i); - valueTable.put(i, "Utilization: " + _utilization); - //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()); - } - } - }*/ - - /*public void askForUpdate() { - sendCommand("time"); - if (hashOK) { - if (animate.isSelected()) { - updateTaskCommands(); - } - if (update.isSelected()) { - updateTasks(); - updateVariables(); - updateCPUs(); - updateBus(); - } - } - }*/ - - - - - - - /*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())) { - sendCommandWithPositiveInt("run-x-time-units"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_TO_TIME].getActionCommand())) { - sendCommandWithPositiveInt("run-to-time"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_X_TRANSACTIONS].getActionCommand())) { - sendCommandWithPositiveInt("run-x-transactions"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_X_COMMANDS].getActionCommand())) { - sendCommandWithPositiveInt("run-x-commands"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_EXPLORATION].getActionCommand())) { - sendCommand("run-exploration"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_TO_NEXT_BUS_TRANSFER].getActionCommand())) { - toNextBusTransfer(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_UNTIL_CPU_EXECUTES].getActionCommand())) { - runUntilCPUExecutes(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_UNTIL_MEMORY_ACCESS].getActionCommand())) { - toNextMemoryTransfer(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_UNTIL_TASK_EXECUTES].getActionCommand())) { - runUntilTaskExecutes(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_UNTIL_CHANNEL_ACCESS].getActionCommand())) { - runUntilChannelAccess(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_VCD].getActionCommand())) { - sendSaveTraceCommand("0"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_HTML].getActionCommand())) { - sendSaveTraceCommand("1"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_TXT].getActionCommand())) { - sendSaveTraceCommand("2"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_STATE].getActionCommand())) { - sendSaveStateCommand(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_RESTORE_STATE].getActionCommand())) { - sendRestoreStateCommand(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_PRINT_BENCHMARK].getActionCommand())) { - sendCommand("get-benchmark 0"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_BENCHMARK].getActionCommand())) { - 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())) { - sendCommand("stop"); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_VARIABLES].getActionCommand())) { - updateVariables(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_CPUS].getActionCommand())) { - updateCPUs(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_MEMS].getActionCommand())) { - updateMemories(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_BUS].getActionCommand())) { - updateBus(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_TASKS].getActionCommand())) { - updateTasks(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_PRINT_CPUS].getActionCommand())) { - printCPUs(); - } else if (command.equals(actions[InteractiveSimulationActions.ACT_PRINT_BUS].getActionCommand())) { - printBuses(); - } */ - - - - /*public boolean isAPositiveInt(String s) { - int val; - try { - val = Integer.decode(s).intValue(); - } catch (Exception e) { - return false; - } - if (val > -1) { - return true; - } - return false; - } - - public Integer getInteger(String s) { - try { - return Integer.decode(s); - } catch (Exception e) { - return null; - } - } - - 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) { - sendCommand("run-to-next-transfer-on-bus " + id); - } - } - - public void runUntilCPUExecutes() { - int id = getIDFromString(cpuIDs[cpus.getSelectedIndex()]); - if (id != -1) { - sendCommand("run-until-cpu-executes " + id); - } - } - - public void toNextMemoryTransfer() { - int id = getIDFromString(memIDs[mems.getSelectedIndex()]); - if (id != -1) { - sendCommand("run-until-memory-access " + id); - } - } - - public void runUntilTaskExecutes() { - int id = getIDFromString(taskIDs[tasks.getSelectedIndex()]); - if (id != -1) { - sendCommand("run-until-task-executes " + id); - } - } - - public void runUntilChannelAccess() { - int id = getIDFromString(chanIDs[chans.getSelectedIndex()]); - if (id != -1) { - sendCommand("run-until-channel-access " + id); - } - } - - - - public int getIDFromString(String s) { - int index0 = s.indexOf("("); - int index1 = s.indexOf(")"); - if ((index0 < 0) || (index1 <0) || (index1 < index0)) { - return -1; - } - - String in = s.substring(index0+1, index1); - - try { - return Integer.decode(in).intValue(); - } catch (Exception e) { - System.err.println("Wrong string: "+ in); - } - - return -1; - } - - - - public void addBreakPoint(int _commandID) { - //TraceManager.addDev("Add breakpoint: " + _commandID); - // Check whether that breakpoint is already listed or not - for(Point p: points) { - if (p.y == _commandID) { - return; - } - } - - if (tmap != null) { - TMLTask task = tmap.getTMLTaskByCommandID(_commandID); - //TraceManager.addDev("Got task: " + task); - if (task != null) { - //TraceManager.addDev("Adding bkp"); - sendCommand("add-breakpoint " + task.getID() + " " + _commandID + "\n"); - jpbp.addExternalBreakpoint(task.getID(), _commandID); - } - } - } - - public void removeBreakPoint(int _commandID) { - TraceManager.addDev("remove breakpoint"); - int cpt = 0; - for(Point p: points) { - if (p.y == _commandID) { - sendCommand("rm-breakpoint " + p.x + " " + p.y + "\n"); - jpbp.removeExternalBreakpoint(cpt); - return; - } - cpt ++; - } - } - - public void sendBreakPointList() { - for(Point p: points) { - sendCommand("add-breakpoint " + p.x + " " + p.y + "\n"); - } - sendCommand("active-breakpoints 1"); - } - - public void removeBreakpoint(Point p) { - if (mode == STARTED_AND_CONNECTED) { - sendCommand("rm-breakpoint " + p.x + " " + p.y + "\n"); - } - if (animate.isSelected()) { - mgui.removeBreakpoint(p); - } - } - - public void addBreakpoint(Point p) { - if (mode == STARTED_AND_CONNECTED) { - sendCommand("add-breakpoint " + p.x + " " + p.y + "\n"); - } - if (animate.isSelected()) { - mgui.addBreakpoint(p); - } - } - - public void printMessage(String msg) { - jta.append("*** " + msg + " ***\n"); - } - - - - public void activeBreakPoint(boolean active) { - if (mode == STARTED_AND_CONNECTED) { - if (active) { - sendCommand("active-breakpoints 1"); - } else { - sendCommand("active-breakpoints 0"); - } - } - } - - public void setVariables(int _idTask, int _idVariable, String _value) { - sendCommand("set-variable " + _idTask + " " + _idVariable + " " + _value); - sendCommand("get-variable-of-task " + _idTask + " " + _idVariable); - }*/ - - /*protected void listTextCommands() { - String text = cp.getCommandList(); - append("Available commands", text); - } - - protected void helpOnCommand() { - String text = textCommand.getText().trim(); - String texts[] = text.split(" "); - text = texts[0]; - String result = cp.getHelp(text); - append("Help on command: " + text, result); - } - - protected void sendCommand() { - String text = textCommand.getText().trim(); - sendCommand(text); - } - - protected void sendCommand(String text) { - jta.append(">" + text + "\n"); - String command = cp.transformCommandFromUserToSimulator(text); - if (command.length() == 0) { - jta.append("** Wrong command / parameters **\n"); - return; - } - - try { - rc.send(command); - } catch (RemoteConnectionException rce) { - jta.append("** Sending command failed **\n"); - return ; - } catch (Exception e) {} - }*/ - - /*protected void append(String info, String list) { - jta.append("\n"); - jta.append(info + "\n"); - printSeparator(); - jta.append(list); - jta.append("\n"); - printSeparator(); - }*/ - - /*protected void analyzeServerAnswer(String s) { - //System.out.println("From server:" + s); - int index0 = s.indexOf("<?xml"); - - if (index0 != -1) { - //System.out.println("toto1"); - ssxml = s.substring(index0, s.length()) + "\n"; - } else { - //System.out.println("toto2"); - ssxml = ssxml + s + "\n"; - } - - index0 = ssxml.indexOf("</siminfo>"); - - if (index0 != -1) { - //System.out.println("toto3"); - ssxml = ssxml.substring(0, index0+10); - loadXMLInfoFromServer(ssxml); - ssxml = ""; - } - //System.out.println("toto4"); - - }*/ - - /*protected boolean loadXMLInfoFromServer(String xmldata) { - //jta.append("XML from server:" + xmldata + "\n\n"); - - DocumentBuilderFactory dbf; - DocumentBuilder db; - - try { - dbf = DocumentBuilderFactory.newInstance(); - db = dbf.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - dbf = null; - db = null; - } - - if ((dbf == null) || (db == null)) { - return false; - } - - ByteArrayInputStream bais = new ByteArrayInputStream(decodeString(xmldata).getBytes()); - int i; - - try { - // building nodes from xml String - Document doc = db.parse(bais); - NodeList nl; - Node node; - - nl = doc.getElementsByTagName(SIMULATION_HEADER); - - if (nl == null) { - return false; - } - - for(i=0; i<nl.getLength(); i++) { - node = nl.item(i); - //System.out.println("Node = " + dnd); - if (node.getNodeType() == Node.ELEMENT_NODE) { - // create design, and get an index for it - return loadConfiguration(node); - } - } - - } catch (IOException e) { - TraceManager.addError("Error when parsing server info:" + e.getMessage()); - return false; - } catch (SAXException saxe) { - TraceManager.addError("Error when parsing server info:" + saxe.getMessage()); - TraceManager.addError("xml:" + xmldata); - return false; - } - return true; - - } - - protected boolean loadConfiguration(Node node1) { - NodeList diagramNl = node1.getChildNodes(); - if (diagramNl == null) { - return false; - } - Element elt, elt0; - Node node, node0; - NodeList nl; - - - String tmp; - int val; - - int[] colors; - String msg = null; - String error = null; - String hash = null; - - String id, idvar; - String name; - String command; - String startTime="", finishTime=""; - String progression="", nextCommand=""; - String transStartTime="", transFinishTime=""; - String util = null; - String value; - String extime; - String contdel; - String busname; - String busid; - String state; - - 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) { - TraceManager.addDev("null node"); - return false; - } - - if (node.getNodeType() == Node.ELEMENT_NODE) { - elt = (Element)node; - - // Status - if (elt.getTagName().compareTo(SIMULATION_GLOBAL) == 0) { - - nl = elt.getElementsByTagName("status"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - - makeStatus(node0.getTextContent()); - } - - nl = elt.getElementsByTagName("brkreason"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - - makeBrkReason(node0.getTextContent()); - } - - nl = elt.getElementsByTagName("simtime"); - if ((nl != null) && (nl.getLength() > 0)) { - gotTimeAnswerFromServer = true; - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - time.setText(node0.getTextContent()); - } - - nl = elt.getElementsByTagName("msg"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - msg = node0.getTextContent(); - } - - nl = elt.getElementsByTagName("error"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - error = node0.getTextContent(); - } - - nl = elt.getElementsByTagName("hashval"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - hash = node0.getTextContent(); - } - - } - - if (hashOK) { - if (elt.getTagName().compareTo(SIMULATION_TASK) == 0) { - id = null; - name = null; - command = null; - nextCommand = null; - progression = null; - startTime = null; finishTime = null; - transStartTime = null; transFinishTime = null; - id = elt.getAttribute("id"); - name = elt.getAttribute("name"); - nl = elt.getElementsByTagName("currcmd"); - 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("transstarttime"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - transStartTime = node0.getTextContent(); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - } - nl = elt.getElementsByTagName("transfinishtime"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - transFinishTime = 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); - extime = null; - nl = elt.getElementsByTagName("extime"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - extime = node0.getTextContent(); - } - - state = null; - nl = elt.getElementsByTagName("tskstate"); - if ((nl != null) && (nl.getLength() > 0)) { - node0 = nl.item(0); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - state = node0.getTextContent(); - //TraceManager.addDev("TASK STATE: " + state); - } - - if ((id != null) && ((extime != null) || (state != null))) { - updateTaskCyclesAndState(id, extime, state); - } - - - if ((id != null) && (command != null)) { - if (nextCommand ==null) { - nextCommand = "-1"; - } - updateRunningCommand(id, command, progression, startTime, finishTime, nextCommand, transStartTime, transFinishTime, state); - } - - if (openDiagram.isEnabled() && openDiagram.isSelected() && (name != null) && (command != null)) { - updateOpenDiagram(name, command, progression, startTime, finishTime, transStartTime, transFinishTime); - } - - - - - nl = elt.getElementsByTagName("var"); - 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; - command = null; - contdel = null; - busname = null; - busid = null; - - id = elt.getAttribute("id"); - name = elt.getAttribute("name"); - nl = elt.getElementsByTagName("util"); - 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("toto12"); - nl = elt.getElementsByTagName("contdel"); - if ((nl != null) && (nl.getLength() > 0)) { - nl = elt.getElementsByTagName("contdel"); - node0 = nl.item(0); - elt0 = (Element)node0; - busid = elt0.getAttribute("busID"); - busname = elt0.getAttribute("busName"); - //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); - contdel = node0.getTextContent(); - } - - //System.out.println("contdel: " + contdel + " busID:" + busid + " busName:" + busname); - - - if ((id != null) && (util != null)) { - updateCPUState(id, util, contdel, busname, busid); - } - } - - //System.out.println("toto2"); - - if (elt.getTagName().compareTo(SIMULATION_BUS) == 0) { - id = null; - name = null; - command = null; - id = elt.getAttribute("id"); - name = elt.getAttribute("name"); - nl = elt.getElementsByTagName("util"); - 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 bus " + id + " util=" + util); - - if ((id != null) && (util != null)) { - updateBusState(id, util); - } - } - } - } - } - } catch (Exception e) { - TraceManager.addError("Exception in xml parsing " + e.getMessage() + " node= " + node1); - return false; - } - - if ((msg != null) && (error != null)) { - if (error.trim().equals("0")) { - printFromServer(msg + ": command successful"); - if (msg.indexOf("reset") != -1) { - time.setText("0"); - } - } else { - printFromServer(msg + ": command failed (error=" + error + ")"); - } - } else if (msg != null) { - printFromServer("Server: " + msg); - } else { - printFromServer("Server: error " + error); - } - - if ((hash != null) && (tmap != null)) { - try { - int thehash = Integer.decode(hash).intValue(); - - if (thehash != hashCode) { - jta.append("\n*** Simulated model is not the model currently loaded under TTool ***\n"); - jta.append("*** Some features are therefore deactivated ***\n\n"); - hashOK = false; - wrongHashCode(); - } else { - askForUpdate(); - sendBreakPointList(); - jta.append("\n*** Simulated model is the one currently loaded under TTool ***\n"); - hashOK = true; - animate.setSelected(true); - animate.setEnabled(true); - diploids.setEnabled(true); - animateWithInfo.setSelected(true); - animateWithInfo.setEnabled(true); - openDiagram.setEnabled(true); - cpus.setEnabled(true); - busses.setEnabled(true); - mems.setEnabled(true); - tasks.setEnabled(true); - chans.setEnabled(true); - } - } catch (Exception e) { - } - } - - return true; - }*/ - - /*private void wrongHashCode() { - 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); - update.setSelected(false); - - cpus.setEnabled(false); - busses.setEnabled(false); - mems.setEnabled(false); - tasks.setEnabled(false); - chans.setEnabled(false); - cpus.removeAllItems(); - busses.removeAllItems(); - mems.removeAllItems(); - tasks.removeAllItems(); - chans.removeAllItems(); - - jpsv.setEnabled(false); - jpsv.unsetElements(); - - actions[InteractiveSimulationActions.ACT_RUN_TO_NEXT_BUS_TRANSFER].setEnabled(false); - actions[InteractiveSimulationActions.ACT_RUN_UNTIL_CPU_EXECUTES].setEnabled(false); - actions[InteractiveSimulationActions.ACT_RUN_UNTIL_TASK_EXECUTES].setEnabled(false); - actions[InteractiveSimulationActions.ACT_RUN_UNTIL_MEMORY_ACCESS].setEnabled(false); - actions[InteractiveSimulationActions.ACT_RUN_UNTIL_CHANNEL_ACCESS].setEnabled(false); - - // Set variable tab is removed - // - commandTab.removeTabAt(2); - jpsv = null; - - while(infoTab.getTabCount() > 2) { - infoTab.removeTabAt(2); - } - jpbp.unsetElements(); - - }*/ - - /*public synchronized void startThread(int mode) { - threadMode = mode; - t = new Thread(this); - t.start(); - threadStarted = false; - //System.out.println("thread of mode:" + threadMode); - while(threadStarted == false) { - try { - wait(); - } catch (InterruptedException ie) {} - } - } - - public synchronized void threadStarted() { - TraceManager.addDev("thread started"); - threadStarted = true; - notify(); - } - - public void makeBrkReason(String s) { - info.setText(s); - }*/ - - /*public void makeStatus(String s) { - //System.out.println("busystatus=" + busyStatus); - - if (s.equals("busy")) { - status.setText("Busy"); - setBusyStatus(); - busyMode = 2; - //busyStatus = true; - } - if (s.equals("ready")) { - status.setText("Ready"); - if (busyMode == 2) { - //System.out.println("Sending time command"); - askForUpdate(); - //sendCommand("time"); - } - busyMode = 1; - setBusyStatus(); - } - - if (s.equals("term")) { - status.setText("Terminated"); - if (busyMode == 2) { - askForUpdate(); - } - busyMode = 3; - setBusyStatus(); - - //System.out.println("**** TERM ****"); - } - setLabelColors(); - } - - public void setBusyStatus() { - setAll(); - actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(busyMode == 2); - }*/ - - /*public void setLabelColors() { - switch(busyMode) { - case 0: - status.setForeground(ColorManager.InteractiveSimulationText_UNKNOWN); - time.setForeground(ColorManager.InteractiveSimulationText_UNKNOWN); - info.setForeground(ColorManager.InteractiveSimulationText_UNKNOWN); - break; - case 1: - status.setForeground(ColorManager.InteractiveSimulationText_READY); - time.setForeground(ColorManager.InteractiveSimulationText_READY); - info.setForeground(ColorManager.InteractiveSimulationText_READY); - break; - case 2: - status.setForeground(ColorManager.InteractiveSimulationText_BUSY); - time.setForeground(ColorManager.InteractiveSimulationText_BUSY); - info.setForeground(ColorManager.InteractiveSimulationText_BUSY); - break; - case 3: - status.setForeground(ColorManager.InteractiveSimulationText_TERM); - time.setForeground(ColorManager.InteractiveSimulationText_TERM); - info.setForeground(ColorManager.InteractiveSimulationText_TERM); - break; - } - - - }*/ - - - } // Class