From 010a24cc7ede312f4ec6acf309e01a0e7f2bec7f Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr>
Date: Fri, 27 May 2011 13:33:27 +0000
Subject: [PATCH] AVATAR code genetator: Update on tracing functions +
 graphical interface to visuliaze traces

---
 executablecode/src/tracemanager.c             |  41 +-
 executablecode/src/tracemanager.h             |   7 +-
 src/avatartranslator/AvatarTransition.java    |  10 +
 .../toexecutable/AVATAR2CPOSIX.java           |  83 +-
 .../GenericTransaction.java                   |  78 ++
 .../JFrameSimulationSDPanel.java              | 219 +++++
 .../JSimulationSDPanel.java                   | 919 ++++++++++++++++++
 ...JDialogAvatarExecutableCodeGeneration.java |  52 +-
 8 files changed, 1389 insertions(+), 20 deletions(-)
 create mode 100755 src/ui/interactivesimulation/GenericTransaction.java
 create mode 100755 src/ui/interactivesimulation/JFrameSimulationSDPanel.java
 create mode 100644 src/ui/interactivesimulation/JSimulationSDPanel.java

diff --git a/executablecode/src/tracemanager.c b/executablecode/src/tracemanager.c
index 3befa1d411..b2e88220c9 100644
--- a/executablecode/src/tracemanager.c
+++ b/executablecode/src/tracemanager.c
@@ -51,13 +51,13 @@ void addInfo(char *dest, char *info) {
   }
   s1[9] = '\0';
   
-  sprintf(dest, "#%d @%ld.%s %s", id, ts1.tv_sec, s1, info);
+  sprintf(dest, "#%d time=%ld.%s %s", id, ts1.tv_sec, s1, info);
   id ++;
 }
 
 
 void writeInTrace(char *info) {
-  char s[1024];
+  char s[CHAR_ALLOC_SIZE];
   addInfo(s, info);
 		 //printf("Write in file\n");
   if (file != NULL) {
@@ -88,7 +88,7 @@ void unactiveTracing() {
 
 
 void traceStateEntering(char *myname, char *statename) {
-  char s[1024];
+  char s[CHAR_ALLOC_SIZE];
 
   debugMsg("Trace function");
 
@@ -102,8 +102,8 @@ void traceStateEntering(char *myname, char *statename) {
   writeInTrace(s);
 }
 
-void traceFunctionCall(char *block, char *func) {
-  char s[1024];
+void traceFunctionCall(char *block, char *func, char *params) {
+  char s[CHAR_ALLOC_SIZE];
 
   debugMsg("Trace function");
 
@@ -111,12 +111,41 @@ void traceFunctionCall(char *block, char *func) {
     return;
   }
 
-  sprintf(s, "block=%s type=function_call func=%s\n", block, func);
+  sprintf(s, "block=%s type=function_call func=%s parameters=%s\n", block, func, params);
+
+  // Saving trace
+  writeInTrace(s);
+}
+
+
+// type=0: int type = 1:bool
+void traceVariableModification(char *block, char *var, int value, int type) {
+  char s[CHAR_ALLOC_SIZE];
+  debugMsg("Trace variable modification");
+
+  if (trace == TRACE_OFF) {
+    return;
+  }
+
+  
+  if (type == 0) {
+    sprintf(s, "block=%s type=variable_modification variable=%s setTo=%d\n", block, var, value);
+  }
+
+  if (type == 1) {
+    if (value == 0) {
+      sprintf(s, "block=%s type=variable_modification variable=%s setTo=false\n", block, var);
+    } else {
+      sprintf(s, "block=%s type=variable_modification variable=%s setTo=true\n", block, var);
+    }
+  }
 
   // Saving trace
   writeInTrace(s);
+
 }
 
+
 void traceRequest(char *myname, request *req) {
   char s[1024];
 
diff --git a/executablecode/src/tracemanager.h b/executablecode/src/tracemanager.h
index c5289dd2bc..e85417a0cb 100644
--- a/executablecode/src/tracemanager.h
+++ b/executablecode/src/tracemanager.h
@@ -3,12 +3,17 @@
 
 #include "request.h"
 
+#define CHAR_ALLOC_SIZE 1024
+
 void activeTracingInFile();
 void unactiveTracing();
 void traceRequest(char *myname, request *req);
-void traceFunctionCall(char *block, char *func);
+void traceFunctionCall(char *block, char *func, char* params);
+void traceVariableModification(char *block, char *var, int value, int type); // type=0: int type = 1:bool
 void traceStateEntering(char *myname, char *statename);
 
+
+
 #endif
 
 
diff --git a/src/avatartranslator/AvatarTransition.java b/src/avatartranslator/AvatarTransition.java
index d308b00d92..bfdc085ff5 100644
--- a/src/avatartranslator/AvatarTransition.java
+++ b/src/avatartranslator/AvatarTransition.java
@@ -312,6 +312,16 @@ public class AvatarTransition extends AvatarStateMachineElement {
 		
 		return "Empty transition";
 	}
+    
+    public static String getVariableInAction(String action) {
+        action = action.trim();
+        int index = action.indexOf("=");
+        if (index == -1) {
+            return action;
+        }
+        
+        return action.substring(0, index).trim();
+    }
 	
 	
 	
diff --git a/src/avatartranslator/toexecutable/AVATAR2CPOSIX.java b/src/avatartranslator/toexecutable/AVATAR2CPOSIX.java
index 76cc998bec..85b68a00c8 100755
--- a/src/avatartranslator/toexecutable/AVATAR2CPOSIX.java
+++ b/src/avatartranslator/toexecutable/AVATAR2CPOSIX.java
@@ -262,7 +262,25 @@ public class AVATAR2CPOSIX {
 			ret += ") {" + CR;
 			
 			if (tracing) {
-				ret += traceFunctionCall(_block.getName(), am.getName());
+                String tr = "";
+                cpt = 0;
+                if (list.size() > 0) {
+                    ret += "char my__attr[CHAR_ALLOC_SIZE];" + CR;
+                    ret += "sprintf(my__attr, \"";
+                    for(AvatarAttribute aa: list) {
+                        if (cpt != 0) {
+                            tr += ",";
+                            ret += ",";
+                        }
+                        tr += aa.getName();
+                        ret += "%d";
+                        cpt ++;
+                    }
+                    ret += "\"," + tr + ");" + CR;
+                    ret += traceFunctionCall(_block.getName(), am.getName(), "my__attr");
+                }  else {
+                    ret += traceFunctionCall(_block.getName(), am.getName(), null);
+                }
 			}
 			
 			if (debug) {
@@ -317,6 +335,10 @@ public class AVATAR2CPOSIX {
 		s+= "request *__returnRequest;" + CR;
 		
 		s+= CR + "char * __myname = (char *)arg;" + CR;
+        
+        /*if (tracing) {
+            s+= CR + "char __value[CHAR_ALLOC_SIZE];" + CR;
+        }*/
 		
 		s+= CR + "pthread_cond_init(&__myCond, NULL);" + CR;
 		
@@ -392,7 +414,8 @@ public class AVATAR2CPOSIX {
 			}
 			
 			String act;
-			for(i=0; i<at.getNbOfAction(); i++) {
+            ret += makeActionsOfTransaction(_block, at);
+			/*for(i=0; i<at.getNbOfAction(); i++) {
 				// Must know whether this is an action or a method call
 				act = at.getAction(i);
 				if (at.isAMethodCall(act)) {
@@ -400,7 +423,7 @@ public class AVATAR2CPOSIX {
 				} else {
 					ret +=  act + ";" + CR;
 				}
-			}
+			}*/
 			return ret + makeBehaviourFromElement(_block, _asme.getNext(0), false);
 		}
 	
@@ -461,14 +484,16 @@ public class AVATAR2CPOSIX {
 					AvatarTransition at = (AvatarTransition)(_asme.getNext(i));
 					if (at.hasActions()) {
 						ret += " if (__returnRequest == &__req" + i + ") {" + CR;
-						for(int j=0; j<at.getNbOfAction(); j++) {
+                         ret += makeActionsOfTransaction(_block, at);
+						/*for(int j=0; j<at.getNbOfAction(); j++) {
 							if (at.isAMethodCall(at.getAction(j))) {
 								ret +=  modifyMethodName(_block, at.getAction(j)) + ";" + CR;
 							} else {
 								ret +=  at.getAction(j) + ";" + CR;
+                                    
 							}
 							
-						}
+						}*/
 						ret += makeBehaviourFromElement(_block, at.getNext(0), false) + CR + "}";
 					}  else {
 						if (at.getNext(0) instanceof AvatarActionOnSignal) {
@@ -741,12 +766,24 @@ public class AVATAR2CPOSIX {
 		}
 		return "traceRequest(__myname, __returnRequest);" + CR;
 	}
+    
+    private String traceVariableModification(String blockName, String varName, String type) {
+		if (!tracing) {
+			return "";
+		}
+        
+		return "traceVariableModification(\"" + blockName + "\", \"" + varName + "\", " + varName + "," + type + ");" + CR;
+	}
 	
-	private String traceFunctionCall(String blockName, String functionName) {
+	private String traceFunctionCall(String blockName, String functionName, String params) {
 		if (!tracing) {
 			return "";
 		}
-		return "traceFunctionCall(\"" + blockName + "\", \"" + functionName + "\");" + CR;
+        
+        if (params == null) {
+            params = "\"-\"";
+        }
+		return "traceFunctionCall(\"" + blockName + "\", \"" + functionName + "\", " + params + ");" + CR;
 	}
 	
 	private String traceStateEntering(String name, String stateName) {
@@ -770,6 +807,36 @@ public class AVATAR2CPOSIX {
 		
 		return "debug2Msg(__myname, \"" + s + "\");" + CR;
 	}
-				
+    
+    public String makeActionsOfTransaction(AvatarBlock _block, AvatarTransition _at) {
+        String ret = "";
+        String act;
+        String var;
+        String type;
+        for(int i=0; i<_at.getNbOfAction(); i++) {
+            // Must know whether this is an action or a method call
+            act = _at.getAction(i);
+            if (_at.isAMethodCall(act)) {
+                ret +=  modifyMethodName(_block, act) + ";" + CR;
+            } else {
+                ret +=  act + ";" + CR;
+                 var = _at.getVariableInAction(act);
+                 AvatarAttribute aa;
+                    aa = _block.getAvatarAttributeWithName(var);
+                    if (aa != null) {
+                        if (aa.isInt()) {
+                            type = "0";
+                        } else {
+                            type = "1";
+                        }
+                        //ret += "sprintf(__value, \"%d\", " + var + ");" + CR;
+                         ret += traceVariableModification(_block.getName(), var, type);
+                    }
+               
+            }
+        }
+        
+        return ret;
+    }		
 	
 }
\ No newline at end of file
diff --git a/src/ui/interactivesimulation/GenericTransaction.java b/src/ui/interactivesimulation/GenericTransaction.java
new file mode 100755
index 0000000000..7f71fb428b
--- /dev/null
+++ b/src/ui/interactivesimulation/GenericTransaction.java
@@ -0,0 +1,78 @@
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+
+ludovic.apvrille AT enst.fr
+
+This software is a computer program whose purpose is to allow the 
+edition of TURTLE analysis, design and deployment diagrams, to 
+allow the generation of RT-LOTOS or Java code from this diagram, 
+and at last to allow the analysis of formal validation traces 
+obtained from external tools, e.g. RTL from LAAS-CNRS and CADP 
+from INRIA Rhone-Alpes.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+
+/**
+ * Class GenericTransaction
+ * Transaction as used  
+ * Creation: 26/05/2011
+ * @version 1.0 26/05/2011
+ * @author Ludovic APVRILLE
+ * @see
+ */
+
+package ui.interactivesimulation;
+
+import java.util.*;
+import javax.swing.table.*;
+
+import myutil.*;
+import tmltranslator.*;
+
+public class GenericTransaction  {
+    
+    public final static int NOT_DEFINED = 0;
+    public final static int FUNCTION_CALL = 1;
+    public final static int STATE_ENTERING = 2;
+    public final static int VAR_MODIFICATION = 3;
+    
+	public int ID;
+    public int type;
+    public String entityName;
+    public String name;
+    public String action;
+    public long startingTime;
+    public long finishTime;
+    
+    public long stamp;
+    
+    
+    
+	public GenericTransaction() {
+	}
+
+
+}
\ No newline at end of file
diff --git a/src/ui/interactivesimulation/JFrameSimulationSDPanel.java b/src/ui/interactivesimulation/JFrameSimulationSDPanel.java
new file mode 100755
index 0000000000..e4ad47e0ae
--- /dev/null
+++ b/src/ui/interactivesimulation/JFrameSimulationSDPanel.java
@@ -0,0 +1,219 @@
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+
+ludovic.apvrille AT enst.fr
+
+This software is a computer program whose purpose is to allow the 
+edition of TURTLE analysis, design and deployment diagrams, to 
+allow the generation of RT-LOTOS or Java code from this diagram, 
+and at last to allow the analysis of formal validation traces 
+obtained from external tools, e.g. RTL from LAAS-CNRS and CADP 
+from INRIA Rhone-Alpes.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+
+/**
+* Class JFrameSimulationSDPanel
+* Creation: 26/05/2011
+* version 1.0 26/05/2011
+* @author Ludovic APVRILLE
+* @see
+*/
+
+package ui.interactivesimulation;
+
+//import java.io.*;
+import javax.swing.*;
+//import javax.swing.event.*;
+import javax.swing.table.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+
+
+import myutil.*;
+import ui.*;
+import ui.file.*;
+
+import tmltranslator.*; 
+
+import launcher.*;
+import remotesimulation.*;
+
+import org.w3c.dom.*;
+import org.xml.sax.*;
+import javax.xml.parsers.*;
+
+
+public	class JFrameSimulationSDPanel extends JFrame implements ActionListener {
+	
+	/*protected static final String SIMULATION_HEADER = "siminfo";
+	protected static final String SIMULATION_GLOBAL = "global";
+	protected static final String SIMULATION_TASK = "task";
+	protected static final String SIMULATION_CPU = "cpu";
+	protected static final String SIMULATION_BUS = "bus";
+	protected static final String SIMULATION_COMMAND = "cmd";
+	
+	private static String buttonStartS = "Start simulator";
+	private static String buttonCloseS = "Close";
+	private static String buttonStopAndCloseS = "Stop simulator and close";
+	
+	private static int NOT_STARTED = 0;
+	private static int STARTING = 1;
+	private static int STARTED_NOT_CONNECTED = 2;
+	private static int STARTED_AND_CONNECTED = 3;*/
+    
+    public InteractiveSimulationActions [] actions;
+	
+	private Frame f;
+	private MainGUI mgui;
+	private String title;
+	//private String hostSystemC;
+	//private String pathExecute;
+	
+    private static String[] unitTab = {"sec", "msec", "usec", "nsec"};
+    private static int[] clockDivisers = {1000000000, 1000000, 1000, 1};
+    protected JComboBox units;
+    
+	protected JButton buttonClose;
+    protected JSimulationSDPanel sdpanel;
+    protected JLabel status;
+    //, buttonStart, buttonStopAndClose;
+	//protected JTextArea jta;
+	//protected JScrollPane jsp;
+	
+	public JFrameSimulationSDPanel(Frame _f, MainGUI _mgui, String _title) {
+		super(_title);
+		
+		f = _f;
+		mgui = _mgui;
+		title = _title;
+        
+		initActions();
+		makeComponents();
+		//setComponents();
+	}
+	
+	private JLabel createStatusBar()  {
+        status = new JLabel("Ready...");
+	    status.setForeground(ColorManager.InteractiveSimulationText);
+        status.setBorder(BorderFactory.createEtchedBorder());
+        return status;
+    }
+	
+	public void makeComponents() {
+		JPanel jp01, jp02;
+		//jp01.setPreferredSize(new Dimension(375, 400));
+		GridBagLayout gridbag01;
+		GridBagConstraints c01 ;
+		
+		//cp = new CommandParser();
+		
+		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+		Container framePanel = getContentPane();
+		framePanel.setLayout(new BorderLayout());
+        
+        // Top panel
+        JPanel topPanel = new JPanel();
+        buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_STOP_ALL]);
+        topPanel.add(buttonClose);
+        topPanel.add(new JLabel(" time unit:"));
+        units = new JComboBox(unitTab);
+        units.setSelectedIndex(1);
+        units.addActionListener(this);
+        topPanel.add(units);
+        framePanel.add(topPanel, BorderLayout.NORTH);
+        
+        // Simulation panel
+        sdpanel = new JSimulationSDPanel();
+        JScrollPane jsp	= new JScrollPane(sdpanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+        sdpanel.setMyScrollPanel(jsp);
+        jsp.setWheelScrollingEnabled(true);
+        jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT);
+        framePanel.add(jsp, BorderLayout.CENTER);
+        
+        // statusBar
+        status = createStatusBar();
+        framePanel.add(status, BorderLayout.SOUTH);
+        
+        // Mouse handler
+        //mouseHandler = new MouseHandler(status);
+        
+        pack();
+        
+        //System.out.println("Row table:" + rowTable.toString());
+        //System.out.println("Value table:" + valueTable.toString());
+	}
+    
+    private	void initActions() {
+        actions = new InteractiveSimulationActions[InteractiveSimulationActions.NB_ACTION];
+        for(int	i=0; i<InteractiveSimulationActions.NB_ACTION; i++) {
+            actions[i] = new InteractiveSimulationActions(i);
+            actions[i].addActionListener(this);
+            //actions[i].addKeyListener(this);
+        }
+    }
+	
+	
+	
+	public void close() {
+		dispose();
+		setVisible(false);
+		
+	}
+    
+	
+	public void	actionPerformed(ActionEvent evt)  {
+		String command = evt.getActionCommand();
+		TraceManager.addDev("Command:" + command);
+		
+		if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand()))  {
+			close();
+			return;
+			//TraceManager.addDev("Start simulation!");
+		} else if (evt.getSource() == units) {
+            if (sdpanel != null) {
+                switch(units.getSelectedIndex()) {
+                case 0:
+                    
+                }
+                sdpanel.setClockDiviser(clockDivisers[units.getSelectedIndex()]);
+            }
+        }
+	}
+    
+    public void setFileReference(String _fileReference) {
+        if (sdpanel != null) {
+            TraceManager.addDev("RSetting file");
+            sdpanel.setFileReference(_fileReference);
+        }
+    }
+	
+    
+	
+	
+} // Class
diff --git a/src/ui/interactivesimulation/JSimulationSDPanel.java b/src/ui/interactivesimulation/JSimulationSDPanel.java
new file mode 100644
index 0000000000..4804336226
--- /dev/null
+++ b/src/ui/interactivesimulation/JSimulationSDPanel.java
@@ -0,0 +1,919 @@
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+
+ludovic.apvrille AT enst.fr
+
+This software is a computer program whose purpose is to allow the 
+edition of TURTLE analysis, design and deployment diagrams, to 
+allow the generation of RT-LOTOS or Java code from this diagram, 
+and at last to allow the analysis of formal validation traces 
+obtained from external tools, e.g. RTL from LAAS-CNRS and CADP 
+from INRIA Rhone-Alpes.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+
+/**
+* Class JSimulationSDPanel
+* Generic panel for displaying simulation transactions in the form
+* of a Sequence Diagram
+* Creation: 26/05/2011
+* @version 1.0 26/05/2011
+* @author Ludovic APVRILLE
+* @see
+*/
+
+
+package ui.interactivesimulation;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+
+import java.awt.image.*;
+
+import avatartranslator.*;
+import avatartranslator.directsimulation.*;
+import myutil.*;
+import ui.*;
+
+public class JSimulationSDPanel extends JPanel implements MouseMotionListener, Runnable  {
+	
+	private static int MAX_X = 800;
+	private static int MAX_Y = 200;
+	private static long stamp = 0;
+	
+	// Drawing area
+    private int minLimit = 10;
+    private int maxX = MAX_X;
+    private int maxY = MAX_Y;
+    private final int limit = 10;
+	
+	// Drawing parameters
+	private int minSpaceBetweenLifeLines = 5;
+	private int spaceBetweenLifeLines = 150;
+	private boolean spaceBetweenLifeLinesComputed = false;
+	private int spaceAtEnd = 50;
+	private int spaceAtTop = 50;
+	private int verticalSpaceUnderBlocks = 15;
+	private int spaceVerticalText = 2;
+	private int spaceHorizontalText = 2;
+	private int spaceStop = 20;
+	private int verticalLink = 10;
+	private int lengthAsync = 50;
+	private int spaceBroadcast = 25;
+	
+	// Transactions
+    protected String fileReference;
+    
+	private int maxNbOfTransactions = 1000;
+	private int drawnTransactions = 1000;
+	
+	// My scroll panel
+	private JScrollPane jsp;
+	private boolean mustScroll = true;
+	
+	// Mouse
+	private int xMouse, yMouse;
+	private boolean drawInfo = false;
+	private long clockValueMouse;
+    private long clockDiviser = 1000000; //ms
+	private Vector<Point> points;
+	private Vector<GenericTransaction> transactionsOfPoints;
+	
+    // List of entities ... List is discovered progressively
+    // Or the list is described in the trace (header information)
+    Vector <String> entityNames;
+    
+    private final int NO_MODE = 0;
+    private final int FILE_MODE = 1;
+    private int mode;
+    private boolean go;
+    private Thread t;
+    
+    Vector<GenericTransaction> transactions;
+    
+    
+    public JSimulationSDPanel() {
+		//points = new Vector<Point>();
+		//transactionsOfPoints = new Vector<AvatarSimulationTransaction>();
+		
+        entityNames = new Vector <String>();
+        transactions = new Vector<GenericTransaction>();
+        transactionsOfPoints = new Vector<GenericTransaction>();
+        points = new Vector<Point>();
+        
+        mode = NO_MODE;
+        
+		setBackground(Color.WHITE);
+		setNewSize();
+		addMouseMotionListener(this);
+        
+        
+    }
+	
+	public void setMyScrollPanel(JScrollPane _jsp) {
+		jsp = _jsp;
+	}
+	
+	protected void paintComponent(Graphics g) {
+		super.paintComponent(g);
+		int currentY = spaceAtTop;
+		int currentX = spaceAtEnd;
+		int oldMaxY = maxY;
+		int oldMaxX = maxX;
+		
+		if (!spaceBetweenLifeLinesComputed) {
+			computeSpaceBetweenLifeLines(g);
+		}
+		
+		
+		currentY = paintTopElements(g, currentX, currentY);
+		paintTransactions(g, currentX, currentY);
+		stamp ++;
+		
+		if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
+			maxX = Math.max(maxX, MAX_X);
+			maxY = Math.max(maxY, MAX_Y);
+			if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
+				setNewSize();
+				//repaint();
+			}
+		} else {
+			if (mustScroll) {
+				scrollToLowerPosition();
+				mustScroll = false;
+			}
+		}
+		
+		if (drawInfo) {
+			drawInfo(g);
+		}
+    }
+	
+	protected void scrollToLowerPosition() {
+		if (jsp != null) {
+			jsp.getVerticalScrollBar().setValue(jsp.getVerticalScrollBar().getMaximum());
+		}
+	}
+	
+	// Returns the currentY position
+	protected int paintTopElements(Graphics g, int currentX, int currentY) {
+		int w;
+		
+		for(String name : entityNames) {
+			g.drawLine(currentX + (spaceBetweenLifeLines/4), currentY, currentX + (3*spaceBetweenLifeLines/4), currentY);
+			g.drawLine(currentX + (spaceBetweenLifeLines/2), currentY, currentX + (spaceBetweenLifeLines/2), currentY + verticalSpaceUnderBlocks);
+			w = g.getFontMetrics().stringWidth(name);
+			g.drawString(name, currentX + ((spaceBetweenLifeLines-w)/2), currentY - spaceVerticalText);
+			currentX += spaceBetweenLifeLines;
+		}
+		
+		maxX = currentX;
+		
+		return currentY + verticalSpaceUnderBlocks;
+	}
+	
+	private void computeSpaceBetweenLifeLines(Graphics g) {
+		int w;
+		
+		spaceBetweenLifeLinesComputed = true;
+		
+		for(String name : entityNames) {
+			w = g.getFontMetrics().stringWidth(name);
+			if ((w+minSpaceBetweenLifeLines) > spaceBetweenLifeLines) {
+				spaceBetweenLifeLines = w+minSpaceBetweenLifeLines;
+			}
+		}
+		
+	}
+    
+    public void setNewSize() {
+		setPreferredSize(new Dimension(maxX + limit, maxY + limit));
+		mustScroll = true;
+		revalidate();
+	}
+	
+	// returns the currentY position
+	protected int paintTransactions(Graphics g, int currentX, int currentY) {
+		long clockValue = -1;
+		int index;
+		int xOfBlock;
+		int newCurrentY = currentY;
+        GenericTransaction gt;
+        
+        
+        if (transactions.size() == 0) {
+            return currentY;
+        }
+		
+		// Draw only the last "drawnTransactions"
+		
+		if (transactions.size() > 0) {
+            gt = transactions.get(Math.max(0, transactions.size()-1000));
+            clockValue = gt.startingTime;
+            clockValueMouse = clockValue;
+            g.drawString("@" + clockValue/clockDiviser, 10, currentY+g.getFontMetrics().getHeight()/2); 
+		}
+		
+		for(int i=Math.max(transactions.size()-drawnTransactions, 0); i<transactions.size(); i++) {
+            gt = transactions.get(i);
+            gt.stamp = stamp;
+            
+            index = getIndexOfEntityName(gt.entityName);
+            xOfBlock = currentX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
+            
+            points.clear();
+            transactionsOfPoints.clear();
+            
+            if (gt.type == gt.STATE_ENTERING) {
+                newCurrentY = drawState(g, gt, xOfBlock, currentY); 
+            }  else if (gt.type == gt.FUNCTION_CALL) {
+                newCurrentY = drawFunctionCall(g, gt, xOfBlock, currentY); 
+            } 
+            
+            if ((yMouse>= currentY) && (yMouse <= newCurrentY)) {
+                for(int cpt = 0; cpt<points.size(); cpt++) {
+                    drawIDInfo(g, points.get(cpt).x, points.get(cpt).y, transactionsOfPoints.get(cpt).ID);
+                }
+            }
+            
+            
+            // Draw the line of other blocks
+            if (currentY != newCurrentY) {
+                xOfBlock = currentX + spaceBetweenLifeLines/2;
+                for(String s: entityNames) {
+                    if (s.compareTo(gt.entityName) != 0) {
+                        g.drawLine(xOfBlock, currentY, xOfBlock, newCurrentY);
+                    }
+                    xOfBlock += spaceBetweenLifeLines;
+                }
+                if (gt.finishTime != clockValue) {
+                    clockValue = gt.finishTime;
+                    if (yMouse >= newCurrentY) {
+                        clockValueMouse = clockValue;
+                    }
+                    g.drawString("@" + clockValue/clockDiviser, 10, newCurrentY+g.getFontMetrics().getHeight()/2); 
+                }
+            }
+            
+            // Update currentY;
+            currentY = newCurrentY;
+            
+		}
+		maxY = currentY;
+		return currentY;
+	}
+	
+	private int drawState(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x, y, width, height;
+        
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+        
+        w = g.getFontMetrics().stringWidth(_gt.action);
+        Color c = g.getColor();
+        Color avat = ColorManager.AVATAR_STATE;
+        g.setColor(avat);
+        
+        x = currentX - w/2 - spaceHorizontalText;
+        y = currentY;
+        width = w + 2*spaceHorizontalText;
+        height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
+        
+        g.fillRoundRect(x, y, width, height, 5, 5);
+        points.add(new Point(x+width, y));
+        transactionsOfPoints.add(_gt);
+        g.setColor(c);
+        g.drawRoundRect(x, y, width, height, 5, 5);
+        
+        g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
+        
+        currentY += height;
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        return currentY + verticalLink;
+	}
+    
+    private int drawFunctionCall(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x, y, width, height;
+        
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+        
+        w = g.getFontMetrics().stringWidth(_gt.action);
+        Color c = g.getColor();
+        
+        x = currentX - w/2 - spaceHorizontalText;
+        y = currentY;
+        width = w + 2*spaceHorizontalText;
+        height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
+        
+        
+        g.setColor(Color.WHITE);
+        g.fillRoundRect(x, y, width, height, 5, 5);
+        g.setColor(c);
+        g.drawRoundRect(x, y, width, height, 5, 5);
+        points.add(new Point(x+width, y));
+        transactionsOfPoints.add(_gt);
+        g.setColor(c);
+        g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
+        
+        currentY += height;
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        return currentY + verticalLink;
+	}
+	
+	/*private int drawTransition(Graphics g, AvatarTransition at, AvatarSimulationTransaction ast, int currentX, int currentY) {
+    int w;
+    int x, y, width, height;
+    int cpt;
+    Color c = g.getColor();
+    
+    // Duration ?
+    if (ast.duration > 0) {
+    g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+    currentY += verticalLink;
+    g.drawRect(currentX-5, currentY, 10, 30);
+    points.add(new Point(currentX+10, currentY));
+    transactionsOfPoints.add(ast);
+    g.drawString(""+ ast.duration, currentX+6, currentY+17);
+    currentY += 30;
+    g.setColor(ColorManager.AVATAR_TIME);
+    g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+    g.setColor(c);
+    currentY += verticalLink;
+    }
+    
+    if (ast.actions == null) {
+    return currentY;
+    }
+    
+    if (ast.actions.size() == 0) {
+    return currentY;
+    }
+    
+    
+    w = 0;
+    for(String action: ast.actions) {
+    w = Math.max(g.getFontMetrics().stringWidth(action), w);
+    }
+    
+    x = currentX - w/2 - spaceHorizontalText;
+    y = currentY;
+    width = w + 2*spaceHorizontalText;
+    height = (g.getFontMetrics().getHeight() + spaceVerticalText * 2) * ast.actions.size();
+    
+    g.setColor(Color.WHITE);
+    g.fillRoundRect(x, y, width, height, 5, 5);
+    g.setColor(c);
+    g.drawRoundRect(x, y, width, height, 5, 5);
+    points.add(new Point(x+width, y));
+    transactionsOfPoints.add(ast);
+    
+    cpt = 1;
+    
+    Color avat = ColorManager.AVATAR_ACTION;
+    g.setColor(avat);
+    int decVert = height / ast.actions.size();
+    for(String action: ast.actions) {
+    g.drawString(action, x + (width - g.getFontMetrics().stringWidth(action))/2, y+(decVert*cpt) - (spaceVerticalText * 2));
+    cpt ++;
+    }
+    g.setColor(c);
+    
+    currentY += height;
+    g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+    
+    return currentY + verticalLink;
+	}
+	
+	private int drawRandom(Graphics g, AvatarRandom arandom, AvatarSimulationTransaction ast, int currentX, int currentY) {
+    int w;
+    int x, y, width, height;
+    Color c = g.getColor();
+    
+    if (ast.actions == null) {
+    return currentY;
+    }
+    
+    String action = ast.actions.get(0);
+    
+    g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+    currentY += verticalLink;
+    
+    w = g.getFontMetrics().stringWidth(action);
+    x = currentX - w/2 - spaceHorizontalText;
+    y = currentY;
+    width = w + 2*spaceHorizontalText;
+    height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
+    g.setColor(Color.WHITE);
+    g.fillRoundRect(x, y, width, height, 5, 5);
+    points.add(new Point(x+width, y));
+    transactionsOfPoints.add(ast);
+    g.setColor(c);
+    g.drawRoundRect(x, y, width, height, 5, 5);
+    
+    g.drawString(action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
+    
+    currentY += height;
+    g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+    return currentY + verticalLink;
+	}
+	
+	private int drawAvatarActionOnSignal(Graphics g, AvatarActionOnSignal aaos, AvatarSimulationTransaction ast, int currentX, int currentY, int startX) {
+    int w;
+    Color c = g.getColor();
+    
+    avatartranslator.AvatarSignal sig = aaos.getSignal();
+    avatartranslator.AvatarRelation rel = ass.getAvatarSpecification().getAvatarRelationWithSignal(sig);
+    if (sig.isIn()) {
+    if (!(rel.isAsynchronous())) {
+    
+    //Synchronous
+    if (ast.linkedTransaction != null) {
+    // Computing message name
+    AvatarActionOnSignal otherAaos = (AvatarActionOnSignal)(ast.linkedTransaction.executedElement);
+    String messageName = otherAaos.getSignal().getName();
+    if (messageName.compareTo(sig.getName()) != 0) {
+    messageName += "_" + sig.getName();
+    }
+    messageName += "(";
+    
+    if(ast.actions != null) {
+    messageName += ast.actions.get(0); 
+    }
+    messageName += ")";
+    
+    //TraceManager.addDev("Working on message name:" + messageName);
+    // Drawing the arrow
+    // Assume a different block in the two transactions
+    int index = ass.getSimulationBlocks().indexOf(ast.linkedTransaction.asb);
+    int xOf2ndBlock = startX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
+    
+    currentY += 10;
+    g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+    g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
+    g.setColor(c);
+    GraphicLib.arrowWithLine(g, 1, 0, 10, xOf2ndBlock, currentY, currentX, currentY, true);
+    points.add(new Point(xOf2ndBlock, currentY));
+    transactionsOfPoints.add(ast.linkedTransaction);
+    transactionsOfPoints.add(ast);
+    points.add(new Point(currentX, currentY));
+    
+    
+    // Putting the message name
+    w = g.getFontMetrics().stringWidth(messageName);
+    int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
+    g.drawString(messageName, xtmp, currentY-2); 
+    
+    
+    currentY += 10;
+    
+    // Vertical line of receiving block
+    g.drawLine(currentX, currentY-20, currentX, currentY);
+    return currentY;
+    }
+    } else {
+    // In, asynchronous
+    String messageName = sig.getName() + "(";
+    if(ast.actions != null) {
+    messageName += ast.actions.get(0); 
+    }
+    messageName += ")";
+    
+    currentY += 10;
+    g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+    g.drawLine(currentX-lengthAsync, currentY-1, currentX, currentY-1);
+    g.setColor(c);
+    GraphicLib.arrowWithLine(g, 1, 1, 10, currentX-lengthAsync, currentY, currentX, currentY, false);
+    points.add(new Point(currentX, currentY));
+    transactionsOfPoints.add(ast);
+    
+    // Putting the message name
+    w = g.getFontMetrics().stringWidth(messageName);
+    g.drawString(messageName, currentX-lengthAsync+w/2, currentY-2); 
+    
+    // Search for sender
+    if (ast.linkedTransaction != null) {
+    if (ast.linkedTransaction.stamp == ast.stamp) {
+    if ((ast.linkedTransaction.x >0) && (ast.linkedTransaction.y >0)) {
+    int x = ast.linkedTransaction.x;
+    int y = ast.linkedTransaction.y;
+    
+    if (x + lengthAsync < currentX-lengthAsync) {
+    // Forward
+    g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+    GraphicLib.dashedLine(g, x + lengthAsync - 1, y, x + lengthAsync-1, currentY);
+    GraphicLib.dashedLine(g, x + lengthAsync, currentY-1, currentX-lengthAsync, currentY-1);
+    g.setColor(c);
+    GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, currentY);
+    GraphicLib.dashedLine(g, x + lengthAsync, currentY, currentX-lengthAsync, currentY);
+    } else {
+    // Backward
+    g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+    GraphicLib.dashedLine(g, x + lengthAsync-1, y, x + lengthAsync-1, y+7);
+    GraphicLib.dashedLine(g, x + lengthAsync, y+6, currentX-lengthAsync, y+6);
+    GraphicLib.dashedLine(g, currentX-lengthAsync-1, currentY, currentX-lengthAsync-1, y+7);
+    g.setColor(c);
+    GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, y+7);
+    GraphicLib.dashedLine(g, x + lengthAsync, y+7, currentX-lengthAsync, y+7);
+    GraphicLib.dashedLine(g, currentX-lengthAsync, currentY, currentX-lengthAsync, y+7);
+    }
+    
+    //g.drawLine(x + lengthAsync, y, currentX-lengthAsync, currentY);
+    }
+    }
+    } else {
+    //TraceManager.addDev("No linked transaction");
+    }
+    
+    currentY += 10;
+    
+    // Vertical line of receiving block
+    g.drawLine(currentX, currentY-20, currentX, currentY);
+    
+    
+    
+    return currentY;
+    }
+    } else {
+    if (rel.isAsynchronous()) {
+    // Out, asynchronous
+    String messageName = sig.getName() + "(";
+    if(ast.actions != null) {
+    messageName += ast.actions.get(0); 
+    }
+    messageName += ")";
+    
+    currentY += 10;
+    g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+    g.drawLine(currentX+lengthAsync, currentY-1, currentX, currentY-1);
+    g.setColor(c);
+    GraphicLib.arrowWithLine(g, 1, 2, 10, currentX, currentY, currentX+lengthAsync, currentY, false);
+    points.add(new Point(currentX, currentY));
+    transactionsOfPoints.add(ast);
+    
+    // Putting the message name
+    w = g.getFontMetrics().stringWidth(messageName);
+    g.drawString(messageName, currentX+lengthAsync-w/2, currentY-2); 
+    
+    ast.x = currentX;
+    ast.y = currentY;
+    
+    currentY += 10;
+    
+    // Vertical line of receiving block
+    g.drawLine(currentX, currentY-20, currentX, currentY);
+    return currentY;
+    
+    // Solo Broadcast Sending?
+    } else if (ast.isSolo) {
+    // Draw a lost message
+    String messageName = sig.getName() + "(";
+    if(ast.actions != null) {
+    messageName += ast.actions.get(0); 
+    }
+    messageName += ")";
+    
+    currentY += 10;
+    g.setColor(ColorManager.AVATAR_SEND_SIGNAL);
+    g.drawLine(currentX+spaceBetweenLifeLines-spaceBroadcast, currentY-1, currentX, currentY-1);
+    g.setColor(c);
+    GraphicLib.arrowWithLine(g, 1, 0, 10, currentX, currentY, currentX+spaceBetweenLifeLines-spaceBroadcast, currentY, true);
+    points.add(new Point(currentX, currentY));
+    transactionsOfPoints.add(ast);
+    g.fillOval(currentX+spaceBetweenLifeLines-spaceBroadcast, currentY-5, 10, 10);
+    
+    // Putting the message name
+    w = g.getFontMetrics().stringWidth(messageName);
+    g.drawString(messageName, currentX+10, currentY-2); 
+    
+    ast.x = currentX;
+    ast.y = currentY;
+    
+    currentY += 10;
+    
+    // Vertical line of receiving block
+    g.drawLine(currentX, currentY-20, currentX, currentY);
+    return currentY;
+    
+    }
+    }
+    
+    return currentY;
+    
+	}
+	
+	private int drawAvatarStartState(Graphics g, int currentX, int currentY, int startX) {
+    currentX -= 7;
+    g.fillOval(currentX, currentY, 15, 15);
+    g.drawLine(currentX, currentY, currentX, currentY+20);
+    
+    currentY += 20;
+    return currentY;
+	}
+	
+	private int drawAvatarStopState(Graphics g, AvatarSimulationTransaction _ast, int currentX, int currentY, int startX) {
+    g.drawLine(currentX, currentY, currentX, currentY+spaceStop+3);
+    currentX -= (spaceStop/2);
+    g.drawLine(currentX, currentY, currentX+spaceStop, currentY+spaceStop);
+    g.drawLine(currentX, currentY+spaceStop, currentX+spaceStop, currentY);
+    points.add(new Point(currentX+spaceStop, currentY));
+    transactionsOfPoints.add(_ast);
+    
+    currentY += spaceStop + 3;
+    return currentY;
+	}
+	
+	public void setNewSize() {
+    setPreferredSize(new Dimension(maxX + limit, maxY + limit));
+    mustScroll = true;
+    revalidate();
+	}*/
+	
+	public void mouseDragged(MouseEvent e) {
+	}
+    
+	public void mouseMoved(MouseEvent e) {
+		xMouse = e.getX();
+		yMouse = e.getY();
+		if ((xMouse > minLimit) && (xMouse<maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
+			drawInfo = true;
+			repaint();
+			return;
+		}
+		
+		if( drawInfo == true) {
+			drawInfo = false;
+			repaint();
+			return;
+		}
+		
+		drawInfo = false;
+	}
+	
+	private void drawInfo(Graphics g) {
+		GraphicLib.dashedLine(g, spaceAtEnd, yMouse, maxX-spaceAtEnd, yMouse);
+		g.drawString("@" + clockValueMouse/clockDiviser, 10, yMouse+g.getFontMetrics().getHeight()/2);
+		/*if (minIdValueMouse == maxIdValueMouse) {
+        g.drawString("ID: " + minIdValueMouse, 10, yMouse+(g.getFontMetrics().getHeight()/2)+12);
+		} else {
+        g.drawString("ID: " + minIdValueMouse + " to " + maxIdValueMouse, 10, yMouse+(g.getFontMetrics().getHeight()/2)+12);
+		}*/
+		
+		int w;
+		int x = spaceAtEnd;
+		
+		for(String name: entityNames) {
+			w = g.getFontMetrics().stringWidth(name);
+			g.drawString(name, x + ((spaceBetweenLifeLines-w)/2), yMouse - spaceVerticalText);
+			x += spaceBetweenLifeLines;
+		}
+	}
+	
+	private void drawIDInfo(Graphics g, int _x, int _y, long _id) {
+		Color c = g.getColor();
+		g.setColor(ColorManager.AVATAR_EXPIRE_TIMER);
+		g.fillOval(_x-3, _y-3, 6, 6);
+		g.drawLine(_x, _y, _x+6, _y-6);
+		g.drawLine(_x+6, _y-6, _x+12, _y-6);
+		g.drawString(""+_id, _x+13, _y-6);
+		g.setColor(c);
+	}
+	
+	public BufferedImage performCapture() {
+		int w = this.getWidth();
+        int h = this.getHeight();
+        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = image.createGraphics();
+		g.setColor(Color.black);
+        paintComponent(g);
+        g.dispose();
+        return image;
+	}
+    
+	public void setFileReference(String _fileReference) {
+        fileReference = _fileReference;
+        
+        mode = FILE_MODE;
+        
+        Thread t = new Thread(this);
+        t.start();
+    }
+    
+    public void run() {
+        TraceManager.addDev("Reading file");
+        
+        go = true;
+        Thread t;
+        
+        if (mode == NO_MODE) {
+            go = false;
+            t = null;
+            return;
+        }
+        
+        if (mode == FILE_MODE) {
+            // Open the file
+            // Read the content of the file
+            // Read line by line
+            // Upate the graphic regularly
+            try{
+                // Open the file that is the first 
+                // command line parameter
+                FileInputStream fstream = new FileInputStream(fileReference);
+                // Get the object of DataInputStream
+                DataInputStream in = new DataInputStream(fstream);
+                BufferedReader br = new BufferedReader(new InputStreamReader(in));
+                String strLine;
+                //Read File Line By Line
+                while ((strLine = br.readLine()) != null)   {
+                    // Print the content on the console
+                    TraceManager.addDev("Computing transaction:" + strLine);
+                    addGenericTransaction(strLine);
+                }
+                //Close the input stream
+                in.close();
+            } catch (Exception e){//Catch exception if any
+                TraceManager.addDev("Reading file Error: " + e.getMessage());
+            }
+        } 
+    }
+    
+    public void addGenericTransaction(String trans) {
+        int index0, index1;
+        String tmp, tmp1, tmp2;
+        long value;
+        int value1, value2;
+        
+        if (!(trans.startsWith("#"))) {
+            return;
+        }
+        
+        
+        GenericTransaction gt = new GenericTransaction();
+        
+        // Adding the ID
+        index0 = trans.indexOf(" ");
+        if (index0 == -1) {
+            return;
+        }
+        tmp = trans.substring(1, index0);
+        try {
+            gt.ID = Integer.decode(tmp).intValue(); 
+        } catch (Exception e) {
+        }
+        
+        
+        //TraceManager.addDev("1");
+        
+        // Time
+        tmp = extract(trans, "time");
+        if (tmp == null) {
+            return;
+        }
+        
+        //TraceManager.addDev("2 tmp=" + tmp);
+        
+        try {
+            index0 = tmp.indexOf('.');
+            if (index0 == -1) {
+                return;
+            }
+            tmp1 = tmp.substring(0, index0);
+            tmp2 = tmp.substring(index0+1, tmp.length());
+            //TraceManager.addDev("2 tmp1=" + tmp1 + " tmp2=" + tmp2);
+            value1 = Integer.decode(tmp1).intValue();
+            value2 = Integer.decode(tmp2).intValue();
+            value = ((long)value1)*1000000000+value2;
+            gt.startingTime = value;
+            gt.finishTime = value;
+        } catch (Exception e) {
+            return;
+        }
+        
+        //TraceManager.addDev("3");
+        
+        // Name of the block
+        tmp = extract(trans, "block");
+        if (tmp == null) {
+            return;
+        }
+        
+        addEntityNameIfApplicable(tmp);
+        gt.entityName = tmp;
+        
+        // Type of the transaction
+        tmp = extract(trans, "type");
+        if (tmp == null) {
+            return;
+        }
+        
+        if (tmp.compareTo("state_entering") == 0) {
+            gt.type = GenericTransaction.STATE_ENTERING;
+        }
+        
+        if (tmp.compareTo("function_call") == 0) {
+            gt.type = GenericTransaction.FUNCTION_CALL;
+        }
+        
+        // State of the transaction?
+        tmp = extract(trans, "state");
+        
+        if (tmp != null) {
+            gt.action = tmp;
+        }
+        
+        // Function of the transaction?
+        tmp = extract(trans, "func");
+        
+        if (tmp != null) {
+            gt.action = tmp;
+        }
+        
+        // Parameters of the function
+        tmp = extract(trans, "parameters");
+        gt.action = gt.action + "(";
+        if( tmp != null) {
+            if (!(tmp.startsWith("-"))) {
+                 gt.action = gt.action + tmp;
+            }
+        } else {
+        }
+        gt.action = gt.action + ")"; 
+        
+        transactions.add(gt);
+        TraceManager.addDev("One transactions added");
+        
+    }
+    
+    public String extract(String main, String selector) {
+        String sel = selector+"=";
+        int index = main.indexOf(sel);
+        if (index == -1) {
+            return null;
+        }
+        
+        String ret = main.substring(index+sel.length(), main.length());
+        index = ret.indexOf(' ');
+        
+        if (index != -1) {
+            ret = ret.substring(0, index);
+        }
+        
+        return ret;
+    }
+    
+    public void addEntityNameIfApplicable(String _entityName) {
+        for(String name: entityNames) {
+            if (name.compareTo(_entityName) ==0) {
+                return;
+            }
+        }
+        
+        entityNames.add(_entityName);
+    }
+    
+    public int getIndexOfEntityName(String _entityName) {
+        int cpt = 0;
+        for(String name: entityNames) {
+            if (name.compareTo(_entityName) ==0) {
+                return cpt;
+            }
+            cpt ++;
+        }
+        
+        return -1;
+    }
+    
+    public void setClockDiviser(long _clockDiviser) {
+        clockDiviser = _clockDiviser;
+    }
+}
\ No newline at end of file
diff --git a/src/ui/window/JDialogAvatarExecutableCodeGeneration.java b/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
index aafd6994ea..4b37b85eb6 100644
--- a/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
+++ b/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
@@ -50,6 +50,7 @@ import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.event.*;
+import java.io.*;
 import java.util.*;
 
 import myutil.*;
@@ -60,11 +61,14 @@ import avatartranslator.*;
 import avatartranslator.toexecutable.*;
 import launcher.*;
 
+import ui.interactivesimulation.*;
 
-public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog implements ActionListener, Runnable, MasterProcessInterface  {
+
+public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame implements ActionListener, Runnable, MasterProcessInterface  {
     
 	private static String[] unitTab = {"usec", "msec", "sec"}; 
 	
+    protected Frame f;
     protected MainGUI mgui;
     
     private String textSysC1 = "Base directory of code generation code:";
@@ -99,11 +103,12 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
 	protected JRadioButton exe, exeint;
 	protected ButtonGroup exegroup;
     protected JLabel gen, comp;
-    protected JTextField code1, code2, compiler1, exe1, exe2, exe3, exe2int;
+    protected JTextField code1, code2, compiler1, exe1, exe2, exe3, exe2int, simulationTraceFile;
     protected JTabbedPane jp1;
     protected JScrollPane jsp;
     protected JCheckBox removeCFiles, removeXFiles, debugmode, tracemode, optimizemode;
 	protected JComboBox versionCodeGenerator, units;
+    protected JButton showSimulationTrace;
 	
 	private static int selectedUnit = 2;
 	
@@ -120,9 +125,10 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
     
     
     /** Creates new form  */
-    public JDialogAvatarExecutableCodeGeneration(Frame f, MainGUI _mgui, String title, String _hostExecute, String _pathCode, String _pathCompiler, String _pathExecute) {
-        super(f, title, true);
+    public JDialogAvatarExecutableCodeGeneration(Frame _f, MainGUI _mgui, String title, String _hostExecute, String _pathCode, String _pathCompiler, String _pathExecute) {
+        super(title);
         
+        f = _f;
         mgui = _mgui;
         
         if (pathCode == null) {
@@ -179,6 +185,12 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
         jp03.setLayout(gridbag03);
         jp03.setBorder(new javax.swing.border.TitledBorder("Execution"));
         
+        JPanel jp04 = new JPanel();
+        GridBagLayout gridbag04 = new GridBagLayout();
+        GridBagConstraints c04 = new GridBagConstraints();
+        jp04.setLayout(gridbag04);
+        jp04.setBorder(new javax.swing.border.TitledBorder("Simulation trace"));
+        
         
         c01.gridheight = 1;
         c01.weighty = 1.0;
@@ -279,7 +291,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
         jp03.add(exe, c03);
         
         exe2 = new JTextField(pathExecute, 100);
-        jp03.add(exe2, c02);
+        jp03.add(exe2, c03);
 		
 		/*exeint = new JRadioButton(textSysC5, true);
 		exeint.addActionListener(this);
@@ -294,6 +306,24 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
         
         jp1.add("Execute", jp03);
         
+        // Panel 04
+        c04.gridheight = 1;
+        c04.weighty = 1.0;
+        c04.weightx = 1.0;
+        c04.gridwidth = GridBagConstraints.REMAINDER; //end row
+        c04.fill = GridBagConstraints.BOTH;
+        c04.gridheight = 1;
+        simulationTraceFile = new JTextField(pathCode + File.separator + "trace.txt", 100);
+        jp04.add(simulationTraceFile, c04);
+        
+        showSimulationTrace = new JButton("Show simulation trace");
+        showSimulationTrace.addActionListener(this);
+         jp04.add(showSimulationTrace, c04);
+        
+        jp1.add("Results", jp04);
+        
+        
+        
         c.add(jp1, BorderLayout.NORTH);
         
         jta = new ScrolledJTextArea();
@@ -342,6 +372,8 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
 			selectedItem = versionCodeGenerator.getSelectedIndex();
 		} else if (evt.getSource() == units) {
 			selectedUnit = units.getSelectedIndex();
+		} else if (evt.getSource() == showSimulationTrace) {
+			showSimulationTrace();
 		}
     }
     
@@ -573,6 +605,16 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JDialog i
     public void setError() {
         hasError = true;
     }
+    
+    public void showSimulationTrace() {
+        JFrameSimulationSDPanel jfssdp = new JFrameSimulationSDPanel(f, mgui, "Simulation trace of " + simulationTraceFile.getText());
+        jfssdp.setIconImage(IconManager.img8);
+        jfssdp.setSize(600, 600);
+        GraphicLib.centerOnParent(jfssdp);
+        jfssdp.setFileReference(simulationTraceFile.getText());
+        jfssdp.setVisible(true);
+        TraceManager.addDev("Ok JFrame");
+    }
 	
 	
 }
-- 
GitLab