diff --git a/SysCAMSGenerationCode/Makefile b/SysCAMSGenerationCode/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..42951da8865322b66734b7a042d8e0f74c699864 --- /dev/null +++ b/SysCAMSGenerationCode/Makefile @@ -0,0 +1,19 @@ +# Compiler and linker flags +CXXFLAGS = -g -Wall -I. $(SYSTEMC_INCLUDE_DIRS) +LDFLAGS = $(SYSTEMC_LIBRARY_DIRS) + +# List of all ecutables to be compiled +EXECUTABLES = cluster_tb + +# .PHONY targets don't generate files +.PHONY: all clean + +# Default targets +all: $(EXECUTABLES) + +cluster_tb: cluster_tb.cpp Block_TDF_0.h + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lsystemc-ams -lsystemc | c++filt + +# Clean rule to delete temporary and generated files +clean: + rm -rf *~ *.o *.dat *.vcd *.dSYM $(EXECUTABLES) diff --git a/SysCAMSGenerationCode/generated_CPP/cluster_tb.cpp b/SysCAMSGenerationCode/generated_CPP/cluster_tb.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/SysCAMSGenerationCode/generated_H/Block_DE_0.h b/SysCAMSGenerationCode/generated_H/Block_DE_0.h new file mode 100644 index 0000000000000000000000000000000000000000..7705c4d15004adb706ea022a92f987cc8ce07514 --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/Block_DE_0.h @@ -0,0 +1,29 @@ +#ifndef BLOCK_DE_0_H +#define BLOCK_DE_0_H + +#include <cmath> +#include <iostream> +#include <systemc> + +class Block_DE_0 : public sca_core::sca_module { + +public: + + sca_core::sca_in<bool> clk; + sca_core::sca_out<double> out; + + SC_HAS_PROCESS(Block_DE_0); + explicit Block_DE_0(sc_core::sc_module_name nm) + : clk("clk") + , out("out") + { + SC_METHOD(attributeCode); + sensitive << clk.pos() + } + + void attributeCode() { + + } +}; + +#endif // BLOCK_DE_0_H \ No newline at end of file diff --git a/SysCAMSGenerationCode/generated_H/Block_TDF_0.h b/SysCAMSGenerationCode/generated_H/Block_TDF_0.h new file mode 100644 index 0000000000000000000000000000000000000000..d91ac5d9fa182480bf4e489c70d0c530f9a6d045 --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/Block_TDF_0.h @@ -0,0 +1,27 @@ +#ifndef BLOCK_TDF_0_H +#define BLOCK_TDF_0_H + +#include <cmath> +#include <iostream> +#include <systemc-ams> + +class Block_TDF_0 : public sca_tdf::sca_module { + +public: + + sca_tdf::sca_in<int> port2; + + sca_tdf::sca_de::sca_out<int> port1; + + explicit Block_TDF_0(sc_core::sc_module_name nm) + : port2("port2") + , port1("port1") + {} + +protected: + void processing() { + } + +}; + +#endif // BLOCK_TDF_0_H \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java index cba5c33600e3e1db6d77b8c4633f58e3ca6abe3c..d687d1b74473408436952e999c5f3dff99357bba 100644 --- a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java +++ b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java @@ -50,26 +50,32 @@ import java.util.LinkedList; public class SysCAMSTBlockDE extends SysCAMSTComponent { private String name; - private int period; +// private int period; + private String nameFn; private String code; private LinkedList<SysCAMSTPortDE> portDE; - public SysCAMSTBlockDE(String _name, int _period, String _code) { + public SysCAMSTBlockDE(String _name, String _nameFn, String _code) { name = _name; - period = _period; +// period = _period; + nameFn = _nameFn; code = _code; portDE = new LinkedList<SysCAMSTPortDE>(); } - public int getPeriod() { - return period; - } +// public int getPeriod() { +// return period; +// } public String getName() { return name; } + public String getNameFn() { + return nameFn; + } + public String getCode() { return code; } diff --git a/src/main/java/syscamstranslator/SysCAMSTPortDE.java b/src/main/java/syscamstranslator/SysCAMSTPortDE.java index 8ac4a1bf8e891365379d977198796f9f34e5af5e..fd8f1ba90f808ff609afd3efe7b5589498871602 100644 --- a/src/main/java/syscamstranslator/SysCAMSTPortDE.java +++ b/src/main/java/syscamstranslator/SysCAMSTPortDE.java @@ -49,23 +49,27 @@ package syscamstranslator; public class SysCAMSTPortDE extends SysCAMSTComponent { private String name; - private int period; - private String time; - private int rate; - private int delay; +// private int period; +// private String time; +// private int rate; +// private int delay; private int origin; private String DEType; + private boolean sensitive; + private String sensitiveMethod; private SysCAMSTBlockDE blockDE; - public SysCAMSTPortDE(String _name, int _period, String _time, int _rate, int _delay, int _origin, String _DEType, SysCAMSTBlockDE _blockDE) { + public SysCAMSTPortDE(String _name, int _origin, String _DEType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockDE _blockDE) { name = _name; - period = _period; - time = _time; - rate = _rate; - delay = _delay; +// period = _period; +// time = _time; +// rate = _rate; +// delay = _delay; origin = _origin; DEType = _DEType; + sensitive = _sensitive; + sensitiveMethod = _sensitiveMethod; blockDE = _blockDE; } @@ -73,21 +77,21 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { return name; } - public int getPeriod() { - return period; - } - - public String getTime() { - return time; - } - - public int getRate() { - return rate; - } - - public int getDelay() { - return delay; - } +// public int getPeriod() { +// return period; +// } +// +// public String getTime() { +// return time; +// } +// +// public int getRate() { +// return rate; +// } +// +// public int getDelay() { +// return delay; +// } public int getOrigin() { return origin; @@ -97,7 +101,15 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { return DEType; } + public boolean getSensitive() { + return sensitive; + } + + public String getSensitiveMethod() { + return sensitiveMethod; + } + public SysCAMSTBlockDE getBlockTDF() { return blockDE; } -} +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java index d159dac6c5fe0fa2fef84a59e75fff1f7038d23e..3a3ff56be31254a80d445ca4ac6bc0ff8f9cd2b6 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java @@ -66,6 +66,8 @@ public class PrimitiveCode { PrimitiveCode() {} public static String getPrimitiveCodeTDF(SysCAMSTBlockTDF tdf) { + corpsPrimitiveTDF = ""; + if (tdf != null) { LinkedList<SysCAMSTPortTDF> tdfports = tdf.getPortTDF(); LinkedList<SysCAMSTPortConverter> convports = tdf.getPortConverter(); @@ -73,7 +75,7 @@ public class PrimitiveCode { int cpt2 = 0; if ((!tdf.getTypeTemplate().equals("")) || (!tdf.getNameTemplate().equals(""))) { - corpsPrimitiveTDF = "template<" + tdf.getTypeTemplate() + " " + tdf.getNameTemplate() + ">" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "template<" + tdf.getTypeTemplate() + " " + tdf.getNameTemplate() + ">" + CR; } //corpsPrimitive = "SCA_TDF_MODULE(" + tdf.getName() + ") {" + CR2; corpsPrimitiveTDF = corpsPrimitiveTDF + "class " + tdf.getName() + " : public sca_tdf::sca_module {" + CR2 + "public:" + CR; @@ -169,7 +171,7 @@ public class PrimitiveCode { corpsPrimitiveTDF = corpsPrimitiveTDF + "\t: "; if (!tdfports.isEmpty()) { for (int i = 0; i < tdfports.size(); i++) { - if (tdfports.size() > 1) { + if (tdfports.size() >= 1) { if (cpt == 0) { corpsPrimitiveTDF = corpsPrimitiveTDF + tdfports.get(i).getName() + "(\"" + tdfports.get(i).getName() + "\")" + CR; cpt++; @@ -184,7 +186,7 @@ public class PrimitiveCode { } if (!convports.isEmpty()) { for (int i = 0; i < convports.size(); i++) { - if (convports.size() > 1) { + if (convports.size() >= 1) { if (cpt == 0) { corpsPrimitiveTDF = corpsPrimitiveTDF + convports.get(i).getName() + "(\"" + convports.get(i).getName() + "\")" + CR; cpt++; @@ -376,6 +378,8 @@ public class PrimitiveCode { } public static String getPrimitiveCodeDE(SysCAMSTBlockDE de) { + corpsPrimitiveDE = ""; + if (de != null) { LinkedList<SysCAMSTPortDE> deports = de.getPortDE(); int cpt = 0; @@ -416,8 +420,28 @@ public class PrimitiveCode { } } + boolean sensitive = false, method = false; if (!de.getCode().equals("")) { - corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR + "\t\tSC_METHOD(" + block.getNameFn() + ");" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR + "\t\tSC_METHOD(" + de.getNameFn() + ");" + CR; + method = true; + } + + for (SysCAMSTPortDE t : deports) { + if (t.getSensitive() == true) { + if (method == false) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR; + } + corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName() + "."; + if (t.getSensitiveMethod().equals("positive")) { + corpsPrimitiveDE = corpsPrimitiveDE + "pos()" + CR; + } else if (t.getSensitiveMethod().equals("negative")) { + corpsPrimitiveDE = corpsPrimitiveDE + "neg()" + CR; + } + sensitive = true; + } + } + if (sensitive == true || method == true) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t}" + CR2; } else { corpsPrimitiveDE = corpsPrimitiveDE + "\t{}" + CR2; } diff --git a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java index f563b4abbeeb0cd147ed6136409a096fbc74a63a..381d6f5fbcaada292aef83d37b1a3ee908449bbf 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java +++ b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java @@ -123,22 +123,23 @@ public class TopCellGenerator { ex.printStackTrace(); } // Save files .h - saveFileBlockTDF(path, c); + saveFileBlock(path, c); } } - public void saveFileBlockTDF(String path, SysCAMSTCluster c) { - String header, code; + public void saveFileBlock(String path, SysCAMSTCluster c) { + String headerTDF, headerDE, codeTDF, codeDE; LinkedList<SysCAMSTBlockTDF> tdf = c.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = c.getBlockDE(); + for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + ".h"); FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); - header = Header.getPrimitiveHeaderTDF(t); - fw.write(header); - code = PrimitiveCode.getPrimitiveCodeTDF(t); - fw.write(code); + headerTDF = Header.getPrimitiveHeaderTDF(t); + fw.write(headerTDF); + codeTDF = PrimitiveCode.getPrimitiveCodeTDF(t); + fw.write(codeTDF); fw.close(); } catch (Exception ex) { ex.printStackTrace(); @@ -148,15 +149,14 @@ public class TopCellGenerator { try { System.err.println(path + GENERATED_PATH2 + t.getName() + ".h"); FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); - header = Header.getPrimitiveHeaderDE(t); - fw.write(header); - code = PrimitiveCode.getPrimitiveCodeDE(t); - fw.write(code); + headerDE = Header.getPrimitiveHeaderDE(t); + fw.write(headerDE); + codeDE = PrimitiveCode.getPrimitiveCodeDE(t); + fw.write(codeDE); fw.close(); } catch (Exception ex) { ex.printStackTrace(); } } } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java index 7424526de139154d131b7dc90fb4170572f634a0..d31a74520724ee3074fbd4849c0a4f1595ee28dc 100644 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -96,24 +96,27 @@ public class SysCAMSPanelTranslator { SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; String blockDEName = blockDE.getValue(); - int periodBlock = blockDE.getPeriod(); +// int periodBlock = blockDE.getPeriod(); + String nameFn = blockDE.getNameFn(); String code = blockDE.getCode(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, periodBlock, code); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, nameFn, code); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int i = 0; i < portsDE.size(); i++) { SysCAMSPortDE portDE = portsDE.get(i); String portName = portDE.getPortName(); - int periodPort = portDE.getPeriod(); - String time = portDE.getTime(); - int rate = portDE.getRate(); - int delay = portDE.getDelay(); +// int periodPort = portDE.getPeriod(); +// String time = portDE.getTime(); +// int rate = portDE.getRate(); +// int delay = portDE.getDelay(); String type = portDE.getDEType(); int origin = portDE.getOrigin(); + boolean sensitive = portDE.getSensitive(); + String sensitiveMethod = portDE.getSensitiveMethod(); - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, periodPort, time, rate, delay, origin, type, syscamsBlockDE); + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, syscamsBlockDE); syscamsMap.put(portDE, syscamsPortDE); syscamsBlockDE.addPortDE(syscamsPortDE); @@ -184,27 +187,30 @@ public class SysCAMSPanelTranslator { syscamsComponents.add(syscamsBlockTDF); } for (int i = 0; i < blocksDE.size(); i++) { - SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; - + SysCAMSBlockDE blockDE = blocksDE.get(i); + String blockDEName = blockDE.getValue(); - int periodBlock = blockDE.getPeriod(); +// int periodBlock = blockDE.getPeriod(); + String nameFn = blockDE.getNameFn(); String code = blockDE.getCode(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, periodBlock, code); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, nameFn, code); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int j = 0; j < portsDE.size(); j++) { SysCAMSPortDE portDE = portsDE.get(j); String portName = portDE.getPortName(); - int periodPort = portDE.getPeriod(); - String time = portDE.getTime(); - int rate = portDE.getRate(); - int delay = portDE.getDelay(); +// int periodPort = portDE.getPeriod(); +// String time = portDE.getTime(); +// int rate = portDE.getRate(); +// int delay = portDE.getDelay(); String type = portDE.getDEType(); int origin = portDE.getOrigin(); + boolean sensitive = portDE.getSensitive(); + String sensitiveMethod = portDE.getSensitiveMethod(); - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, periodPort, time, rate, delay, origin, type, syscamsBlockDE); + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, syscamsBlockDE); syscamsMap.put(portDE, syscamsPortDE); syscamsBlockDE.addPortDE(syscamsPortDE); diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index 5e77dbeb89602d700f6326d9eb528e9869df2cfc..55c8cdc8e3208b7ee84945132151572239c851d0 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -59,8 +59,9 @@ import java.util.LinkedList; */ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { - private int period; - private String time; +// private int period; +// private String time; + private String nameFn; private String code; private int maxFontSize = 14; @@ -101,8 +102,9 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements value = tdp.findSysCAMSPrimitiveComponentName("Block_DE_"); name = "Primitive component - Block DE"; - setPeriod(-1); - setTime(""); +// setPeriod(-1); +// setTime(""); + setNameFn(""); setCode(""); myImageIcon = IconManager.imgic1202; @@ -158,19 +160,19 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements g.setFont(f.deriveFont(Font.BOLD)); g.drawString(value, x + textX + 1, y + currentFontSize + textX); g.setFont(f.deriveFont(Font.PLAIN)); - if (this.getPeriod() != -1) { - String s = "Tm = " + this.getPeriod() + " " + this.getTime(); - g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); - } +// if (this.getPeriod() != -1) { +// String s = "Tm = " + this.getPeriod() + " " + this.getTime(); +// g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); +// } } else { g.setFont(f.deriveFont(Font.BOLD)); g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); g.setFont(f.deriveFont(Font.PLAIN)); - if (this.getPeriod() != -1) { - String s = "Tm = " + this.getPeriod() + " " + this.getTime(); - w = g.getFontMetrics().stringWidth(s); - g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); - } +// if (this.getPeriod() != -1) { +// String s = "Tm = " + this.getPeriod() + " " + this.getTime(); +// w = g.getFontMetrics().stringWidth(s); +// g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); +// } } g.setFont(fold); @@ -287,9 +289,9 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<Attribute period=\""); - sb.append(getPeriod()); - sb.append("\" time=\"" + getTime()); + sb.append("<Attribute name_function=\"" + getNameFn()); +// sb.append(getPeriod()); +// sb.append("\" time=\"" + getTime()); sb.append("\" code=\"" + encode(getCode())); sb.append("\" />\n"); sb.append("</extraparam>\n"); @@ -403,7 +405,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements Element elt; int period; - String time, code; + String time, code, nameFn; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -414,11 +416,13 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("Attribute")) { - period = Integer.decode(elt.getAttribute("period")).intValue(); - time = elt.getAttribute("time"); +// period = Integer.decode(elt.getAttribute("period")).intValue(); +// time = elt.getAttribute("time"); code = elt.getAttribute("code"); - setPeriod(period); - setTime(time); + nameFn = elt.getAttribute("name_function"); +// setPeriod(period); +// setTime(time); + setNameFn(nameFn); code = decode(code).toString(); setCode(code); } @@ -468,27 +472,35 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements return list; } - public int getPeriod() { - return period; - } - - public void setPeriod(int _period) { - period = _period; - } - - public String getTime() { - return time; +// public int getPeriod() { +// return period; +// } +// +// public void setPeriod(int _period) { +// period = _period; +// } +// +// public String getTime() { +// return time; +// } +// +// public void setTime(String _time) { +// time = _time; +// } + + public void setNameFn(String nameFn) { + this.nameFn = nameFn; } - public void setTime(String _time) { - time = _time; + public void setCode(String _code) { + code = _code; } - + public String getCode() { return code; } - public void setCode(String _code) { - code = _code; + public String getNameFn() { + return nameFn; } } \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSBlockTDF.java b/src/main/java/ui/syscams/SysCAMSBlockTDF.java index 5fcb9ea814d637c106fd8495eef56977e7a13647..b831b1ee56bc20770dd2a77a7af452b9081f4895 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockTDF.java +++ b/src/main/java/ui/syscams/SysCAMSBlockTDF.java @@ -470,7 +470,9 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements String[] splita = listStruct.split("\\|"); DefaultListModel<String> lista = new DefaultListModel<String>(); for (String s : splita) { - lista.addElement(s); + if (!s.equals("")) { + lista.addElement(s); + } } setListStruct(lista); setNameTemplate(nameTemplate); diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java index 7162b70481baf261d2247ddff98f088240395fae..df3a9c33d3027a82a5fa43a4b266768ac7753916 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -58,9 +58,11 @@ import javax.swing.border.*; public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { private JTextField nameTextField; - private JTextField periodTextField; - private String listPeriodString[]; - private JComboBox<String> periodComboBoxString; +// private JTextField periodTextField; +// private String listPeriodString[]; +// private JComboBox<String> periodComboBoxString; + private JTextField nameFnTextField; + private JButton nameFnButton; private JPanel codeMainPanel; private JTextArea codeTextArea; @@ -167,7 +169,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { JTabbedPane tabbedPane = new JTabbedPane(); codeMainPanel = new JPanel(); tabbedPane.add("Attributes", attributesMainPanel); - tabbedPane.add("Process Code", codeMainPanel); + tabbedPane.add("Method Code", codeMainPanel); mainPanel.add(tabbedPane, BorderLayout.NORTH); } else { @@ -202,40 +204,40 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { gridBag.setConstraints(nameTextField, constraints); attributesBoxPanel.add(nameTextField); - JLabel periodLabel = new JLabel("Period Tm : "); - constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 15, 10), 0, 0); - gridBag.setConstraints(periodLabel, constraints); - attributesBoxPanel.add(periodLabel); - - if (block.getPeriod() == -1) { - periodTextField = new JTextField(10); - } else { - periodTextField = new JTextField("" + block.getPeriod(), 10); - } - constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 15, 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 if (block.getTime().equals("s")) { - 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, 15, 10), 0, 0); - gridBag.setConstraints(periodComboBoxString, constraints); - attributesBoxPanel.add(periodComboBoxString); +// JLabel periodLabel = new JLabel("Period Tm : "); +// constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, +// new Insets(5, 10, 15, 10), 0, 0); +// gridBag.setConstraints(periodLabel, constraints); +// attributesBoxPanel.add(periodLabel); +// +// if (block.getPeriod() == -1) { +// periodTextField = new JTextField(10); +// } else { +// periodTextField = new JTextField("" + block.getPeriod(), 10); +// } +// constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, +// new Insets(5, 10, 15, 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 if (block.getTime().equals("s")) { +// 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, 15, 10), 0, 0); +// gridBag.setConstraints(periodComboBoxString, constraints); +// attributesBoxPanel.add(periodComboBoxString); attributesBox.add(attributesBoxPanel); @@ -250,6 +252,21 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { JPanel codeBoxPanel = new JPanel(new BorderLayout()); + JPanel nameFnGrid = new JPanel(new GridLayout(1, 3)); + + JLabel nameFnLabel = new JLabel("Name of the method : "); + nameFnGrid.add(nameFnLabel); + + nameFnTextField = new JTextField(block.getNameFn()); + nameFnGrid.add(nameFnTextField); + + nameFnButton = new JButton("OK"); + nameFnButton.setActionCommand("OK"); + nameFnButton.addActionListener(this); + nameFnGrid.add(nameFnButton); + + codeBoxPanel.add(nameFnGrid, BorderLayout.NORTH); + StringBuffer stringbuf = encode(block.getCode()); String beginString = stringbuf.toString(); finalString = beginString.replaceAll("\t}", "}"); @@ -297,30 +314,42 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { } public void actionPerformed(ActionEvent e) { + if ("OK".equals(e.getActionCommand())) { + if (!nameFnTextField.getText().equals("")) { + codeTextArea.setText("void " + nameFnTextField.getText() + "() {\n\n}"); + } else { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "This method has no name. Please add a name for this method.", "Warning !", + JOptionPane.WARNING_MESSAGE); + } + } + if ("Save_Close".equals(e.getActionCommand())) { block.setValue(new String(nameTextField.getText())); - if (!(periodTextField.getText().isEmpty())) { - Boolean periodValueInteger = false; - try { - Integer.parseInt(periodTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !", - JOptionPane.WARNING_MESSAGE); - periodValueInteger = true; - } - if (periodValueInteger == false) { - block.setPeriod(Integer.parseInt(periodTextField.getText())); - block.setTime((String) periodComboBoxString.getSelectedItem()); - } - } else { - block.setPeriod(-1); - block.setTime(""); - } +// if (!(periodTextField.getText().isEmpty())) { +// Boolean periodValueInteger = false; +// try { +// Integer.parseInt(periodTextField.getText()); +// } catch (NumberFormatException e1) { +// JDialog msg = new JDialog(this); +// msg.setLocationRelativeTo(null); +// JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !", +// JOptionPane.WARNING_MESSAGE); +// periodValueInteger = true; +// } +// if (periodValueInteger == false) { +// block.setPeriod(Integer.parseInt(periodTextField.getText())); +// block.setTime((String) periodComboBoxString.getSelectedItem()); +// } +// } else { +// block.setPeriod(-1); +// block.setTime(""); +// } if (block.getFather() != null) { + block.setNameFn(nameFnTextField.getText()); block.setCode(codeTextArea.getText()); } diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index e4613a260b4f932858d70c313b802f10125d0995..3888b5619df2c45cc7b75727b80c8abcc35c0ff2 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -281,6 +281,7 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { sensitiveComboBoxString.setSelectedIndex(1); } sensitiveComboBoxString.setActionCommand("Sensitive_method"); + sensitiveComboBoxString.setEnabled(port.getSensitive()); sensitiveComboBoxString.addActionListener(this); constraints = new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(15, 10, 5, 10), 0, 0); @@ -310,6 +311,13 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } public void actionPerformed(ActionEvent e) { + if ("Sensitive".equals(e.getActionCommand())) { + if (sensitiveRadioButton.isSelected() == true) { + sensitiveComboBoxString.setEnabled(true); + } else { + sensitiveComboBoxString.setEnabled(false); + } + } if ("Save_Close".equals(e.getActionCommand())) { port.setPortName(new String(nameTextField.getText()));