diff --git a/src/ui/ConfigurationTTool.java b/src/ui/ConfigurationTTool.java index fdfac32ca66484b9410421206f9ede6059997675..6d98db7927b1c184eaeefc0e0bd637f792af13b8 100755 --- a/src/ui/ConfigurationTTool.java +++ b/src/ui/ConfigurationTTool.java @@ -98,6 +98,7 @@ public class ConfigurationTTool { public static String TMLCodeDirectory = ""; public static String SystemCCodeCompileCommand = ""; public static String SystemCCodeExecuteCommand = ""; + public static String SystemCCodeInteractiveExecuteCommand = ""; public static String SystemCHost = ""; public static String GTKWavePath = ""; public static String UPPAALCodeDirectory = ""; @@ -278,6 +279,7 @@ public class ConfigurationTTool { System.out.println("SystemCHost: " + SystemCHost); System.out.println("SystemCCodeCompileCommand: " + SystemCCodeCompileCommand); System.out.println("SystemCCodeExecuteCommand: " + SystemCCodeExecuteCommand); + System.out.println("SystemCCodeInteractiveExecuteCommand: " + SystemCCodeInteractiveExecuteCommand); System.out.println("GTKWavePath: " + GTKWavePath); } @@ -425,6 +427,9 @@ public class ConfigurationTTool { nl = doc.getElementsByTagName("SystemCCodeExecuteCommand"); if (nl.getLength() > 0) SystemCCodeExecuteCommand(nl); + nl = doc.getElementsByTagName("SystemCCodeInteractiveExecuteCommand"); + if (nl.getLength() > 0) + SystemCCodeInteractiveExecuteCommand(nl); nl = doc.getElementsByTagName("GTKWavePath"); if (nl.getLength() > 0) GTKWavePath(nl); @@ -805,6 +810,15 @@ public class ConfigurationTTool { throw new MalformedConfigurationException(e.getMessage()); } } + + private static void SystemCCodeInteractiveExecuteCommand(NodeList nl) throws MalformedConfigurationException { + try { + Element elt = (Element)(nl.item(0)); + SystemCCodeInteractiveExecuteCommand = elt.getAttribute("data"); + } catch (Exception e) { + throw new MalformedConfigurationException(e.getMessage()); + } + } private static void GTKWavePath(NodeList nl) throws MalformedConfigurationException { try { diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index 1695254036c617de930ed4797c9a33918a2877b0..0d7aac4e0c15f202f4b26fddb5008a064e9033bc 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -72,7 +72,8 @@ 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; + // Class diagram public static ImageIcon imgic100, imgic101, imgic102, imgic104, imgic106, imgic108; public static ImageIcon imgic110, imgic112, imgic114, imgic116, imgic118; @@ -205,6 +206,12 @@ public class IconManager { private static String icon64 = "images/genaut.gif"; private static String icon65 = "images/concomment.gif"; private static String icon66 = "images/gentmltxt.gif"; + + private static String icon70 = "images/toolbarButtonGraphics/general/SendMai16.gif"; + 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 icon100 = "images/toolbarButtonGraphics/general/Properties16.gif"; private static String icon101 = "images/toolbarButtonGraphics/general/Properties24.gif"; @@ -514,6 +521,11 @@ public class IconManager { imgic64 = getIcon(icon64); imgic65 = getIcon(icon65); imgic66 = getIcon(icon66); + + imgic70 = getIcon(icon70); + imgic71 = getIcon(icon71); + imgic72 = getIcon(icon72); + imgic73 = getIcon(icon73); imgic100 = getIcon(icon100); imgic101 = getIcon(icon101); diff --git a/src/ui/JToolBarMainTurtle.java b/src/ui/JToolBarMainTurtle.java index b6e02bf82828322d7c8424daa78e2e8fb506ecb6..19a0c8743dfdb9ce893b47a6563608a6d913e5af 100755 --- a/src/ui/JToolBarMainTurtle.java +++ b/src/ui/JToolBarMainTurtle.java @@ -189,6 +189,9 @@ public class JToolBarMainTurtle extends JToolBar { if (MainGUI.systemcOn) { button = add(mgui.actions[TGUIAction.ACT_GEN_SYSTEMC]); + button.addMouseListener(mgui.mouseHandler); + + button = add(mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC]); button.addMouseListener(mgui.mouseHandler); addSeparator(); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index be35b22a5e5109e1fd48acada42b46f4b6daba8d..c33d169f2629e305b1194093b20f1f0cfcacdad4 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -492,6 +492,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actions[TGUIAction.ACT_VIEW_WAVE].setEnabled(true); actions[TGUIAction.EXTERNAL_ACTION_1].setEnabled(true); actions[TGUIAction.EXTERNAL_ACTION_2].setEnabled(true); + actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(true); break; case OPENED: actions[TGUIAction.ACT_MERGE].setEnabled(true); @@ -2774,24 +2775,29 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void generateSystemC() { - JDialogSystemCGeneration jgen = new JDialogSystemCGeneration(frame, this, "SystemC code generation and compilation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeDirectory, ConfigurationTTool.SystemCCodeCompileCommand, ConfigurationTTool.SystemCCodeExecuteCommand); + JDialogSystemCGeneration jgen = new JDialogSystemCGeneration(frame, this, "SystemC code generation and compilation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeDirectory, ConfigurationTTool.SystemCCodeCompileCommand, ConfigurationTTool.SystemCCodeExecuteCommand, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand); jgen.setSize(450, 600); GraphicLib.centerOnParent(jgen); jgen.setVisible(true); dtree.toBeUpdated(); - - - /*System.out.println("Generate SystemC"); - gtm.generateSystemC(); - JOptionPane.showMessageDialog(frame, - "SystemC code generated", - "SystemC generator", - JOptionPane.INFORMATION_MESSAGE); - dtree.toBeUpdated();*/ - - + + if (jgen.isInteractiveSimulationSelected()) { + JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, jgen.getPathInteractiveExecute()); + jfis.setIconImage(IconManager.img9); + jfis.setSize(800, 600); + GraphicLib.centerOnParent(jfis); + jfis.setVisible(true); + } } + public void interactiveSimulationSystemC() { + JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand); + jfis.setIconImage(IconManager.img9); + jfis.setSize(800, 600); + GraphicLib.centerOnParent(jfis); + jfis.setVisible(true); + } + public void generateTMLTxt() { String path = ConfigurationTTool.FILEPath; if (file != null) { @@ -5011,6 +5017,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { simuJava(); } else if (command.equals(actions[TGUIAction.ACT_GEN_SYSTEMC].getActionCommand())) { generateSystemC(); + } else if (command.equals(actions[TGUIAction.ACT_SIMU_SYSTEMC].getActionCommand())) { + interactiveSimulationSystemC(); } else if (command.equals(actions[TGUIAction.ACT_GEN_TMLTXT].getActionCommand())) { generateTMLTxt(); } else if (command.equals(actions[TGUIAction.ACT_GEN_DESIGN].getActionCommand())) { diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index afb517b795e6d41a4c31c787fabedce2be8d311d..34333398a3ae94901b81bddd1d4d7f545a804a7f 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -279,6 +279,7 @@ public class TGUIAction extends AbstractAction { public static final int ACT_GEN_JAVA = 112; public static final int ACT_SIMU_JAVA = 167; public static final int ACT_GEN_SYSTEMC = 148; + public static final int ACT_SIMU_SYSTEMC = 263; public static final int ACT_GEN_TMLTXT = 215; public static final int ACT_GEN_AUT = 157; public static final int ACT_GEN_AUTS = 202; @@ -371,7 +372,7 @@ public class TGUIAction extends AbstractAction { public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 263; + public static final int NB_ACTION = 264; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -469,6 +470,7 @@ public class TGUIAction extends AbstractAction { actions[ACT_GEN_JAVA] = new TAction("gen_java-command", "Generate JAVA", IconManager.imgic38, IconManager.imgic39, "Generate JAVA", "Generates Java code from TURTLE diagrams", 0); actions[ACT_SIMU_JAVA] = new TAction("gen_simujava-command", "Java-based simulation", IconManager.imgic38, IconManager.imgic39, "JAVA-based simualtion", "Simulate diagrams using Java language", 0); actions[ACT_GEN_SYSTEMC] = new TAction("gen_systemc-command", "Generate SystemC", IconManager.imgic61, IconManager.imgic61, "Generate SystemC", "Generates SystemC code from TML Design diagrams", 0); + actions[ACT_SIMU_SYSTEMC] = new TAction("simu_systemc", "Interactive Simulation", IconManager.imgic61, IconManager.imgic61, "Interactive simulation", "Interactive simulation from DIPLODOCUS models", 0); actions[ACT_GEN_TMLTXT] = new TAction("gen_tmltxt-command", "Generate TML / TMAP in text format", IconManager.imgic66, IconManager.imgic66, "Generate TML / TMAP in text format", "Generates TML / TMAP code in text format from TML Design diagrams", 0); actions[ACT_GEN_AUT] = new TAction("gen_aut-command", "Generate automata", IconManager.imgic64, IconManager.imgic64, "Generate automata", "Generates automata from TML Design diagrams", 0); actions[ACT_GEN_AUTS] = new TAction("gen_auts-command", "Generate automata via LOTOS", IconManager.imgic64, IconManager.imgic64, "Generate automata via LOTOS", "Generates automata from TML Design diagrams, using LOTOS", 0); diff --git a/src/ui/window/JDialogSystemCGeneration.java b/src/ui/window/JDialogSystemCGeneration.java index e576045904fdcec95bd749d400e2173e715089e5..8017f0fb38e3ce40ffbfbb1466c7500c95196a27 100755 --- a/src/ui/window/JDialogSystemCGeneration.java +++ b/src/ui/window/JDialogSystemCGeneration.java @@ -66,7 +66,8 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act private String textSysC1 = "Generate SystemC code in"; private String textSysC2 = "Compile SystemC code in"; //private String textSysC3 = "with"; - private String textSysC4 = "Execute SystemC application:"; + private String textSysC4 = "Run simulation to completion:"; + private String textSysC5 = "Run interactive simulation:"; private static String unitCycle = "1"; @@ -76,6 +77,9 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act protected static String pathCode; protected static String pathCompiler; protected static String pathExecute; + protected static String pathInteractiveExecute; + + protected static boolean interactiveSimulationSelected = true; protected final static int NOT_STARTED = 1; protected final static int STARTED = 2; @@ -89,8 +93,10 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act protected JButton stop; protected JButton close; - protected JLabel gen, comp, exe; - protected JTextField code1, code2, unitcycle, compiler1, exe1, exe2, exe3; + protected JRadioButton exe, exeint; + protected ButtonGroup exegroup; + protected JLabel gen, comp; + protected JTextField code1, code2, unitcycle, compiler1, exe1, exe2, exe3, exe2int; protected JTabbedPane jp1; protected JScrollPane jsp; protected JCheckBox removeCppFiles, removeXFiles, debugmode; @@ -100,6 +106,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act private boolean go = false; //private ProcessThread pt; private boolean hasError = false; + protected boolean startProcess = false; //private TURTLE2Java t2j; @@ -109,7 +116,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act /** Creates new form */ - public JDialogSystemCGeneration(Frame f, MainGUI _mgui, String title, String _hostSystemC, String _pathCode, String _pathCompiler, String _pathExecute) { + public JDialogSystemCGeneration(Frame f, MainGUI _mgui, String title, String _hostSystemC, String _pathCode, String _pathCompiler, String _pathExecute, String _pathInteractiveExecute) { super(f, title, true); mgui = _mgui; @@ -123,6 +130,9 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act if (pathExecute == null) pathExecute = _pathExecute; + + if (pathInteractiveExecute == null) + pathInteractiveExecute = _pathInteractiveExecute; hostSystemC = _hostSystemC; @@ -138,6 +148,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act protected void myInitComponents() { mode = NOT_STARTED; setButtons(); + updateInteractiveSimulation(); } protected void initComponents() { @@ -252,12 +263,25 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act c03.gridwidth = GridBagConstraints.REMAINDER; //end row c03.fill = GridBagConstraints.BOTH; c03.gridheight = 1; - exe = new JLabel(textSysC4); + + exegroup = new ButtonGroup(); + exe = new JRadioButton(textSysC4, false); + exe.addActionListener(this); + exegroup.add(exe); //exeJava.addActionListener(this); jp03.add(exe, c03); exe2 = new JTextField(pathExecute, 100); jp03.add(exe2, c02); + + exeint = new JRadioButton(textSysC5, true); + exeint.addActionListener(this); + exegroup.add(exeint); + //exeJava.addActionListener(this); + jp03.add(exeint, c03); + + exe2int = new JTextField(pathInteractiveExecute, 100); + jp03.add(exe2int, c02); jp03.add(new JLabel(" "), c03); @@ -296,13 +320,27 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act c.add(jp2, BorderLayout.SOUTH); } + + public void updateInteractiveSimulation() { + interactiveSimulationSelected = !(exe.isSelected()); + if (!interactiveSimulationSelected) { + exe2.setEnabled(true); + exe2int.setEnabled(false); + } else { + exe2.setEnabled(false); + exe2int.setEnabled(true); + } + } public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); //System.out.println("Actions"); // Compare the action command to the known actions. - if (command.equals("Start")) { + updateInteractiveSimulation(); + + + if (command.equals("Start")) { startProcess(); } else if (command.equals("Stop")) { stopProcess(); @@ -333,11 +371,17 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } public void startProcess() { - t = new Thread(this); - mode = STARTED; - setButtons(); - go = true; - t.start(); + if ((interactiveSimulationSelected) && (jp1.getSelectedIndex() == 2)) { + startProcess = true; + dispose(); + } else { + startProcess = false; + t = new Thread(this); + mode = STARTED; + setButtons(); + go = true; + t.start(); + } } private void testGo() throws InterruptedException { @@ -579,4 +623,12 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act public void setError() { hasError = true; } + + public boolean isInteractiveSimulationSelected() { + return (startProcess && interactiveSimulationSelected); + } + + public String getPathInteractiveExecute() { + return pathInteractiveExecute; + } }