diff --git a/src/remotesimulation/CommandParser.java b/src/remotesimulation/CommandParser.java index e0264e448b0fc494392b45a0755598475699d997..d2ed7d7137dcbd95f363805b83ba61ae8eb76f5c 100755 --- a/src/remotesimulation/CommandParser.java +++ b/src/remotesimulation/CommandParser.java @@ -244,9 +244,9 @@ public class CommandParser { // get-variable-of-task params = new int[2]; paramNames = new String[2]; - params[0] = 1; + params[0] = 0; paramNames[0] = "Task id"; - params[1] = 1; + params[1] = 0; paramNames[1] = "Variable id"; sc = new SimulationCommand("get-variable-of-task", "gvof", "3", params, paramNames, "Returns the value of a variable a a task"); commandList.add(sc); diff --git a/src/tmltranslator/DIPLOElement.java b/src/tmltranslator/DIPLOElement.java index 711874f12727a3935ee07c65b86ee82b66bf9966..06b5906eca0092daf02e8cf4a57d47e9c0e5b1b9 100755 --- a/src/tmltranslator/DIPLOElement.java +++ b/src/tmltranslator/DIPLOElement.java @@ -62,6 +62,7 @@ public class DIPLOElement { } public static void resetID() { + System.out.println("Reset DIPLOID"); ID = 0; } } \ No newline at end of file diff --git a/src/ui/CorrespondanceTGElement.java b/src/ui/CorrespondanceTGElement.java index 122ddf18c5249ef61bac781c94ec35780ada4318..c3a17e5349efcee80fea79f2770abd741646f531 100755 --- a/src/ui/CorrespondanceTGElement.java +++ b/src/ui/CorrespondanceTGElement.java @@ -410,7 +410,7 @@ public class CorrespondanceTGElement { o1 = tg.get(i); if ((o1 != null) && !(list.contains(o1))){ de = (DIPLOElement)(o0); - System.out.println("Putting DIPLO ID on " + o1 + ": " + de.getID()); + //System.out.println("Putting DIPLO ID on " + o1 + ": " + de.getID()); tgc = (TGComponent)(o1); tgc.setDIPLOID(de.getID()); list.add(tgc); diff --git a/src/ui/DesignPanelTranslator.java b/src/ui/DesignPanelTranslator.java index 115d77c80bf7287a024cb9df5de6ece8f3dffe65..63eb10a2b7b26240297727b8bb5d74fed76dfa13 100755 --- a/src/ui/DesignPanelTranslator.java +++ b/src/ui/DesignPanelTranslator.java @@ -710,12 +710,14 @@ public class DesignPanelTranslator { adtlo.setAction(s1); adtlo.setDelay(TURTLEModeling.manageGateDataStructures(t, ((TADTimeLimitedOffer)tgc).getDelay())); listE.addCor(adtlo, tgc); + ((TADTimeLimitedOffer)tgc).setStateAction(TADTimeLimitedOffer.GATE); } else { CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Time-limited offer (" + s + ", " + ((TADTimeLimitedOffer)tgc).getDelay() + "): \"" + s + "\" is not a correct expression"); ce.setTClass(t); ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + ((TADTimeLimitedOffer)tgc).setStateAction(TADTimeLimitedOffer.UNKNOWN); //System.out.println("Bad time limited offer found " + s); } } else if (tgc instanceof TADTimeLimitedOfferWithLatency) { @@ -733,12 +735,14 @@ public class DesignPanelTranslator { adtlo.setAction(s1); adtlo.setDelay(TURTLEModeling.manageGateDataStructures(t, ((TADTimeLimitedOfferWithLatency)tgc).getDelay())); listE.addCor(adtlo, tgc); + ((TADTimeLimitedOfferWithLatency)tgc).setStateAction(TADTimeLimitedOfferWithLatency.GATE); } else { CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Time-limited offer (" + s + ", " + ((TADTimeLimitedOfferWithLatency)tgc).getLatency() + ", " + ((TADTimeLimitedOfferWithLatency)tgc).getDelay() + "): \"" + s + "\" is not a correct expression"); ce.setTClass(t); ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + ((TADTimeLimitedOfferWithLatency)tgc).setStateAction(TADTimeLimitedOfferWithLatency.UNKNOWN); //System.out.println("Bad time limited offer found " + s); } diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index 3a01ab434dd77fbbb7e5c038988776b13fa7de0d..fd6f07d96da9c657ab1d6f364538032fc87f58e7 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -96,12 +96,12 @@ public class GTMLModeling { } } - public TMLModeling translateToTMLModeling() { - return translateToTMLModeling(false); + public TMLModeling translateToTMLModeling(boolean _resetID) { + return translateToTMLModeling(false, _resetID); } - public TMLModeling translateToTMLModeling(boolean onlyTakenIntoAccount) { - tmlm = new TMLModeling(true); + public TMLModeling translateToTMLModeling(boolean onlyTakenIntoAccount, boolean _resetID) { + tmlm = new TMLModeling(_resetID); checkingErrors = new Vector(); warnings = new Vector(); @@ -1613,7 +1613,7 @@ public class GTMLModeling { gtml = new GTMLModeling(panel, false); gtml.setTasks((Vector)(taskss.get(index))); index ++; - tmpm = gtml.translateToTMLModeling(); + tmpm = gtml.translateToTMLModeling(false); warnings.addAll(gtml.getCheckingWarnings()); if (gtml.getCheckingErrors().size() >0) { checkingErrors.addAll(gtml.getCheckingErrors()); @@ -1630,7 +1630,7 @@ public class GTMLModeling { TMLComponentDesignPanel panel = cpanels.get(cpanels.size()-1); gtml = new GTMLModeling(panel, false); gtml.setComponents(allcomp); - tmpm = gtml.translateToTMLModeling(true); + tmpm = gtml.translateToTMLModeling(true, false); warnings.addAll(gtml.getCheckingWarnings()); if (gtml.getCheckingErrors().size() >0) { checkingErrors.addAll(gtml.getCheckingErrors()); diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index b31e0090f22fac10dec3c9326a315bbbfd088815..1530638cb6ec439e394cbeadd7f4ba3bc7c47fda 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -4404,7 +4404,7 @@ public class GTURTLEModeling { //System.out.println("New TML Modeling"); GTMLModeling gtmlm = new GTMLModeling(tmldp, true); gtmlm.setTasks(tasksToTakeIntoAccount); - tmlm = gtmlm.translateToTMLModeling(); + tmlm = gtmlm.translateToTMLModeling(true); artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gtmlm.getCorrespondanceTable(); @@ -4473,7 +4473,7 @@ public class GTURTLEModeling { //System.out.println("New TML Component Modeling"); GTMLModeling gctmlm = new GTMLModeling(tmlcdp, true); gctmlm.setComponents(componentsToTakeIntoAccount); - tmlm = gctmlm.translateToTMLModeling(); + tmlm = gctmlm.translateToTMLModeling(true); artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gctmlm.getCorrespondanceTable(); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 1119a0e8af8974048c67cc4f4b339812b47f7749..ff370dbb43a18a13abacd6219d5d60ad3c4f2416 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -2845,7 +2845,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } jfis.setIconImage(IconManager.img9); - jfis.setSize(1024, 800); + jfis.setSize(1024, 900); GraphicLib.centerOnParent(jfis); jfis.setVisible(true); @@ -2883,13 +2883,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { ArrayList<Point> points = new ArrayList<Point>(); TURTLEPanel tp; - for(int i=0; i<tabs.size(); i++) { - tp = (TURTLEPanel)(tabs.elementAt(i)); - if (tp instanceof TMLDesignPanel) { - ((TMLDesignPanel)tp).getListOfBreakPoints(points); - } - if (tp instanceof TMLComponentDesignPanel) { - ((TMLComponentDesignPanel)tp).getListOfBreakPoints(points); + if (tabs != null) { + for(int i=0; i<tabs.size(); i++) { + tp = (TURTLEPanel)(tabs.elementAt(i)); + if (tp instanceof TMLDesignPanel) { + ((TMLDesignPanel)tp).getListOfBreakPoints(points); + } + if (tp instanceof TMLComponentDesignPanel) { + ((TMLComponentDesignPanel)tp).getListOfBreakPoints(points); + } } } return points; @@ -3702,13 +3704,13 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public TMLActivityDiagramPanel getReferencedTMLActivityDiagramPanel(String name) { TURTLEPanel tp; TMLActivityDiagramPanel tmladp; - System.out.println("global search for: " + name); + //System.out.println("global search for: " + name); for(int i=0; i<tabs.size(); i++) { tp = (TURTLEPanel)(tabs.elementAt(i)); if (tp instanceof TMLComponentDesignPanel) { tmladp = ((TMLComponentDesignPanel)tp).getTMLActivityDiagramPanel(name); if (tmladp != null) { - System.out.println("Found"); + //System.out.println("Found"); return tmladp; } } @@ -3718,6 +3720,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return null; } + + public LinkedList getAllTMLComponents() { TURTLEPanel tp; LinkedList ll = new LinkedList(); diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index 34ce51d1d5ed7805f05df6c8495ae913a7f6a532..fef6003936a5299cded205267377305f02ffae84 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -3132,12 +3132,23 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { Point p; TGComponent tgc; Iterator iterator = componentList.listIterator(); + int i; + boolean found; while(iterator.hasNext()) { tgc = (TGComponent)(iterator.next()); if (tgc.getBreakpoint() && (tgc.getDIPLOID() != -1)) { - p = new Point(taskID, tgc.getDIPLOID()); - points.add(p); + found = false; + for(i=0; i<points.size(); i++) { + if (points.get(i).y == tgc.getDIPLOID()) { + found = true; + break; + } + } + if (!found) { + p = new Point(taskID, tgc.getDIPLOID()); + points.add(p); + } } } diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index f20567c06cb1cbc7cd05ba3a019fc1021a54ac32..3640746dfc776c819136ca5ea55259d756ff399f 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -427,8 +427,10 @@ public abstract class TGComponent implements CDElement, GenericTree { } public void drawDiploID(Graphics g) { - g.setColor(ColorManager.DIPLOID); - g.drawString(""+getDIPLOID(), x+width, y+height + 5); + if (getDIPLOID() != -1) { + g.setColor(ColorManager.DIPLOID); + g.drawString(""+getDIPLOID(), x+width, y+height + 5); + } } public void drawRunningDiploID(Graphics g) { diff --git a/src/ui/TMLComponentDesignPanel.java b/src/ui/TMLComponentDesignPanel.java index 96d5ed3cff32893b819ac77995e3dc51de7eb69f..5c427b07285135e06b15cff09986b539cb7a5ed6 100755 --- a/src/ui/TMLComponentDesignPanel.java +++ b/src/ui/TMLComponentDesignPanel.java @@ -71,27 +71,27 @@ public class TMLComponentDesignPanel extends TURTLEPanel { tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); } - public TMLActivityDiagramPanel getTMLActivityDiagramPanel(String name) { + public TMLActivityDiagramPanel getTMLActivityDiagramPanel(String _name) { TMLActivityDiagramPanel tmladp; for(int i=1; i<panels.size(); i++) { tmladp = (TMLActivityDiagramPanel)(panels.elementAt(i)); - if (tmladp.getName().compareTo(name) ==0) { + if (tmladp.getName().compareTo(_name) ==0) { return tmladp; } } return null; } - public TMLActivityDiagramPanel getReferencedTMLActivityDiagramPanel(String name) { - System.out.println("Searching for activity diagram of:" + name); - TMLActivityDiagramPanel tmladp = getTMLActivityDiagramPanel(name); + public TMLActivityDiagramPanel getReferencedTMLActivityDiagramPanel(String _name) { + //System.out.println("Searching for activity diagram of:" + _name); + TMLActivityDiagramPanel tmladp = getTMLActivityDiagramPanel(_name); if (tmladp != null) { - System.out.println("Locally found"); + //System.out.println("Locally found"); return tmladp; } // Search on other tabs - return mgui.getReferencedTMLActivityDiagramPanel(name); + return mgui.getReferencedTMLActivityDiagramPanel(_name); } public void addTMLActivityDiagram(String s) { @@ -180,8 +180,13 @@ public class TMLComponentDesignPanel extends TURTLEPanel { if (tgc instanceof TMLCPrimitiveComponent) { tmlcpc = (TMLCPrimitiveComponent)tgc; if (tmlcpc.getDIPLOID() != -1) { - tmladp = getTMLActivityDiagramPanel(tmlcpc.getValue()); - tmladp.getListOfBreakPoints(points, tmlcpc.getDIPLOID()); + //System.out.println("Searching for ad of name: " + tmlcpc.getValue()); + tmladp = mgui.getReferencedTMLActivityDiagramPanel(tmlcpc.getValue()); + if (tmladp != null) { + tmladp.getListOfBreakPoints(points, tmlcpc.getDIPLOID()); + } else { + System.out.println("Unknown panel:" + tmlcpc.getValue()); + } } } } diff --git a/src/ui/ad/TADTimeLimitedOffer.java b/src/ui/ad/TADTimeLimitedOffer.java index f4b605a16bd5a861caa4b3f8a7577b3da66c7f01..147f903c15eff19fc366b14267c8456317c30d23 100755 --- a/src/ui/ad/TADTimeLimitedOffer.java +++ b/src/ui/ad/TADTimeLimitedOffer.java @@ -63,6 +63,10 @@ public class TADTimeLimitedOffer extends TGCWithInternalComponent { protected int distanceStateLine = 20; protected int distanceTwoLines = 15; protected int arrowLength = 10; + + protected int stateAction = 0; // 0: unchecked 1: attribute; 2: gate; 3:unknown + public static final int GATE = 1; + public static final int UNKNOWN = 2; public TADTimeLimitedOffer(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -107,6 +111,20 @@ public class TADTimeLimitedOffer extends TGCWithInternalComponent { //updateConnectingPoints(); updateInternalComponents(width - w2, x - x1); } + + if (stateAction > 0) { + Color c = g.getColor(); + switch(stateAction) { + case 1: + g.setColor(ColorManager.GATE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRoundRect(x, y, width, height, arc, arc); + g.setColor(c); + } + // action state g.drawRoundRect(x, y, width, height, arc, arc); g.drawString(value, x + (width - w) / 2 , y + textY); @@ -197,6 +215,10 @@ public class TADTimeLimitedOffer extends TGCWithInternalComponent { public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + + public void setStateAction(int _stateAction) { + stateAction = _stateAction; + } } diff --git a/src/ui/ad/TADTimeLimitedOfferWithLatency.java b/src/ui/ad/TADTimeLimitedOfferWithLatency.java index 1188fd25e9196644e78cf137dd8cfb62d95b3f02..55184b137d673b47aa487a2769dec00b7f06528d 100755 --- a/src/ui/ad/TADTimeLimitedOfferWithLatency.java +++ b/src/ui/ad/TADTimeLimitedOfferWithLatency.java @@ -70,6 +70,10 @@ public class TADTimeLimitedOfferWithLatency extends TGCWithInternalComponent { protected int arrowLength = 10; private int incrementY = 4; private int segment = 4; + + protected int stateAction = 0; // 0: unchecked 1: attribute; 2: gate; 3:unknown + public static final int GATE = 1; + public static final int UNKNOWN = 2; //private boolean first; @@ -126,6 +130,19 @@ public class TADTimeLimitedOfferWithLatency extends TGCWithInternalComponent { //updateConnectingPoints(); updateInternalComponents(width - w2, x - x1); } + + if (stateAction > 0) { + Color c = g.getColor(); + switch(stateAction) { + case 1: + g.setColor(ColorManager.GATE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRoundRect(x, y, width, height, arc, arc); + g.setColor(c); + } // action state g.drawRoundRect(x, y, width, height, arc, arc); g.drawString(value, x + (width - w) / 2 , y + textY); @@ -253,5 +270,9 @@ public class TADTimeLimitedOfferWithLatency extends TGCWithInternalComponent { public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + + public void setStateAction(int _stateAction) { + stateAction = _stateAction; + } } diff --git a/src/ui/interactivesimulation/CPUTableModel.java b/src/ui/interactivesimulation/CPUTableModel.java index 802c5ad564b79eae796229211921f7380b016522..6789afcacb338db609d3b141ce40eb75b03e3cac 100755 --- a/src/ui/interactivesimulation/CPUTableModel.java +++ b/src/ui/interactivesimulation/CPUTableModel.java @@ -115,7 +115,7 @@ public class CPUTableModel extends AbstractTableModel { valueTable.put(ID, "-"); - rowTable.put(ID, row); + rowTable.put(ID, new Integer(row)); return "-"; } diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index f0a944971562ebdd508730018b49ed00ff76a218..61949dae23a6af6a9b70eb648727601a18e94b04 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -74,6 +74,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene protected static final String SIMULATION_HEADER = "siminfo"; protected static final String SIMULATION_GLOBAL = "global"; protected static final String SIMULATION_TASK = "task"; + protected static final String SIMULATION_CPU = "cpu"; + protected static final String SIMULATION_BUS = "bus"; private static String buttonStartS = "Start simulator"; private static String buttonCloseS = "Close"; @@ -115,7 +117,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene protected StateCommandsToolBar stctb; JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel; // from MGUI - JCheckBox debug, animate; + JCheckBox debug, animate, update; JTabbedPane commandTab, infoTab; protected JTextField paramMainCommand; protected JTextField saveFileName; @@ -439,7 +441,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //Info - infos = new JPanel(); + infos = new JPanel(new BorderLayout()); infos.setMinimumSize(new Dimension(300, 250)); //infos.setPreferredSize(new Dimension(400, 450)); infos.setBorder(new javax.swing.border.TitledBorder("Simulation information")); @@ -448,9 +450,22 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene infoTab = new JTabbedPane(); infoTab.setMinimumSize(new Dimension(300, 250)); - infos.add(infoTab); + infos.add(infoTab, BorderLayout.NORTH); // Simulation time + jp02 = new JPanel(); + infos.add(jp02, BorderLayout.SOUTH); + jp02.add(new JLabel("Status:")); + status = new JLabel("Unknown"); + status.setForeground(ColorManager.InteractiveSimulationText); + jp02.add(status); + jp02.add(new JLabel(" ")); + jp02.add(new JLabel("Time:")); + time = new JLabel("Unknown"); + time.setForeground(ColorManager.InteractiveSimulationText); + jp02.add(time); + + // Options jp01 = new JPanel(); //jp01.setMinimumSize(new Dimension(375, 400)); //jp01.setPreferredSize(new Dimension(375, 400)); @@ -461,7 +476,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // INFORMATION - infoTab.addTab("Status", null, jp01, "Current status of the simulation"); + infoTab.addTab("Options", null, jp01, "Options on simulation"); c01.gridheight = 1; c01.weighty = 1.0; @@ -469,22 +484,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene c01.gridwidth = GridBagConstraints.REMAINDER; //end row c01.fill = GridBagConstraints.BOTH; c01.gridheight = 1; - - jp01.add(new JLabel(" "), c01); - - c01.gridwidth = 1; - jp01.add(new JLabel("Status:"), c01); - c01.gridwidth = GridBagConstraints.REMAINDER; //end row - status = new JLabel("Unknown"); - status.setForeground(ColorManager.InteractiveSimulationText); - jp01.add(status, c01); - jp01.add(new JLabel(" "), c01); - c01.gridwidth = 1; - jp01.add(new JLabel("Time:"), c01); - c01.gridwidth = GridBagConstraints.REMAINDER; //end row - time = new JLabel("Unknown"); - time.setForeground(ColorManager.InteractiveSimulationText); - jp01.add(time, c01); + jp01.add(new JLabel(" "), c01); debug = new JCheckBox("Print messages received from server"); jp01.add(debug, c01); @@ -492,6 +492,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene jp01.add(animate, c01); animate.addItemListener(this); animate.setSelected(true); + update = new JCheckBox("Automatically update information (task, CPU, etc.)"); + jp01.add(update, c01); + update.addItemListener(this); + update.setSelected(true); TableSorter sorterPI; @@ -505,7 +509,6 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene taskPanel = new JPanel(); taskPanel.setLayout(new BorderLayout()); infoTab.addTab("Tasks", IconManager.imgic1202, taskPanel, "Current state of tasks"); - TaskTableModel tasktm; if (tmap == null) { tasktm = new TaskTableModel(null, valueTable, rowTable); } else { @@ -531,7 +534,6 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene 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, valueTable, rowTable); } else { @@ -558,7 +560,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene cpuPanel = new JPanel(); cpuPanel.setLayout(new BorderLayout()); infoTab.addTab("CPUs", IconManager.imgic1100, cpuPanel, "Current state of CPUs"); - CPUTableModel cputm = new CPUTableModel(tmap, valueTable, rowTable); + cputm = new CPUTableModel(tmap, valueTable, rowTable); sorterPI = new TableSorter(cputm); jtablePI = new JTable(sorterPI); sorterPI.setTableHeader(jtablePI.getTableHeader()); @@ -598,7 +600,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene busPanel = new JPanel(); busPanel.setLayout(new BorderLayout()); infoTab.addTab("Bus", IconManager.imgic1102, busPanel, "Current state of busses"); - BusTableModel bustm = new BusTableModel(tmap, valueTable, rowTable); + bustm = new BusTableModel(tmap, valueTable, rowTable); sorterPI = new TableSorter(bustm); jtablePI = new JTable(sorterPI); sorterPI.setTableHeader(jtablePI.getTableHeader()); @@ -996,9 +998,14 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene String error = null; String hash = null; - String id; + String id, idvar; String name; String command; + String util = null; + String value; + String extime; + + int k; try { for(int j=0; j<diagramNl.getLength(); j++) { @@ -1061,11 +1068,80 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } - System.out.println("Got info on task " + id + " command=" + command); + //System.out.println("Got info on task " + id + " command=" + command); if ((id != null) && (command != null)) { updateRunningCommand(id, command); } + + extime = null; + nl = elt.getElementsByTagName("extime"); + if (nl.getLength() > 0) { + node0 = nl.item(0); + //System.out.println("nl:" + nl + " value=" + node0.getNodeValue() + " content=" + node0.getTextContent()); + extime = node0.getTextContent(); + } + + if ((id != null) && (extime != null)) { + updateTaskState(id, extime); + } + + + + 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); + } + } + } + + if (elt.getTagName().compareTo(SIMULATION_CPU) == 0) { + id = null; + name = null; + command = null; + id = elt.getAttribute("id"); + name = elt.getAttribute("name"); + 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(); + } + + //System.out.println("Got info on cpu " + id + " util=" + util); + + if ((id != null) && (util != null)) { + updateCPUState(id, util); + } + } + + 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.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); + + if ((id != null) && (util != null)) { + updateBusState(id, util); + } } } } @@ -1259,6 +1335,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + + private void updateVariables() { if (tmap == null) { return; @@ -1268,11 +1346,13 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene return; } - for(TMLTask task: tmap.getTMLModeling().getTasks()) { + sendCommand("get-variable-of-task all all\n"); + + /*for(TMLTask task: tmap.getTMLModeling().getTasks()) { for(TMLAttribute tmla: task.getAttributes()) { sendCommand("get-variable-of-task " + task.getID() + " " + tmla.getID()); } - } + }*/ } private void updateCPUs() { @@ -1376,11 +1456,93 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } + 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 = rowTable.get(i).intValue(); + tvtm.fireTableCellUpdated(row, 4); + } catch (Exception e) { + System.out.println("Exception updateVariableState: " + e.getMessage() + "idvar=" + _idvar + " val=" + _value); + } + } + + } + + private void updateTaskState(String _id, String _extime) { + Integer i = getInteger(_id); + Integer ex = getInteger(_extime); + int row; + + if ((i != null) && (ex != null)) { + try { + valueTable.remove(i); + valueTable.put(i, "nbOfCycles: " + _extime); + //System.out.println("Searching for old row"); + row = rowTable.get(i).intValue(); + tasktm.fireTableCellUpdated(row, 2); + } catch (Exception e) { + System.out.println("Exception updateTaskState: " + e.getMessage()); + } + } + + } + + private void updateCPUState(String _id, String _utilization) { + Integer i = getInteger(_id); + int row; + + if (i != null) { + try { + System.out.println("CPU 0"); + valueTable.remove(i); + System.out.println("CPU 1"); + valueTable.put(i, "Utilization: " + _utilization); + System.out.println("CPU 2"); + //System.out.println("Searching for old row"); + row = rowTable.get(i).intValue(); + System.out.println("CPU 3"); + cputm.fireTableCellUpdated(row, 2); + System.out.println("CPU 4"); + } catch (Exception e) { + System.out.println("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); + //System.out.println("Searching for old row"); + row = rowTable.get(i).intValue(); + bustm.fireTableCellUpdated(row, 2); + } catch (Exception e) { + System.out.println("Exception updateBusState: " + e.getMessage()); + } + } + } + public void askForUpdate() { sendCommand("time"); if (animate.isSelected()) { updateTaskCommands(); } + if (update.isSelected()) { + updateTasks(); + updateVariables(); + updateCPUs(); + updateBus(); + } } public void itemStateChanged(ItemEvent e) {