Commit a4815ae3 authored by Letitia Li's avatar Letitia Li
Browse files

Latency Backtracing added

parent c0b541d5
This diff is collapsed.
......@@ -41,7 +41,7 @@
package ui;
import java.util.HashMap;
/**
* Class CheckableLatency
* Components which can be set as a latency checkpoint
......@@ -51,4 +51,5 @@ package ui;
*/
public interface CheckableLatency {
}
......@@ -1474,6 +1474,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements Avatar
minTimes.add(time);
}
}
System.out.println(transTimes.get(st1) + " " + transTimes.get(st2) + " " + minTimes);
if (minTimes.size()>0){
int sum=0;
sl.setMinTime(Integer.toString(Collections.min(minTimes)));
......
......@@ -51,7 +51,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.geom.Line2D;
import java.util.LinkedList;
import java.util.HashMap;
/**
* Class AvatarSMDReceiveSignal
* Action of receiving a signal
......@@ -66,8 +66,14 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
protected int arc = 5;
protected int linebreak = 10;
protected int textX1 = 2;
private HashMap<String, String> latencyVals;
protected int latencyX=30;
protected int latencyY=10;
protected int textWidth=10;
protected int textHeight=20;
protected int stateOfError = 0; // Not yet checked
public AvatarSMDReceiveSignal(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
......@@ -93,8 +99,14 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
//makeValue();
myImageIcon = IconManager.imgic908;
latencyVals = new HashMap<String, String>();
latencyVals.put("sendChannel: distanceData", "15");
}
public void addLatency(String name, String num){
latencyVals.put(name,num);
}
public void internalDrawing(Graphics g) {
int w = g.getFontMetrics().stringWidth(value + textX1);
......@@ -154,9 +166,24 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
//g.drawString("sig()", x+(width-w) / 2, y);
g.drawString(value, x + linebreak + textX1, y + textY);
if (getCheckLatency()){
drawLatencyInformation(g);
}
}
public void drawLatencyInformation(Graphics g){
for (String s:latencyVals.keySet()){
int w = g.getFontMetrics().stringWidth(s);
g.drawString(s, x-latencyX-w+1, y-latencyY-2);
g.drawRect(x-latencyX-w, y-latencyY-textHeight, w+4, textHeight);
g.drawLine(x,y,x-latencyX, y-latencyY);
Color c = g.getColor();
g.setColor(Color.ORANGE);
g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY/2);
g.setColor(c);
}
}
public TGComponent isOnMe(int _x, int _y) {
if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
......
......@@ -985,8 +985,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene
jspLatency = new JScrollPane(latTable);
jspLatency.setWheelScrollingEnabled(true);
jspLatency.getVerticalScrollBar().setUnitIncrement(10);
jspLatency.setMinimumSize(new Dimension(400, 250));
jspLatency.setPreferredSize(new Dimension(1400, 250));
jspLatency.setMinimumSize(new Dimension(1000, 250));
jspLatency.setPreferredSize(new Dimension(2100, 250));
latencyPanel.add(jspLatency, c0);
......
......@@ -53,7 +53,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Class TMLADReadChannel
* Action of writting data in channel
......@@ -62,6 +62,7 @@ import java.util.ArrayList;
* @author Ludovic APVRILLE
*/
public class TMLADReadChannel extends TGCWithoutInternalComponent implements CheckableAccessibility, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight {
private HashMap<String, String> latencyVals;
protected int lineLength = 5;
protected int textX = 5;
protected int textX0 = 2;
......@@ -69,6 +70,11 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
protected int textY1 = 15;
protected int linebreak = 10;
protected int latencyX=30;
protected int latencyY=10;
protected int textWidth=10;
protected int textHeight=20;
protected String channelName = "ch";
protected String nbOfSamples= "1";
public String securityContext ="";
......@@ -80,6 +86,7 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
public int reachabilityInformation;
public TMLADReadChannel(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);
......@@ -100,8 +107,14 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
name = "read channel";
myImageIcon = IconManager.imgic906;
latencyVals = new HashMap<String, String>();
latencyVals.put("sendChannel: distanceData", "3");
}
public void addLatency(String name, String num){
latencyVals.put(name,num);
}
public void internalDrawing(Graphics g) {
int w = g.getFontMetrics().stringWidth(value);
int w1 = Math.max(minWidth, w + 2 * textX);
......@@ -156,10 +169,21 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
if (!securityContext.equals("")){
g.drawString("sec:"+securityContext, x+3*width/4, y+height+textY1);
}
drawReachabilityInformation(g);
drawReachabilityInformation(g);
if (getCheckLatency()){
drawLatencyInformation(g);
}
}
public void drawLatencyInformation(Graphics g){
for (String s:latencyVals.keySet()){
int w = g.getFontMetrics().stringWidth(s);
g.drawString(s, x-latencyX-w+1, y-latencyY-2);
g.drawRect(x-latencyX-w, y-latencyY-textHeight, w+4, textHeight);
g.drawLine(x,y,x-latencyX, y-latencyY);
g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY/2);
}
}
public void drawReachabilityInformation(Graphics g) {
if (reachabilityInformation > 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment