From 68732248391fd7d1caef1988df53cac5ed5a88cc Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Fri, 29 May 2009 13:46:40 +0000 Subject: [PATCH] Hashcode on TMLModeling and task variables vizualization on interactive simulation --- src/remotesimulation/CommandParser.java | 10 + src/tmltranslator/TMLMapping.java | 2 +- .../TMLMappingTextSpecification.java | 2 - src/tmltranslator/TMLModeling.java | 23 ++ src/ui/GTURTLEModeling.java | 7 + src/ui/IconManager.java | 4 +- src/ui/MainGUI.java | 137 ++++++----- .../InteractiveSimulationActions.java | 6 +- .../JFrameInteractiveSimulation.java | 84 +++++-- .../TaskVariableTableModel.java | 212 ++++++++++++++++++ src/ui/window/JDialogSystemCGeneration.java | 14 +- 11 files changed, 419 insertions(+), 82 deletions(-) create mode 100755 src/ui/interactivesimulation/TaskVariableTableModel.java diff --git a/src/remotesimulation/CommandParser.java b/src/remotesimulation/CommandParser.java index 52defb2909..80207dc48f 100755 --- a/src/remotesimulation/CommandParser.java +++ b/src/remotesimulation/CommandParser.java @@ -208,6 +208,16 @@ public class CommandParser { 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 + 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"); + commandList.add(sc); + // kill params = new int[0]; paramNames = new String[0]; diff --git a/src/tmltranslator/TMLMapping.java b/src/tmltranslator/TMLMapping.java index 34341c018f..5c61639238 100755 --- a/src/tmltranslator/TMLMapping.java +++ b/src/tmltranslator/TMLMapping.java @@ -95,7 +95,7 @@ public class TMLMapping { private void computeHashCode() { hashCode = tmlm.getHashCode() + tmla.getHashCode(); TMLMappingTextSpecification tmaptxt = new TMLMappingTextSpecification("spec.tmap"); - hashCode += tmaptxt.toString().hashCode(); + hashCode += tmaptxt.toTextFormat(this).hashCode(); System.out.println("TMAP hashcode = " + hashCode); } diff --git a/src/tmltranslator/TMLMappingTextSpecification.java b/src/tmltranslator/TMLMappingTextSpecification.java index 4cccf447ea..c01358717f 100755 --- a/src/tmltranslator/TMLMappingTextSpecification.java +++ b/src/tmltranslator/TMLMappingTextSpecification.java @@ -72,8 +72,6 @@ public class TMLMappingTextSpecification { private String taskparameters[] = {"PRIORITY"}; - private int hashCode; - public TMLMappingTextSpecification(String _title) { title = _title; diff --git a/src/tmltranslator/TMLModeling.java b/src/tmltranslator/TMLModeling.java index d88bcb8d40..c9fa2da915 100755 --- a/src/tmltranslator/TMLModeling.java +++ b/src/tmltranslator/TMLModeling.java @@ -74,6 +74,29 @@ public class TMLModeling { DIPLOElement.resetID(); } } + + public TMLMapping getDefaultMapping() { + TMLMapping tmlmapping; + TMLArchitecture tmla = new TMLArchitecture(); + TMLTask t; + + HwCPU cpu = new HwCPU("cpu0"); + cpu.byteDataSize = 4; + cpu.pipelineSize = 1; + cpu.goIdleTime = 0; + cpu.taskSwitchingTime = 1; + cpu.branchingPredictionPenalty = 0; + cpu.execiTime = 1; + tmla.addHwNode(cpu); + tmlmapping = new TMLMapping(this, tmla); + ListIterator iterator = getTasks().listIterator(); + + while(iterator.hasNext()) { + t = (TMLTask)(iterator.next()); + tmlmapping.addTaskToHwExecutionNode(t, cpu); + } + return tmlmapping; + } private void init() { /*tasks = new LinkedList(); diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index 1da7c9d15d..5a230ac27c 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -110,6 +110,7 @@ public class GTURTLEModeling { private TURTLEModeling tm; private int tmState; // 0:generated, 1: to be generated from mapping private TMLModeling tmlm; + private TMLMapping artificialtmap; private TMLMapping tmap; private RequirementModeling rm; private NCStructure ncs; @@ -936,6 +937,10 @@ public class GTURTLEModeling { return tmlm; } + public TMLMapping getArtificialTMLMapping() { + return artificialtmap; + } + public TMLMapping getTMLMapping() { return tmap; } @@ -4393,6 +4398,7 @@ public class GTURTLEModeling { GTMLModeling gtmlm = new GTMLModeling(tmldp); gtmlm.setTasks(tasksToTakeIntoAccount); tmlm = gtmlm.translateToTMLModeling(); + artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gtmlm.getCorrespondanceTable(); //System.out.println("TML Modeling translated"); @@ -4457,6 +4463,7 @@ public class GTURTLEModeling { GTMLModeling gctmlm = new GTMLModeling(tmlcdp); gctmlm.setComponents(componentsToTakeIntoAccount); tmlm = gctmlm.translateToTMLModeling(); + artificialtmap = tmlm.getDefaultMapping(); tmap = null; listE = gctmlm.getCorrespondanceTable(); //System.out.println("TML Modeling translated"); diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index a82621c6db..9350c69829 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -72,7 +72,7 @@ public class IconManager { public static ImageIcon imgic40, imgic41, imgic42, imgic43, imgic44, imgic45, imgic46, imgic47, imgic48, imgic49; public static ImageIcon imgic50, imgic51, imgic52, imgic53, imgic54, imgic55, imgic56, imgic57, imgic58, imgic59; public static ImageIcon imgic60, imgic61, imgic62, imgic63, imgic64, imgic65, imgic66; - public static ImageIcon imgic70, imgic71, imgic72, imgic73; + public static ImageIcon imgic70, imgic71, imgic72, imgic73, imgic75; // Class diagram public static ImageIcon imgic100, imgic101, imgic102, imgic104, imgic106, imgic108; @@ -212,6 +212,7 @@ public class IconManager { private static String icon71 = "images/toolbarButtonGraphics/general/SendMail24.gif"; private static String icon72 = "images/toolbarButtonGraphics/general/Help16.gif"; private static String icon73 = "images/toolbarButtonGraphics/general/Help24.gif"; + private static String icon75 = "images/toolbarButtonGraphics/general/Refresh24.gif"; private static String icon100 = "images/toolbarButtonGraphics/general/Properties16.gif"; @@ -538,6 +539,7 @@ public class IconManager { imgic71 = getIcon(icon71); imgic72 = getIcon(icon72); imgic73 = getIcon(icon73); + imgic75 = getIcon(icon75); imgic100 = getIcon(icon100); imgic101 = getIcon(icon101); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index f7aab3ef57..a3f00bcf42 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -1020,7 +1020,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return index; } - public int createNC(String name) { + public int createNC(String name) { int index = addNCDesignPanel(name, -1); mainTabbedPane.setSelectedIndex(index); return index; @@ -1070,7 +1070,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { UIManager.put("TabbedPane.focus", Color.green);*/ SwingUtilities.updateComponentTreeUI(mainTabbedPane); mainTabbedPane.setOpaque(true); - + ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent e){ @@ -1661,7 +1661,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } dtree.forceUpdate(); } - + } @@ -1842,7 +1842,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (s == null) { throw new Exception("TIF specification is void"); - + } FileOutputStream fos = new FileOutputStream(file); fos.write(s.getBytes()); @@ -1856,8 +1856,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } return false; } - - public boolean openTIF() { + + public boolean openTIF() { //jfc.setApproveButtonText("Open"); int returnVal = jfctif.showOpenDialog(frame); @@ -1883,13 +1883,13 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (s == null) { return false; } - System.out.println("Open TIF =" + s); - if (gtm == null) { - newTurtleModeling(); - } - return gtm.openTIF(s); - - } + System.out.println("Open TIF =" + s); + if (gtm == null) { + newTurtleModeling(); + } + return gtm.openTIF(s); + + } public boolean saveProject() { if (file == null) { @@ -2019,7 +2019,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { saveRGAUT(gtm.getLastTextualRGAUTProj(), gtm.getLastGraphicalRGAUTProj()); } - public void saveLastModifiedRG() { + public void saveLastModifiedRG() { saveRGAUT(modifiedaut, modifiedautdot); } @@ -2263,10 +2263,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { boolean ret = false; if (file == null) { - JOptionPane.showMessageDialog(frame, - "The project must be saved before any simulation or formal verification can be performed", - "Syntax analysis failed", - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(frame, + "The project must be saved before any simulation or formal verification can be performed", + "Syntax analysis failed", + JOptionPane.INFORMATION_MESSAGE); return false; } @@ -2357,7 +2357,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { JOptionPane.INFORMATION_MESSAGE); } } - + // NC } else if (tp instanceof NCPanel) { NCPanel ncp = (NCPanel) tp; @@ -2813,18 +2813,35 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { dtree.toBeUpdated(); if (jgen.isInteractiveSimulationSelected()) { - JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, jgen.getPathInteractiveExecute()); - jfis.setIconImage(IconManager.img9); - jfis.setSize(800, 700); - GraphicLib.centerOnParent(jfis); - jfis.setVisible(true); + interactiveSimulationSystemC(jgen.getPathInteractiveExecute()); } } public void interactiveSimulationSystemC() { - JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand); + interactiveSimulationSystemC(ConfigurationTTool.SystemCCodeInteractiveExecuteCommand); + } + + public void interactiveSimulationSystemC(String executePath) { + JFrameInteractiveSimulation jfis; + //System.out.println("toto0"); + if (gtm == null) { + jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, null); + } else { + //System.out.println("toto1"); + if (gtm.getTMLMapping() != null) { + jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, gtm.getTMLMapping()); + } else { + //System.out.println("toto2"); + if (gtm.getArtificialTMLMapping() != null) { + jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, gtm.getArtificialTMLMapping()); + } else { + //System.out.println("toto3"); + jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, null); + } + } + } jfis.setIconImage(IconManager.img9); - jfis.setSize(800, 700); + jfis.setSize(1024, 800); GraphicLib.centerOnParent(jfis); jfis.setVisible(true); } @@ -2834,9 +2851,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (file != null) { path = file.getAbsolutePath(); } - //System.out.println("Generating TML code: "+file.getAbsolutePath()); - gtm.generateTMLTxt(path); - //System.out.println("Done"); + //System.out.println("Generating TML code: "+file.getAbsolutePath()); + gtm.generateTMLTxt(path); + //System.out.println("Done"); } public void generateDesign() { @@ -3046,20 +3063,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void modifyGraph() { JDialogGraphModification jdgm; if (gtm == null ){ - jdgm = new JDialogGraphModification(frame, - GTURTLEModeling.getHostAldebaran(), - GTURTLEModeling.getPathBcgio(), - "graph", - "Minimization using Aldebaran", - null, null); + jdgm = new JDialogGraphModification(frame, + GTURTLEModeling.getHostAldebaran(), + GTURTLEModeling.getPathBcgio(), + "graph", + "Minimization using Aldebaran", + null, null); } else { jdgm = new JDialogGraphModification(frame, - GTURTLEModeling.getHostAldebaran(), - gtm.getPathBcgio(), - "graph", - "Minimization using Aldebaran", - gtm.getLastRGAUT(), - gtm.getLastTextualRGAUTProj()); + GTURTLEModeling.getHostAldebaran(), + gtm.getPathBcgio(), + "graph", + "Minimization using Aldebaran", + gtm.getLastRGAUT(), + gtm.getLastTextualRGAUTProj()); } jdgm.setSize(600, 500); GraphicLib.centerOnParent(jdgm); @@ -3634,10 +3651,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } public TMLActivityDiagramPanel getReferencedTMLActivityDiagramPanel(String name) { - TURTLEPanel tp; - TMLActivityDiagramPanel tmladp; - System.out.println("global search for: " + name); - for(int i=0; i<tabs.size(); i++) { + TURTLEPanel tp; + TMLActivityDiagramPanel tmladp; + 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); @@ -3650,19 +3667,19 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { System.out.println("Not found"); return null; - } - - public LinkedList getAllTMLComponents() { - TURTLEPanel tp; - LinkedList ll = new LinkedList(); - for(int i=0; i<tabs.size(); i++) { + } + + public LinkedList getAllTMLComponents() { + TURTLEPanel tp; + LinkedList ll = new LinkedList(); + for(int i=0; i<tabs.size(); i++) { tp = (TURTLEPanel)(tabs.elementAt(i)); if (tp instanceof TMLComponentDesignPanel) { ll.addAll(((TMLComponentDesignPanel)tp).tmlctdp.getComponentList()); } - } - return ll; - } + } + return ll; + } public void removeTClass(TURTLEPanel tp, String s) { if (!(tp instanceof DesignPanel)) { @@ -3825,7 +3842,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (tp instanceof TMLDesignPanel) { return ((TMLDesignPanel)tp).getTMLActivityDiagramPanel(name); } - if (tp instanceof TMLComponentDesignPanel) { + if (tp instanceof TMLComponentDesignPanel) { return ((TMLComponentDesignPanel)tp).getTMLActivityDiagramPanel(name); } return null; @@ -4075,7 +4092,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { // ProactiveSMDPanel temp=((ProactiveDesignPanel)tp).getSMDPanel(s); //Added by Solange //And removed by Emil - + /* LinkedList cmps=gtm.gpdtemp.getProCSDComponentsList(); for (int i=0;i<cmps.size();i++) @@ -4707,7 +4724,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void renameMapping(String oldName, String newName) { TURTLEPanel tp; - for(int i = 0; i<mainTabbedPane.getTabCount(); i++) { + for(int i = 0; i<mainTabbedPane.getTabCount(); i++) { tp = (TURTLEPanel)(tabs.elementAt(i)); if (tp instanceof TMLArchiPanel) { ((TMLArchiPanel)tp).renameMapping(oldName, newName); @@ -4875,7 +4892,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } - public void toggleInternalComment() { + public void toggleInternalComment() { TDiagramPanel tdp = getCurrentTDiagramPanel(); if (tdp != null) { tdp.setInternalCommentVisible((tdp.getInternalCommentVisible() +1 )% 3); @@ -4885,7 +4902,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } - public void toggleAttr() { + public void toggleAttr() { TDiagramPanel tdp = getCurrentTDiagramPanel(); if (tdp != null){ System.out.println("Toggle attributes"); @@ -5599,7 +5616,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (systemcOn) { menu.addSeparator(); menu.add(newTMLDesign); - menu.add(newTMLComponentDesign); + menu.add(newTMLComponentDesign); menu.add(newTMLArchi); } diff --git a/src/ui/interactivesimulation/InteractiveSimulationActions.java b/src/ui/interactivesimulation/InteractiveSimulationActions.java index 611b77d342..20eba872dc 100755 --- a/src/ui/interactivesimulation/InteractiveSimulationActions.java +++ b/src/ui/interactivesimulation/InteractiveSimulationActions.java @@ -75,8 +75,10 @@ public class InteractiveSimulationActions extends AbstractAction { public static final int ACT_START_ALL = 3; public static final int ACT_STOP_ALL = 4; public static final int ACT_STOP_AND_CLOSE_ALL = 5; + + public static final int ACT_UPDATE_VARIABLES = 15; - public static final int NB_ACTION = 15; + public static final int NB_ACTION = 16; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -135,6 +137,8 @@ public class InteractiveSimulationActions extends AbstractAction { actions[ACT_STOP_ALL] = new TAction("stop-all", "Quit simulation window", IconManager.imgic27, IconManager.imgic27, "Quit simulation window", "Quit the simulation window without terminating the simulation", 'Q'); 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'); + } diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 6c1b53aa40..30dc293c25 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -59,6 +59,8 @@ import myutil.*; import ui.*; import ui.file.*; +import tmltranslator.*; + import launcher.*; import remotesimulation.*; @@ -121,6 +123,11 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Status elements JLabel status, time; + // Task elements + JButton updateTaskVariableInformationButton; + private JScrollPane jspTaskVariableInfo; + + private int mode = 0; private boolean busyStatus = false; private boolean threadStarted = false; @@ -131,8 +138,12 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public MouseHandler mouseHandler; public KeyListener keyHandler; + private TMLMapping tmap; + int hashCode; - public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute) { + private Hashtable <String, String> mainTable; + + public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute, TMLMapping _tmap) { super(_title); f = _f; @@ -143,10 +154,16 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene mode = NOT_STARTED; + tmap = _tmap; + if (tmap != null) { + hashCode = tmap.getHashCode(); + } + //System.out.println("Tmap=" + tmap); - setBackground(new Color(50, 40, 40, 200)); + mainTable = new Hashtable<String, String>(); + setBackground(new Color(50, 40, 40, 200)); initActions(); makeComponents(); @@ -398,6 +415,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene c01 = new GridBagConstraints(); jp01.setLayout(gridbag01); + + // INFORMATION + infoTab.addTab("Status", null, jp01, "Current status of the simulation"); c01.gridheight = 1; @@ -426,6 +446,36 @@ 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"); + + + TaskVariableTableModel tvtm; + if (tmap == null) { + tvtm = new TaskVariableTableModel(null, mainTable); + } else { + tvtm = new TaskVariableTableModel(tmap.getTMLModeling(), mainTable); + } + TableSorter sorterPI = new TableSorter(tvtm); + JTable 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.getColumnModel()).getColumn(3)).setPreferredWidth(75); + ((jtablePI.getColumnModel()).getColumn(3)).setPreferredWidth(100); + jtablePI.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jspTaskVariableInfo = new JScrollPane(jtablePI); + jspTaskVariableInfo.setWheelScrollingEnabled(true); + jspTaskVariableInfo.getVerticalScrollBar().setUnitIncrement(10); + jspTaskVariableInfo.setPreferredSize(new Dimension(500, 300)); + + jp01.add(jspTaskVariableInfo, BorderLayout.NORTH); + + updateTaskVariableInformationButton = new JButton(actions[InteractiveSimulationActions.ACT_UPDATE_VARIABLES]); + jp01.add(updateTaskVariableInformationButton, BorderLayout.SOUTH); pack(); } @@ -736,7 +786,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } protected boolean loadXMLInfoFromServer(String xmldata) { - //jta.append("XML from server:" + xmldata + "\n\n"); + jta.append("XML from server:" + xmldata + "\n\n"); DocumentBuilderFactory dbf; DocumentBuilder db; @@ -886,25 +936,15 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } public void makeStatus(String s) { + System.out.println("busystatus=" + busyStatus); status.setText(s); if (s.equals("busy")) { setBusyStatus(true); - /*actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(false); - actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(false); - actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(true);*/ - /*runCommand.setEnabled(false); - resetCommand.setEnabled(false); - StopCommand.setEnabled(true);*/ busyStatus = true; } if (s.equals("ready")) { - /*runCommand.setEnabled(true); - resetCommand.setEnabled(true); - StopCommand.setEnabled(false);*/ - /*actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(true); - actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(true); - actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(false);*/ if (busyStatus) { + System.out.println("Sending time command"); sendCommand("time"); } setBusyStatus(false); @@ -1023,6 +1063,18 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene } } + private void updateVariables() { + if (tmap == null) { + return; + } + + for(TMLTask task: tmap.getTMLModeling().getTasks()) { + for(TMLAttribute tmla: task.getAttributes()) { + sendCommand("get-variable-of-task " + task.getID() + " " + tmla.getID()); + } + } + } + public void actionPerformed(ActionEvent evt) { @@ -1064,6 +1116,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene sendCommand("reset"); } else if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_SIMU].getActionCommand())) { sendCommand("stop"); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_UPDATE_VARIABLES].getActionCommand())) { + updateVariables(); } } diff --git a/src/ui/interactivesimulation/TaskVariableTableModel.java b/src/ui/interactivesimulation/TaskVariableTableModel.java new file mode 100755 index 0000000000..dd840432f2 --- /dev/null +++ b/src/ui/interactivesimulation/TaskVariableTableModel.java @@ -0,0 +1,212 @@ +/**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 TaskVariableTableModel + * Variables of TML tasks + * Creation: 29/05/2009 + * @version 1.0 29/05/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.interactivesimulation; + +import java.util.*; +import javax.swing.table.*; + +import myutil.*; +import tmltranslator.*; + +public class TaskVariableTableModel extends AbstractTableModel { + private TMLModeling tmlm; + private Hashtable<String, String> table; + + private int nbOfRows; + + //private String [] names; + public TaskVariableTableModel(TMLModeling _tmlm, Hashtable<String, String> _table) { + tmlm = _tmlm; + table = _table; + if (tmlm == null) { + System.out.println("No data"); + } + computeData(); + } + + // From AbstractTableModel + public int getRowCount() { + return nbOfRows; + } + + public int getColumnCount() { + return 5; + } + + public Object getValueAt(int row, int column) { + if (tmlm == null) { + return "-"; + } + + if (column == 0) { + return getTaskName(row); + } else if (column == 1) { + return getTaskID(row); + } else if (column == 2) { + return getVariableName(row); + } else if (column == 3) { + return getVariableID(row); + } else if (column == 4) { + return getVariableValue(row); + } + return ""; + } + + public String getColumnName(int columnIndex) { + switch(columnIndex) { + case 0: + return "Task Name"; + case 1: + return "Task ID"; + case 2: + return "Variable name"; + case 3: + return "Variable ID"; + case 4: + return "Value"; + } + return "unknown"; + } + + // Assumes tmlm != null + private String getTaskName(int row) { + int cpt = 0; + for(TMLTask task: tmlm.getTasks()) { + cpt += task.getAttributes().size(); + if (row < cpt) { + return task.getName(); + } + } + + return "unknown task"; + } + + // Assumes tmlm != null + private String getTaskID(int row) { + int cpt = 0; + for(TMLTask task: tmlm.getTasks()) { + cpt += task.getAttributes().size(); + if (row < cpt) { + return "" + task.getID(); + } + } + + return "unknown ID"; + } + + private String getVariableName(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).getName(); + } + } + + return "unknown name"; + } + + private String 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 "unknown ID"; + } + + private String getVariableInitialValue(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).getInitialValue(); + } + } + + return "unknown ID"; + } + + private String getVariableValue(int row) { + String ID = getVariableID(row); + String s = table.get(ID); + if (s != null) { + return s; + } + + // Must set the ID; + String val = getVariableInitialValue(row); + table.put(ID, val); + return val; + + } + + private void computeData() { + if (tmlm == null) { + nbOfRows = 0; + return ; + } + + int cpt = 0; + for(TMLTask task: tmlm.getTasks()) { + cpt += task.getAttributes().size(); + } + + nbOfRows = cpt; + return; + } + +} \ No newline at end of file diff --git a/src/ui/window/JDialogSystemCGeneration.java b/src/ui/window/JDialogSystemCGeneration.java index 7d3b8fae06..f1fbc4c7ff 100755 --- a/src/ui/window/JDialogSystemCGeneration.java +++ b/src/ui/window/JDialogSystemCGeneration.java @@ -464,7 +464,12 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act if (selectedItem == 0) { tmltranslator.tomappingsystemc.TML2MappingSystemC tml2systc; if (mgui.gtm.getTMLMapping() == null) { - tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getTMLModeling()); + if (mgui.gtm.getArtificialTMLMapping() == null) { + tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getTMLModeling()); + } else { + System.out.println("Using artifical mapping"); + tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getArtificialTMLMapping()); + } } else { tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getTMLMapping()); } @@ -483,7 +488,12 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } else { tmltranslator.tomappingsystemc2.TML2MappingSystemC tml2systc; if (mgui.gtm.getTMLMapping() == null) { - tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getTMLModeling()); + if (mgui.gtm.getArtificialTMLMapping() == null) { + tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getTMLModeling()); + } else { + System.out.println("Using artifical mapping"); + tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getArtificialTMLMapping()); + } } else { tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getTMLMapping()); } -- GitLab