From dcc553a4b9262dc791a550e139a36f2ad8fdfb1b Mon Sep 17 00:00:00 2001 From: andrea <andrea.enrici@nokia.com> Date: Thu, 18 Jan 2018 16:59:05 +0100 Subject: [PATCH] to be committed to branch diplodocus_gui --- src/main/java/tmltranslator/HwMemory.java | 4 ++- .../java/ui/tmldd/TMLArchiMemoryNode.java | 25 +++++++++++++++++++ .../java/ui/window/JDialogMemoryNode.java | 12 ++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/tmltranslator/HwMemory.java b/src/main/java/tmltranslator/HwMemory.java index 7e56dbef42..e417e93a71 100755 --- a/src/main/java/tmltranslator/HwMemory.java +++ b/src/main/java/tmltranslator/HwMemory.java @@ -50,10 +50,12 @@ package tmltranslator; public class HwMemory extends HwCommunicationNode { public static final int DEFAULT_BYTE_DATA_SIZE = 4; + public static final int DEFAULT_MEMORY_SIZE = 1024; public static final int DEFAULT_BUFFER_TYPE = 0; public int bufferType = DEFAULT_BUFFER_TYPE; public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // In bytes. Should more than 0 + public int memorySize = DEFAULT_MEMORY_SIZE; // In bytes. Should more than 0 public HwMemory(String _name) { super(_name); @@ -61,7 +63,7 @@ public class HwMemory extends HwCommunicationNode { public String toXML() { - String s = "<MEMORY name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" bufferType=\"" + bufferType + "\" />\n"; + String s = "<MEMORY name=\"" + name + "\" clockRatio=\"" + clockRatio + "\" byteDataSize=\"" + byteDataSize + "\" memorySize=\"" + memorySize + "\" bufferType=\"" + bufferType + "\" />\n"; return s; } diff --git a/src/main/java/ui/tmldd/TMLArchiMemoryNode.java b/src/main/java/ui/tmldd/TMLArchiMemoryNode.java index 39a100281b..7df37e12fc 100755 --- a/src/main/java/ui/tmldd/TMLArchiMemoryNode.java +++ b/src/main/java/ui/tmldd/TMLArchiMemoryNode.java @@ -70,6 +70,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa private int bufferType = 0; private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE; + private int memorySize = HwMemory.DEFAULT_MEMORY_SIZE; public TMLArchiMemoryNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -226,6 +227,21 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa } } + if (dialog.getMemorySize().length() != 0) { + try { + tmp = memorySize; + memorySize = Integer.decode(dialog.getMemorySize()).intValue(); + if (memorySize <= 0) { + memorySize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Memory size "; + } + } + if (dialog.getClockRatio().length() != 0) { try { tmp = clockRatio; @@ -291,6 +307,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); sb.append("\" />\n"); sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" memorySize=\"" + memorySize + "\" "); sb.append(" clockRatio=\"" + clockRatio + "\" "); sb.append(" bufferType=\"" + bufferType + "\" "); sb.append("/>\n"); @@ -332,6 +349,9 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa if (elt.getTagName().equals("attributes")) { byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + if ((elt.getAttribute("memorySize") != null) && (elt.getAttribute("memorySize").length() > 0)) { + memorySize = Integer.decode(elt.getAttribute("memorySize")).intValue(); + } if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); } @@ -354,9 +374,14 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa return byteDataSize; } + public int getMemorySize(){ + return memorySize; + } + public String getAttributes() { String attr = ""; attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Memory size (in byte) = " + memorySize + "\n"; attr += "Clock divider = " + clockRatio + "\n"; return attr; } diff --git a/src/main/java/ui/window/JDialogMemoryNode.java b/src/main/java/ui/window/JDialogMemoryNode.java index a3156093e2..6c2c9218ec 100755 --- a/src/main/java/ui/window/JDialogMemoryNode.java +++ b/src/main/java/ui/window/JDialogMemoryNode.java @@ -74,7 +74,7 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener { protected JTextField nodeName; // Panel2 - protected JTextField byteDataSize, monitored, clockRatio; + protected JTextField byteDataSize, memorySize, monitored, clockRatio; //Panel3: code generation protected int bufferType = 0; //it is the index in the ArrayList of String @@ -176,6 +176,12 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener { bufferTypesCB.setSelectedIndex( bufferType ); panel3.add( bufferTypesCB, c3 ); + c3.gridwidth = 1; + panel3.add( new JLabel( "Memory size (in byte):" ), c3 ); + c3.gridwidth = GridBagConstraints.REMAINDER; //end row + memorySize = new JTextField( "" + node.getMemorySize(), 15 ); + panel3.add( memorySize, c3 ); + // main panel; c0.gridheight = 10; c0.weighty = 1.0; @@ -240,6 +246,10 @@ public class JDialogMemoryNode extends JDialogBase implements ActionListener { return byteDataSize.getText(); } + public String getMemorySize() { + return memorySize.getText(); + } + public int getMonitored() { return tracemode.getSelectedIndex(); //return monitored.getText(); -- GitLab