Newer
Older
/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
* ludovic.apvrille AT telecom-paristech.fr
* andrea.enrici AT telecom-paristech.f
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
*
* 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 JDialogSystemCGeneration
* Dialog for managing the generation and compilation of SystemC code
* Creation: 01/12/2005
* @version 1.2 02/06/2014
* @author Ludovic APVRILLE, Andrea ENRICI
* @see
*/
package ui.window;
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import launcher.LauncherException;
import launcher.RshClient;
import myutil.FileUtils;
import myutil.GraphicLib;
import myutil.MasterProcessInterface;
import myutil.ScrolledJTextArea;
import myutil.TraceManager;
import req.ebrdd.EBRDD;
import tepe.TEPE;
import ui.AvatarRequirementPanelTranslator;
import ui.IconManager;
import ui.MainGUI;
import ui.avatarpd.AvatarPDPanel;
public class JDialogSystemCGeneration extends javax.swing.JDialog implements ActionListener, Runnable, MasterProcessInterface, ListSelectionListener {

Ludovic Apvrille
committed

Ludovic Apvrille
committed
private static String textSysC1 = "Generate SystemC code in";
private static String textSysC2 = "Compile SystemC code in";
//private String textSysC3 = "with";
private static String textSysC4 = "Run simulation to completion:";

Ludovic Apvrille
committed
private static String textSysC5 = "Run interactive simulation:";
private static String textSysC6 = "Run formal verification:";
private static String unitCycle = "1";

Ludovic Apvrille
committed
/*private static String[] simus = { "SystemC Simulator - LabSoC version",
"C++ Simulator - LabSoc version" };*/
private static String[] simus = { "C++ Simulator - LabSoc version" };
private static int selectedItem = 0;

Ludovic Apvrille
committed
protected static String pathCode;
protected static String pathCompiler;
protected static String pathExecute;

Ludovic Apvrille
committed
protected static String pathInteractiveExecute;
protected static String pathFormalExecute;
protected static boolean interactiveSimulationSelected = true;
protected static boolean optimizeModeSelected = true;
protected final static int NOT_STARTED = 1;
protected final static int STARTED = 2;
protected final static int STOPPED = 3;

Ludovic Apvrille
committed
//components
protected JTextArea jta;
protected JButton start;
protected JButton stop;
protected JButton close;

Ludovic Apvrille
committed
protected JRadioButton exe, exeint, exeformal;
protected ButtonGroup exegroup;
protected JTextField code1, code2, unitcycle, compiler1, exe1, exe2, exe3, exe2int, exe2formal;
protected JTabbedPane jp1;
protected JScrollPane jsp;
protected JCheckBox removeCppFiles, removeXFiles, debugmode, optimizemode;

Ludovic Apvrille
committed
protected JComboBox versionSimulator;
//EBRDD
/*private static Vector validated, ignored;
private Vector val, ign;
private JList listIgnored;
private JList listValidated;
private JButton allValidated;
private JButton addOneValidated;
private JButton addOneIgnored;
private JButton allIgnored;
private JPanel panele1, panele2, panele3, panele4, panel5, panel6;*/
//TEPED
private static Vector validatedTepe, ignoredTepe;
private Vector valTepe, ignTepe;
private JList listIgnoredTepe;
private JList listValidatedTepe;
private JButton allValidatedTepe;
private JButton addOneValidatedTepe;
private JButton addOneIgnoredTepe;
private JButton allIgnoredTepe;

Ludovic Apvrille
committed
private JPanel panele1Tepe, panele2Tepe, panele3Tepe, panele4Tepe, panel5Tepe, panel6Tepe;
private Thread t;
private boolean go = false;
//private ProcessThread pt;
private boolean hasError = false;

Ludovic Apvrille
committed
protected boolean startProcess = false;

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
// Automatic modes
public final static int MANUAL = 0;
public final static int ONE_TRACE = 1;
public final static int ANIMATION = 2;
public final static int FORMAL_VERIFICATION = 3;

Ludovic Apvrille
committed
private int automatic;

Ludovic Apvrille
committed
public JDialogSystemCGeneration(Frame f, MainGUI _mgui, String title, String _hostSystemC, String _pathCode, String _pathCompiler, String _pathExecute, String _pathInteractiveExecute, String _graphPath, int _automatic) {

Ludovic Apvrille
committed

Ludovic Apvrille
committed
if (pathCode == null) {
pathCode = _pathCode;
}

Ludovic Apvrille
committed
if (pathCompiler == null)
pathCompiler = _pathCompiler;

Ludovic Apvrille
committed
if (pathExecute == null)
pathExecute = _pathExecute;

Ludovic Apvrille
committed
if (pathInteractiveExecute == null) {
if (_graphPath != null) {
_pathInteractiveExecute += " -gpath " + _graphPath;
}
pathInteractiveExecute = _pathInteractiveExecute;

Ludovic Apvrille
committed
}
if (pathFormalExecute == null) {
pathFormalExecute = pathInteractiveExecute;
int index = pathFormalExecute.indexOf("-server");
if (index != -1) {
pathFormalExecute = pathFormalExecute.substring(0, index) + pathFormalExecute.substring(index+7, pathFormalExecute.length());
pathFormalExecute += " -explo";
}
}

Ludovic Apvrille
committed

Ludovic Apvrille
committed
makeLists();
initComponents();
myInitComponents();
pack();

Ludovic Apvrille
committed
//getGlassPane().addMouseListener( new MouseAdapter() {});
getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

Ludovic Apvrille
committed
if (automatic > 0) {

Ludovic Apvrille
committed
startProcess();
}
}
protected void makeLists() {
if (validatedTepe == null) {
validatedTepe = new Vector();
}
if (ignoredTepe == null) {
ignoredTepe = new Vector();
}
valTepe = new Vector();
ignTepe = new Vector();
ArrayList<AvatarPDPanel> al = mgui.getAllAvatarPDPanels();
for(AvatarPDPanel panel: al) {
if(validatedTepe.contains(panel)) {
valTepe.add(panel);
} else {
ignTepe.add(panel);
}

Ludovic Apvrille
committed
protected void myInitComponents() {
mode = NOT_STARTED;
setButtons();

Ludovic Apvrille
committed
setList();
updateInteractiveSimulation();

Ludovic Apvrille
committed

Ludovic Apvrille
committed
Container c = getContentPane();
setFont(new Font("Helvetica", Font.PLAIN, 14));
c.setLayout(new BorderLayout());
//setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
JPanel jp01 = new JPanel();
GridBagLayout gridbag01 = new GridBagLayout();
GridBagConstraints c01 = new GridBagConstraints();
jp01.setLayout(gridbag01);
jp01.setBorder(new javax.swing.border.TitledBorder("Code generation"));

Ludovic Apvrille
committed
JPanel jp02 = new JPanel();
GridBagLayout gridbag02 = new GridBagLayout();
GridBagConstraints c02 = new GridBagConstraints();
jp02.setLayout(gridbag02);
jp02.setBorder(new javax.swing.border.TitledBorder("Compilation"));

Ludovic Apvrille
committed
JPanel jp03 = new JPanel();
GridBagLayout gridbag03 = new GridBagLayout();
GridBagConstraints c03 = new GridBagConstraints();
jp03.setLayout(gridbag03);
jp03.setBorder(new javax.swing.border.TitledBorder("Execution"));

Ludovic Apvrille
committed
c01.gridheight = 1;
c01.weighty = 1.0;
c01.weightx = 1.0;
c01.gridwidth = GridBagConstraints.REMAINDER; //end row
c01.fill = GridBagConstraints.BOTH;
c01.gridheight = 1;

Ludovic Apvrille
committed
gen = new JLabel(textSysC1);
//genJava.addActionListener(this);
jp01.add(gen, c01);

Ludovic Apvrille
committed
code1 = new JTextField(pathCode, 100);
jp01.add(code1, c01);

Ludovic Apvrille
committed
jp01.add(new JLabel(" "), c01);
c01.gridwidth = GridBagConstraints.REMAINDER; //end row

Ludovic Apvrille
committed
c01.gridwidth = GridBagConstraints.REMAINDER; //end row
jp01.add(new JLabel("1 time unit = "), c01);

Ludovic Apvrille
committed
unitcycle = new JTextField(unitCycle, 10);
jp01.add(unitcycle, c01);

Ludovic Apvrille
committed
jp01.add(new JLabel("cycle"), c01);

Ludovic Apvrille
committed
removeCppFiles = new JCheckBox("Remove old .h / .cpp files");
removeCppFiles.setSelected(true);
jp01.add(removeCppFiles, c01);

Ludovic Apvrille
committed
removeXFiles = new JCheckBox("Remove old .x files");
removeXFiles.setSelected(true);
jp01.add(removeXFiles, c01);

Ludovic Apvrille
committed
debugmode = new JCheckBox("Put debug information in code");
debugmode.setSelected(false);
jp01.add(debugmode, c01);

Ludovic Apvrille
committed
optimizemode = new JCheckBox("Optimize code");
optimizemode.setSelected(optimizeModeSelected);
jp01.add(optimizemode, c01);

Ludovic Apvrille
committed
jp01.add(new JLabel("Simulator used:"), c01);
versionSimulator = new JComboBox(simus);
versionSimulator.setSelectedIndex(selectedItem);
versionSimulator.addActionListener(this);
jp01.add(versionSimulator, c01);
//System.out.println("selectedItem=" + selectedItem);
//devmode = new JCheckBox("Development version of the simulator");
//devmode.setSelected(true);
//jp01.add(devmode, c01);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
//EBRDDs
panele1Tepe = new JPanel();
panele1Tepe.setLayout(new BorderLayout());
panele1Tepe.setBorder(new javax.swing.border.TitledBorder("Ignored TEPE Diagrams"));
listIgnoredTepe = new JList(ignTepe);
//listIgnored.setPreferredSize(new Dimension(200, 250));
listIgnoredTepe.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
listIgnoredTepe.addListSelectionListener(this);
JScrollPane scrollPane1 = new JScrollPane(listIgnoredTepe);
panele1Tepe.add(scrollPane1, BorderLayout.CENTER);
panele1Tepe.setPreferredSize(new Dimension(200, 250));

Ludovic Apvrille
committed
// validated list
panele2Tepe = new JPanel();
panele2Tepe.setLayout(new BorderLayout());

Ludovic Apvrille
committed
panele2Tepe.setBorder(new javax.swing.border.TitledBorder("TEPE Diagrams taken into account"));
//listValidated.setPreferredSize(new Dimension(200, 250));
listValidatedTepe.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
listValidatedTepe.addListSelectionListener(this);
JScrollPane scrollPane2 = new JScrollPane(listValidatedTepe);
panele2Tepe.add(scrollPane2, BorderLayout.CENTER);
panele2Tepe.setPreferredSize(new Dimension(200, 250));

Ludovic Apvrille
committed
// central buttons

Ludovic Apvrille
committed
GridBagLayout gridbage1 = new GridBagLayout();
GridBagConstraints ce1 = new GridBagConstraints();

Ludovic Apvrille
committed
ce1.weighty = 1.0;
ce1.weightx = 1.0;
ce1.gridwidth = GridBagConstraints.REMAINDER; //end row
ce1.fill = GridBagConstraints.HORIZONTAL;
ce1.gridheight = 1;

Ludovic Apvrille
committed
allValidatedTepe = new JButton(IconManager.imgic50);
allValidatedTepe.setPreferredSize(new Dimension(50, 25));
allValidatedTepe.addActionListener(this);
allValidatedTepe.setActionCommand("allValidatedTepe");
panele3Tepe.add(allValidatedTepe, ce1);

Ludovic Apvrille
committed
addOneValidatedTepe = new JButton(IconManager.imgic48);
addOneValidatedTepe.setPreferredSize(new Dimension(50, 25));
addOneValidatedTepe.addActionListener(this);
addOneValidatedTepe.setActionCommand("addOneValidatedTepe");
panele3Tepe.add(addOneValidatedTepe, ce1);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
addOneIgnoredTepe = new JButton(IconManager.imgic46);
addOneIgnoredTepe.addActionListener(this);
addOneIgnoredTepe.setPreferredSize(new Dimension(50, 25));
addOneIgnoredTepe.setActionCommand("addOneIgnoredTepe");
panele3Tepe.add(addOneIgnoredTepe, ce1);

Ludovic Apvrille
committed
allIgnoredTepe = new JButton(IconManager.imgic44);
allIgnoredTepe.addActionListener(this);
allIgnoredTepe.setPreferredSize(new Dimension(50, 25));
allIgnoredTepe.setActionCommand("allIgnoredTepe");
panele3Tepe.add(allIgnoredTepe, ce1);

Ludovic Apvrille
committed
panele4Tepe = new JPanel();
panele4Tepe.setLayout(new BorderLayout());
panele4Tepe.add(panele1Tepe, BorderLayout.WEST);
panele4Tepe.add(panele2Tepe, BorderLayout.EAST);
panele4Tepe.add(panele3Tepe, BorderLayout.CENTER);
jp01.add(panele4Tepe, c01);
if (automatic > 0) {
//GraphicLib.enableComponents(jp01, false);

Ludovic Apvrille
committed
jp1.add("Generate code", jp01);

Ludovic Apvrille
committed
// Panel 02
c02.gridheight = 1;
c02.weighty = 1.0;
c02.weightx = 1.0;
c02.gridwidth = GridBagConstraints.REMAINDER; //end row
c02.fill = GridBagConstraints.BOTH;
c02.gridheight = 1;

Ludovic Apvrille
committed
comp = new JLabel(textSysC2);
//compJava.addActionListener(this);
jp02.add(comp, c02);

Ludovic Apvrille
committed
code2 = new JTextField(pathCode, 100);
jp02.add(code2, c02);

Ludovic Apvrille
committed
jp02.add(new JLabel("with"), c02);

Ludovic Apvrille
committed
compiler1 = new JTextField(pathCompiler, 100);
jp02.add(compiler1, c02);

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
// Panel 03
c03.gridheight = 1;
c03.weighty = 1.0;
c03.weightx = 1.0;
c03.gridwidth = GridBagConstraints.REMAINDER; //end row
c03.fill = GridBagConstraints.BOTH;
c03.gridheight = 1;

Ludovic Apvrille
committed
exegroup = new ButtonGroup();
exe = new JRadioButton(textSysC4, false);

Ludovic Apvrille
committed
exe.addActionListener(this);
exegroup.add(exe);
//exeJava.addActionListener(this);
jp03.add(exe, c03);

Ludovic Apvrille
committed
exe2 = new JTextField(pathExecute, 100);
jp03.add(exe2, c02);

Ludovic Apvrille
committed
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);

Ludovic Apvrille
committed
exeformal = new JRadioButton(textSysC6, true);

Ludovic Apvrille
committed
exeformal.addActionListener(this);
exegroup.add(exeformal);
jp03.add(exeformal, c03);
exe2formal = new JTextField(pathFormalExecute, 100);
jp03.add(exe2formal, c02);

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
if (automatic > 0) {

Ludovic Apvrille
committed
//GraphicLib.enableComponents(jp03, false);
GraphicLib.enableComponents(jp1, false);

Ludovic Apvrille
committed
jta = new ScrolledJTextArea();
jta.setEditable(false);
jta.setMargin(new Insets(10, 10, 10, 10));
jta.setTabSize(3);
if (automatic == 0) {

Ludovic Apvrille
committed
jta.append("Select options and then, click on 'start' to launch SystemC code generation / compilation\n");
Font f = new Font("Courrier", Font.BOLD, 12);
jta.setFont(f);
jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
start = new JButton("Start", IconManager.imgic53);
stop = new JButton("Stop", IconManager.imgic55);
start.setPreferredSize(new Dimension(100, 30));
stop.setPreferredSize(new Dimension(100, 30));
start.addActionListener(this);
stop.addActionListener(this);
close = new JButton("Close", IconManager.imgic27);
close.setPreferredSize(new Dimension(100, 30));

Ludovic Apvrille
committed
if (automatic == 0) {

Ludovic Apvrille
committed
jp2.add(start);
jp2.add(stop);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
}
public void updateInteractiveSimulation() {
if (automatic == 0) {
exe2.setEnabled(exe.isSelected());
exe2int.setEnabled(exeint.isSelected());
exe2formal.setEnabled(exeformal.isSelected());
}

Ludovic Apvrille
committed
public void actionPerformed(ActionEvent evt) {
String command = evt.getActionCommand();
//System.out.println("Actions");

Ludovic Apvrille
committed
// Compare the action command to the known actions.

Ludovic Apvrille
committed
updateInteractiveSimulation();
if (command.equals("Start")) {
startProcess();
} else if (command.equals("Stop")) {
stopProcess();
} else if (command.equals("Close")) {
closeDialog();
} else if (command.equals("addOneIgnoredTepe")) {
addOneIgnoredTepe();
} else if (command.equals("addOneValidatedTepe")) {
addOneValidatedTepe();
} else if (command.equals("allValidatedTepe")) {
allValidatedTepe();
} else if (command.equals("allIgnoredTepe")) {
allIgnoredTepe();

Ludovic Apvrille
committed
selectedItem = versionSimulator.getSelectedIndex();
}

Ludovic Apvrille
committed
public void closeDialog() {
if (mode == STARTED) {
stopProcess();
}

Ludovic Apvrille
committed
updateStaticList();
optimizeModeSelected = optimizemode.isSelected();
wasClosed = true;

Ludovic Apvrille
committed

Ludovic Apvrille
committed
return wasClosed;

Ludovic Apvrille
committed
public void stopProcess() {
try {
rshc.stopFillJTA();
} catch (LauncherException le) {

Ludovic Apvrille
committed

Ludovic Apvrille
committed
mode = STOPPED;
setButtons();
go = false;
}

Ludovic Apvrille
committed

Ludovic Apvrille
committed
if (automatic > 0) {
startProcess = false;
t = new Thread(this);
mode = STARTED;
go = true;
t.start();
} else {
/*if ((interactiveSimulationSelected) && (jp1.getSelectedIndex() == 2)) {
startProcess = true;
dispose();
} else {*/
startProcess = false;
t = new Thread(this);
mode = STARTED;
setButtons();
go = true;
t.start();
//}
}

Ludovic Apvrille
committed
private void testGo() throws InterruptedException {
if (go == false) {
throw new InterruptedException("Stopped by user");
}
}

Ludovic Apvrille
committed
// String cmd;
// String data;

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
if (automatic > 0) {
generateCode();
testGo();
compileCode();
testGo();
executeSimulation();
} else {
// Code generation
if (jp1.getSelectedIndex() == 0) {
generateCode();
}
testGo();
// Compilation
if (jp1.getSelectedIndex() == 1) {
compileCode();
}
if (jp1.getSelectedIndex() == 2) {
executeSimulation();
}
if ((hasError == false) && (jp1.getSelectedIndex() < 2)) {
jp1.setSelectedIndex(jp1.getSelectedIndex() + 1);
}

Ludovic Apvrille
committed
} catch (InterruptedException ie) {
jta.append("Interrupted\n");
}

Ludovic Apvrille
committed
jta.append("\n\nReady to process next command\n");

Ludovic Apvrille
committed

Ludovic Apvrille
committed
//System.out.println("Selected item=" + selectedItem);

Ludovic Apvrille
committed
private void generateCode() throws InterruptedException {

Ludovic Apvrille
committed
String list;

Ludovic Apvrille
committed
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
jta.append("Generating SystemC code\n");
if (removeCppFiles.isSelected()) {
jta.append("Removing all old h files\n");
list = FileUtils.deleteFiles(code1.getText(), ".h");
if (list.length() == 0) {
jta.append("No files were deleted\n");
} else {
jta.append("Files deleted:\n" + list + "\n");
}
jta.append("Removing all old cpp files\n");
list = FileUtils.deleteFiles(code1.getText(), ".cpp");
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 old 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();
try {
unitCycle = unitcycle.getText();
// cycle = Integer.valueOf(unitCycle).intValue();

Ludovic Apvrille
committed
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
} catch (Exception e) {
jta.append("Wrong number of cycles: " + unitcycle.getText());
jta.append("Aborting");
jta.append("\n\nReady to process next command\n");
checkMode();
setButtons();
return;
}
/*TML2SystemC tml2systc = new TML2SystemC(mgui.gtm.getTMLModeling());
tml2systc.generateSystemC(debugmode.isSelected());
testGo();
jta.append("SystemC code generation done\n");
//t2j.printJavaClasses();
try {
jta.append("Generating SystemC file\n");
pathCode = code1.getText();
tml2systc.saveFile(pathCode, "appmodel");
jta.append("SystemC file generated\n");
} catch (Exception e) {
jta.append("Could not generate SystemC file\n");
}*/
selectedItem = versionSimulator.getSelectedIndex();
//System.out.println("Selected item=" + selectedItem);
switch( selectedItem ) { //Old SystemC generator
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
/*case 0: {
tmltranslator.tomappingsystemc.TML2MappingSystemC tml2systc;
if (mgui.gtm.getTMLMapping() == null) {
if (mgui.gtm.getArtificialTMLMapping() == null) {
tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getTMLModeling());
} else {
TraceManager.addDev("Using artifical mapping");
tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getArtificialTMLMapping());
}
}
else {
tml2systc = new tmltranslator.tomappingsystemc.TML2MappingSystemC(mgui.gtm.getTMLMapping());
}
tml2systc.generateSystemC(debugmode.isSelected(), optimizemode.isSelected());
testGo();
jta.append("SystemC code generation done\n");
//t2j.printJavaClasses();
try {
jta.append("Generating SystemC file\n");
pathCode = code1.getText();
tml2systc.saveFile(pathCode, "appmodel");
jta.append("SystemC files generated\n");
}
catch( Exception e ) {
jta.append("Could not generate SystemC file\n");
}
break;
}*/
case 0: { //Simulator without CPs (Daniel's version)

Ludovic Apvrille
committed
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
tmltranslator.tomappingsystemc2.TML2MappingSystemC tml2systc;
// Making EBRDDs
ArrayList<EBRDD> al = new ArrayList<EBRDD>();
ArrayList<TEPE> alTepe = new ArrayList<TEPE>();
TEPE tepe;
AvatarRequirementPanelTranslator arpt = new AvatarRequirementPanelTranslator();
for(int k=0; k<valTepe.size(); k++) {
testGo();
tepe = arpt.generateTEPESpecification((AvatarPDPanel)(valTepe.get(k)));
jta.append("TEPE: " + tepe.getName() + "\n");
jta.append("Checking syntax\n");
// tepe.checkSyntax();
alTepe.add(tepe);
jta.append("Done.\n");
}
/*EBRDDTranslator ebrddt;
EBRDDPanel ep;
EBRDD ebrdd;
for(int k=0; k<val.size(); k++) {
testGo();
ebrddt = new EBRDDTranslator();
ep = (EBRDDPanel)(val.get(k));
jta.append("EBRDD: " + ep.getName() + "\n");
ebrdd = ebrddt.generateEBRDD(ep, ep.getName());
jta.append("Checking syntax\n");
if (ebrddt.getErrors().size() > 0) {
jta.append("Syntax error: ignoring EBRDD\n\n");
} else {
jta.append("No Syntax error: EBRDD taken into account\n\n");
al.add(ebrdd);
}
}*/
// Generating code
if (mgui.gtm.getTMLMapping() == null) {
if (mgui.gtm.getArtificialTMLMapping() == null) {
tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getTMLModeling(), al, alTepe);
} else {
TraceManager.addDev("Using artifical mapping");
tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getArtificialTMLMapping(), al, alTepe);
}
} else {
tml2systc = new tmltranslator.tomappingsystemc2.TML2MappingSystemC(mgui.gtm.getTMLMapping(), al, alTepe);
}

Ludovic Apvrille
committed
tml2systc.generateSystemC(debugmode.isSelected(), optimizemode.isSelected());
testGo();
jta.append("SystemC code generation done\n");
for(TEPE tep: alTepe) {
TraceManager.addDev(tep.toString());
}
//t2j.printJavaClasses();
try {
jta.append("Generating SystemC file\n");
pathCode = code1.getText();
tml2systc.saveFile(pathCode, "appmodel");
jta.append("SystemC files generated\n");
} catch (Exception e) {
jta.append("Could not generate SystemC file\n");
}
break;
}
}
} //End of method generateCode()
public void compileCode() throws InterruptedException {

Ludovic Apvrille
committed
String cmd = compiler1.getText();
jta.append("Compiling SystemC code with command: \n" + cmd + "\n");
rshc = new RshClient(hostSystemC);
// Assuma data are on the remote host
// Command
try {
processCmd(cmd, jta);
if (jta.getText().contains("Error ")){
mode = ERROR;
setButtons();
return;
}

Ludovic Apvrille
committed
//jta.append(data);
jta.append("Compilation done\n");

Ludovic Apvrille
committed
} catch (LauncherException le) {
jta.append("Error: " + le.getMessage() + "\n");
mode = STOPPED;
setButtons();
return;
} catch (Exception e) {
mode = STOPPED;
setButtons();
return;
}

Ludovic Apvrille
committed
public void executeSimulation() throws InterruptedException {

Ludovic Apvrille
committed
if (hasError) {
jta.append("Simulation not executed: error");
return;
}
int toDo = automatic;
if (toDo == 0) {
if (exe.isSelected()) {
toDo = ONE_TRACE;
} else if (exeint.isSelected()) {
toDo = ANIMATION;
} else {
toDo = FORMAL_VERIFICATION;
}
}

Ludovic Apvrille
committed
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
switch(toDo) {
case ONE_TRACE:
executeSimulationCmd(exe2.getText(), "Generating one simulation trace");
break;
case ANIMATION:
dispose();
mgui.interactiveSimulationSystemC(getPathInteractiveExecute());
break;
case FORMAL_VERIFICATION:
executeSimulationCmd(exe2formal.getText(), "Running formal verification");
break;
}
}
public void executeSimulationCmd(String cmd, String text) throws InterruptedException {
try {
jta.append(text + " with command: \n" + cmd + "\n");
rshc = new RshClient(hostSystemC);
// It assumes that data are on the remote host
// Command
processCmd(cmd, jta);
//jta.append(data);
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;
}
}

Ludovic Apvrille
committed
protected void processCmd(String cmd, JTextArea _jta) throws LauncherException {
rshc.setCmd(cmd);
String s = null;
rshc.sendProcessRequest();

Ludovic Apvrille
committed
rshc.fillJTA(_jta);

Ludovic Apvrille
committed
//s = rshc.getDataFromProcess();
//return s;
return;

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
if (automatic == 0) {
switch(mode) {
case NOT_STARTED:
start.setEnabled(true);
stop.setEnabled(false);
close.setEnabled(true);
//setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
getGlassPane().setVisible(false);
break;
case STARTED:
start.setEnabled(false);
stop.setEnabled(true);
close.setEnabled(false);
getGlassPane().setVisible(true);
//setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
break;
case STOPPED:
break;
case ERROR:
start.setEnabled(false);
stop.setEnabled(false);
close.setEnabled(true);
break;

Ludovic Apvrille
committed
default:
start.setEnabled(false);
stop.setEnabled(false);