Newer
Older
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) {
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
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);
}
} 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);
}
}
} 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)) {
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
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);
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);
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
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;
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
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);
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
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)) {
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
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;
i++;
}
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);
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
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
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
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) {
}
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);
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
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);
}