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

automatic backtracing for latency

parent 6a9e92e4
......@@ -308,6 +308,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
private ArrayList<RunningInfo> runningIDs;
private ArrayList<LoadInfo> loadIDs;
private ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>> transactionMap = new ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>>();
private ConcurrentHashMap<Integer, String[]> latencyMap = new ConcurrentHashMap<Integer, String[]>();
private ConcurrentHashMap<String, String> statusMap = new ConcurrentHashMap<String, String>();
private JFrameInteractiveSimulation jfis;
private JFrameAvatarInteractiveSimulation jfais;
......@@ -7646,6 +7647,21 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
return transactionMap.get(id);
}
public synchronized void addLatencyVals(int id, String[] latency){
if (latencyMap!=null){
latencyMap.put(id, latency);
}
// System.out.println(latencyMap);
}
public synchronized String[] getLatencyVals(int id){
// System.out.println(id + " " + latencyMap);
if (latencyMap!=null){
return latencyMap.get(id);
}
return null;
}
public synchronized ConcurrentHashMap<String,String> getStatus(int id){
if (statusMap == null) {
return null;
......
......@@ -1482,7 +1482,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements Avatar
minTimes.add(time);
}
}
System.out.println(transTimes.get(st1) + " " + transTimes.get(st2) + " " + minTimes);
// System.out.println(transTimes.get(st1) + " " + transTimes.get(st2) + " " + minTimes);
if (minTimes.size()>0){
int sum=0;
sl.setMinTime(Integer.toString(Collections.min(minTimes)));
......@@ -1499,6 +1499,7 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements Avatar
stdev = Math.sqrt(stdev);
sl.setAverageTime(String.format("%.1f",average));
sl.setStDev(String.format("%.1f",stdev));
mgui.addLatencyVals(Integer.valueOf(st2.split(":")[1]), new String[]{st1, Integer.toString(Collections.max(minTimes))});
}
latencies.add(sl);
......
......@@ -100,7 +100,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
myImageIcon = IconManager.imgic908;
latencyVals = new HashMap<String, String>();
latencyVals.put("sendChannel: distanceData", "15");
//latencyVals.put("sendChannel: sensorData", "15");
}
......@@ -166,8 +166,13 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
//g.drawString("sig()", x+(width-w) / 2, y);
g.drawString(value, x + linebreak + textX1, y + textY);
//System.out.println(getDIPLOID());
if (getCheckLatency()){
drawLatencyInformation(g);
String[] latency =tdp.getMGUI().getLatencyVals(getAVATARID());
if (latency!=null){
addLatency(latency[0], latency[1]);
drawLatencyInformation(g);
}
}
}
......@@ -178,7 +183,7 @@ public class AvatarSMDReceiveSignal extends AvatarSMDBasicComponent implements C
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.setColor(Color.RED);
g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY/2);
g.setColor(c);
}
......
......@@ -50,6 +50,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.geom.Line2D;
import java.util.LinkedList;
import java.util.HashMap;
/**
* Class AvatarSMDSendSignal
......@@ -65,6 +66,12 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicComponent implements Chec
protected int arc = 5;
protected int linebreak = 10;
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
......@@ -91,8 +98,11 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicComponent implements Chec
//makeValue();
myImageIcon = IconManager.imgic904;
latencyVals = new HashMap<String, String>();
}
public void addLatency(String name, String num){
latencyVals.put(name,num);
}
public void internalDrawing(Graphics g) {
int w = g.getFontMetrics().stringWidth(value);
......@@ -152,9 +162,29 @@ public class AvatarSMDSendSignal extends AvatarSMDBasicComponent implements Chec
//g.drawString("sig()", x+(width-w) / 2, y);
g.drawString(value, x + (width - w) / 2 , y + textY);
if (getCheckLatency()){
String[] latency =tdp.getMGUI().getLatencyVals(getAVATARID());
if (latency!=null){
addLatency(latency[0], latency[1]);
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.RED);
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)) {
return this;
......
......@@ -2671,6 +2671,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene
stdev = Math.sqrt(stdev);
sl.setAverageTime(String.format("%.1f",average));
sl.setStDev(String.format("%.1f",stdev));
mgui.addLatencyVals(Integer.valueOf(st2), new String[]{sl.getTransaction1(), Integer.toString(Collections.max(minTimes))});
}
}
......
......@@ -108,7 +108,7 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
myImageIcon = IconManager.imgic906;
latencyVals = new HashMap<String, String>();
latencyVals.put("sendChannel: distanceData", "3");
//latencyVals.put("sendChannel: sensorData", "3");
}
......@@ -171,7 +171,11 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
}
drawReachabilityInformation(g);
if (getCheckLatency()){
drawLatencyInformation(g);
String[] latency =tdp.getMGUI().getLatencyVals(getDIPLOID());
if (latency!=null){
addLatency(latency[0], latency[1]);
drawLatencyInformation(g);
}
}
}
......
......@@ -54,6 +54,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Class TMLADWriteChannel
......@@ -69,6 +70,15 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
protected int arc = 5;
protected int linebreak = 10;
private HashMap<String, String> latencyVals;
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 = "";
......@@ -87,6 +97,8 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
height = 20;
minWidth = 30;
nbConnectingPoint = 2;
connectingPoint = new TGConnectingPoint[2];
connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0);
......@@ -100,6 +112,7 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
name = "write channel";
myImageIcon = IconManager.imgic900;
latencyVals = new HashMap<String, String>();
}
public void internalDrawing(Graphics g) {
......@@ -155,10 +168,32 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
if (!securityContext.equals("")){
g.drawString("sec:"+securityContext, x+3*width/4, y+height+textY);
}
drawReachabilityInformation(g);
if (getCheckLatency()){
String[] latency =tdp.getMGUI().getLatencyVals(getDIPLOID());
if (latency!=null){
addLatency(latency[0], latency[1]);
drawLatencyInformation(g);
}
}
drawReachabilityInformation(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 addLatency(String name, String num){
latencyVals.put(name,num);
}
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