diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java index 70765f3685dc74aae61a5a3d29698ea151549c5e..1b9c580e9ea4e7322e2a1a3121ed2cc16cc7bbc8 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -42,7 +42,11 @@ import ui.syscams.*; import ui.util.IconManager; import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -50,6 +54,7 @@ import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; @@ -73,6 +78,8 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { /** Access to ActionPerformed **/ private JTextField nameTextField; private JTextField periodTextField; + private String listPeriodString[]; + private JComboBox<String> periodComboBoxString; /** Parameters **/ private SysCAMSBlockDE block; @@ -81,7 +88,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { public JDialogSysCAMSBlockDE(SysCAMSBlockDE block) { /** Set JDialog **/ this.setTitle("Setting TDF Block Attributes"); - this.setSize(500, 168); + this.setSize(500, 180); this.setLocationRelativeTo(null); this.setVisible(true); this.setAlwaysOnTop(true); @@ -117,28 +124,74 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { attributesBox.setBorder(BorderFactory.createTitledBorder("Setting DE block attributes")); // BorderLayout for Adding Attributes - JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10)); - - // GridLayout for name - JLabel nameLabel = new JLabel("Name : "); - attributesBoxPanel.add(nameLabel); - if (block.getValue().toString().equals("")) { // name empty + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel attributesBoxPanel = new JPanel(); + attributesBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + attributesBoxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + attributesBoxPanel.add(labelName); + + if (block.getValue().toString().equals("")) { // name empty nameTextField = new JTextField(10); } else { nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty } - attributesBoxPanel.add(nameTextField); + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + attributesBoxPanel.add(nameTextField); - // GridLayout for period - JLabel periodLabel = new JLabel("Period Tm (ms) : "); + JLabel periodLabel = new JLabel("Period Tp : "); + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodLabel, constraints); attributesBoxPanel.add(periodLabel); - if (block.getPeriod() == -1) { + + if (block.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || periodTextField = new JTextField(10); } else { - periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10); + periodTextField = new JTextField("" + block.getPeriod(), 10); // name not empty } - attributesBoxPanel.add(periodTextField); - attributesBox.add(attributesBoxPanel); // add border to box + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodTextField, constraints); + attributesBoxPanel.add(periodTextField); + + listPeriodString = new String[3]; + listPeriodString[0] = "us"; + listPeriodString[1] = "ms"; + listPeriodString[2] = "s"; + periodComboBoxString = new JComboBox<String>(listPeriodString); + if (block.getTime().equals("") || block.getTime().equals("us")) { + periodComboBoxString.setSelectedIndex(0); + } else if (block.getTime().equals("ms")){ + periodComboBoxString.setSelectedIndex(1); + } else { + periodComboBoxString.setSelectedIndex(2); + } + periodComboBoxString.setActionCommand("time"); + periodComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodComboBoxString, constraints); + attributesBoxPanel.add(periodComboBoxString); + + attributesBox.add(attributesBoxPanel); attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid @@ -193,4 +246,4 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { this.dispose(); } } -} \ No newline at end of file +} diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java index b2303903c19ea4908d26e60c5766b462b9a9beca..48bfbb6fc335e6b0b1f865ef52abf9d2ac888e7f 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java @@ -44,7 +44,10 @@ import ui.util.IconManager; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -52,6 +55,7 @@ import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; @@ -78,6 +82,8 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener { /** Access to ActionPerformed **/ private JTextField nameTextField; private JTextField periodTextField; + private String listPeriodString[]; + private JComboBox<String> periodComboBoxString; private JTextArea processCodeTextArea; /** Parameters **/ @@ -128,27 +134,73 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener { attributesBox.setBorder(BorderFactory.createTitledBorder("Setting TDF block attributes")); // BorderLayout for Adding Attributes - JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10)); - - // GridLayout for name - JLabel nameLabel = new JLabel("Name : "); - attributesBoxPanel.add(nameLabel); - if (block.getValue().toString().equals("")) { // name empty + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel attributesBoxPanel = new JPanel(); + attributesBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + attributesBoxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + attributesBoxPanel.add(labelName); + + if (block.getValue().toString().equals("")) { // name empty nameTextField = new JTextField(10); } else { nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty } - attributesBoxPanel.add(nameTextField); + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + attributesBoxPanel.add(nameTextField); - // GridLayout for period - JLabel periodLabel = new JLabel("Period Tm (ms) : "); + JLabel periodLabel = new JLabel("Period Tp : "); + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodLabel, constraints); attributesBoxPanel.add(periodLabel); - if (block.getPeriod() == -1) { + + if (block.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || periodTextField = new JTextField(10); } else { - periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10); + periodTextField = new JTextField("" + block.getPeriod(), 10); // name not empty } - attributesBoxPanel.add(periodTextField); + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodTextField, constraints); + attributesBoxPanel.add(periodTextField); + + listPeriodString = new String[3]; + listPeriodString[0] = "us"; + listPeriodString[1] = "ms"; + listPeriodString[2] = "s"; + periodComboBoxString = new JComboBox<String>(listPeriodString); + if (block.getTime().equals("") || block.getTime().equals("us")) { + periodComboBoxString.setSelectedIndex(0); + } else if (block.getTime().equals("ms")){ + periodComboBoxString.setSelectedIndex(1); + } else { + periodComboBoxString.setSelectedIndex(2); + } + periodComboBoxString.setActionCommand("time"); + periodComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodComboBoxString, constraints); + attributesBoxPanel.add(periodComboBoxString); + attributesBox.add(attributesBoxPanel); // add border to box attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid @@ -235,4 +287,4 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener { this.dispose(); } } -} \ No newline at end of file +} diff --git a/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java new file mode 100644 index 0000000000000000000000000000000000000000..899adb58be1af17bd3e6bdf5a8bc5f77ca636bf2 --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java @@ -0,0 +1,745 @@ +/* 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. + */ + +package ui.window; + +import syscamstranslator.toSysCAMS.TopCellGenerator; +import launcher.LauncherException; +import launcher.RshClient; +import myutil.*; +import syscamstranslator.SysCAMSSpecification; +import ui.util.IconManager; +import ui.MainGUI; +import ui.SysCAMSPanelTranslator; +import ui.syscams.SysCAMSComponentTaskDiagramPanel; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.StringWriter; +import java.io.Writer; + +/** + * Class JDialogSysCAMSExecutableCodeGeneration + * Dialog for managing the generation and compilation of SystemC-AMS executable code + * Creation: 23/05/2018 + * @version 1.0 23/05/2018 + * @author Irina Kit Yan LEE + */ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame implements ActionListener, Runnable, MasterProcessInterface { + + protected Frame f; + protected MainGUI mgui; + + private String textSysC1 = "Base directory of code generation:"; + private String textSysC7 = "Base directory of topcell generation:"; +// private String textSysC2 = "Compile SystemC-AMS executable with"; // compile +// private String textSysC4 = "Run code in soclib / mutekh:"; +// private String textSysC5 = "Show AVATAR trace from file w/o hardware:"; +// private String textSysC6 = "Show cycle accurate trace from MPSoC file:"; + +// private static String[] codes = {"AVATAR SOCLIB"}; + +// private static int selectedRun = 1; +// private static int selectedCompile = 0; +// private static int selectedViewTrace = 0; +// private static boolean static_putUserCode = true; + + protected static String pathCode; + protected static String pathSoclibTraceFile; + protected static String pathCompileMPSoC; + protected static String pathExecuteMPSoC; + protected static boolean optimizeModeSelected = true; + + protected final static int NOT_STARTED = 1; + protected final static int STARTED = 2; + protected final static int STOPPED = 3; + + private static + + int mode; + + //components + protected JTextArea jta; + protected JButton start; + protected JButton stop; + protected JButton close; + + protected JRadioButton exe, exeint, exetrace, exesoclib, compile, compilesoclib, viewtrace, viewtracesoclib; + protected ButtonGroup compilegroup, exegroup, viewgroup; + protected JLabel gen; + protected JTextField code1, code2, compiler, exe1, exe2, exe3, exe4, exe2int, simulationTraceFile, simulationsoclibTraceFile; + protected JTabbedPane jp1; + protected JScrollPane jsp; + protected JCheckBox removeCFiles, removeXFiles, debugmode, tracemode, optimizemode, putUserCode; + protected JComboBox<String> versionCodeGenerator, units; + protected JButton showSimulationTrace, showOverflowStatus; + +// private static int selectedUnit = 2; +// private static boolean removeCFilesValue = true; +// private static boolean removeXFilesValue = true; +// private static boolean debugValue = false; +// private static boolean tracingValue = false; +// private static boolean optimizeValue = true; + + private Thread t; + private boolean go = false; +// private boolean hasError = false; + protected boolean startProcess = false; + +// private String hostExecute; + + protected RshClient rshc; + + public JDialogSysCAMSExecutableCodeGeneration(Frame _f, MainGUI _mgui, String title, String _pathCode) { + super(title); + f = _f; + mgui = _mgui; + + if (pathCode == null) { + pathCode = _pathCode; + } + +// if (pathCompileMPSoC == null) { +// pathCompileMPSoC = _pathCompileMPSoC; +// } +// +// if (pathExecuteMPSoC == null) { +// pathExecuteMPSoC = _pathExecuteMPSoC; +// } +// +// hostExecute = _hostExecute; + + initComponents(); + myInitComponents(); + pack(); + + getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + protected void myInitComponents() { + mode = NOT_STARTED; + setButtons(); +// makeSelectionCompile(); +// makeSelectionExecute(); +// makeSelectionViewTrace(); + } + + protected void initComponents() { + Container c = getContentPane(); + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(new BorderLayout()); + + // Issue #41 Ordering of tabbed panes + jp1 = GraphicLib.createTabbedPane();//new JTabbedPane(); + + JPanel jp01 = new JPanel(); + GridBagLayout gridbag01 = new GridBagLayout(); + GridBagConstraints c01 = new GridBagConstraints(); + jp01.setLayout(gridbag01); + jp01.setBorder(new javax.swing.border.TitledBorder("Code generation")); + +// JPanel jp02 = new JPanel(); +// GridBagLayout gridbag02 = new GridBagLayout(); +// GridBagConstraints c02 = new GridBagConstraints(); +// jp02.setLayout(gridbag02); +// jp02.setBorder(new javax.swing.border.TitledBorder("Compilation")); +// +// JPanel jp03 = new JPanel(); +// GridBagLayout gridbag03 = new GridBagLayout(); +// GridBagConstraints c03 = new GridBagConstraints(); +// jp03.setLayout(gridbag03); +// jp03.setBorder(new javax.swing.border.TitledBorder("Execution")); +// +// JPanel jp04 = new JPanel(); +// GridBagLayout gridbag04 = new GridBagLayout(); +// GridBagConstraints c04 = new GridBagConstraints(); +// jp04.setLayout(gridbag04); +// jp04.setBorder(new javax.swing.border.TitledBorder("Simulation trace")); + + c01.gridheight = 1; + c01.weighty = 1.0; + c01.weightx = 1.0; + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + c01.fill = GridBagConstraints.BOTH; + c01.gridheight = 1; + + gen = new JLabel(textSysC1); + //genJava.addActionListener(this); + jp01.add(gen, c01); + + code1 = new JTextField(pathCode, 100); + jp01.add(code1, c01); + + gen = new JLabel(textSysC7); + //genJava.addActionListener(this); + jp01.add(gen, c01); + + code2 = new JTextField(pathCode, 100); + jp01.add(code2, c01); + + jp01.add(new JLabel(" "), c01); + c01.gridwidth = GridBagConstraints.REMAINDER; //end row + +// removeCFiles = new JCheckBox("Remove .c / .h files"); +// removeCFiles.setSelected(removeCFilesValue); +// jp01.add(removeCFiles, c01); + +// removeXFiles = new JCheckBox("Remove .x files"); +// removeXFiles.setSelected(removeXFilesValue); +// jp01.add(removeXFiles, c01); + +// debugmode = new JCheckBox("Put debug information in generated code"); +// debugmode.setSelected(debugValue); +// jp01.add(debugmode, c01); +// +// tracemode = new JCheckBox("Put tracing capabilities in generated code"); +// tracemode.setSelected(tracingValue); +// jp01.add(tracemode, c01); +// +// optimizemode = new JCheckBox("Optimize code"); +// optimizemode.setSelected(optimizeModeSelected); +// jp01.add(optimizemode, c01); +// +// putUserCode = new JCheckBox("Include user code"); +// putUserCode.setSelected(static_putUserCode); +// jp01.add(putUserCode, c01); + +// jp01.add(new JLabel("1 time unit ="), c01); +// +// units = new JComboBox<String>(unitTab); +// units.setSelectedIndex(selectedUnit); +// units.addActionListener(this); +// jp01.add(units, c01); + +// jp01.add(new JLabel("Code generator used:"), c01); + +// versionCodeGenerator = new JComboBox<String>(codes); + // versionCodeGenerator.setSelectedIndex(selectedItem); +// versionCodeGenerator.addActionListener(this); +// jp01.add(versionCodeGenerator, c01); + + jp01.add(new JLabel(" "), c01); + jp1.add("Generate code", jp01); + + // Panel 02 -> compile +// c02.gridheight = 1; +// c02.weighty = 1.0; +// c02.weightx = 1.0; +// c02.gridwidth = GridBagConstraints.REMAINDER; //end row +// c02.fill = GridBagConstraints.BOTH; +// c02.gridheight = 1; + +// compilegroup = new ButtonGroup(); +// +// compilesoclib = new JRadioButton(textSysC2, false); +// compilesoclib.addActionListener(this); +// jp02.add(compilesoclib, c02); +// compilegroup.add(compilesoclib); +// compiler = new JTextField(pathCompileMPSoC, 100); +// jp02.add(compiler, c02); + + //compile.setSelected(selectedCompile == 0); +// compilesoclib.setSelected(selectedCompile == 1); +// +// jp1.add("Compile", jp02); + + // Panel 03 -> Execute +// c03.gridheight = 1; +// c03.weighty = 1.0; +// c03.weightx = 1.0; +// c03.gridwidth = GridBagConstraints.REMAINDER; //end row +// c03.fill = GridBagConstraints.BOTH; +// c03.gridheight = 1; + +// exegroup = new ButtonGroup(); + + /*exetrace = new JRadioButton(textSysC3, false); + exetrace.addActionListener(this); + exegroup.add(exetrace); + jp03.add(exetrace, c03); + exe3 = new JTextField(pathExecuteMPSoC+"-trace", 100); + jp03.add(exe3, c03);*/ +// +// exesoclib = new JRadioButton(textSysC4, false); +// exesoclib.addActionListener(this); +// exegroup.add(exesoclib); +// jp03.add(exesoclib, c03); +// exe4 = new JTextField(pathExecuteMPSoC, 100); +// jp03.add(exe4, c03); + + //exe.setSelected(selectedRun == 0); + //exetrace.setSelected(selectedRun == 1); + // exesoclib.setSelected(selectedRun == 2); + +// jp03.add(new JLabel(" "), c03); + +// jp1.add("Execute", jp03); + + // Panel 04 -> View trace +// c04.gridheight = 1; +// c04.weighty = 1.0; +// c04.weightx = 1.0; +// c04.gridwidth = GridBagConstraints.REMAINDER; //end row +// c04.fill = GridBagConstraints.HORIZONTAL; +// c04.gridheight = 1; + +// viewgroup = new ButtonGroup(); +// viewtrace = new JRadioButton(textSysC5, false); +// viewgroup.add(viewtrace); +// viewtrace.addActionListener(this); +// jp04.add(viewtrace, c04); +// simulationTraceFile = new JTextField(pathCode + "trace.txt", 100); +// jp04.add(simulationTraceFile, c04); +// viewtracesoclib = new JRadioButton(textSysC6, false); +// viewgroup.add(viewtracesoclib); +// viewtracesoclib.addActionListener(this); +// jp04.add(viewtracesoclib, c04); +// simulationsoclibTraceFile = new JTextField(pathSoclibTraceFile, 100); +// jp04.add(simulationsoclibTraceFile, c04); +// +// showSimulationTrace = new JButton("Show simulation trace"); +// showSimulationTrace.addActionListener(this); +// jp04.add(showSimulationTrace, c04); + + //-------------Ajout C.Demarigny--------------- + +// showOverflowStatus = new JButton("Show overflow status"); +// showOverflowStatus.addActionListener(this); +// jp04.add(showOverflowStatus, c04); + + //----------------Fin ajout-------------------- + +// viewtrace.setSelected(selectedViewTrace == 0); +// viewtracesoclib.setSelected(selectedViewTrace == 1); + +// jp1.add("Results", jp04); + + c.add(jp1, BorderLayout.NORTH); + + jta = new ScrolledJTextArea(); + jta.setEditable(false); + jta.setMargin(new Insets(10, 10, 10, 10)); + jta.setTabSize(3); + jta.append("Select options and then, click on 'start' to launch code generation\n"); // / compilation / execution + Font f = new Font("Courrier", Font.BOLD, 12); + jta.setFont(f); + jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + c.add(jsp, BorderLayout.CENTER); + + start = new JButton("Start", IconManager.imgic53); + stop = new JButton("Stop", IconManager.imgic55); + close = new JButton("Close", IconManager.imgic27); + + start.setPreferredSize(new Dimension(100, 30)); + stop.setPreferredSize(new Dimension(100, 30)); + close.setPreferredSize(new Dimension(100, 30)); + + start.addActionListener(this); + stop.addActionListener(this); + close.addActionListener(this); + + JPanel jp2 = new JPanel(); + jp2.add(start); + jp2.add(stop); + jp2.add(close); + + c.add(jp2, BorderLayout.SOUTH); + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Start")) { + startProcess(); + } else if (command.equals("Stop")) { + stopProcess(); + } else if (command.equals("Close")) { + closeDialog(); + } else if (evt.getSource() == versionCodeGenerator) { + // selectedItem = versionCodeGenerator.getSelectedIndex(); +// } else if (evt.getSource() == units) { +// selectedUnit = units.getSelectedIndex(); +// } else if (evt.getSource() == showSimulationTrace) { +// showSimulationTrace(); + //} else if ((evt.getSource() == exe) || (evt.getSource() == exetrace)|| (evt.getSource() == exesoclib)) { +// else if ((evt.getSource() == exetrace) || (evt.getSource() == exesoclib)) { +// makeSelectionExecute(); +// // } else if ((evt.getSource() == compile) || (evt.getSource() == compilesoclib)) { +// } else if ((evt.getSource() == compilesoclib)) { +// makeSelectionCompile(); +// } else if ((evt.getSource() == viewtrace) || (evt.getSource() == viewtracesoclib)) { +// makeSelectionViewTrace(); +// } else if ((evt.getSource() == showOverflowStatus)) { //ajout CD +// showOverflowStatus(); + } + } + + public void closeDialog() { + if (mode == STARTED) { + stopProcess(); + } +// optimizeModeSelected = optimizemode.isSelected(); +// removeCFilesValue = removeCFiles.isSelected(); +// removeXFilesValue = removeXFiles.isSelected(); +// debugValue = debugmode.isSelected(); +// tracingValue = tracemode.isSelected(); +// static_putUserCode = putUserCode.isSelected(); + dispose(); + } +// +// public void makeSelectionExecute() { +// +// //if (exetrace.isSelected()) { +// // selectedRun = 1; +// //} else { +// selectedRun = 2; +// //} +// +// // exe2.setEnabled(selectedRun == 0); +// //exe3.setEnabled(selectedRun == 1); +// exe4.setEnabled(selectedRun == 2); +// } + +// public void makeSelectionCompile() { +// +// selectedCompile = 1; +// compiler.setEnabled(selectedCompile == 1); +// +// } + +// public void makeSelectionViewTrace() { +// if (viewtrace.isSelected()) { +// selectedViewTrace = 0; +// } else { +// selectedViewTrace = 1; +// } +// simulationTraceFile.setEnabled(selectedViewTrace == 0); +// // simulationsoclibTraceFile.setEnabled(selectedViewTrace == 1); +// } + + public void stopProcess() { + try { + rshc.stopCommand(); + } catch (LauncherException le) { + + } + rshc = null; + mode = STOPPED; + setButtons(); + go = false; + } + + public void startProcess() { + startProcess = false; + t = new Thread(this); + mode = STARTED; + setButtons(); + go = true; + t.start(); + } + + private void testGo() throws InterruptedException { + if (go == false) { + throw new InterruptedException("Stopped by user"); + } + } + + public void run() { +// String cmd; +// String list;//, data; +// hasError = false; + + try { + if (jp1.getSelectedIndex() == 0) { + jta.append("Generating executable code (SOCLIB version)\n"); + + SysCAMSComponentTaskDiagramPanel syscamsDiagramPanel = mgui.getFirstSysCAMSPanelFound(); + SysCAMSPanelTranslator syscamspaneltranslator = new SysCAMSPanelTranslator(syscamsDiagramPanel); + SysCAMSSpecification syscalsspec = syscamspaneltranslator.getSysCAMSSpecification(); + + // Generating code + if (syscalsspec == null) { + jta.append("Error: No SYSCAMS specification\n"); + } else { + System.err.println("**SYSCAMS TOPCELL found"); + + TopCellGenerator topCellGenerator = new TopCellGenerator(syscalsspec); + testGo(); + jta.append("Generation of TopCell executable code: done\n"); + + try { + jta.append("Saving SysCAMS code in files\n"); + System.err.println("Saving SysCAMS code in files\n"); + pathCode = code2.getText(); + + System.err.println("SYSCAMS TOPCELL saved in " + code2.getText()); + topCellGenerator.saveFile(pathCode); + + jta.append("Code saved\n"); + } catch (Exception e) { + jta.append("Could not generate files\n"); + System.err.println("Could not generate SysCAMS files\n"); + e.printStackTrace(); + } + } + + testGo(); + +// if (removeCFiles.isSelected()) { +// +// jta.append("Removing all .h files\n"); +// +// list = FileUtils.deleteFiles(code1.getText() + TasksAndMainGenerator.getGeneratedPath(), ".h"); +// if (list.length() == 0) { +// jta.append("No files were deleted\n"); +// } else { +// jta.append("Files deleted:\n" + list + "\n"); +// } +// jta.append("Removing all .c files\n"); +// list = FileUtils.deleteFiles(code1.getText() + TasksAndMainGenerator.getGeneratedPath(), ".c"); +// if (list.length() == 0) { +// jta.append("No files were deleted\n"); +// } else { +// jta.append("Files deleted:\n" + list + "\n"); +// } +// } + +// if (removeXFiles.isSelected()) { +// jta.append("Removing all .x files\n"); +// list = FileUtils.deleteFiles(code1.getText(), ".x"); +// if (list.length() == 0) { +// jta.append("No files were deleted\n"); +// } else { +// jta.append("Files deleted:\n" + list + "\n"); +// } +// } + +// testGo(); + +// selectedUnit = units.getSelectedIndex(); + + // Generating code +// if (avspec == null) { +// jta.append("Error: No AVATAR specification\n"); +// } else { +// +// TasksAndMainGenerator gene = new TasksAndMainGenerator(syscalsspec, avspec); +// gene.includeUserCode(putUserCode.isSelected()); +// gene.setTimeUnit(selectedUnit); +// gene.generateSoclib(debugmode.isSelected(), tracemode.isSelected()); +// +// if (syscalsspec == null) { +// jta.append("Error: No AVATAR Deployment specification\n"); +// } else { +// System.err.println("AVATAR TOPCELL found"); +// } +// +// TopCellGenerator topCellGenerator = new TopCellGenerator(syscalsspec, tracemode.isSelected(), avspec); +// testGo(); +// jta.append("Generation of TopCell executable code: done\n"); +// +// try { +// jta.append("Saving code in files\n"); +// pathCode = code2.getText(); +// topCellGenerator.saveFile(pathCode); +// +// jta.append("Code saved\n"); +// } catch (Exception e) { +// jta.append("Could not generate files\n"); +// } +// +// testGo(); +// jta.append("Generation of C-SOCLIB executable code: done\n"); +// try { +// jta.append("Saving code in files\n"); +// pathCode = code1.getText(); +// gene.saveInFiles(pathCode); +// +// jta.append("Code saved\n"); +// } catch (Exception e) { +// jta.append("Could not generate files\n"); +// } +// } +// } + +// testGo(); + +// if (jp1.getSelectedIndex() == 1) { +// cmd = compiler.getText(); +// jta.append("Compiling executable code with command: \n" + cmd + "\n"); +// +// rshc = new RshClient(hostExecute); +// try { +// processCmd(cmd, jta); +// jta.append("Compilation done\n"); +// } catch (LauncherException le) { +// jta.append("Error: " + le.getMessage() + "\n"); +// mode = STOPPED; +// setButtons(); +// return; +// } catch (Exception e) { +// mode = STOPPED; +// setButtons(); +// return; +// } +// } +// +// if (jp1.getSelectedIndex() == 2) { +// try { +// cmd = exe4.getText(); +// jta.append("Executing code with command: \n" + cmd + "\n"); +// rshc = new RshClient(hostExecute); +// processCmd(cmd, jta); +// jta.append("Execution done\n"); +// } catch (LauncherException le) { +// jta.append("Error: " + le.getMessage() + "\n"); +// mode = STOPPED; +// setButtons(); +// return; +// } catch (Exception e) { +// mode = STOPPED; +// setButtons(); +// return; +// } +// } +// if ((hasError == false) && (jp1.getSelectedIndex() < 2)) { +// jp1.setSelectedIndex(jp1.getSelectedIndex() + 1); +// } + }} catch (InterruptedException ie) { + jta.append("Interrupted\n"); + } + + jta.append("\n\nReady to process next command\n"); + + checkMode(); + setButtons(); + } + + protected void processCmd(String cmd, JTextArea _jta) throws LauncherException { + rshc.setCmd(cmd); + rshc.sendExecuteCommandRequest(); + final Writer output = new StringWriter(); + rshc.writeCommandMessages(output); + _jta.append(output.toString()); + + return; + } + + protected void checkMode() { + mode = NOT_STARTED; + } + + protected void setButtons() { + switch (mode) { + case NOT_STARTED: + start.setEnabled(true); + stop.setEnabled(false); + close.setEnabled(true); + getGlassPane().setVisible(false); + break; + case STARTED: + start.setEnabled(false); + stop.setEnabled(true); + close.setEnabled(false); + getGlassPane().setVisible(true); + break; + case STOPPED: + default: + start.setEnabled(false); + stop.setEnabled(false); + close.setEnabled(true); + getGlassPane().setVisible(false); + break; + } + } + + public boolean hasToContinue() { + return (go == true); + } + + public void appendOut(String s) { + jta.append(s); + } + + + public void setError() { +// hasError = true; + } + +// public void showSimulationTrace() { +// JFrameSimulationSDPanel jfssdp = new JFrameSimulationSDPanel(f, mgui, "Simulation trace of " + simulationTraceFile.getText()); +// jfssdp.setIconImage(IconManager.img8); +// GraphicLib.centerOnParent(jfssdp, 600, 600); +// if (selectedViewTrace == 0) { +// jfssdp.setFileReference(simulationTraceFile.getText()); +// } else { +// jfssdp.setFileReference(simulationsoclibTraceFile.getText()); +// } +// jfssdp.setVisible(true); +// TraceManager.addDev("Ok JFrame"); +// } + +// public void showOverflowStatus() { +// try { +// String path = ConfigurationTTool.AVATARMPSoCPerformanceEvaluationDirectory; +// String taille = "0"; +// +// String log = "mwmr0.log"; +// +// String[] commande = {"sh", path + "callingOverflow.sh", taille, path, log}; +// +// ProcessBuilder pb = new ProcessBuilder(commande); +// pb.redirectError(ProcessBuilder.Redirect.INHERIT); +// Process p = pb.start(); +// +// int exitStatus = p.waitFor(); +// +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java index 4dc79f42d769dee7650796d48344927f6af2b3f8..db3326645095ecc32366dca994f33363aeee62aa 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java @@ -42,7 +42,11 @@ import ui.syscams.*; import ui.util.IconManager; import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -74,6 +78,8 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen /** Access to ActionPerformed **/ private JTextField nameTextField; private JTextField periodTextField; + private String listPeriodString[]; + private JComboBox<String> periodComboBoxString; private JTextField rateTextField; private JTextField delayTextField; private String listTypeString[]; @@ -119,58 +125,125 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting converter input port attributes")); - JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel boxPanel = new JPanel(); + boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + boxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + boxPanel.add(labelName); - JLabel labelName = new JLabel("Name : "); - boxPanel.add(labelName); - - if (port.getPortName().toString().equals("")) { // name empty + if (port.getPortName().toString().equals("")) { // name empty nameTextField = new JTextField(10); } else { nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty } + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + boxPanel.add(nameTextField); + + JLabel periodLabel = new JLabel("Period Tp : "); + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodLabel, constraints); + boxPanel.add(periodLabel); - boxPanel.add(nameTextField); - - // Period - JLabel periodLabel = new JLabel("Period Tp (us) : "); - boxPanel.add(periodLabel); // add label to box - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || periodTextField = new JTextField(10); } else { periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty } - boxPanel.add(periodTextField); // add text to box - - // Rate + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodTextField, constraints); + boxPanel.add(periodTextField); + + listPeriodString = new String[3]; + listPeriodString[0] = "us"; + listPeriodString[1] = "ms"; + listPeriodString[2] = "s"; + periodComboBoxString = new JComboBox<String>(listPeriodString); + if (port.getTime().equals("") || port.getTime().equals("us")) { + periodComboBoxString.setSelectedIndex(0); + } else if (port.getTime().equals("ms")){ + periodComboBoxString.setSelectedIndex(1); + } else { + periodComboBoxString.setSelectedIndex(2); + } + periodComboBoxString.setActionCommand("time"); + periodComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodComboBoxString, constraints); + boxPanel.add(periodComboBoxString); + JLabel rateLabel = new JLabel("Rate : "); + constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateLabel, constraints); boxPanel.add(rateLabel); // add label to box - if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getRate() == -1) { // name empty rateTextField = new JTextField(10); } else { rateTextField = new JTextField("" + port.getRate(), 10); // name not empty } + constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateTextField, constraints); boxPanel.add(rateTextField); // add text to box - // Delay JLabel delayLabel = new JLabel("Delay : "); + constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayLabel, constraints); boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || delayTextField = new JTextField(10); } else { delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty } + constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayTextField, constraints); boxPanel.add(delayTextField); // add text to box - // Type JLabel typeLabel = new JLabel("Type : "); + constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeLabel, constraints); boxPanel.add(typeLabel); // add label to box - listTypeString = new String[4]; + + listTypeString = new String[3]; listTypeString[0] = "int"; listTypeString[1] = "bool"; listTypeString[2] = "double"; - listTypeString[3] = "sc_dt::sc_logic"; typeComboBoxString = new JComboBox<String>(listTypeString); if (port.getConvType().equals("") || port.getConvType().equals("int")) { typeComboBoxString.setSelectedIndex(0); @@ -181,16 +254,23 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen if (port.getConvType().equals("double")) { typeComboBoxString.setSelectedIndex(2); } - if (port.getConvType().equals("sc_dt::sc_logic")) { - typeComboBoxString.setSelectedIndex(3); - } typeComboBoxString.setActionCommand("type"); typeComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 4, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeComboBoxString, constraints); boxPanel.add(typeComboBoxString); // add combo to box - - // Origin + JLabel orginLabel = new JLabel("Origin : "); + constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(orginLabel, constraints); boxPanel.add(orginLabel); // add label to box + listOriginString = new String[2]; listOriginString[0] = "Input"; listOriginString[1] = "Output"; @@ -202,6 +282,11 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen } originComboBoxString.setActionCommand("origin"); originComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(originComboBoxString, constraints); boxPanel.add(originComboBoxString); // add combo to box box.add(boxPanel); // add border to box @@ -284,7 +369,8 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen port.setDelay(-1); } port.setConvType((String) typeComboBoxString.getSelectedItem()); - + port.setTime((String) periodComboBoxString.getSelectedItem()); + if ((String) originComboBoxString.getSelectedItem() == "Output") { port.setOrigin(1); } else { diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index 8befc5994a249a62064277ba51353cc78bc27626..fa2b488b7e017d0c8a9e9806bfc1bf9458fb2aa7 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -42,7 +42,11 @@ import ui.syscams.*; import ui.util.IconManager; import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -74,6 +78,8 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { /** Access to ActionPerformed **/ private JTextField nameTextField; private JTextField periodTextField; + private String listPeriodString[]; + private JComboBox<String> periodComboBoxString; private JTextField rateTextField; private JTextField delayTextField; private String listTypeString[]; @@ -119,53 +125,121 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting DE port attributes")); - JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel boxPanel = new JPanel(); + boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + boxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + boxPanel.add(labelName); - JLabel labelName = new JLabel("Name : "); - boxPanel.add(labelName); - - if (port.getPortName().toString().equals("")) { // name empty + if (port.getPortName().toString().equals("")) { // name empty nameTextField = new JTextField(10); } else { nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty } + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + boxPanel.add(nameTextField); + + JLabel periodLabel = new JLabel("Period Tp : "); + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodLabel, constraints); + boxPanel.add(periodLabel); - boxPanel.add(nameTextField); - - // Period - JLabel periodLabel = new JLabel("Period Tp (us) : "); - boxPanel.add(periodLabel); // add label to box - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || periodTextField = new JTextField(10); } else { periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty } - boxPanel.add(periodTextField); // add text to box - - // Rate + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodTextField, constraints); + boxPanel.add(periodTextField); + + listPeriodString = new String[3]; + listPeriodString[0] = "us"; + listPeriodString[1] = "ms"; + listPeriodString[2] = "s"; + periodComboBoxString = new JComboBox<String>(listPeriodString); + if (port.getTime().equals("") || port.getTime().equals("us")) { + periodComboBoxString.setSelectedIndex(0); + } else if (port.getTime().equals("ms")){ + periodComboBoxString.setSelectedIndex(1); + } else { + periodComboBoxString.setSelectedIndex(2); + } + periodComboBoxString.setActionCommand("time"); + periodComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodComboBoxString, constraints); + boxPanel.add(periodComboBoxString); + JLabel rateLabel = new JLabel("Rate : "); + constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateLabel, constraints); boxPanel.add(rateLabel); // add label to box - if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getRate() == -1) { // name empty rateTextField = new JTextField(10); } else { rateTextField = new JTextField("" + port.getRate(), 10); // name not empty } + constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateTextField, constraints); boxPanel.add(rateTextField); // add text to box - // Delay JLabel delayLabel = new JLabel("Delay : "); + constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayLabel, constraints); boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || delayTextField = new JTextField(10); } else { delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty } + constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayTextField, constraints); boxPanel.add(delayTextField); // add text to box - // Type JLabel typeLabel = new JLabel("Type : "); + constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeLabel, constraints); boxPanel.add(typeLabel); // add label to box + listTypeString = new String[3]; listTypeString[0] = "int"; listTypeString[1] = "bool"; @@ -182,11 +256,21 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } typeComboBoxString.setActionCommand("type"); typeComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 4, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeComboBoxString, constraints); boxPanel.add(typeComboBoxString); // add combo to box - // Origin JLabel orginLabel = new JLabel("Origin : "); + constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(orginLabel, constraints); boxPanel.add(orginLabel); // add label to box + listOriginString = new String[2]; listOriginString[0] = "Input"; listOriginString[1] = "Output"; @@ -198,6 +282,11 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } originComboBoxString.setActionCommand("origin"); originComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(originComboBoxString, constraints); boxPanel.add(originComboBoxString); // add combo to box box.add(boxPanel); // add border to box @@ -280,6 +369,7 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { port.setDelay(-1); } port.setDEType((String) typeComboBoxString.getSelectedItem()); + port.setTime((String) periodComboBoxString.getSelectedItem()); if ((String) originComboBoxString.getSelectedItem() == "Output") { port.setOrigin(1); diff --git a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java index 59f0a08f8cb68fa71e75f91fec35bebd127a7106..804dba8975b1718b3c6cbdcd198cc96041d68256 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java @@ -42,7 +42,11 @@ import ui.syscams.*; import ui.util.IconManager; import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -74,6 +78,8 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { /** Access to ActionPerformed **/ private JTextField nameTextField; private JTextField periodTextField; + private String listPeriodString[]; + private JComboBox<String> periodComboBoxString; private JTextField rateTextField; private JTextField delayTextField; private String listTypeString[]; @@ -119,53 +125,121 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting TDF port attributes")); - JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel boxPanel = new JPanel(); + boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + boxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + boxPanel.add(labelName); - JLabel labelName = new JLabel("Name : "); - boxPanel.add(labelName); - - if (port.getPortName().toString().equals("")) { // name empty + if (port.getPortName().toString().equals("")) { // name empty nameTextField = new JTextField(10); } else { nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty } + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + boxPanel.add(nameTextField); + + JLabel periodLabel = new JLabel("Period Tp : "); + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodLabel, constraints); + boxPanel.add(periodLabel); - boxPanel.add(nameTextField); - - // Period - JLabel periodLabel = new JLabel("Period Tp (us) : "); - boxPanel.add(periodLabel); // add label to box - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || periodTextField = new JTextField(10); } else { periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty } - boxPanel.add(periodTextField); // add text to box - - // Rate + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodTextField, constraints); + boxPanel.add(periodTextField); + + listPeriodString = new String[3]; + listPeriodString[0] = "us"; + listPeriodString[1] = "ms"; + listPeriodString[2] = "s"; + periodComboBoxString = new JComboBox<String>(listPeriodString); + if (port.getTime().equals("") || port.getTime().equals("us")) { + periodComboBoxString.setSelectedIndex(0); + } else if (port.getTime().equals("ms")){ + periodComboBoxString.setSelectedIndex(1); + } else { + periodComboBoxString.setSelectedIndex(2); + } + periodComboBoxString.setActionCommand("time"); + periodComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(periodComboBoxString, constraints); + boxPanel.add(periodComboBoxString); + JLabel rateLabel = new JLabel("Rate : "); + constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateLabel, constraints); boxPanel.add(rateLabel); // add label to box - if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getRate() == -1) { // name empty rateTextField = new JTextField(10); } else { rateTextField = new JTextField("" + port.getRate(), 10); // name not empty } + constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(rateTextField, constraints); boxPanel.add(rateTextField); // add text to box - // Delay JLabel delayLabel = new JLabel("Delay : "); + constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayLabel, constraints); boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || delayTextField = new JTextField(10); } else { delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty } + constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(delayTextField, constraints); boxPanel.add(delayTextField); // add text to box - // Type JLabel typeLabel = new JLabel("Type : "); + constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeLabel, constraints); boxPanel.add(typeLabel); // add label to box + listTypeString = new String[3]; listTypeString[0] = "int"; listTypeString[1] = "bool"; @@ -182,11 +256,21 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { } typeComboBoxString.setActionCommand("type"); typeComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 4, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(typeComboBoxString, constraints); boxPanel.add(typeComboBoxString); // add combo to box - - // Origin + JLabel orginLabel = new JLabel("Origin : "); + constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(orginLabel, constraints); boxPanel.add(orginLabel); // add label to box + listOriginString = new String[2]; listOriginString[0] = "Input"; listOriginString[1] = "Output"; @@ -198,6 +282,11 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { } originComboBoxString.setActionCommand("origin"); originComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); + gridBag.setConstraints(originComboBoxString, constraints); boxPanel.add(originComboBoxString); // add combo to box box.add(boxPanel); // add border to box @@ -280,7 +369,8 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { port.setDelay(-1); } port.setTDFType((String) typeComboBoxString.getSelectedItem()); - + port.setTime((String) periodComboBoxString.getSelectedItem()); + if ((String) originComboBoxString.getSelectedItem() == "Output") { port.setOrigin(1); } else {