From 2f5de4275afc64262cacce33df1a03f69588c446 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Wed, 16 Apr 2014 13:50:42 +0000 Subject: [PATCH] Update on DIPLODOCUS methdology: simulations from methodology --- src/ui/MainGUI.java | 11 +- .../DiplodocusMethodologyDiagramName.java | 19 ++- ...hodologyDiagramReferenceToApplication.java | 27 ++-- ...sMethodologyDiagramReferenceToMapping.java | 22 ++- src/ui/window/JDialogSystemCGeneration.java | 145 +++++++++++++----- 5 files changed, 162 insertions(+), 62 deletions(-) diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index f50812aeaf..acee3ab524 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -3712,25 +3712,26 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } public void generateSystemC() { - generateSystemC(false); + generateSystemC(0); } - public void generateSystemC(boolean automatic) { + // Modes are defined in JDialogSystemCGeneration "automatic modes" + public void generateSystemC(int _mode) { TURTLEPanel tp = getCurrentTURTLEPanel(); if (tp instanceof AvatarDesignPanel) { avatarSimulation(); } else if ((tp instanceof TMLDesignPanel) || (tp instanceof TMLComponentDesignPanel) || (tp instanceof TMLArchiPanel)) { JDialogSystemCGeneration jgen = new JDialogSystemCGeneration(frame, this, "Simulation code generation and compilation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeDirectory, ConfigurationTTool.SystemCCodeCompileCommand, - ConfigurationTTool.SystemCCodeExecuteCommand, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand, ConfigurationTTool.GGraphPath, automatic); + ConfigurationTTool.SystemCCodeExecuteCommand, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand, ConfigurationTTool.GGraphPath, _mode); jgen.setSize(500, 750); GraphicLib.centerOnParent(jgen); jgen.setVisible(true); dtree.toBeUpdated(); - if (jgen.isInteractiveSimulationSelected() && !automatic) { + /*if (jgen.isInteractiveSimulationSelected() && (mode == 0)) { interactiveSimulationSystemC(jgen.getPathInteractiveExecute()); - } + }*/ } } diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java index c95f19ab48..245e73e75e 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramName.java @@ -61,27 +61,32 @@ public class DiplodocusMethodologyDiagramName extends TGCScalableWithoutInternal public final static int Y_MARGIN = 3; - protected final static int SIM_APP_DIPLO = 0; + protected final static int SIM_TRACE_APP_DIPLO = 0; + protected final static int SIM_ANIM_APP_DIPLO = 7; protected final static int UPP_APP_DIPLO = 1; protected final static int LOT_APP_DIPLO = 2; protected final static int TML_APP_DIPLO = 3; protected final static int FV_MAPPING_DIPLO = 4; - protected final static int SIM_MAPPING_DIPLO = 5; + protected final static int SIM_TRACE_MAPPING_DIPLO = 5; + protected final static int SIM_ANIM_MAPPING_DIPLO = 8; protected final static int TML_MAPPING_DIPLO = 6; protected final String[] SHORT_ACTION_NAMES = { - "sim", "upp", "lot", "tml", - "fv", "sim", "tmap"}; + "sim-trace", "upp", "lot", "tml", + "fv", "sim-trace", "tmap", "sim-anim", "sim-anim"}; protected final String[] LONG_ACTION_NAMES = { - "Simulate a DIPLODOCUS functional model", + /*0*/ "Generate a vcd simulation trace of a DIPLODOCUS functional model", "Verify a DIPLODOCUS functional model with UPPAAL", "Generate a Reachability graph of a DIPLODOCUS functional model", "Generate a TML text description of a DIPLODOCUS functional model", "Formal verify a DIPLODOCUS mapping model", - "Simulate a DIPLODOCUS mapping model", - "Generate a TMAP/TARCHI/TML text dscription of a DIPLODOCUS mapping model"}; + /*5*/ "Simulate a DIPLODOCUS mapping model", + "Generate a TMAP/TARCHI/TML text dscription of a DIPLODOCUS mapping model", + "Simulate and animate DIPLODOCUS functional models", + "Simulate and animate DIPLODOCUS mapping models" + }; protected int[] validations; protected int[] valMinX; diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java index cc10bc82bb..4dd67fc216 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToApplication.java @@ -90,11 +90,12 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc } public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { - dn.setValidationsNumber(4); - dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_APP_DIPLO); - dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.LOT_APP_DIPLO); - dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.UPP_APP_DIPLO); - dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.TML_APP_DIPLO); + dn.setValidationsNumber(5); + dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_ANIM_APP_DIPLO); + dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.SIM_TRACE_APP_DIPLO); + dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.LOT_APP_DIPLO); + dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.UPP_APP_DIPLO); + dn.setValidationsInfo(4, DiplodocusMethodologyDiagramName.TML_APP_DIPLO); } public boolean makeCall(String diagramName, int index) { @@ -106,12 +107,20 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc return false; } if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { - tdp.getMGUI().generateSystemC(true); + tdp.getMGUI().generateSystemC(JDialogSystemCGeneration.ANIMATION); return true; } return false; - case 1: + if (!openDiagram(diagramName)) { + return false; + } + if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { + tdp.getMGUI().generateSystemC(JDialogSystemCGeneration.ONE_TRACE); + return true; + } + return false; + case 2: if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { if (!tdp.getMGUI().generateLOTOS(true)) { TraceManager.addDev("Generate LOTOS: error"); @@ -127,7 +136,7 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc return false; } - case 2: + case 3: if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { tdp.getMGUI().generateUPPAAL(false); boolean result = tdp.getMGUI().gtm.generateUPPAALFromTML(ConfigurationTTool.UPPAALCodeDirectory, false, 8, false); @@ -144,7 +153,7 @@ public class DiplodocusMethodologyDiagramReferenceToApplication extends Diplodoc } break; - case 3: + case 4: if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { TraceManager.addDev("Generate TML"); tmp = tdp.getMGUI().generateTMLTxt(); diff --git a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java index b456bfc5ea..f80a7ba41e 100755 --- a/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java +++ b/src/ui/diplodocusmethodology/DiplodocusMethodologyDiagramReferenceToMapping.java @@ -91,10 +91,11 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe } public void makeValidationInfos(DiplodocusMethodologyDiagramName dn) { - dn.setValidationsNumber(3); - dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_MAPPING_DIPLO); - dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.FV_MAPPING_DIPLO); - dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.TML_MAPPING_DIPLO); + dn.setValidationsNumber(4); + dn.setValidationsInfo(0, DiplodocusMethodologyDiagramName.SIM_ANIM_MAPPING_DIPLO); + dn.setValidationsInfo(1, DiplodocusMethodologyDiagramName.SIM_TRACE_MAPPING_DIPLO); + dn.setValidationsInfo(2, DiplodocusMethodologyDiagramName.FV_MAPPING_DIPLO); + dn.setValidationsInfo(3, DiplodocusMethodologyDiagramName.TML_MAPPING_DIPLO); } public boolean makeCall(String diagramName, int index) { @@ -106,7 +107,7 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe return false; } if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { - tdp.getMGUI().generateSystemC(true); + tdp.getMGUI().generateSystemC(JDialogSystemCGeneration.ANIMATION); return true; } return false; @@ -115,11 +116,20 @@ public class DiplodocusMethodologyDiagramReferenceToMapping extends DiplodocusMe return false; } if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { - tdp.getMGUI().generateSystemC(true); + tdp.getMGUI().generateSystemC(JDialogSystemCGeneration.ONE_TRACE); return true; } return false; case 2: + if (!openDiagram(diagramName)) { + return false; + } + if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { + tdp.getMGUI().generateSystemC(JDialogSystemCGeneration.FORMAL_VERIFICATION); + return true; + } + return false; + case 3: if (tdp.getMGUI().checkModelingSyntax(diagramName, true)) { TraceManager.addDev("Generate TML"); tmp = tdp.getMGUI().generateTMLTxt(); diff --git a/src/ui/window/JDialogSystemCGeneration.java b/src/ui/window/JDialogSystemCGeneration.java index 03d74e3906..b9e78fef40 100755 --- a/src/ui/window/JDialogSystemCGeneration.java +++ b/src/ui/window/JDialogSystemCGeneration.java @@ -96,6 +96,8 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act int mode; + + //components protected JTextArea jta; protected JButton start; @@ -149,12 +151,18 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act protected RshClient rshc; - private boolean automatic; + // Automatic modes + public final static int MANUAL = 0; + public final static int ONE_TRACE = 1; + public final static int ANIMATION = 2; + public final static int FORMAL_VERIFICATION = 3; + + private int automatic; private boolean wasClosed = false; /** Creates new form */ - public JDialogSystemCGeneration(Frame f, MainGUI _mgui, String title, String _hostSystemC, String _pathCode, String _pathCompiler, String _pathExecute, String _pathInteractiveExecute, String _graphPath, boolean _automatic) { + public JDialogSystemCGeneration(Frame f, MainGUI _mgui, String title, String _hostSystemC, String _pathCode, String _pathCompiler, String _pathExecute, String _pathInteractiveExecute, String _graphPath, int _automatic) { super(f, title, true); mgui = _mgui; @@ -180,9 +188,9 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act pathFormalExecute = pathInteractiveExecute; int index = pathFormalExecute.indexOf("-server"); - if (index == -1) { + if (index != -1) { pathFormalExecute = pathFormalExecute.substring(0, index) + pathFormalExecute.substring(index+7, pathFormalExecute.length()); - pathFormalExecute += " -cmd '1 7 100 100'"; + pathFormalExecute += " -explo"; } } @@ -199,7 +207,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act //getGlassPane().addMouseListener( new MouseAdapter() {}); getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - if (automatic) { + if (automatic > 0) { startProcess(); } } @@ -389,7 +397,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act panele4Tepe.add(panele3Tepe, BorderLayout.CENTER); jp01.add(panele4Tepe, c01); - if (automatic) { + if (automatic > 0) { //GraphicLib.enableComponents(jp01, false); } @@ -437,25 +445,30 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act exe2 = new JTextField(pathExecute, 100); jp03.add(exe2, c02); + + exeint = new JRadioButton(textSysC5, true); exeint.addActionListener(this); exegroup.add(exeint); //exeJava.addActionListener(this); jp03.add(exeint, c03); + exe2int = new JTextField(pathInteractiveExecute, 100); + jp03.add(exe2int, c02); - exe2formal = new JTextField(pathInteractiveExecute, 100); - jp03.add(exe2formal, c02); exeformal = new JRadioButton(textSysC6, true); exeformal.addActionListener(this); exegroup.add(exeformal); + jp03.add(exeformal, c03); + exe2formal = new JTextField(pathFormalExecute, 100); + jp03.add(exe2formal, c02); jp03.add(new JLabel(" "), c03); jp1.add("Execute", jp03); c.add(jp1, BorderLayout.NORTH); - if (automatic) { + if (automatic > 0) { //GraphicLib.enableComponents(jp03, false); GraphicLib.enableComponents(jp1, false); } @@ -464,7 +477,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act jta.setEditable(false); jta.setMargin(new Insets(10, 10, 10, 10)); jta.setTabSize(3); - if (!automatic) { + if (automatic == 0) { jta.append("Select options and then, click on 'start' to launch SystemC code generation / compilation\n"); } Font f = new Font("Courrier", Font.BOLD, 12); @@ -492,7 +505,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act close.addActionListener(this); JPanel jp2 = new JPanel(); - if (!automatic) { + if (automatic == 0) { jp2.add(start); jp2.add(stop); } @@ -503,15 +516,10 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } public void updateInteractiveSimulation() { - if (!automatic) { - interactiveSimulationSelected = !(exe.isSelected()); - if (!interactiveSimulationSelected) { - exe2.setEnabled(true); - exe2int.setEnabled(false); - } else { - exe2.setEnabled(false); - exe2int.setEnabled(true); - } + if (automatic == 0) { + exe2.setEnabled(exe.isSelected()); + exe2int.setEnabled(exeint.isSelected()); + exe2formal.setEnabled(exeformal.isSelected()); } } @@ -569,24 +577,24 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } public void startProcess() { - if (automatic) { + if (automatic > 0) { startProcess = false; t = new Thread(this); mode = STARTED; go = true; t.start(); } else { - if ((interactiveSimulationSelected) && (jp1.getSelectedIndex() == 2)) { + /*if ((interactiveSimulationSelected) && (jp1.getSelectedIndex() == 2)) { startProcess = true; dispose(); - } else { + } else {*/ startProcess = false; t = new Thread(this); mode = STARTED; setButtons(); go = true; t.start(); - } + //} } } @@ -605,7 +613,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act try { - if (automatic) { + if (automatic > 0) { generateCode(); testGo(); @@ -838,22 +846,87 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act return; } - if (automatic) { - if (interactiveSimulationSelected) { - dispose(); - mgui.interactiveSimulationSystemC(getPathInteractiveExecute()); + String cmd; + int mode = 0; + + if (automatic > 0) { + mode = automatic; + } else { + if (exe.isSelected()) { + mode = ONE_TRACE; + } + if (exeint.isSelected()) { + mode = ANIMATION; + } + if (exeformal.isSelected()) { + mode = FORMAL_VERIFICATION; } } - String cmd; + TraceManager.addDev("Mode=" + mode); + switch(mode) { + case ONE_TRACE: + executeSimulationCommand(exe2.getText()); + break; + case ANIMATION: + dispose(); + mgui.interactiveSimulationSystemC(getPathInteractiveExecute()); + break; + case FORMAL_VERIFICATION: + executeSimulationCommand(exe2formal.getText()); + break; + default: + + } + + /* + if (automatic > 0) { + switch(automatic) { + + + + } + if (interactiveSimulationSelected) { + dispose(); + mgui.interactiveSimulationSystemC(getPathInteractiveExecute()); + } + } else { + + + + try { + cmd = exe2.getText(); + + jta.append("Executing SystemC code with command: \n" + cmd + "\n"); + + rshc = new RshClient(hostSystemC); + // It assumes that data are on the remote host + // Command + + processCmd(cmd, jta); + //jta.append(data); + jta.append("Execution done\n"); + } catch (LauncherException le) { + jta.append("Error: " + le.getMessage() + "\n"); + mode = STOPPED; + setButtons(); + return; + } catch (Exception e) { + mode = STOPPED; + setButtons(); + return; + } + }*/ + } + + protected void executeSimulationCommand(String cmd) { try { - cmd = exe2.getText(); - jta.append("Executing SystemC code with command: \n" + cmd + "\n"); + jta.append("Executing simulation code with command: \n" + cmd + "\n"); rshc = new RshClient(hostSystemC); - // Assuma data are on the remote host + // It assumes that data are on the remote host // Command processCmd(cmd, jta); @@ -871,6 +944,8 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } } + + protected void processCmd(String cmd, JTextArea _jta) throws LauncherException { rshc.setCmd(cmd); String s = null; @@ -886,7 +961,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } protected void setButtons() { - if (!automatic) { + if (automatic == 0) { switch(mode) { case NOT_STARTED: start.setEnabled(true); @@ -941,7 +1016,7 @@ public class JDialogSystemCGeneration extends javax.swing.JDialog implements Act } private void setList() { - if (!automatic) { + if (automatic == 0) { int i1 = listIgnoredTepe.getSelectedIndex(); int i2 = listValidatedTepe.getSelectedIndex(); -- GitLab