Skip to content
Snippets Groups Projects
Commit 5df6100f authored by Daniela Genius's avatar Daniela Genius
Browse files

DTDF (restricted) in TDF modules

parent 37f8feea
No related branches found
No related tags found
2 merge requests!288New lip6,!286New lip6
...@@ -55,6 +55,7 @@ import javax.swing.DefaultListModel; ...@@ -55,6 +55,7 @@ import javax.swing.DefaultListModel;
public class SysCAMSTBlockTDF extends SysCAMSTComponent { public class SysCAMSTBlockTDF extends SysCAMSTComponent {
private String name; private String name;
private double period; private double period;
private Boolean dynamic;
private String time; private String time;
private String processCode; private String processCode;
private String constructorCode; private String constructorCode;
...@@ -73,9 +74,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { ...@@ -73,9 +74,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
private int n; private int n;
private boolean isTimestepPropagated; private boolean isTimestepPropagated;
public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, String _constructorCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { public SysCAMSTBlockTDF(String _name, double _period, Boolean _dynamic, String _time, String _processCode, String _constructorCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
name = _name; name = _name;
period = _period; period = _period;
dynamic = _dynamic;
time = _time; time = _time;
processCode = _processCode; processCode = _processCode;
constructorCode = _constructorCode; constructorCode = _constructorCode;
...@@ -103,6 +105,14 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { ...@@ -103,6 +105,14 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
public void setPeriod(double _period) { public void setPeriod(double _period) {
period = _period; period = _period;
} }
public Boolean getDynamic() {
return dynamic;
}
public void setDynamic(double _dynamic) {
dynamic = _dynamic;
}
public String getTime() { public String getTime() {
return time; return time;
......
...@@ -321,7 +321,11 @@ public class PrimitiveCode { ...@@ -321,7 +321,11 @@ public class PrimitiveCode {
} }
} }
} }
if(tdf.getDynamic().equals(true)){
corpsPrimitiveTDF = corpsPrimitiveTDF+"allow_dynamic_tfd();"+CR;
cpt2++;
}
if (cpt2 > 0) { if (cpt2 > 0) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t}" + CR2; corpsPrimitiveTDF = corpsPrimitiveTDF + "\t}" + CR2;
} }
......
...@@ -330,6 +330,11 @@ public class PrimitiveCodeCluster { ...@@ -330,6 +330,11 @@ public class PrimitiveCodeCluster {
} }
} }
if(tdf.getDynamic().equals(true)){
corpsPrimitiveTDF = corpsPrimitiveTDF+"allow_dynamic_tfd();"+CR;
cpt2++;
}
if (cpt2 > 0) { if (cpt2 > 0) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t}" + CR2; corpsPrimitiveTDF = corpsPrimitiveTDF + "\t}" + CR2;
} }
......
...@@ -201,6 +201,7 @@ public class SysCAMSPanelTranslator { ...@@ -201,6 +201,7 @@ public class SysCAMSPanelTranslator {
String blockTDFName = blockTDF.getValue(); String blockTDFName = blockTDF.getValue();
double periodBlock = blockTDF.getPeriod(); double periodBlock = blockTDF.getPeriod();
Boolean dynamicBlock = blockTDF.getDynamic();
String timeBlock = blockTDF.getTime(); String timeBlock = blockTDF.getTime();
if (timeBlock.equals("s")) { if (timeBlock.equals("s")) {
timeBlock = timeBlock + "ec"; timeBlock = timeBlock + "ec";
...@@ -215,7 +216,7 @@ public class SysCAMSPanelTranslator { ...@@ -215,7 +216,7 @@ public class SysCAMSPanelTranslator {
String valueTemplate = blockTDF.getValueTemplate(); String valueTemplate = blockTDF.getValueTemplate();
DefaultListModel<String> listTypedef = blockTDF.getListTypedef(); DefaultListModel<String> listTypedef = blockTDF.getListTypedef();
SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, periodBlock, timeBlock, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, periodBlock, dynamicBlock, timeBlock, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster);
List<SysCAMSPortTDF> portsTDF = blockTDF.getAllInternalPortsTDF(); List<SysCAMSPortTDF> portsTDF = blockTDF.getAllInternalPortsTDF();
for (int j = 0; j < portsTDF.size(); j++) { for (int j = 0; j < portsTDF.size(); j++) {
......
...@@ -60,13 +60,14 @@ import java.util.LinkedList; ...@@ -60,13 +60,14 @@ import java.util.LinkedList;
public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent {
private double period; private double period;
private Boolean dynamic;
private String time; private String time;
private String processCode; private String processCode;
private String constructorCode; private String constructorCode;
private DefaultListModel<String> listStruct; private DefaultListModel<String> listStruct;
private String nameTemplate; private String nameTemplate;
private String typeTemplate; private String typeTemplate;
private String valueTemplate; private String valueTemplate;
private DefaultListModel<String> listTypedef; private DefaultListModel<String> listTypedef;
private int maxFontSize = 14; private int maxFontSize = 14;
...@@ -107,15 +108,15 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -107,15 +108,15 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
value = tdp.findSysCAMSPrimitiveComponentName("blockTDF"); value = tdp.findSysCAMSPrimitiveComponentName("blockTDF");
oldValue = value; oldValue = value;
name = "Primitive component - Block TDF"; name = "Primitive component - Block TDF";
setDynamic(false);
setPeriod(-1); setPeriod(-1);
setTime(""); setTime("");
setProcessCode("void processing() {\n\n}"); setProcessCode("void processing() {\n\n}");
setConstructorCode(""); setConstructorCode("");
setListStruct(new DefaultListModel<String>()); setListStruct(new DefaultListModel<String>());
setNameTemplate(""); setNameTemplate("");
setTypeTemplate(""); setTypeTemplate("");
setValueTemplate(""); setValueTemplate("");
setListTypedef(new DefaultListModel<String>()); setListTypedef(new DefaultListModel<String>());
myImageIcon = IconManager.imgic1202; myImageIcon = IconManager.imgic1202;
...@@ -318,6 +319,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -318,6 +319,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
protected String translateExtraParam() { protected String translateExtraParam() {
StringBuffer sb = new StringBuffer("<extraparam>\n"); StringBuffer sb = new StringBuffer("<extraparam>\n");
sb.append("<Attribute period=\"" + getPeriod()); sb.append("<Attribute period=\"" + getPeriod());
sb.append("\" dynamic=\"" + getDynamic());
sb.append("\" time=\"" + getTime()); sb.append("\" time=\"" + getTime());
sb.append("\" processCode=\"" + encode(getProcessCode())); sb.append("\" processCode=\"" + encode(getProcessCode()));
sb.append("\" constructorCode=\"" + encode(getConstructorCode())); sb.append("\" constructorCode=\"" + encode(getConstructorCode()));
...@@ -452,7 +454,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -452,7 +454,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
NodeList nli; NodeList nli;
Node n1, n2; Node n1, n2;
Element elt; Element elt;
Boolean dynamic;
double period; double period;
String time, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef; String time, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef;
...@@ -466,6 +468,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -466,6 +468,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
elt = (Element) n2; elt = (Element) n2;
if (elt.getTagName().equals("Attribute")) { if (elt.getTagName().equals("Attribute")) {
period = Double.valueOf(elt.getAttribute("period")).doubleValue(); period = Double.valueOf(elt.getAttribute("period")).doubleValue();
dynamic = Boolean.valueOf(elt.getAttribute("dynamic")).booleanValue();
time = elt.getAttribute("time"); time = elt.getAttribute("time");
processCode = elt.getAttribute("processCode"); processCode = elt.getAttribute("processCode");
constructorCode = elt.getAttribute("constructorCode"); constructorCode = elt.getAttribute("constructorCode");
...@@ -475,6 +478,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -475,6 +478,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
valueTemplate = elt.getAttribute("valueTemplate"); valueTemplate = elt.getAttribute("valueTemplate");
listTypedef = elt.getAttribute("listTypedef"); listTypedef = elt.getAttribute("listTypedef");
setPeriod(period); setPeriod(period);
setDynamic(dynamic);
setTime(time); setTime(time);
processCode = decode(processCode).toString(); processCode = decode(processCode).toString();
setProcessCode(processCode); setProcessCode(processCode);
...@@ -587,6 +591,14 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements ...@@ -587,6 +591,14 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements
period = _period; period = _period;
} }
public Boolean getDynamic() {
return dynamic;
}
public void setDynamic(Boolean _dynamic) {
dynamic = _dynamic;
}
public String getTime() { public String getTime() {
return time; return time;
} }
......
...@@ -90,10 +90,14 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L ...@@ -90,10 +90,14 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L
private JTextArea processCodeTextArea; private JTextArea processCodeTextArea;
private String finalString; private String finalString;
private JTextArea constructorCodeTextArea; private JTextArea constructorCodeTextArea;
private SysCAMSBlockTDF block; private SysCAMSBlockTDF block;
private JRadioButton dynamicRadioButton;
//private String listDynamicString[];
//private JComboBox<String> dynamicComboBoxString;
public JDialogSysCAMSBlockTDF(SysCAMSBlockTDF block) { public JDialogSysCAMSBlockTDF(SysCAMSBlockTDF block) {
this.setTitle("Setting TDF Block Attributes"); this.setTitle("Setting TDF Block Attributes");
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
...@@ -265,9 +269,50 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L ...@@ -265,9 +269,50 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L
gridBag.setConstraints(periodComboBoxString, constraints); gridBag.setConstraints(periodComboBoxString, constraints);
attributesBoxPanel.add(periodComboBoxString); attributesBoxPanel.add(periodComboBoxString);
JPanel dynamicPanel = new JPanel(new FlowLayout());
dynamicRadioButton = new JRadioButton();
dynamicRadioButton.setActionCommand("Dynamic");
dynamicRadioButton.setSelected(block.getDynamic());
dynamicRadioButton.addActionListener(this);
dynamicPanel.add(dynamicRadioButton);
JLabel dynamicLabel = new JLabel("Dynamic");
dynamicPanel.add(dynamicLabel);
constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(dynamicPanel, constraints);
attributesBoxPanel.add(dynamicPanel);
/* listDynamicString = new String[3];
listDynamicString[0] = "";
listDynamicString[1] = "";
listDynamicString[2] = "accepts attribute changes";
dynamicComboBoxString = new JComboBox<String>(listDynamicString);
if (block.getClockSensitivityMethod().equals("")) {
dynamicComboBoxString.setSelectedIndex(0);
} else if (block.getClockSensitivityMethod().equals("changes attributes")) {
dynamicComboBoxString.setSelectedIndex(1);
} else if (block.getClockSensitivityMethod().equals("accepts attribute changes")) {
dynamicComboBoxString.setSelectedIndex(2);
}
dynamicComboBoxString.setActionCommand("Dynamic_method");
dynamicComboBoxString.setEnabled(block.getDynamic());
dynamicComboBoxString.addActionListener(this);
constraints = new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(dynamicComboBoxString, constraints);
//boxPanel.add(dynamicComboBoxString);
attributesBoxPanel.add(dynamicComboBoxString);*/
attributesBox.add(attributesBoxPanel); attributesBox.add(attributesBoxPanel);
attributesMainPanel.add(attributesBox, BorderLayout.NORTH); attributesMainPanel.add(attributesBox, BorderLayout.NORTH);
// --- Parameters ---// // --- Parameters ---//
parametersMainPanel.setLayout(new BorderLayout()); parametersMainPanel.setLayout(new BorderLayout());
...@@ -688,6 +733,15 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L ...@@ -688,6 +733,15 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
/*if ("Dynamic".equals(e.getActionCommand())) {
if (dynamicRadioButton.isSelected() == true) {
dynamicComboBoxString.setEnabled(true);
} else {
dynamicComboBoxString.setEnabled(false);
}
}*/
if ("OK".equals(e.getActionCommand())) { if ("OK".equals(e.getActionCommand())) {
nameTypedefTextField.setEditable(true); nameTypedefTextField.setEditable(true);
typeTypedefComboBoxString.setEnabled(true); typeTypedefComboBoxString.setEnabled(true);
...@@ -989,6 +1043,9 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L ...@@ -989,6 +1043,9 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L
if ("Save_Close".equals(e.getActionCommand())) { if ("Save_Close".equals(e.getActionCommand())) {
block.setValue(new String(nameTextField.getText())); block.setValue(new String(nameTextField.getText()));
block.setDynamic(dynamicRadioButton.isSelected());
//block.setDynamicMethod((String) dynamicComboBoxString.getSelectedItem());
if (!(periodTextField.getText().isEmpty())) { if (!(periodTextField.getText().isEmpty())) {
Boolean periodValueInteger = false; Boolean periodValueInteger = false;
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment