diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java index f6d04675b8998798e797ec0c4bc40faddfd466e0..41ea6420f37be16a138c5fc3b0ba1b4755c00466 100644 --- a/src/main/java/syscamstranslator/SysCAMSSpecification.java +++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java @@ -47,26 +47,26 @@ import java.util.List; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE -*/ + */ public class SysCAMSSpecification{ - private List<SysCAMSTComponent> components; - private List<SysCAMSTConnector> connectors; - - public SysCAMSSpecification(List<SysCAMSTComponent> _components, List<SysCAMSTConnector> _connectors){ + private List<SysCAMSTComponent> components; + private List<SysCAMSTConnector> connectors; + + public SysCAMSSpecification(List<SysCAMSTComponent> _components, List<SysCAMSTConnector> _connectors){ components = _components ; connectors = _connectors ; } - - public List<SysCAMSTComponent> getComponents(){ - return components; - } - public List<SysCAMSTConnector> getConnectors(){ - return connectors; - } + public List<SysCAMSTComponent> getComponents(){ + return components; + } + + public List<SysCAMSTConnector> getConnectors(){ + return connectors; + } - public LinkedList<SysCAMSTBlockTDF> getAllBlockTDF(){ + public LinkedList<SysCAMSTBlockTDF> getAllBlockTDF(){ LinkedList<SysCAMSTBlockTDF> blocksTDF = new LinkedList<SysCAMSTBlockTDF>(); for (SysCAMSTComponent blockTDF : components) { if (blockTDF instanceof SysCAMSTBlockTDF) { @@ -74,121 +74,116 @@ public class SysCAMSSpecification{ } } return blocksTDF; - } - - public LinkedList<SysCAMSTBlockDE> getAllBlockDE(){ - LinkedList<SysCAMSTBlockDE> blocksDE = new LinkedList<SysCAMSTBlockDE>(); - for (SysCAMSTComponent blockDE : components) { - if (blockDE instanceof SysCAMSTBlockDE) { - blocksDE.add((SysCAMSTBlockDE) blockDE); - } - } - return blocksDE; - } - - public LinkedList<SysCAMSTBlockGPIO2VCI> getAllBlockGPIO2VCI(){ - LinkedList<SysCAMSTBlockGPIO2VCI> blocksGPIO2VCI = new LinkedList<SysCAMSTBlockGPIO2VCI>(); - for (SysCAMSTComponent blockGPIO2VCI : components) { - if (blockGPIO2VCI instanceof SysCAMSTBlockGPIO2VCI) { - blocksGPIO2VCI.add((SysCAMSTBlockGPIO2VCI) blockGPIO2VCI); - } - } - return blocksGPIO2VCI; - } - - public LinkedList<SysCAMSTCluster> getAllCluster(){ - LinkedList<SysCAMSTCluster> clusters = new LinkedList<SysCAMSTCluster>(); - for (SysCAMSTComponent cluster : components) { - if (cluster instanceof SysCAMSTCluster) { - clusters.add((SysCAMSTCluster) cluster); - } - } - return clusters; - } - - public LinkedList<SysCAMSTPortConverter> getAllPortConverter(){ - LinkedList<SysCAMSTPortConverter> portsConv = new LinkedList<SysCAMSTPortConverter>(); - for (SysCAMSTComponent portConv : components) { - if (portConv instanceof SysCAMSTPortConverter) { - portsConv.add((SysCAMSTPortConverter) portConv); - } - } - return portsConv; - } - - public LinkedList<SysCAMSTPortTDF> getAllPortTDF(){ - LinkedList<SysCAMSTPortTDF> portsTDF = new LinkedList<SysCAMSTPortTDF>(); - for (SysCAMSTComponent portTDF : components) { - if (portTDF instanceof SysCAMSTPortTDF) { - portsTDF.add((SysCAMSTPortTDF) portTDF); - } - } - return portsTDF; - } - - public LinkedList<SysCAMSTPortDE> getAllPortDE(){ - LinkedList<SysCAMSTPortDE> portsDE = new LinkedList<SysCAMSTPortDE>(); - for (SysCAMSTComponent portDE : components) { - if (portDE instanceof SysCAMSTPortDE) { - portsDE.add((SysCAMSTPortDE) portDE); - } - } - return portsDE; - } - - public LinkedList<SysCAMSTConnector> getAllConnectorCluster(){ - LinkedList<SysCAMSTConnector> cons = new LinkedList<SysCAMSTConnector>(); - for (SysCAMSTConnector con : connectors) { - if (con instanceof SysCAMSTConnector) { - if (con.get_p1().getComponent() instanceof SysCAMSTPortTDF && con.get_p2().getComponent() instanceof SysCAMSTPortTDF) { - cons.add(con); - } else if (con.get_p1().getComponent() instanceof SysCAMSTPortConverter && con.get_p2().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE() != null) { - if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { - cons.add(con); - } - } - } else if (con.get_p2().getComponent() instanceof SysCAMSTPortConverter && con.get_p1().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE() != null) { - if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { - cons.add(con); - } - } - } - } - } - return cons; - } - - public int getNbBlockTDF(){ - return (getAllBlockTDF()).size(); - } - - public int getNbBlockDE(){ - return (getAllBlockDE()).size(); - } - - public int getNbBlockGPIO2VCI(){ - return (getAllBlockGPIO2VCI()).size(); - } - - public int getNbCluster(){ - return (getAllCluster()).size(); - } - - public int getNbPortConverter(){ - return (getAllPortConverter()).size(); - } - - public int getNbPortTDF(){ - return (getAllPortTDF()).size(); - } - - public int getNbPortDE(){ - return (getAllPortDE()).size(); - } - - public int getNbConnectorCluster(){ - return (getAllConnectorCluster()).size(); - } + } + + public LinkedList<SysCAMSTBlockDE> getAllBlockDE(){ + LinkedList<SysCAMSTBlockDE> blocksDE = new LinkedList<SysCAMSTBlockDE>(); + for (SysCAMSTComponent blockDE : components) { + if (blockDE instanceof SysCAMSTBlockDE) { + blocksDE.add((SysCAMSTBlockDE) blockDE); + } + } + return blocksDE; + } + + public LinkedList<SysCAMSTBlockGPIO2VCI> getAllBlockGPIO2VCI(){ + LinkedList<SysCAMSTBlockGPIO2VCI> blocksGPIO2VCI = new LinkedList<SysCAMSTBlockGPIO2VCI>(); + for (SysCAMSTComponent blockGPIO2VCI : components) { + if (blockGPIO2VCI instanceof SysCAMSTBlockGPIO2VCI) { + blocksGPIO2VCI.add((SysCAMSTBlockGPIO2VCI) blockGPIO2VCI); + } + } + return blocksGPIO2VCI; + } + + public SysCAMSTCluster getCluster(){ + for (SysCAMSTComponent comp : components) { + if (comp instanceof SysCAMSTCluster) { + return (SysCAMSTCluster) comp; + } + } + return null; + } + + public LinkedList<SysCAMSTPortConverter> getAllPortConverter(){ + LinkedList<SysCAMSTPortConverter> portsConv = new LinkedList<SysCAMSTPortConverter>(); + for (SysCAMSTComponent portConv : components) { + if (portConv instanceof SysCAMSTPortConverter) { + portsConv.add((SysCAMSTPortConverter) portConv); + } + } + return portsConv; + } + + public LinkedList<SysCAMSTPortTDF> getAllPortTDF(){ + LinkedList<SysCAMSTPortTDF> portsTDF = new LinkedList<SysCAMSTPortTDF>(); + for (SysCAMSTComponent portTDF : components) { + if (portTDF instanceof SysCAMSTPortTDF) { + portsTDF.add((SysCAMSTPortTDF) portTDF); + } + } + return portsTDF; + } + + public LinkedList<SysCAMSTPortDE> getAllPortDE(){ + LinkedList<SysCAMSTPortDE> portsDE = new LinkedList<SysCAMSTPortDE>(); + for (SysCAMSTComponent portDE : components) { + if (portDE instanceof SysCAMSTPortDE) { + portsDE.add((SysCAMSTPortDE) portDE); + } + } + return portsDE; + } + + public LinkedList<SysCAMSTConnector> getAllConnectorCluster(){ + LinkedList<SysCAMSTConnector> cons = new LinkedList<SysCAMSTConnector>(); + for (SysCAMSTConnector con : connectors) { + if (con instanceof SysCAMSTConnector) { + if (con.get_p1().getComponent() instanceof SysCAMSTPortTDF && con.get_p2().getComponent() instanceof SysCAMSTPortTDF) { + cons.add(con); + } else if (con.get_p1().getComponent() instanceof SysCAMSTPortConverter && con.get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE() != null) { + if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { + cons.add(con); + } + } + } else if (con.get_p2().getComponent() instanceof SysCAMSTPortConverter && con.get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE() != null) { + if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { + cons.add(con); + } + } + } + } + } + return cons; + } + + public int getNbBlockTDF(){ + return (getAllBlockTDF()).size(); + } + + public int getNbBlockDE(){ + return (getAllBlockDE()).size(); + } + + public int getNbBlockGPIO2VCI(){ + return (getAllBlockGPIO2VCI()).size(); + } + + public int getNbPortConverter(){ + return (getAllPortConverter()).size(); + } + + public int getNbPortTDF(){ + return (getAllPortTDF()).size(); + } + + public int getNbPortDE(){ + return (getAllPortDE()).size(); + } + + public int getNbConnectorCluster(){ + return (getAllConnectorCluster()).size(); + } } \ No newline at end of file diff --git a/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java b/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java index 0f5dd750dda66fbc965b8639a373074f424e039e..6080c5e4dd30844b5e12be61e623727f1f168627 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java @@ -50,46 +50,64 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class MakefileCode - * Principal code of a makefile - * Creation: 02/06/2018 + * Class MakefileCode Principal code of a makefile Creation: 02/06/2018 + * * @version 1.0 02/06/2018 * @author Irina Kit Yan LEE -*/ + */ public class MakefileCode { static private String corpsMakefile; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - MakefileCode() {} + MakefileCode() { + } - public static String getMakefileCode(SysCAMSTCluster cluster) { - if (cluster != null) { - LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF(); - LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE(); - - corpsMakefile = "# Compiler and linker flags" + CR + "CXXFLAGS = -g -Wall -I. $(SYSTEMC_INCLUDE_DIRS)" + CR + public static String getMakefileCode(LinkedList<SysCAMSTCluster> clusters) { + if (clusters != null) { + corpsMakefile = "# Compiler and linker flags" + CR + "CXXFLAGS = -g -Wall -I. $(SYSTEMC_INCLUDE_DIRS)" + CR + "LDFLAGS = $(SYSTEMC_LIBRARY_DIRS)" + CR2 + "# List of all ecutables to be compiled" + CR - + "EXECUTABLES = " + cluster.getClusterName() + "_tb" + CR2 + "# .PHONY targets don't generate files" + CR - + ".PHONY: all clean" + CR2 + "# Default targets" + CR + "all: $(EXECUTABLES)" + CR2; - - corpsMakefile = corpsMakefile + cluster.getClusterName() + "_tb: " + cluster.getClusterName() + "_tb.cpp"; - - for (SysCAMSTBlockTDF t : tdf) { - corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + + "EXECUTABLES = "; + + for (int i = 0; i < clusters.size(); i++) { + if (i == 0) { + corpsMakefile = corpsMakefile + clusters.get(i).getClusterName() + "_tb"; + } + if (i > 0) { + corpsMakefile = corpsMakefile + " " + clusters.get(i).getClusterName() + "_tb"; + } + if (i == clusters.size() - 1) { + corpsMakefile = corpsMakefile + CR2; + } } - - for (SysCAMSTBlockDE t : de) { - corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + + corpsMakefile = corpsMakefile + "# .PHONY targets don't generate files" + CR + ".PHONY: all clean" + CR2 + + "# Default targets" + CR + "all: $(EXECUTABLES)" + CR2; + + for (int i = 0; i < clusters.size(); i++) { + LinkedList<SysCAMSTBlockTDF> tdf = clusters.get(i).getBlockTDF(); + LinkedList<SysCAMSTBlockDE> de = clusters.get(i).getBlockDE(); + + corpsMakefile = corpsMakefile + clusters.get(i).getClusterName() + "_tb: " + + clusters.get(i).getClusterName() + "_tb.cpp"; + + for (SysCAMSTBlockTDF t : tdf) { + corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + } + + for (SysCAMSTBlockDE t : de) { + corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + } + corpsMakefile = corpsMakefile + CR + + "\t$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lsystemc-ams -lsystemc | c++filt" + CR2; } - - corpsMakefile = corpsMakefile + CR + "\t$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lsystemc-ams -lsystemc | c++filt" - + CR2 + "# Clean rule to delete temporary and generated files" + CR + "clean:" + CR - + "\trm -rf *~ *.o *.dat *.vcd *.dSYM $(EXECUTABLES)" + CR; + + corpsMakefile = corpsMakefile + "# Clean rule to delete temporary and generated files" + CR + "clean:" + CR + + "\trm -rf *~ *.o *.dat *.vcd *.dSYM $(EXECUTABLES)" + CR; } else { corpsMakefile = ""; } return corpsMakefile; } -} +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java index 0c3dc7e3da0277dd6bee0c57814163f8bf458175..bdd086cb14809db39231753ad3e2768ddb88af3c 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java +++ b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java @@ -47,7 +47,6 @@ package syscamstranslator.toSysCAMS; import syscamstranslator.*; - import java.io.*; import java.util.LinkedList; @@ -70,7 +69,7 @@ public class TopCellGenerator { } public String generateTopCell(SysCAMSTCluster c, LinkedList<SysCAMSTConnector> connectors) { - if (TopCellGenerator.syscams.getNbCluster() == 0) { + if (c == null) { System.out.println("***Warning: require at least one cluster***"); } if (TopCellGenerator.syscams.getNbBlockTDF() == 0) { @@ -96,35 +95,23 @@ public class TopCellGenerator { } public void saveFile(String path) { - LinkedList<SysCAMSTCluster> clusters = TopCellGenerator.syscams.getAllCluster(); + SysCAMSTCluster cluster = TopCellGenerator.syscams.getCluster(); LinkedList<SysCAMSTConnector> connectors = TopCellGenerator.syscams.getAllConnectorCluster(); - - String top, makefile; - - for (SysCAMSTCluster c : clusters) { - try { - // Save file .cpp - System.err.println(path + GENERATED_PATH1 + c.getClusterName() + ".cpp"); - FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + c.getClusterName() + "_tb.cpp"); - top = generateTopCell(c, connectors); - fw.write(top); - fw.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - try { - // Save Makefile - System.err.println(path + "Makefile"); - FileWriter fw = new FileWriter(path + "/" + "Makefile"); - makefile = MakefileCode.getMakefileCode(c); - fw.write(makefile); - fw.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - // Save files .h - saveFileBlock(path, c); + + String top; + + try { + // Save file .cpp + System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + ".cpp"); + FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tb.cpp"); + top = generateTopCell(cluster, connectors); + fw.write(top); + fw.close(); + } catch (Exception ex) { + ex.printStackTrace(); } + // Save files .h + saveFileBlock(path, cluster); } public void saveFileBlock(String path, SysCAMSTCluster c) { diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 434d751cf435b125396f8bf2ec95ed5e4ec1f565..891aa6172d0fe629ba288660a992fcb9f4e6699b 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -8582,18 +8582,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return null; } } - - public SysCAMSComponentTaskDiagramPanel getFirstSysCAMSPanelFound() { - SysCAMSComponentTaskDiagramPanel syscamsdp = null; - for (int i = 0; i < tabs.size(); i++) - if (tabs.get(i) instanceof SysCAMSComponentDesignPanel) { - syscamsdp = ((SysCAMSComponentDesignPanel) tabs.get(i)).syscamsctdp; - } - if (syscamsdp == null) - System.err.println("No SysCAMS Panel Found : MainGUI.getFirstSysCAMSPanelFound()"); - return syscamsdp; - } - + public void syscamsExecutableCodeGeneration() { JDialogSysCAMSExecutableCodeGeneration jgen = new JDialogSysCAMSExecutableCodeGeneration(frame, this, "Executable Code generation, compilation and execution", "../SysCAMSGenerationCode/"); diff --git a/src/main/java/ui/eln/ELNConnector.java b/src/main/java/ui/eln/ELNConnector.java index 48e032c174af85d7b0a2978e5e09755651435f4c..a37827b45e32aaeaed388f8e11bdf668f0d6cb3c 100644 --- a/src/main/java/ui/eln/ELNConnector.java +++ b/src/main/java/ui/eln/ELNConnector.java @@ -39,74 +39,86 @@ package ui.eln; import ui.*; -import ui.eln.sca_eln.ELNComponentIndependentVoltageSource; import ui.util.IconManager; - +import ui.window.JDialogELNConnector; import java.awt.*; -import java.util.ArrayList; -import java.util.Vector; +import java.util.*; +import javax.swing.JFrame; /** - * Class ELNConnector - * Connector used in ELN diagrams + * Class ELNConnector + * Connector used in ELN diagrams * Creation: 11/06/2018 * @version 1.0 11/06/2018 * @author Irina Kit Yan LEE */ -public class ELNConnector extends TGConnector implements ScalableTGComponent { - +public class ELNConnector extends TGConnector implements ScalableTGComponent { protected double oldScaleFactor; - protected int c = 10; //square length - - public ELNConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { - super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); - myImageIcon = IconManager.imgic202; - value = "Connector between ports"; - editable = false; - oldScaleFactor = tdp.getZoom(); - p1 = _p1; - p2 = _p2; - } - - public TGConnectingPoint get_p1(){ - return p1; + + public ELNConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + + myImageIcon = IconManager.imgic202; + value = ""; + editable = true; + oldScaleFactor = tdp.getZoom(); + + p1 = _p1; + p2 = _p2; + } + + public TGConnectingPoint get_p1() { + return p1; + } + + public TGConnectingPoint get_p2() { + return p2; + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogELNConnector jde = new JDialogELNConnector(this); + jde.setVisible(true); + return true; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { + int w = g.getFontMetrics().stringWidth(value); + Font fold = g.getFont(); + Font f = fold.deriveFont(Font.ITALIC, (float) (tdp.getFontSize())); + g.setFont(f); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2); + g.setFont(fold); + + g.drawLine(x1, y1, x2, y2); + } + + public void rescale(double scaleFactor) { + int xx, yy; + + for (int i = 0; i < nbInternalTGComponent; i++) { + xx = tgcomponent[i].getX(); + yy = tgcomponent[i].getY(); + tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor; + tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor; + xx = (int) (tgcomponent[i].dx); + tgcomponent[i].dx = tgcomponent[i].dx - xx; + yy = (int) (tgcomponent[i].dy); + tgcomponent[i].dy = tgcomponent[i].dy - yy; + tgcomponent[i].setCd(xx, yy); + } + oldScaleFactor = scaleFactor; } - public TGConnectingPoint get_p2(){ - return p2; + public int getType() { + return TGComponentManager.ELN_CONNECTOR; } - protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2) { - g.drawLine(x1, y1, x2, y2); - } - - public void rescale(double scaleFactor){ - int xx, yy; - - for(int i=0; i<nbInternalTGComponent; i++) { - xx = tgcomponent[i].getX(); - yy = tgcomponent[i].getY(); - tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor; - tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor; - xx = (int)(tgcomponent[i].dx); - tgcomponent[i].dx = tgcomponent[i].dx - xx; - yy = (int)(tgcomponent[i].dy); - tgcomponent[i].dy = tgcomponent[i].dy - yy; - tgcomponent[i].setCd(xx, yy); - } - oldScaleFactor = scaleFactor; - } - - public int getType() { - return TGComponentManager.ELN_CONNECTOR; - } - public java.util.List<ELNMidPortTerminal> getAllMidPortTerminal() { java.util.List<ELNMidPortTerminal> list = new ArrayList<ELNMidPortTerminal>(); - for(int i=0; i<nbInternalTGComponent; i++) { + for (int i = 0; i < nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof ELNMidPortTerminal) { - list.add((ELNMidPortTerminal)(tgcomponent[i])); + list.add((ELNMidPortTerminal) (tgcomponent[i])); } } return list; diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java index f2072a66a16df8495b07b94c0bc03e2072b69335..9b5b5bffb497041d88b350ca3d5e3eb950ca7277 100644 --- a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java +++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java @@ -401,6 +401,9 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple case '>' : buffer.append(">"); break; + case '\u03BC': + buffer.append("μ"); + break; default : buffer.append(databuf.charAt(pos)); break; diff --git a/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java index 82286b763bf2e173bbd907073539d00ca417ee07..b87a16a33582dd67bc8a589270813f55afd4706a 100644 --- a/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java +++ b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java @@ -38,11 +38,13 @@ package ui.window; +import syscamstranslator.toSysCAMS.MakefileCode; import syscamstranslator.toSysCAMS.TopCellGenerator; import launcher.LauncherException; import launcher.RshClient; import myutil.*; import syscamstranslator.SysCAMSSpecification; +import syscamstranslator.SysCAMSTCluster; import ui.util.IconManager; import ui.MainGUI; import ui.SysCAMSPanelTranslator; @@ -52,8 +54,11 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.FileWriter; import java.io.StringWriter; import java.io.Writer; +import java.util.LinkedList; +import java.util.Vector; /** * Class JDialogSysCAMSExecutableCodeGeneration @@ -500,38 +505,56 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i if (jp1.getSelectedIndex() == 0) { jta.append("Generating executable code (SystemC-AMS 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(); - } + Vector<SysCAMSComponentTaskDiagramPanel> syscamsDiagramPanels = mgui.getListSysCAMSPanel(); + LinkedList<SysCAMSTCluster> clusters = new LinkedList<SysCAMSTCluster>(); + for (SysCAMSComponentTaskDiagramPanel syscamsDiagramPanel : syscamsDiagramPanels) { + SysCAMSPanelTranslator syscamspaneltranslator = new SysCAMSPanelTranslator(syscamsDiagramPanel); + SysCAMSSpecification syscalsspec = syscamspaneltranslator.getSysCAMSSpecification(); + clusters.add(syscalsspec.getCluster()); } - + for (SysCAMSComponentTaskDiagramPanel syscamsDiagramPanel : syscamsDiagramPanels) { + 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 \"" + syscalsspec.getCluster().getClusterName() + "\" 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 : " + syscalsspec.getCluster().getClusterName() + "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(); + } + try { + String makefile; + System.err.println(pathCode + "Makefile"); + FileWriter fw = new FileWriter(pathCode + "/" + "Makefile"); + makefile = MakefileCode.getMakefileCode(clusters); + fw.write(makefile); + fw.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } testGo(); - + } // if (removeCFiles.isSelected()) { // // jta.append("Removing all .h files\n"); @@ -652,7 +675,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i // if ((hasError == false) && (jp1.getSelectedIndex() < 2)) { // jp1.setSelectedIndex(jp1.getSelectedIndex() + 1); // } - }} catch (InterruptedException ie) { + } catch (InterruptedException ie) { jta.append("Interrupted\n"); } diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java index f97aad8c14411735f518fb6c0b506de489fa1369..1a985c62dd4b2219bd803e256f802511c0b61d61 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java @@ -144,17 +144,20 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen gridBag.setConstraints(periodTextField, constraints); boxPanel.add(periodTextField); - listPeriodString = new String[3]; - listPeriodString[0] = "us"; + listPeriodString = new String[4]; + listPeriodString[0] = "s"; listPeriodString[1] = "ms"; - listPeriodString[2] = "s"; + listPeriodString[2] = "\u03BCs"; + listPeriodString[3] = "ns"; periodComboBoxString = new JComboBox<String>(listPeriodString); - if (port.getTime().equals("") || port.getTime().equals("us")) { + if (port.getTime().equals("") || port.getTime().equals("s")) { periodComboBoxString.setSelectedIndex(0); } else if (port.getTime().equals("ms")){ periodComboBoxString.setSelectedIndex(1); - } else { + } else if (port.getTime().equals("\u03BCs")){ periodComboBoxString.setSelectedIndex(2); + } else if (port.getTime().equals("ns")){ + periodComboBoxString.setSelectedIndex(3); } periodComboBoxString.setActionCommand("time"); periodComboBoxString.addActionListener(this); diff --git a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java index 51362637cb1ef689adeaca671573d61e86073382..75702fa326c0b73de7877444b15747fade6bfba4 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java @@ -144,17 +144,20 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { gridBag.setConstraints(periodTextField, constraints); boxPanel.add(periodTextField); - listPeriodString = new String[3]; - listPeriodString[0] = "us"; + listPeriodString = new String[4]; + listPeriodString[0] = "s"; listPeriodString[1] = "ms"; - listPeriodString[2] = "s"; + listPeriodString[2] = "\u03BCs"; + listPeriodString[3] = "ns"; periodComboBoxString = new JComboBox<String>(listPeriodString); - if (port.getTime().equals("") || port.getTime().equals("us")) { + if (port.getTime().equals("") || port.getTime().equals("s")) { periodComboBoxString.setSelectedIndex(0); } else if (port.getTime().equals("ms")){ periodComboBoxString.setSelectedIndex(1); - } else if (port.getTime().equals("s")){ + } else if (port.getTime().equals("\u03BCs")){ periodComboBoxString.setSelectedIndex(2); + } else if (port.getTime().equals("ns")){ + periodComboBoxString.setSelectedIndex(3); } periodComboBoxString.setActionCommand("time"); periodComboBoxString.addActionListener(this);