diff --git a/src/remotesimulation/CommandParser.java b/src/remotesimulation/CommandParser.java index 80207dc48fcf49428641a7f74da83af066a8d374..97ac3484ce55a5490e0a09882e268ecf283aa0ad 100755 --- a/src/remotesimulation/CommandParser.java +++ b/src/remotesimulation/CommandParser.java @@ -202,20 +202,36 @@ public class CommandParser { sc = new SimulationCommand("get-command-and-task", "gcat", "14", params, paramNames, "Returns the current command and task"); commandList.add(sc); + // get-hash-code + params = new int[0]; + paramNames = new String[0]; + sc = new SimulationCommand("get-hashcode", "gh", "19", params, paramNames, "Returns the hashcode of the tmap under simulation"); + commandList.add(sc); + + // get-info-on-hw + params = new int[2]; + paramNames = new String[2]; + params[0] = 1; + paramNames[0] = "0: CPU; 1:Bus; 2: Mem; 3: Bridge; 4: Channel"; + params[1] = 1; + paramNames[1] = "id"; + sc = new SimulationCommand("get-info-on-hw", "gioh", "4", params, paramNames, "Returns information on hardware nodes of the architecture"); + commandList.add(sc); + // get-simulation-time params = new int[0]; paramNames = new String[0]; sc = new SimulationCommand("get-simulation-time", "time", "13", params, paramNames, "Returns the current absolute time unit of the simulation"); commandList.add(sc); - // save-trace-in-file + // get-variable-of-task params = new int[2]; paramNames = new String[2]; params[0] = 1; paramNames[0] = "Task id"; params[1] = 1; paramNames[1] = "Variable id"; - sc = new SimulationCommand("get-variable-of-task", "gvof", "3", params, paramNames, "Saves the current trace of the simulation in a VCD, HTML or TXT file"); + sc = new SimulationCommand("get-variable-of-task", "gvof", "3", params, paramNames, "Returns the value of a variable a a task"); commandList.add(sc); // kill @@ -254,20 +270,28 @@ public class CommandParser { sc = new SimulationCommand("run-to-next-breakpoint", "rtnb", "1 0", params, paramNames, "Runs the simulation until a breakpoint is met"); commandList.add(sc); - // run-x-time-units + // run-to-time params = new int[1]; paramNames = new String[1]; params[0] = 1; - paramNames[0] = "nb of time units"; - sc = new SimulationCommand("run-x-time-units", "rxtu", "1 6", params, paramNames, "Runs the simulation for x units of time"); + paramNames[0] = "x: time value"; + sc = new SimulationCommand("run-to-time", "rtt", "1 5", params, paramNames, "Runs the simulation until time x is reached"); commandList.add(sc); - // run-to-time + // run-x-commands params = new int[1]; paramNames = new String[1]; params[0] = 1; - paramNames[0] = "x: time value"; - sc = new SimulationCommand("run-to-time", "rtt", "1 5", params, paramNames, "Runs the simulation until time x is reached"); + paramNames[0] = "nb of commands"; + sc = new SimulationCommand("run-x-commands", "rxcomm", "1 4", params, paramNames, "Runs the simulation for x commands"); + commandList.add(sc); + + // run-x-time-units + params = new int[1]; + paramNames = new String[1]; + params[0] = 1; + paramNames[0] = "nb of time units"; + sc = new SimulationCommand("run-x-time-units", "rxtu", "1 6", params, paramNames, "Runs the simulation for x units of time"); commandList.add(sc); // run-x-transactions @@ -278,12 +302,12 @@ public class CommandParser { sc = new SimulationCommand("run-x-transactions", "rxtr", "1 2", params, paramNames, "Runs the simulation for x transactions"); commandList.add(sc); - // run-x-commands + // save-simulation-state-in-file params = new int[1]; paramNames = new String[1]; - params[0] = 1; - paramNames[0] = "nb of commands"; - sc = new SimulationCommand("run-x-commands", "rxcomm", "1 4", params, paramNames, "Runs the simulation for x commands"); + params[0] = 2; + paramNames[0] = "File name"; + sc = new SimulationCommandSaveState("save-simulation-state-in-file", "sssif", "8", params, paramNames, "Saves the current simulation state into a file"); commandList.add(sc); // save-trace-in-file @@ -296,14 +320,6 @@ public class CommandParser { sc = new SimulationCommand("save-trace-in-file", "stif", "7", params, paramNames, "Saves the current trace of the simulation in a VCD, HTML or TXT file"); commandList.add(sc); - // save-simulation-state-in-file - params = new int[1]; - paramNames = new String[1]; - params[0] = 2; - paramNames[0] = "File name"; - sc = new SimulationCommandSaveState("save-simulation-state-in-file", "sssif", "8", params, paramNames, "Saves the current simulation state into a file"); - commandList.add(sc); - // stop params = new int[0]; paramNames = new String[0]; diff --git a/src/tmltranslator/TMLModeling.java b/src/tmltranslator/TMLModeling.java index c9fa2da915182d7d0e77f4663c6ab39e30b1d849..01e334aab03f7982bfb442cda8429620423a2644 100755 --- a/src/tmltranslator/TMLModeling.java +++ b/src/tmltranslator/TMLModeling.java @@ -144,6 +144,11 @@ public class TMLModeling { private void computeHashCode() { TMLTextSpecification tmltxt = new TMLTextSpecification("spec.tml"); String s = tmltxt.toTextFormat(this); + + int index = s.indexOf("// Channels"); + if (index != -1) { + s = s.substring(index, s.length()); + } hashCode = s.hashCode(); System.out.println("TML hashcode = " + hashCode); } diff --git a/src/ui/interactivesimulation/InteractiveSimulationActions.java b/src/ui/interactivesimulation/InteractiveSimulationActions.java index 20eba872dcf34b0c482eeabfd9e1eea9afc06a9b..8652e8b4cb4c78fcf5cbe30f929a0aeaf91bfd44 100755 --- a/src/ui/interactivesimulation/InteractiveSimulationActions.java +++ b/src/ui/interactivesimulation/InteractiveSimulationActions.java @@ -77,8 +77,9 @@ public class InteractiveSimulationActions extends AbstractAction { public static final int ACT_STOP_AND_CLOSE_ALL = 5; public static final int ACT_UPDATE_VARIABLES = 15; + public static final int ACT_UPDATE_CPUS = 16; - public static final int NB_ACTION = 16; + public static final int NB_ACTION = 17; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -138,6 +139,7 @@ public class InteractiveSimulationActions extends AbstractAction { actions[ACT_STOP_AND_CLOSE_ALL] = new TAction("stop-and-close-all", "Terminate simulation and quit", IconManager.imgic27, IconManager.imgic27, "Terminate simulation and quit", "Terminate the simulation and quit the simulation window", 'T'); actions[ACT_UPDATE_VARIABLES] = new TAction("update-variables", "Update variables", IconManager.imgic75, IconManager.imgic75, "Update variables", "Update variables", 'R'); + actions[ACT_UPDATE_CPUS] = new TAction("update-cpus", "Update CPU information", IconManager.imgic75, IconManager.imgic75, "Update CPU information", "Update information on CPUs", 'R'); } diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 30dc293c25b8596f556a2599481aed3075de0e60..047886b60dcac7f351713d3d174560dd1866b887 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -113,9 +113,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene protected SaveCommandsToolBar sctb; protected StateCommandsToolBar stctb; - JPanel main, mainTop, commands, save, state, infos, outputs; // from MGUI + JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel; // from MGUI JCheckBox debug; - JTabbedPane commandTab, infoTab, saveTab, stateTab; + JTabbedPane commandTab, infoTab; protected JTextField paramMainCommand; protected JTextField saveFileName; protected JTextField stateFileName; @@ -124,9 +124,15 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene JLabel status, time; // Task elements + TaskVariableTableModel tvtm; JButton updateTaskVariableInformationButton; private JScrollPane jspTaskVariableInfo; + // CPU + CPUTableModel cputm; + JButton updateCPUInformationButton; + private JScrollPane jspCPUInfo; + private int mode = 0; private boolean busyStatus = false; @@ -141,7 +147,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene private TMLMapping tmap; int hashCode; - private Hashtable <String, String> mainTable; + private Hashtable <Integer, String> valueTable; + private Hashtable <Integer, Integer> rowTable; public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute, TMLMapping _tmap) { super(_title); @@ -161,7 +168,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //System.out.println("Tmap=" + tmap); - mainTable = new Hashtable<String, String>(); + valueTable = new Hashtable<Integer, String>(); + rowTable = new Hashtable<Integer, Integer>(); setBackground(new Color(50, 40, 40, 200)); @@ -446,21 +454,23 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene debug = new JCheckBox("Print messages received from server"); jp01.add(debug, c01); - jp01 = new JPanel(); - jp01.setLayout(new BorderLayout()); - infoTab.addTab("Tasks variables", null, jp01, "Current value of variables"); + TableSorter sorterPI; + JTable jtablePI; + // Variables + variablePanel = new JPanel(); + variablePanel.setLayout(new BorderLayout()); + infoTab.addTab("Tasks variables", null, variablePanel, "Current value of variables"); TaskVariableTableModel tvtm; if (tmap == null) { - tvtm = new TaskVariableTableModel(null, mainTable); + tvtm = new TaskVariableTableModel(null, valueTable, rowTable); } else { - tvtm = new TaskVariableTableModel(tmap.getTMLModeling(), mainTable); + tvtm = new TaskVariableTableModel(tmap.getTMLModeling(), valueTable, rowTable); } - TableSorter sorterPI = new TableSorter(tvtm); - JTable jtablePI = new JTable(sorterPI); + sorterPI = new TableSorter(tvtm); + jtablePI = new JTable(sorterPI); sorterPI.setTableHeader(jtablePI.getTableHeader()); - ((jtablePI.getColumnModel()).getColumn(0)).setPreferredWidth(100); ((jtablePI.getColumnModel()).getColumn(1)).setPreferredWidth(75); ((jtablePI.getColumnModel()).getColumn(2)).setPreferredWidth(100); @@ -471,11 +481,29 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene jspTaskVariableInfo.setWheelScrollingEnabled(true); jspTaskVariableInfo.getVerticalScrollBar().setUnitIncrement(10); jspTaskVariableInfo.setPreferredSize(new Dimension(500, 300)); - - jp01.add(jspTaskVariableInfo, BorderLayout.NORTH); - + variablePanel.add(jspTaskVariableInfo, BorderLayout.NORTH); updateTaskVariableInformationButton = new JButton(actions[InteractiveSimulationActions.ACT_UPDATE_VARIABLES]); - jp01.add(updateTaskVariableInformationButton, BorderLayout.SOUTH); + variablePanel.add(updateTaskVariableInformationButton, BorderLayout.SOUTH); + + // CPUs + cpuPanel = new JPanel(); + cpuPanel.setLayout(new BorderLayout()); + infoTab.addTab("CPUs", null, cpuPanel, "Current state of CPUs"); + CPUTableModel cputm = new CPUTableModel(tmap, valueTable, rowTable); + sorterPI = new TableSorter(cputm); + jtablePI = new JTable(sorterPI); + sorterPI.setTableHeader(jtablePI.getTableHeader()); + ((jtablePI.getColumnModel()).getColumn(0)).setPreferredWidth(100); + ((jtablePI.getColumnModel()).getColumn(1)).setPreferredWidth(75); + ((jtablePI.getColumnModel()).getColumn(2)).setPreferredWidth(100); + jtablePI.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jspCPUInfo = new JScrollPane(jtablePI); + jspCPUInfo.setWheelScrollingEnabled(true); + jspCPUInfo.getVerticalScrollBar().setUnitIncrement(10); + jspCPUInfo.setPreferredSize(new Dimension(500, 300)); + cpuPanel.add(jspCPUInfo, BorderLayout.NORTH); + updateCPUInformationButton = new JButton(actions[InteractiveSimulationActions.ACT_UPDATE_CPUS]); + cpuPanel.add(updateCPUInformationButton, BorderLayout.SOUTH); pack(); } @@ -624,6 +652,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene setComponents(); sendCommand("time"); + if (tmap != null) { + sendCommand("get-hashcode"); + } try { while(true) { @@ -851,6 +882,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene int[] colors; String msg = null; String error = null; + String hash = null; try { for(int j=0; j<diagramNl.getLength(); j++) { @@ -890,6 +922,12 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene error = node0.getTextContent(); } + nl = elt.getElementsByTagName("hashval"); + if (nl.getLength() > 0) { + node0 = nl.item(0); + hash = node0.getTextContent(); + } + } } } @@ -913,6 +951,21 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene 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"); + cpuPanel.setVisible(false); + variablePanel.setVisible(false); + } else { + jta.append("\n*** Simulated model is the one currently loaded under TTool ***\n"); + } + } catch (Exception e) { + } + } + return true; } @@ -1075,6 +1128,18 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + private void updateCPUs() { + if (tmap == null) { + return; + } + + for(HwNode node: tmap.getTMLArchitecture().getHwNodes()) { + if (node instanceof HwCPU) { + sendCommand("get-info-on-hw 0 " + node.getID()); + } + } + } + public void actionPerformed(ActionEvent evt) { @@ -1118,6 +1183,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene sendCommand("stop"); } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_VARIABLES].getActionCommand())) { updateVariables(); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_CPUS].getActionCommand())) { + updateCPUs(); } } diff --git a/src/ui/interactivesimulation/TaskVariableTableModel.java b/src/ui/interactivesimulation/TaskVariableTableModel.java index dd840432f2e7182689587b8e9f543ab255f873d1..c55920f9455ba029ec780dbc4c2c5d0d6da95c6c 100755 --- a/src/ui/interactivesimulation/TaskVariableTableModel.java +++ b/src/ui/interactivesimulation/TaskVariableTableModel.java @@ -54,17 +54,16 @@ import tmltranslator.*; public class TaskVariableTableModel extends AbstractTableModel { private TMLModeling tmlm; - private Hashtable<String, String> table; + private Hashtable <Integer, String> valueTable; + private Hashtable <Integer, Integer> rowTable; private int nbOfRows; //private String [] names; - public TaskVariableTableModel(TMLModeling _tmlm, Hashtable<String, String> _table) { + public TaskVariableTableModel(TMLModeling _tmlm, Hashtable<Integer, String> _valueTable, Hashtable <Integer, Integer> _rowTable) { tmlm = _tmlm; - table = _table; - if (tmlm == null) { - System.out.println("No data"); - } + valueTable = _valueTable; + rowTable = _rowTable; computeData(); } @@ -89,7 +88,7 @@ public class TaskVariableTableModel extends AbstractTableModel { } else if (column == 2) { return getVariableName(row); } else if (column == 3) { - return getVariableID(row); + return getStringVariableID(row); } else if (column == 4) { return getVariableValue(row); } @@ -152,18 +151,26 @@ public class TaskVariableTableModel extends AbstractTableModel { return "unknown name"; } - private String getVariableID(int row) { + private String getStringVariableID(int row) { + int id = getVariableID(row); + if (id < 0) { + return "unknown id"; + } + return "" + id; + } + + private int getVariableID(int row) { int cpt = 0; int size; for(TMLTask task: tmlm.getTasks()) { size = task.getAttributes().size(); cpt += size; if (row < cpt) { - return "" + task.getAttributes().get(row+size-cpt).getID(); + return task.getAttributes().get(row+size-cpt).getID(); } } - return "unknown ID"; + return 0; } private String getVariableInitialValue(int row) { @@ -181,15 +188,16 @@ public class TaskVariableTableModel extends AbstractTableModel { } private String getVariableValue(int row) { - String ID = getVariableID(row); - String s = table.get(ID); + int ID = getVariableID(row); + String s = valueTable.get(ID); if (s != null) { - return s; + return s.toString(); } // Must set the ID; String val = getVariableInitialValue(row); - table.put(ID, val); + valueTable.put(ID, val); + rowTable.put(ID, row); return val; } diff --git a/src/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java b/src/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java index 4561919621dce4b7963b746f99a2b271d9d0e20d..a9d9057d7e601e23dc7cd93caae87b0c87172a91 100755 --- a/src/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java +++ b/src/ui/tmlcompd/TMLComponentTaskDiagramToolBar.java @@ -70,7 +70,7 @@ public class TMLComponentTaskDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.TMLCTD_PCOMPONENT].setEnabled(b); mgui.actions[TGUIAction.TMLCTD_COPORT].setEnabled(b); mgui.actions[TGUIAction.TMLCTD_PORT_CONNECTOR].setEnabled(b); - mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); + //mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); mgui.updateZoomInfo(); @@ -124,10 +124,10 @@ public class TMLComponentTaskDiagramToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.TMLCTD_CREMOTECOMPONENT]); button.addMouseListener(mgui.mouseHandler); - this.addSeparator(); + /*this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]); - button.addMouseListener(mgui.mouseHandler); + button.addMouseListener(mgui.mouseHandler);*/ }