From c88182564503be00a1e561d8c0b5d076737d8d4a Mon Sep 17 00:00:00 2001
From: apvrille <ludovic.apvrille@eurecom.fr>
Date: Thu, 9 May 2019 17:56:32 +0200
Subject: [PATCH] Update on FPGA node : scheduling, and update on help
 management

---
 src/main/java/tmltranslator/HwFPGA.java       | 15 ++--
 .../TMLArchiTextSpecification.java            | 19 +++-
 src/main/java/ui/GTMLModeling.java            |  2 +-
 src/main/java/ui/tmldd/TMLArchiFPGANode.java  | 15 ++++
 src/main/java/ui/window/JDialogCPUNode.java   | 90 +++++++++++++------
 src/main/java/ui/window/JDialogFPGANode.java  | 12 ++-
 6 files changed, 116 insertions(+), 37 deletions(-)

diff --git a/src/main/java/tmltranslator/HwFPGA.java b/src/main/java/tmltranslator/HwFPGA.java
index c97a353429..cf1833f793 100755
--- a/src/main/java/tmltranslator/HwFPGA.java
+++ b/src/main/java/tmltranslator/HwFPGA.java
@@ -51,7 +51,6 @@ import tmltranslator.modelcompiler.ArchUnitMEC;
  */
 public class HwFPGA extends HwExecutionNode {
 
-
     public static final int DEFAULT_BYTE_DATA_SIZE = 4;
     public static final int DEFAULT_GO_IDLE_TIME = 10;
     public static final int DEFAULT_MAX_CONSECUTIVE_IDLE_CYCLES = 10;
@@ -59,14 +58,14 @@ public class HwFPGA extends HwExecutionNode {
     public static final int DEFAULT_MAPPING_PENALTY = 0;
     public static final int DEFAULT_RECONFIGURATION_TIME = 50;
 
-
-
     public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // Should be greater than 0
     public int goIdleTime = DEFAULT_GO_IDLE_TIME; // Should be greater or equal to 0
     public int maxConsecutiveIdleCycles = DEFAULT_MAX_CONSECUTIVE_IDLE_CYCLES; // Should be greater or equal to 0
     public int capacity = HwFPGA.DEFAULT_CAPACITY;
     public int mappingPenalty = HwFPGA.DEFAULT_MAPPING_PENALTY;
     public int reconfigurationTime = HwFPGA.DEFAULT_RECONFIGURATION_TIME;
+    public String scheduling = "";
+
 
     public HwFPGA(String _name) {
         super(_name);
@@ -76,9 +75,15 @@ public class HwFPGA extends HwExecutionNode {
         return "FPGA";
     }
 
+    public void setScheduling(String scheduling) { this.scheduling = scheduling;}
+
+    public String getScheduling() {return scheduling;}
+
     public String toXML() {
-        String s = "<FPGA name=\"" + name + "\" clockRatio=\"" + clockRatio + "\"  byteDataSize=\"" + byteDataSize + "\" execiTime=\"" + execiTime + "\" execcTime=\"" + execcTime + "\" pipelineSize=\"";
-        s +=  "\" capacity=\"" + capacity + "\" mappingPenalty=\"" + mappingPenalty + "\" reconfigurationTime=\"" + reconfigurationTime + "\" />\n";
+        String s = "<FPGA name=\"" + name + "\" clockRatio=\"" + clockRatio + "\"  byteDataSize=\"" + byteDataSize +
+                "\" execiTime=\"" + execiTime + "\" execcTime=\"" + execcTime + "\" pipelineSize=\"";
+        s +=  "\" capacity=\"" + capacity + "\" scheduling=\"" + scheduling + "\" mappingPenalty=\"" +
+                mappingPenalty + "\" reconfigurationTime=\"" + reconfigurationTime + "\" />\n";
         return s;
     }
 
diff --git a/src/main/java/tmltranslator/TMLArchiTextSpecification.java b/src/main/java/tmltranslator/TMLArchiTextSpecification.java
index a643c7c3a2..281d99d6d8 100755
--- a/src/main/java/tmltranslator/TMLArchiTextSpecification.java
+++ b/src/main/java/tmltranslator/TMLArchiTextSpecification.java
@@ -74,7 +74,8 @@ public class TMLArchiTextSpecification {
     private String nodetypes[] = {"CPU", "FPGA", "BUS", "LINK", "BRIDGE", "ROUTER", "MEMORY", "HWA", "DMA"};
     private String cpuparameters[] = {"nbOfCores", "byteDataSize", "pipelineSize", "goIdleTime", "maxConsecutiveIdleCycles", "taskSwitchingTime",
             "branchingPredictionPenalty", "cacheMiss", "schedulingPolicy", "sliceTime", "execiTime", "execcTime", "operation"};
-    private String fpgaparameters[] = {"capacity", "byteDataSize", "mappingPenalty", "goIdleTime", "maxConsecutiveIdleCycles", "reconfigurationTime", "execiTime", "execcTime"};
+    private String fpgaparameters[] = {"capacity", "byteDataSize", "mappingPenalty", "goIdleTime",
+            "maxConsecutiveIdleCycles", "reconfigurationTime", "execiTime", "execcTime", "scheduling"};
     private String linkparameters[] = {"bus", "node", "priority"};
     private String hwaparameters[] = {"byteDataSize", "execiTime"};
     private String busparameters[] = {"byteDataSize", "pipelineSize", "arbitration"};
@@ -193,6 +194,9 @@ public class TMLArchiTextSpecification {
                 if (fpga.getOperation().length() > 0) {
                     code += set + "operation " + fpga.getOperation() + CR;
                 }
+                if (fpga.getScheduling().length() > 0) {
+                    code += set + "scheduling " + fpga.getScheduling() + CR;
+                }
 
             }
 
@@ -346,8 +350,8 @@ public class TMLArchiTextSpecification {
 
     public void browseCode() {
         // Browse lines of code one after the other
-        // Build accordinlgy the TMLModeling and updates errors and warnings
-        // In case of fatal error, immedialty quit code bowsing
+        // Build accordingly the TMLModeling and updates errors and warnings
+        // In case of fatal error, immediately quit code browsing
 
         StringReader sr = new StringReader(spec);
         BufferedReader br = new BufferedReader(sr);
@@ -681,6 +685,15 @@ public class TMLArchiTextSpecification {
                         fpga.setOperation(tmpOp.trim());
 
                     }
+
+                    if (_split[2].toUpperCase().equals("SCHEDULING")) {
+                        String tmpOp = "";
+                        for (int i=3; i<_split.length; i++) {
+                            tmpOp += _split[i] + " ";
+                        }
+
+                        fpga.setScheduling(tmpOp.trim());
+                    }
                 }
 
                 if (node instanceof HwA) {
diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java
index 388768b67e..4dc0892986 100644
--- a/src/main/java/ui/GTMLModeling.java
+++ b/src/main/java/ui/GTMLModeling.java
@@ -2858,8 +2858,8 @@ public class GTMLModeling {
                     fpga.execiTime = fpgaNode.getExeciTime();
                     fpga.execcTime = fpgaNode.getExeccTime();
                     fpga.clockRatio = fpgaNode.getClockRatio();
-
                     fpga.setOperation(fpgaNode.getOperation());
+                    fpga.setScheduling(fpgaNode.getScheduling());
 
                     listE.addCor(fpga, fpgaNode);
                     archi.addHwNode(fpga);
diff --git a/src/main/java/ui/tmldd/TMLArchiFPGANode.java b/src/main/java/ui/tmldd/TMLArchiFPGANode.java
index 24b196a9d6..4a00e6903c 100755
--- a/src/main/java/ui/tmldd/TMLArchiFPGANode.java
+++ b/src/main/java/ui/tmldd/TMLArchiFPGANode.java
@@ -80,6 +80,8 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
 
     private String operation = "";
 
+    private String scheduling = "";
+
 
     public TMLArchiFPGANode(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);
@@ -329,6 +331,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
             }
         }
 
+
         if (dialog.getClockRatio().length() != 0) {
             try {
                 tmp = clockRatio;
@@ -345,6 +348,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
         }
 
        operation = dialog.getOperation().trim();
+        scheduling = dialog.getScheduling().trim();
 
 
         if (error) {
@@ -418,6 +422,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
         sb.append(" execcTime=\"" + execcTime + "\"");
         sb.append(" clockRatio=\"" + clockRatio + "\"");
         sb.append(" operation =\"" + operation + "\" ");
+        sb.append(" scheduling =\"" + scheduling + "\" ");
         sb.append("/>\n");
         sb.append("</extraparam>\n");
         return new String(sb);
@@ -495,6 +500,11 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
                                     operation = "";
                                 }
 
+                                scheduling = elt.getAttribute("scheduling");
+                                if (scheduling == null) {
+                                    scheduling = "";
+                                }
+
                             }
                         }
                     }
@@ -546,6 +556,10 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
         return operation;
     }
 
+    public String getScheduling() {
+        return scheduling;
+    }
+
 
     public String getAttributes() {
         String attr = "";
@@ -558,6 +572,7 @@ public class TMLArchiFPGANode extends TMLArchiNode implements SwallowTGComponent
         attr += "EXECI exec. time (in cycle) = " + execiTime + "\n";
         attr += "EXECC exec. time (in cycle) = " + execcTime + "\n";
         attr += "Operation  = " + operation + "\n";
+        attr += "Scheduling  = " + scheduling + "\n";
         attr += "Clock divider = " + clockRatio + "\n";
         return attr;
 
diff --git a/src/main/java/ui/window/JDialogCPUNode.java b/src/main/java/ui/window/JDialogCPUNode.java
index f75a7bbc26..69e1be69fd 100644
--- a/src/main/java/ui/window/JDialogCPUNode.java
+++ b/src/main/java/ui/window/JDialogCPUNode.java
@@ -71,6 +71,12 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
 //    private static String[] tracemodeTab = {"VCI logger"};
 
 
+    public static final String[] helpStrings = {"cpuname.html", "schedulingpolicy.html", "slicetime.html",
+            "numbercores.html", "datasize.html", "pipelinesize.html", "taskswitchingtime.html",
+            "misbrandingprediction.html", "cachemiss.html", "goidletime.html", "maxconsecutivecycles.html",
+            "execi.html", "execc.html", "clockdivider.html", "encryption.html", "cpuextension.html", "operation.html"};
+
+
     protected MainGUI mgui;
 
 
@@ -101,7 +107,7 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
     private java.util.List<SimulationTransaction> transactions;
 
     //issue 183
-    List<JButton>   buttons = new ArrayList<>();
+    List<JButton>  buttons;
     List<HelpEntry> helpEntries;
     TGComponentHelp cpuHelp;
 
@@ -114,6 +120,7 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         node = _node;
         MECType = _MECType;
         transactions = _transactions;
+
         initComponents();
         pack();
     }
@@ -135,14 +142,14 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         but.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
-                if(cpuHelp == null ) {
+                if(cpuHelp == null) {
                     cpuHelp = new TGComponentHelp(mgui, he);
                     cpuHelp.setLocationHelpWindow(but);
-                }else{
+                } else {
                     if(!cpuHelp.isVisible()) {
                         cpuHelp = new TGComponentHelp(mgui, he);
                         cpuHelp.setLocationHelpWindow(but);
-                    }else{
+                    } else{
                         cpuHelp.setVisible(false);
                     }
                 }
@@ -154,8 +161,16 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
 
     //issue 183
     private void hardwareHelp(){
-        HelpManager helpManager = new HelpManager();
-        if(helpManager.loadEntries()) {
+        HelpManager helpManager = mgui.getHelpManager();
+
+        if(!helpManager.loadEntries()) {
+            return;
+        }
+
+        buttons = new ArrayList<>();
+        helpEntries = new ArrayList<>();
+
+        /*if(helpManager.loadEntries()) {
             helpEntries = new ArrayList<>();
             HelpEntry he0 = helpManager.getHelpEntryWithHTMLFile("cpuname.html");
             helpEntries.add(he0);
@@ -191,13 +206,16 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
             helpEntries.add(he15);
             HelpEntry he16 = helpManager.getHelpEntryWithHTMLFile("operation.html");
             helpEntries.add(he16);
-        }
+        }*/
+
 
-        for(int i = 0; i < 17; i++) {
+        for(int i=0; i<helpStrings.length; i++) {
+            HelpEntry he = helpManager.getHelpEntryWithHTMLFile(helpStrings[i]);
+            helpEntries.add(he);
             Icon myIcon = IconManager.imgic32;
             JButton but = new JButton(myIcon);
             setButton(but);
-            buttonClick(but,helpEntries.get(i));
+            buttonClick(but, he);
             buttons.add(but);
         }
     }
@@ -247,7 +265,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(0),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(0),c2);
         c2.gridwidth = 1;
         c2.gridheight = 1;
         c2.weighty = 1.0;
@@ -266,7 +285,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-         panel2.add(buttons.get(1),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(1), c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -281,7 +301,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(2),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(2),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -290,13 +311,15 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         panel2.add(new JLabel("Nb of cores:"), c2);
         //c2.gridwidth = GridBagConstraints.REMAINDER; //end row
         nbOfCores = new JTextField(""+node.getNbOfCores(), 15);
-        panel2.add(nbOfCores, c2);
+        if (buttons != null)
+            panel2.add(nbOfCores, c2);
 
         //issue 183
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(3),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(3),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -311,7 +334,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(4),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(4),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -326,7 +350,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(5),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(5),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -341,7 +366,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(6),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(6),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -356,7 +382,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(7),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(7),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -371,7 +398,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(8),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(8),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -386,7 +414,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(9),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(9), c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -401,7 +430,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(10),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(10), c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -416,7 +446,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(11),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(11),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -431,7 +462,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(12),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(12),c2);
 
         c2.gridwidth = 1;
         //issue 183
@@ -446,7 +478,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c2.weighty = 0.5;
         c2.weightx = 0.5;
         c2.gridwidth = GridBagConstraints.REMAINDER;
-        panel2.add(buttons.get(13),c2);
+        if (buttons != null)
+            panel2.add(buttons.get(13), c2);
 
         // monitored
         /*c2.gridwidth = 1;
@@ -484,7 +517,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c4.weighty = 0.5;
         c4.weightx = 0.5;
         c4.gridwidth = GridBagConstraints.REMAINDER;
-        panel4.add(buttons.get(14),c4);
+        if (buttons != null)
+            panel4.add(buttons.get(14),c4);
         c4.weighty = 1.0;
         c4.weightx = 1.0;
         
@@ -499,7 +533,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c4.weighty = 0.5;
         c4.weightx = 0.5;
         c4.gridwidth = GridBagConstraints.REMAINDER;
-        panel4.add(buttons.get(16),c4);
+        if (buttons != null)
+            panel4.add(buttons.get(16),c4);
         c4.weighty = 1.0;
         c4.weightx = 1.0;
 
@@ -520,7 +555,8 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
         c4.weighty = 0.5;
         c4.weightx = 0.5;
         c4.gridwidth = GridBagConstraints.REMAINDER;
-        panel4.add(buttons.get(15),c4);
+        if (buttons != null)
+            panel4.add(buttons.get(15),c4);
 
         TraceManager.addDev("Transactions size=" + transactions.size());
         if (transactions.size()!=0) {
diff --git a/src/main/java/ui/window/JDialogFPGANode.java b/src/main/java/ui/window/JDialogFPGANode.java
index 76ca51f362..7c2e9e8399 100644
--- a/src/main/java/ui/window/JDialogFPGANode.java
+++ b/src/main/java/ui/window/JDialogFPGANode.java
@@ -72,7 +72,7 @@ public class JDialogFPGANode extends JDialogBase implements ActionListener {
 
     // Panel2
     protected JTextField byteDataSize, goIdleTime, maxConsecutiveIdleCycles, clockRatio, execiTime, execcTime,
-            capacity, mappingPenalty, reconfigurationTime, operation;
+            capacity, mappingPenalty, reconfigurationTime, operation, scheduling;
 
     // Tabbed pane for panel1 and panel2
     //private JTabbedPane tabbedPane;
@@ -185,6 +185,12 @@ public class JDialogFPGANode extends JDialogBase implements ActionListener {
         operation = new JTextField(""+node.getOperation(), 15);
         panel2.add(operation, c2);
 
+        c2.gridwidth = 1;
+        panel2.add(new JLabel("Scheduling:"), c2);
+        c2.gridwidth = GridBagConstraints.REMAINDER; //end row
+        scheduling = new JTextField(""+node.getScheduling(), 15);
+        panel2.add(scheduling, c2);
+
         c2.gridwidth = 1;
         panel2.add(new JLabel("Clock divider:"), c2);
         c2.gridwidth = GridBagConstraints.REMAINDER; //end row
@@ -281,6 +287,10 @@ public class JDialogFPGANode extends JDialogBase implements ActionListener {
         return operation.getText();
     }
 
+    public String getScheduling() {
+        return scheduling.getText();
+    }
+
 
     public String getClockRatio() {
         return clockRatio.getText();
-- 
GitLab