Newer
Older
// message = "there exists " +path.size()+" between: " + task12 + " and " +
// task22;
if (path2 != null && path2.getLength() > 0) {
for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) {
String ChannelName = entry.getKey();
ArrayList<String> busChList = entry.getValue();
GraphPath<String, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, task12, ChannelName);
GraphPath<String, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, ChannelName, task22);
if (pathTochannel != null && pathTochannel.getLength() > 0 && pathFromChannel != null && pathFromChannel.getLength() > 0) {
devicesToBeConsidered.addAll(busChList);
for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) {
String ChannelName = entry.getKey();
ArrayList<String> busChList = entry.getValue();
GraphPath<String, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, task12, ChannelName);
GraphPath<String, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, ChannelName, task22);
if ((pathTochannel != null && pathTochannel.getLength() > 0) || (pathFromChannel != null && pathFromChannel.getLength() > 0)) {
devicesToBeConsidered.addAll(busChList);
for (SimulationTransaction st : transFile1) {
if (st.id.equals(idTask1)) {
Task1Traces.add(st);
task1DeviceName = st.deviceName;
times1.add(Integer.valueOf(st.startTime));
Collections.sort(times1);
if (st.id.equals(idTask2)) {
Task2Traces.add(st);
task2DeviceName = st.deviceName;
times2.add(Integer.valueOf(st.endTime));
Collections.sort(times1);
}
}
// one to one
int minIndex = 0;
if (times1.size() != times2.size()) {
minIndex = Math.min(times1.size(), times2.size());
} else {
minIndex = times1.size();
}
dataByTask = new Object[minIndex][7];
dataByTaskBYRow = new Object[minIndex][2];
dataByTaskHWBYRow = new Object[minIndex][2];
for (int i = 0; i < minIndex; i++) {
HashMap<String, ArrayList<SimulationTransaction>> relatedHWs = new HashMap<String, ArrayList<SimulationTransaction>>();
HashMap<String, ArrayList<SimulationTransaction>> relatedTasks = new HashMap<String, ArrayList<SimulationTransaction>>();
relatedsimTraces = new Vector<SimulationTransaction>();
delayDueTosimTraces = new Vector<SimulationTransaction>();
runnableTimePerDevice = new HashMap<String, ArrayList<ArrayList<Integer>>>();
for (SimulationTransaction st : transFile1) {
Boolean onPath = false;
// if (Integer.valueOf(st.startTime) >= times1.get(i) &&
// Integer.valueOf(st.startTime) < times2.get(i)) {
if (!(Integer.valueOf(st.startTime) < times1.get(i) && Integer.valueOf(st.endTime) < times1.get(i))
&& !(Integer.valueOf(st.startTime) > times2.get(i) && Integer.valueOf(st.endTime) > times2.get(i))) {
// if (Integer.valueOf(st.startTime) >= minTime && Integer.valueOf(st.startTime)
// < maxTime) {
if (Integer.valueOf(st.endTime) > times2.get(i)) {
st.endTime = times2.get(i).toString();
st.length = Integer.valueOf(Integer.valueOf(times2.get(i)) - Integer.valueOf(st.startTime)).toString();
}
if (Integer.valueOf(st.startTime) < times1.get(i)) {
st.startTime = Integer.valueOf(times1.get(i)).toString();
st.length = Integer.valueOf(Integer.valueOf(st.endTime) - Integer.valueOf(times1.get(i))).toString();
}
if (Integer.valueOf(st.startTime) < times1.get(i) && Integer.valueOf(st.endTime) > times2.get(i)) {
st.startTime = Integer.valueOf(times1.get(i)).toString();
st.endTime = times2.get(i).toString();
st.length = Integer.valueOf(Integer.valueOf(times2.get(i)) - Integer.valueOf(times1.get(i))).toString();
}
String taskname = "";
for (String tasknameCheck : g.vertexSet()) {
String[] taskToAdd = tasknameCheck.replaceAll(" ", "").split("__");
int taskToAddindex = taskToAdd.length;
String taskToAddid = taskToAdd[taskToAddindex - 1];
if (isNumeric(taskToAddid)) {
if (Integer.valueOf(taskToAddid).equals(Integer.valueOf(st.id))) {
taskname = tasknameCheck;
break;
String[] name = st.deviceName.split("_");
String deviceName = name[0];
// there is a path between task 1 and task 2
if (path2 != null && path2.getLength() > 0) {
if (!taskname.equals(null) && !taskname.equals("")) {
GraphPath<String, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, task12, taskname);
GraphPath<String, DefaultEdge> pathToDestination = DijkstraShortestPath.findPathBetween(g, taskname, task22);
if (taskname.equals(task12) || taskname.equals(task22) || (pathToOrigin != null && pathToOrigin.getLength() > 0
&& pathToDestination != null && pathToDestination.getLength() > 0)) {
relatedsimTraces.add(st);
ArrayList<Integer> timeValues = new ArrayList<Integer>();
timeValues.add(0, Integer.valueOf(st.runnableTime));
timeValues.add(1, Integer.valueOf(st.startTime));
if (!(st.runnableTime).equals(st.startTime)) {
if (runnableTimePerDevice.containsKey(st.deviceName)) {
if (!runnableTimePerDevice.get(st.deviceName).contains(timeValues)) {
runnableTimePerDevice.get(st.deviceName).add(timeValues);
ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>();
timeValuesList.add(timeValues);
runnableTimePerDevice.put(st.deviceName, timeValuesList);
} else if (((st.deviceName.equals(task2DeviceName)) || st.deviceName.equals(task1DeviceName)
|| devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) {
delayDueTosimTraces.add(st);
}
}
} else {
if (!taskname.equals(null) && !taskname.equals("")) {
GraphPath<String, DefaultEdge> pathExistsTestwithTask1 = DijkstraShortestPath.findPathBetween(g, task12, taskname);
GraphPath<String, DefaultEdge> pathExistsTestwithTask2 = DijkstraShortestPath.findPathBetween(g, taskname, task22);
if (pathExistsTestwithTask1 != null && pathExistsTestwithTask1.getLength() > 0
|| pathExistsTestwithTask2 != null && pathExistsTestwithTask2.getLength() > 0) {
relatedsimTraces.add(st);
} else if (((st.deviceName.equals(task2DeviceName)) || st.deviceName.equals(task1DeviceName)
|| devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) {
delayDueTosimTraces.add(st);
dataByTask[i][0] = task12;
dataByTask[i][1] = times1.get(i);
dataByTask[i][2] = task22;
dataByTask[i][3] = times2.get(i);
dataByTask[i][4] = times2.get(i) - times1.get(i);
dataByTask[i][5] = "";
dataByTaskR.put(i, relatedsimTraces);
dataBydelayedTasks.put(i, delayDueTosimTraces);
timeDelayedPerRow.put(i, runnableTimePerDevice);
// dataByTask[i][5] = list.getModel();
// dataByTask[i][6] = totalTime;
return dataByTask;
}
// fill the detailed latency table once a row is selected
public Object[][] getTaskByRowDetails(int row) {
Object[][] dataByTaskRowDetails = new Object[dataByTaskR.get(row).size()][5];
int i = 0;
for (SimulationTransaction st : dataByTaskR.get(row)) {
dataByTaskRowDetails[i][0] = st.command;
dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id);
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
dataByTaskRowDetails[i][2] = st.deviceName;
dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime);
dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime);
i++;
}
return dataByTaskRowDetails;
}
// fill the detailed latency table once a row is selected
public List<SimulationTransaction> getRowDetailsTaks(int row) {
return dataByTaskR.get(row);
}
// fill the detailed latency table once a row is selected
public List<SimulationTransaction> getRowDetailsByHW(int row) {
return dataBydelayedTasks.get(row);
}
// fill the detailed latency table once a row is selected
public HashMap<String, ArrayList<ArrayList<Integer>>> getRowDelayDetailsByHW(int row) {
return timeDelayedPerRow.get(row);
}
// fill the detailed latency table once a row is selected from min/max table
public Vector<SimulationTransaction> getMinMaxTasksByRow(int row) {
return relatedsimTraces;
}
// fill the tasks that run on the same hardware but don't belong to the path
// between selected activities
public Vector<SimulationTransaction> getTaskMinMaxHWByRowDetails(int row) {
return delayDueTosimTraces;
}
// get the details of the delay for a selected min or max delay row
public void getRowDetailsMinMax(int row) {
String task12 = (String) dataByTaskMinMax[row][0];
int minTime = (int) dataByTaskMinMax[row][1];
String task22 = (String) dataByTaskMinMax[row][2];
int maxTime = (int) dataByTaskMinMax[row][3];
HashMap<String, ArrayList<SimulationTransaction>> relatedHWs = new HashMap<String, ArrayList<SimulationTransaction>>();
HashMap<String, ArrayList<SimulationTransaction>> relatedTasks = new HashMap<String, ArrayList<SimulationTransaction>>();
relatedsimTraces = new Vector<SimulationTransaction>();
delayDueTosimTraces = new Vector<SimulationTransaction>();
runnableTimePerDevice = new HashMap<String, ArrayList<ArrayList<Integer>>>();
// AllDirectedPaths<String, DefaultEdge> allPaths = new AllDirectedPaths<String,
// DefaultEdge>(g);
// List<GraphPath<String, DefaultEdge>> path = allPaths.getAllPaths(task12,
// task22, false, g.vertexSet().size());
// int size = path.size();
GraphPath<String, DefaultEdge> path2 = DijkstraShortestPath.findPathBetween(g, task12, task22);
if (path2 != null && path2.getLength() > 0) {
for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) {
String ChannelName = entry.getKey();
ArrayList<String> busChList = entry.getValue();
GraphPath<String, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, task12, ChannelName);
GraphPath<String, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, ChannelName, task22);
if (pathTochannel != null && pathTochannel.getLength() > 0 && pathFromChannel != null && pathFromChannel.getLength() > 0) {
devicesToBeConsidered.addAll(busChList);
}
}
} else {
for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) {
String ChannelName = entry.getKey();
ArrayList<String> busChList = entry.getValue();
GraphPath<String, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, task12, ChannelName);
GraphPath<String, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, ChannelName, task22);
if ((pathTochannel != null && pathTochannel.getLength() > 0) || (pathFromChannel != null && pathFromChannel.getLength() > 0)) {
devicesToBeConsidered.addAll(busChList);
}
}
}
for (SimulationTransaction st : transFile) {
Boolean onPath = false;
if (!(Integer.valueOf(st.startTime) < minTime && Integer.valueOf(st.endTime) < minTime)
&& !(Integer.valueOf(st.startTime) > maxTime && Integer.valueOf(st.endTime) > maxTime)) {
// if (Integer.valueOf(st.startTime) >= minTime && Integer.valueOf(st.startTime)
// < maxTime) {
if (Integer.valueOf(st.endTime) > maxTime) {
st.endTime = Integer.valueOf(maxTime).toString();
st.length = Integer.valueOf(Integer.valueOf(maxTime) - Integer.valueOf(st.startTime)).toString();
}
if (Integer.valueOf(st.startTime) < minTime) {
st.startTime = Integer.valueOf(minTime).toString();
st.length = Integer.valueOf(Integer.valueOf(st.endTime) - Integer.valueOf(minTime)).toString();
if (Integer.valueOf(st.startTime) < minTime && Integer.valueOf(st.endTime) > maxTime) {
st.startTime = Integer.valueOf(minTime).toString();
st.endTime = Integer.valueOf(maxTime).toString();
st.length = Integer.valueOf(Integer.valueOf(maxTime) - Integer.valueOf(minTime)).toString();
}
String taskname = "";
for (String tasknameCheck : g.vertexSet()) {
String[] taskToAdd = tasknameCheck.split("__");
int taskToAddindex = taskToAdd.length;
String taskToAddid = taskToAdd[taskToAddindex - 1];
if (isNumeric(taskToAddid)) {
if (Integer.valueOf(taskToAddid).equals(Integer.valueOf(st.id))) {
taskname = tasknameCheck;
break;
}
}
}
String[] name = st.deviceName.split("_");
String deviceName = name[0];
// there is a path between task 1 and task 2
if (path2 != null && path2.getLength() > 0) {
if (!taskname.equals(null) && !taskname.equals("")) {
GraphPath<String, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, task12, taskname);
GraphPath<String, DefaultEdge> pathToDestination = DijkstraShortestPath.findPathBetween(g, taskname, task22);
if (taskname.equals(task12) || taskname.equals(task22) || (pathToOrigin != null && pathToOrigin.getLength() > 0
&& pathToDestination != null && pathToDestination.getLength() > 0)) {
relatedsimTraces.add(st);
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
ArrayList<Integer> timeValues = new ArrayList<Integer>();
timeValues.add(0, Integer.valueOf(st.runnableTime));
timeValues.add(1, Integer.valueOf(st.startTime));
if (!(st.runnableTime).equals(st.startTime)) {
if (runnableTimePerDevice.containsKey(st.deviceName)) {
if (!runnableTimePerDevice.get(st.deviceName).contains(timeValues)) {
runnableTimePerDevice.get(st.deviceName).add(timeValues);
}
} else {
ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>();
timeValuesList.add(timeValues);
runnableTimePerDevice.put(st.deviceName, timeValuesList);
}
}
} else if (((st.deviceName.equals(task2DeviceName)) || st.deviceName.equals(task1DeviceName)
|| devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) {
delayDueTosimTraces.add(st);
}
}
timeDelayedPerRow.put(row, runnableTimePerDevice);
} else {
if (!taskname.equals(null) && !taskname.equals("")) {
GraphPath<String, DefaultEdge> pathExistsTestwithTask1 = DijkstraShortestPath.findPathBetween(g, task12, taskname);
GraphPath<String, DefaultEdge> pathExistsTestwithTask2 = DijkstraShortestPath.findPathBetween(g, taskname, task22);
if (pathExistsTestwithTask1 != null && pathExistsTestwithTask1.getLength() > 0
|| pathExistsTestwithTask2 != null && pathExistsTestwithTask2.getLength() > 0) {
relatedsimTraces.add(st);
} else if (((st.deviceName.equals(task2DeviceName)) || st.deviceName.equals(task1DeviceName)
|| devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) {
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
delayDueTosimTraces.add(st);
}
}
}
}
}
}
// fill the tasks that run on the same hardware but don't belong to the path
// between selected activities
public Object[][] getTaskHWByRowDetails(int row) {
Object[][] dataByTaskRowDetails = new Object[dataBydelayedTasks.get(row).size()][6];
int i = 0;
for (SimulationTransaction st : dataBydelayedTasks.get(row)) {
dataByTaskRowDetails[i][0] = st.command;
dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id);
dataByTaskRowDetails[i][2] = st.deviceName;
dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime);
dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime);
HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = timeDelayedPerRow.get(row);
boolean causeDelay = false;
if (delayTime.containsKey(st.deviceName)) {
for (Entry<String, ArrayList<ArrayList<Integer>>> entry : delayTime.entrySet()) {
if (entry.getKey().equals(st.deviceName)) {
ArrayList<ArrayList<Integer>> timeList = entry.getValue();
for (int j = 0; j < timeList.size(); j++) {
if (Integer.valueOf(st.startTime) > timeList.get(j).get(0) && Integer.valueOf(st.startTime) < timeList.get(j).get(1)) {
causeDelay = true;
dataByTaskRowDetails[i][5] = causeDelay;
return dataByTaskRowDetails;
// fill the Min max delay table on main latency analysis frame
public Object[][] latencyMinMaxAnalysis(String task12ID, String task22ID, Vector<SimulationTransaction> transFile1) {
List<Integer> times1MinMAx = new ArrayList<Integer>();
List<Integer> times2MinMAx = new ArrayList<Integer>();
String[] task1 = task12ID.split("__");
int task1index = task1.length;
idTask1 = task1[task1index - 1];
String[] task2 = task22ID.split("__");
int task2index = task2.length;
idTask2 = task2[task2index - 1];
String task12 = nameIDTaskList.get(idTask1);
String task22 = nameIDTaskList.get(idTask2);
times1MinMAx = times1;
times2MinMAx = times2;
HashMap<Integer, ArrayList<Integer>> minTimes = new HashMap<Integer, ArrayList<Integer>>();
for (int time1 : times1MinMAx) {
int match = Integer.MAX_VALUE;
// Find the first subsequent transaction
int time = Integer.MAX_VALUE;
for (int time2 : times2MinMAx) {
int diff = time2 - time1;
if (diff < time && diff >= 0) {
time = diff;
match = time2;
}
}
try {
if (times2MinMAx.contains(match)) {
times2MinMAx.remove(Integer.valueOf(match));
}
} catch (Exception e) {
}
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
if (time != Integer.MAX_VALUE) {
ArrayList<Integer> startEndT = new ArrayList<Integer>();
startEndT.add(time1);
startEndT.add(match);
minTimes.put(time, startEndT);
}
}
dataByTaskMinMax = new Object[2][5];
if (minTimes.size() > 0) {
Integer min = Collections.min(minTimes.keySet());
Integer max = Collections.max(minTimes.keySet());
dataByTaskMinMax = new Object[2][5];
ArrayList<Integer> numMax = minTimes.get(max);
ArrayList<Integer> numMin = minTimes.get(min);
dataByTaskMinMax[0][0] = task12;
dataByTaskMinMax[0][1] = numMin.get(0);
dataByTaskMinMax[0][2] = task22;
dataByTaskMinMax[0][3] = numMin.get(1);
dataByTaskMinMax[0][4] = min;
dataByTaskMinMax[1][0] = task12;
dataByTaskMinMax[1][1] = numMax.get(0);
dataByTaskMinMax[1][2] = task22;
dataByTaskMinMax[1][3] = numMax.get(1);
dataByTaskMinMax[1][4] = max;
}
return dataByTaskMinMax;
}
// fill the detailed latency table once a row is selected from min/max table
public Object[][] getTasksByRowMinMax(int row) {
Object[][] dataByTaskRowDetails = new Object[relatedsimTraces.size()][5];
int i = 0;
for (SimulationTransaction st : relatedsimTraces) {
dataByTaskRowDetails[i][0] = st.command;
dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id);
dataByTaskRowDetails[i][2] = st.deviceName;
dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime);
dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime);
i++;
}
return dataByTaskRowDetails;
}
// fill the tasks that run on the same hardware but don't belong to the path
// between selected activities
public Object[][] getTaskHWByRowDetailsMinMax(int row) {
Object[][] dataByTaskRowDetails = new Object[delayDueTosimTraces.size()][5];
int i = 0;
for (SimulationTransaction st : delayDueTosimTraces) {
dataByTaskRowDetails[i][0] = st.command;
dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id);
dataByTaskRowDetails[i][2] = st.deviceName;
dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime);
dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime);
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
i++;
}
return dataByTaskRowDetails;
}
// import graph in .graphml format
public void importGraph(String filename) throws ExportException, IOException, ImportException {
FileReader ps = new FileReader(filename + ".graphml");
// gmlExporter.exportGraph(g, PS);
// FileWriter PS2 = new FileWriter(filename + "test.graphml");
VertexProvider<String> vertexProvider = (id, attributes) -> {
String cv = new String(id);
return cv;
};
EdgeProvider<String, DefaultEdge> edgeProvider = (from, to, label, attributes) -> new DefaultEdge();
GraphMLImporter<String, DefaultEdge> importer = new GraphMLImporter<String, DefaultEdge>(vertexProvider, edgeProvider);
Graph<String, DefaultEdge> importedGraph = null;
importer.importGraph(importedGraph, ps);
}
public List<TMLComponentDesignPanel> getCpanels() {
return cpanels;
}
public void setCpanels(List<TMLComponentDesignPanel> cpanels) {
this.cpanels = cpanels;
}