Newer
Older
/* 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.
*/
import com.mxgraph.layout.hierarchical.mxHierarchicalLayout;
import com.mxgraph.swing.mxGraphComponent;
import org.jgrapht.Graph;
import org.jgrapht.GraphPath;
import org.jgrapht.alg.shortestpath.AllDirectedPaths;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
import org.jgrapht.ext.JGraphXAdapter;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.io.*;
import tmltranslator.*;
import tmltranslator.tomappingsystemc2.DiploSimulatorCodeGenerator;
import ui.TGComponent;
import ui.TGConnectingPoint;
import ui.TGConnector;
import ui.TMLComponentDesignPanel;
import ui.interactivesimulation.SimulationTransaction;
import ui.tmlcompd.TMLCPrimitivePort;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
/**
* Class DirectedGraphTranslator: this class generate the directed graph
* equivalent for the sysml model
* 23/09/2019
*
* @author Maysam Zoor
*/
public class DirectedGraphTranslator extends JApplet {
// private TMLArchiPanel tmlap; // USed to retrieve the currently opened
// architecture panel
// private TMLMapping<TGComponent> tmap;
private TMLActivity activity;
private int nodeNbProgressBar = 0;
private int nodeNb = 0;
// List<HwNode> path;
private TMLActivityElement currentElement;
private TMLActivityElement backwardElement;
private ArrayList<String> SummaryCommMapping;
private Graph<vertex, DefaultEdge> g;
private static final Dimension DEFAULT_SIZE = new Dimension(530, 320);
private final List<HwLink> links;
private final TMLMapping<TGComponent> tmap;
private final HashMap<String, String> addedEdges = new HashMap<String, String>();
private final HashMap<String, HashSet<String>> sendEventWaitEventEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> readWriteChannelEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> writeReadChannelEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> forkreadEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> forkwriteEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> joinreadEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> joinwriteEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, HashSet<String>> sequenceEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, ArrayList<String>> orderedSequenceList = new HashMap<String, ArrayList<String>>();
private final HashMap<String, HashSet<String>> unOrderedSequenceEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, ArrayList<String>> unOrderedSequenceList = new HashMap<String, ArrayList<String>>();
private final List<String> forEverLoopList = new ArrayList<String>();
private final HashMap<String, List<TMLTask>> requests = new HashMap<String, List<TMLTask>>();
private final HashMap<String, HashSet<String>> requestEdges = new HashMap<String, HashSet<String>>();
private final HashMap<String, List<String>> requestsOriginDestination = new HashMap<String, List<String>>();
private final HashMap<String, List<String>> requestsPorts = new HashMap<String, List<String>>();
private final HashMap<String, List<String>> requestsDestination = new HashMap<String, List<String>>();
private final Vector<String> allLatencyTasks = new Vector<String>();
private static JScrollPane scrollPane = new JScrollPane();
// List<String,String> = new ArrayList<String,String>();
private final HashMap<String, String> nameIDTaskList = new HashMap<String, String>();
private final HashMap<String, ArrayList<String>> channelPaths = new HashMap<String, ArrayList<String>>();
private Object[][] dataByTask = null;
private Object[][] dataByTaskMinMax = null;
private Object[][] dataByTaskBYRow;
private Object[][] dataByTaskHWBYRow;
private HashMap<Integer, Vector<SimulationTransaction>> dataByTaskR = new HashMap<Integer, Vector<SimulationTransaction>>();
private HashMap<Integer, List<SimulationTransaction>> dataBydelayedTasks = new HashMap<Integer, List<SimulationTransaction>>();
private HashMap<Integer, HashMap<String, ArrayList<ArrayList<Integer>>>> timeDelayedPerRow = new HashMap<Integer, HashMap<String, ArrayList<ArrayList<Integer>>>>();
private HashMap<Integer, List<String>> detailsOfMinMaxRow = new HashMap<Integer, List<String>>();
private HashMap<Integer, List<SimulationTransaction>> dataBydelayedTasksOfMinMAx = new HashMap<Integer, List<SimulationTransaction>>();
private final JFrame frame = new JFrame("The Sys-ML Model As Directed Graph");
private List<Integer> times1 = new ArrayList<Integer>();
private List<Integer> times2 = new ArrayList<Integer>();
private Vector<SimulationTransaction> transFile;
private String idTask1;
private String idTask2;
private String task2DeviceName = "";
private String task1DeviceName = "";
private ArrayList<String> devicesToBeConsidered = new ArrayList<String>();
private Vector<SimulationTransaction> relatedsimTraces = new Vector<SimulationTransaction>();
private Vector<SimulationTransaction> delayDueTosimTraces = new Vector<SimulationTransaction>();
private HashMap<String, ArrayList<SimulationTransaction>> relatedsimTraceswithTaint = new HashMap<String, ArrayList<SimulationTransaction>>();
private JFrameLatencyDetailedAnalysis frameLatencyDetailedAnalysis;
private JFrameCompareLatencyDetail frameCompareLatencyDetail;
private int callingFrame;
private int nbOfNodes = 0;
private List<String> usedLabels = new ArrayList<String>();
private List<String> warnings = new ArrayList<String>();
private static Random random = new Random();
private static final String CHAR_LOWER = "abcdefghijklmnopqrstuvwxyz";
private static final String CHAR_UPPER = CHAR_LOWER.toUpperCase();
private static final String data = CHAR_LOWER + CHAR_UPPER;
// List<vertex> gVertecies = new ArrayList<vertex>();
private HashMap<String, ArrayList<ArrayList<Integer>>> runnableTimePerDevice = new HashMap<String, ArrayList<ArrayList<Integer>>>();
private HashMap<String, List<String>> allForLoopNextValues = new HashMap<String, List<String>>();
private HashMap<vertex, List<vertex>> allChoiceValues = new HashMap<vertex, List<vertex>>();
private HashMap<vertex, List<vertex>> allSeqValues = new HashMap<vertex, List<vertex>>();
private HashMap<vertex, List<vertex>> allRandomSeqValues = new HashMap<vertex, List<vertex>>();
private String taintLabel = "";
private Vector<String> readChannelTransactions = new Vector<String>();
private Vector<String> writeChannelTransactions = new Vector<String>();
private HashMap<vertex, List<vertex>> ruleAddedEdges = new HashMap<vertex, List<vertex>>();
private HashMap<vertex, List<vertex>> ruleAddedEdgesChannels = new HashMap<vertex, List<vertex>>();
private HashMap<String, Integer> cpuIDs = new HashMap<String, Integer>();
private HashMap<String, List<String>> forLoopNextValues = new HashMap<String, List<String>>();
private int opCount;
private HashMap<String, List<String>> sendEvt = new HashMap<String, List<String>>();
private HashMap<String, List<String>> waitEvt = new HashMap<String, List<String>>();
private HashMap<String, String> sendData = new HashMap<String, String>();
private HashMap<String, String> receiveData = new HashMap<String, String>();
private String taskStartName = "";
@SuppressWarnings("deprecation")
public DirectedGraphTranslator(JFrameLatencyDetailedAnalysis jFrameLatencyDetailedAnalysis, JFrameCompareLatencyDetail jframeCompareLatencyDetail,
TMLMapping<TGComponent> tmap1, List<TMLComponentDesignPanel> cpanels1, int i) {
links = tmap.getTMLArchitecture().getHwLinks();
// tmlcdp = getCpanels().get(0);
callingFrame = i;
if (callingFrame == 0)
{
frameLatencyDetailedAnalysis = jFrameLatencyDetailedAnalysis;
} else if (callingFrame == 1) {
frameCompareLatencyDetail = jframeCompareLatencyDetail;
DrawDirectedGraph();
}
// The main function to add the vertices and edges according to the model
// TODO Auto-generated method stub
private void DrawDirectedGraph() {
nodeNbProgressBar = 0;
nodeNbProgressBar = tmap.getArch().getBUSs().size() + tmap.getArch().getHwBridge().size() + tmap.getArch().getHwA().size()
+ tmap.getArch().getMemories().size() + tmap.getArch().getCPUs().size();
frameLatencyDetailedAnalysis.getPbar().setMaximum(nodeNbProgressBar);
frameLatencyDetailedAnalysis.getPbar().setMinimum(0);
frameCompareLatencyDetail.getPbar().setMaximum(nodeNbProgressBar);
frameCompareLatencyDetail.getPbar().setMinimum(0);
HashMap<String, HashSet<TMLElement>> buschannel = new HashMap<String, HashSet<TMLElement>>();
HashMap<String, HashSet<TMLElement>> memorychannel = new HashMap<String, HashSet<TMLElement>>();
HashMap<String, HashSet<TMLElement>> bridgechannel = new HashMap<String, HashSet<TMLElement>>();
// HashMap<String, HashSet<TMLTask>> cpuTask = new HashMap<String,
// HashSet<TMLTask>>();
g = new DefaultDirectedGraph<>(DefaultEdge.class);
buschannel = addBUSs();
bridgechannel = addBridge();
addHwAs();
memorychannel = addMemories();
addBuschannel(buschannel);
addBridgechannel(bridgechannel);
addMemorychannel(memorychannel);
addUnmappedchannel();
addCPUs();
addLinkEdges();
addFlowEdges();
addSendEventWaitEventEdges();
addReadWriteChannelEdges();
addForkreadEdges();
addJoinreadEdges();
addWriteReadChannelEdges();
addSeqEdges();
addunOrderedSeqEdges();
addRequestEdges();
private void addUnmappedchannel() {
// TODO Auto-generated method stub
DiploSimulatorCodeGenerator gen = new DiploSimulatorCodeGenerator(tmap);
for (TMLChannel ch : tmap.getTMLModeling().getChannels()) {
List<HwCommunicationNode> pathNodes = gen.determineRoutingPath(tmap.getHwNodeOf(ch.getOriginTask()),
tmap.getHwNodeOf(ch.getDestinationTask()), ch);
if (!g.vertexSet().contains(getvertex(ch.getName()))) {
vertex v2 = vertex(ch.getName(), ch.getID());
g.addVertex(v2);
// gVertecies.add(vertex(ch.getName()));
getvertex(ch.getName()).setType(vertex.TYPE_CHANNEL);
getvertex(ch.getName()).setTaintFixedNumber(0);
updatemainBar(ch.getName());
if (!pathNodes.isEmpty()) {
for (HwCommunicationNode node : pathNodes) {
if (channelPaths.containsKey(ch.getName())) {
if (!channelPaths.get(ch.getName()).contains(node.getName())) {
channelPaths.get(ch.getName()).add(node.getName());
}
} else {
ArrayList<String> pathNodeNames = new ArrayList<String>();
pathNodeNames.add(node.getName());
channelPaths.put(ch.getName(), pathNodeNames);
}
vertex v1 = vertex(node.getName(), node.getID());
if (!g.containsEdge(v1, v2)) {
g.addEdge(v1, v2);
}
SummaryCommMapping = tmap.getSummaryCommMapping();
private void addCPUs() {
// TODO Auto-generated method stub
HashMap<String, HashSet<TMLTask>> cpuTask = new HashMap<String, HashSet<TMLTask>>();
HashMap<String, HashSet<String>> cpuTasks;
for (HwNode node : tmap.getArch().getCPUs()) {
cpuTask = new HashMap<String, HashSet<TMLTask>>();
cpuIDs.put(node.getName(), node.getID());
if (tmap.getLisMappedTasks(node).size() > 0) {
cpuTask.put(node.getName(), tmap.getLisMappedTasks(node));
}
cpuTasks = getCPUTaskMap(cpuTask);
}
private void addMemorychannel(HashMap<String, HashSet<TMLElement>> memorychannel) {
// TODO Auto-generated method stub
for (Entry<String, HashSet<TMLElement>> entry : memorychannel.entrySet()) {
String busName = entry.getKey();
HashSet<TMLElement> busChList = entry.getValue();
for (TMLElement busCh : busChList) {
String ChannelName = busCh.getName();
vertex v = vertex(ChannelName, busCh.getID());
if (!g.containsVertex(getvertex(ChannelName))) {
g.addVertex(v);
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
}
private void addBridgechannel(HashMap<String, HashSet<TMLElement>> bridgechannel) {
// TODO Auto-generated method stub
for (Entry<String, HashSet<TMLElement>> entry : bridgechannel.entrySet()) {
String busName = entry.getKey();
HashSet<TMLElement> busChList = entry.getValue();
for (TMLElement busCh : busChList) {
String ChannelName = busCh.getName();
vertex v = vertex(ChannelName, busCh.getID());
if (!g.containsVertex(getvertex(ChannelName))) {
g.addVertex(v);
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
}
private void addBuschannel(HashMap<String, HashSet<TMLElement>> buschannel) {
// TODO Auto-generated method stub
for (Entry<String, HashSet<TMLElement>> entry : buschannel.entrySet()) {
String busName = entry.getKey();
HashSet<TMLElement> busChList = entry.getValue();
for (TMLElement busCh : busChList) {
String ChannelName = busCh.getName();
vertex v = vertex(ChannelName, busCh.getID());
if (!g.containsVertex(v)) {
g.addVertex(v);
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
// String writeChannel = tmlch.getDestinationTask().getName() + "__" +
// "writechannel:" + tmlch.getDestinationPort();
// String readChannel;
private HashMap<String, HashSet<TMLElement>> addMemories() {
HashMap<String, HashSet<TMLElement>> memorychannel = new HashMap<String, HashSet<TMLElement>>();
for (HwNode node : tmap.getArch().getMemories()) {
vertex v = vertex(node.getName(), node.getID());
if (!g.containsVertex(v)) {
g.addVertex(v);
updatemainBar("getMemories");
}
if (tmap.getLisMappedChannels(node).size() > 0) {
memorychannel.put(node.getName(), tmap.getLisMappedChannels(node));
return memorychannel;
}
private void addHwAs() {
// TODO Auto-generated method stub
HashMap<String, HashSet<TMLTask>> cpuTask = new HashMap<String, HashSet<TMLTask>>();
HashMap<String, HashSet<String>> cpuTasks;
for (HwA node : tmap.getArch().getHwA()) {
if (tmap.getLisMappedTasks(node).size() > 0) {
cpuTask.put(node.getName(), tmap.getLisMappedTasks(node));
}
cpuTasks = getCPUTaskMap(cpuTask);
}
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
}
private HashMap<String, HashSet<TMLElement>> addBridge() {
// TODO Auto-generated method stub
HashMap<String, HashSet<TMLElement>> bridgechannel = new HashMap<String, HashSet<TMLElement>>();
for (HwNode node : tmap.getArch().getHwBridge()) {
vertex v = vertex(node.getName(), node.getID());
if (!g.containsVertex(v)) {
g.addVertex(v);
updatemainBar("getHwBridge");
}
if (tmap.getLisMappedChannels(node).size() > 0) {
bridgechannel.put(node.getName(), tmap.getLisMappedChannels(node));
}
}
return bridgechannel;
}
private HashMap<String, HashSet<TMLElement>> addBUSs() {
// TODO Auto-generated method stub
HashMap<String, HashSet<TMLElement>> buschannel = new HashMap<String, HashSet<TMLElement>>();
for (HwNode node : tmap.getArch().getBUSs()) {
vertex v = vertex(node.getName(), node.getID());
if (!g.containsVertex(v)) {
g.addVertex(v);
updatemainBar("getBUSs");
}
if (tmap.getLisMappedChannels(node).size() > 0) {
buschannel.put(node.getName(), tmap.getLisMappedChannels(node));
}
}
return buschannel;
}
private void addLinkEdges() {
// TODO Auto-generated method stub
for (HwLink link : links) {
vertex vlink1 = vertex(link.hwnode.getName(), link.hwnode.getID());
vertex vlink2 = vertex(link.bus.getName(), link.bus.getID());
if (g.containsVertex(getvertex(link.hwnode.getName())) && g.containsVertex(getvertex(link.bus.getName()))) {
g.addEdge(vlink1, vlink2);
g.addEdge(vlink2, vlink1);
}
private void addFlowEdges() {
// TODO Auto-generated method stub
if (addedEdges.size() > 0) {
for (Entry<String, String> edge : addedEdges.entrySet()) {
g.addEdge(getvertex(edge.getKey()), getvertex(edge.getValue()));
}
private void addSendEventWaitEventEdges() {
// TODO Auto-generated method stub
if (sendEventWaitEventEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : sendEventWaitEventEdges.entrySet()) {
for (String waitEventEdge : edge.getValue())
g.addEdge(getvertex(edge.getKey()), getvertex(waitEventEdge));
}
private void addReadWriteChannelEdges() {
// TODO Auto-generated method stub
if (readWriteChannelEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : readWriteChannelEdges.entrySet()) {
for (String readChannelEdge : edge.getValue()) {
g.addEdge(getvertex(edge.getKey()), getvertex(readChannelEdge));
getvertex(edge.getKey()).setTaintFixedNumber(getvertex(edge.getKey()).getTaintFixedNumber() + 1);
}
}
}
}
private void addForkreadEdges() {
// TODO Auto-generated method stub
if (forkreadEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : forkreadEdges.entrySet()) {
HashSet<String> writech = forkwriteEdges.get(edge.getKey());
for (String readChannelEdge : edge.getValue()) {
for (String wch : writech) {
g.addEdge(getvertex(readChannelEdge), getvertex(wch));
}
}
}
}
}
// draw the vertices and edges for the tasks mapped to the CPUs
private void addJoinreadEdges() {
// TODO Auto-generated method stub
if (joinreadEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : joinreadEdges.entrySet()) {
HashSet<String> writech = joinwriteEdges.get(edge.getKey());
for (String readChannelEdge : edge.getValue()) {
g.addEdge(getvertex(readChannelEdge), getvertex(wch));
}
}
}
}
}
private void addWriteReadChannelEdges() {
// TODO Auto-generated method stub
if (writeReadChannelEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : writeReadChannelEdges.entrySet()) {
for (String readChannelEdge : edge.getValue()) {
g.addEdge(getvertex(edge.getKey()), getvertex(readChannelEdge));
getvertex(readChannelEdge).setTaintFixedNumber(getvertex(readChannelEdge).getTaintFixedNumber() + 1);
}
private void addRequestEdges() {
// TODO Auto-generated method stub
if (requestEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : requestEdges.entrySet()) {
for (String requestsingleEdges : edge.getValue()) {
g.addEdge(getvertex(edge.getKey()), getvertex(requestsingleEdges));
}
}
}
}
private void addunOrderedSeqEdges() {
// TODO Auto-generated method stub
if (unOrderedSequenceEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : unOrderedSequenceEdges.entrySet()) {
g.addEdge(getvertex(edge.getKey()), getvertex(sequenceEdge));
private void addSeqEdges() {
if (sequenceEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : sequenceEdges.entrySet()) {
for (String sequenceEdge : edge.getValue())
g.addEdge(getvertex(edge.getKey()), getvertex(sequenceEdge));
}
private void expectedNumberofVertex() {
for (HwA node : tmap.getArch().getHwA()) {
if (tmap.getLisMappedTasks(node).size() > 0) {
nodeNbProgressBar = tmap.getLisMappedTasks(node).size() + nodeNbProgressBar;
for (TMLTask task : tmap.getLisMappedTasks(node)) {
for (TMLActivityElement ae : task.getActivityDiagram().getElements()) {
if (ae.getName().equals("Stop after infinite loop")) {
for (HwNode node : tmap.getArch().getCPUs()) {
if (tmap.getLisMappedTasks(node).size() > 0) {
nodeNbProgressBar = tmap.getLisMappedTasks(node).size() + nodeNbProgressBar;
for (TMLTask task : tmap.getLisMappedTasks(node)) {
for (TMLActivityElement ae : task.getActivityDiagram().getElements()) {
if (ae.getName().equals("Stop after infinite loop")) {
}
}
HashSet<String> mappedcomm = new HashSet<String>();
for (HwNode node : tmap.getArch().getBUSs()) {
if (tmap.getLisMappedChannels(node).size() > 0) {
for (TMLElement entry : tmap.getLisMappedChannels(node)) {
if (!mappedcomm.contains(entry.getName())) {
mappedcomm.add(entry.getName());
nodeNbProgressBar++;
}
}
}
for (HwNode node : tmap.getArch().getHwBridge()) {
if (tmap.getLisMappedChannels(node).size() > 0) {
for (TMLElement entry : tmap.getLisMappedChannels(node)) {
if (!mappedcomm.contains(entry.getName())) {
mappedcomm.add(entry.getName());
nodeNbProgressBar++;
for (HwNode node : tmap.getArch().getMemories()) {
if (tmap.getLisMappedChannels(node).size() > 0) {
for (TMLElement entry : tmap.getLisMappedChannels(node)) {
if (!mappedcomm.contains(entry.getName())) {
mappedcomm.add(entry.getName());
nodeNbProgressBar++;
for (TMLChannel ch : tmap.getTMLModeling().getChannels()) {
if (!mappedcomm.contains(ch.getName())) {
mappedcomm.add(ch.getName());
{
frameLatencyDetailedAnalysis.updateBar(nbOfNodes);
} else if (callingFrame == 1) {
frameCompareLatencyDetail.updateBar(nbOfNodes);
public HashMap<String, HashSet<String>> getCPUTaskMap(HashMap<String, HashSet<TMLTask>> cpuTask) {
HashMap<String, HashSet<String>> cpuTaskMap = new HashMap<String, HashSet<String>>();
if (tmap == null) {
return cpuTaskMap;
}
for (Entry<String, HashSet<TMLTask>> entry : cpuTask.entrySet()) {
String key = entry.getKey();
int keyID = cpuIDs.get(key);
HashSet<TMLTask> value = entry.getValue();
Vector<TMLActivityElement> multiNexts = new Vector<TMLActivityElement>();
// Map <String, String> sendEvt;
sendEvt = new HashMap<String, List<String>>();
waitEvt = new HashMap<String, List<String>>();
sendData = new HashMap<String, String>();
receiveData = new HashMap<String, String>();
// HashMap<String, List<String>> sendEvt = new HashMap<String, List<String>>();
for (TMLTask task : value) {
int taskID = task.getID();
String taskName = task.getName();
// get the names and params of send events per task and their corresponding wait
// events
// get the names of read channels per task and their corresponding write
// channels
// get the names of write channels per task and their corresponding read
// channels
// get the names and params of wait events per task and their corresponding send
// events
waitEventNames();
if (!g.vertexSet().contains(getvertex(key))) {
g.addVertex(vertex(key, keyID));
updatemainBar(key);
}
if (!g.vertexSet().contains(getvertex(taskName))) {
g.addVertex(vertex(taskName, taskID));
updatemainBar(taskName);
}
g.addEdge(getvertex(key), getvertex(taskName));
activity = task.getActivityDiagram();
opCount = 1;
currentElement = activity.getFirst();
taskStartName = "";
// int taskStartid;
forLoopNextValues = new HashMap<String, List<String>>();
// loop over all the activites corresponding to a task
while (opCount <= activity.nElements()) {
if (currentElement.getName().equals("Stop after infinite loop")) {
opCount++;
if (opCount <= activity.nElements()) {
if (currentElement.getNexts().size() == 1) {
currentElement = currentElement.getNexts().firstElement();
} else if (!multiNexts.isEmpty()) {
currentElement = multiNexts.get(0);
continue;
} else {
break;
}
} else if (currentElement.getName().equals("startOfFork") || currentElement.getName().equals("junctionOfFork")
|| currentElement.getName().equals("startOfJoin") || currentElement.getName().equals("junctionOfJoin")) {
opCount++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (taskName.startsWith("FORKTASK_S_") && currentElement.getName().equals("ReadOfFork")) {
String name = ((TMLReadChannel) (currentElement)).getChannel(0).getName();
int id = ((TMLReadChannel) (currentElement)).getChannel(0).getID();
if (!g.containsVertex(getvertex(name))) {
g.addVertex(vertex(name, id));
g.addEdge(getvertex(taskName), getvertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()));
HashSet<String> readForkVertex = new HashSet<String>();
readForkVertex.add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
if (!forkreadEdges.get(taskName).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) {
forkreadEdges.get(taskName).add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
}
currentElement = currentElement.getNexts().firstElement();
} else if (taskName.startsWith("FORKTASK_S_") && currentElement.getName().startsWith("WriteOfFork_S")) {
String vName = ((TMLWriteChannel) (currentElement)).getChannel(0).getName();
int vid = ((TMLWriteChannel) (currentElement)).getChannel(0).getID();
vertex v = getvertex(vName);
if (!g.containsVertex(v)) {
g.addVertex(vertex(vName, vid));
}
HashSet<String> writeForkVertex = new HashSet<String>();
writeForkVertex.add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
if (forkwriteEdges.containsKey(taskName)) {
if (!forkwriteEdges.get(taskName).contains(((TMLWriteChannel) (currentElement)).getChannel(0).getName())) {
forkwriteEdges.get(taskName).add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
forkwriteEdges.put(taskName, writeForkVertex);
// g.addEdge(getvertex(taskName),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName()));
currentElement = currentElement.getNexts().firstElement();
} else if (currentElement.getName().equals("stopOfFork") || currentElement.getName().equals("stop2OfFork")
|| currentElement.getName().equals("stopOfJoin")) {
opCount++;
continue;
} else if (taskName.startsWith("JOINTASK_S_") && currentElement.getName().startsWith("ReadOfJoin")) {
String vName = ((TMLReadChannel) (currentElement)).getChannel(0).getName();
int vid = ((TMLReadChannel) (currentElement)).getChannel(0).getID();
if (!g.containsVertex(getvertex(vName))) {
g.addVertex(vertex(vName, vid));
HashSet<String> writeForkVertex = new HashSet<String>();
writeForkVertex.add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
if (!joinreadEdges.get(taskName).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) {
joinreadEdges.get(task.getName()).add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
}
joinreadEdges.put(taskName, writeForkVertex);
// g.addEdge(getvertex(task.getName()),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName()));
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (taskName.startsWith("JOINTASK_S_") && currentElement.getName().equals("WriteOfJoin")) {
String vName = ((TMLWriteChannel) (currentElement)).getChannel(0).getName();
int vid = ((TMLWriteChannel) (currentElement)).getChannel(0).getID();
if (!g.containsVertex(getvertex(vName))) {
g.addVertex(vertex(vName, vid));
g.addEdge(getvertex(taskName), getvertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()));
HashSet<String> readForkVertex = new HashSet<String>();
readForkVertex.add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
if (!joinwriteEdges.get(taskName).contains(((TMLWriteChannel) (currentElement)).getChannel(0).getName())) {
joinwriteEdges.get(taskName).add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
}
} else {
joinwriteEdges.put(taskName, readForkVertex);
currentElement = currentElement.getNexts().firstElement();
continue;
}
updatemainBar(eventName);
if (currentElement.getNexts().size() > 1) {
for (TMLActivityElement ae : currentElement.getNexts()) {
multiNexts.add(ae);
eventName = getEventName(taskName, currentElement);
// in case an end was encountered , the previous activities should be checked:
// in
// case it is an end for a loop or sequence speavial edges should be added
if (currentElement.getReferenceObject() instanceof TMLADStopState) {
// start activity is added as a vertex
if (currentElement.getReferenceObject() instanceof TMLADStartState) {
addStartVertex(taskName);
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
}
// the below activities are added as vertex with the required edges
// these activities can be used to check later for latency
else if (currentElement.getReferenceObject() instanceof TMLADSendEvent
|| currentElement.getReferenceObject() instanceof TMLADWaitEvent
|| currentElement.getReferenceObject() instanceof TMLADForLoop
|| currentElement.getReferenceObject() instanceof TMLADForStaticLoop
|| currentElement.getReferenceObject() instanceof TMLADChoice
|| currentElement.getReferenceObject() instanceof TMLADForEverLoop
|| (currentElement.getReferenceObject() instanceof TMLADExecI && !currentElement.getValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecC && !currentElement.getValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADDelay
&& !((TMLADDelay) currentElement.getReferenceObject()).getDelayValue().equals("0"))
|| currentElement.getReferenceObject() instanceof TMLADSendRequest
|| currentElement.getReferenceObject() instanceof TMLADReadRequestArg
|| currentElement.getReferenceObject() instanceof TMLADActionState
|| (currentElement.getReferenceObject() instanceof TMLADDelayInterval
&& !((TMLADDelayInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& !((TMLADDelayInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecCInterval
&& !((TMLADExecCInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& !((TMLADExecCInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecIInterval
&& !((TMLADExecIInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& !((TMLADExecIInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| currentElement.getReferenceObject() instanceof TMLADNotifiedEvent
|| currentElement.getReferenceObject() instanceof TMLADRandom
|| currentElement.getReferenceObject() instanceof TMLADReadChannel
|| currentElement.getReferenceObject() instanceof TMLADWriteChannel
|| currentElement.getReferenceObject() instanceof TMLADSequence
|| currentElement.getReferenceObject() instanceof TMLADUnorderedSequence
|| currentElement.getReferenceObject() instanceof TMLADSelectEvt
|| currentElement.getReferenceObject() instanceof TMLADDecrypt
|| currentElement.getReferenceObject() instanceof TMLADEncrypt) {
addcurrentElementVertex(taskName, taskStartName);
}
// check if the next activity :add to an array:
// in case of for loop : the first element of inside/outside branches of loop
// in case of sequence: add first element of all branches
if (currentElement.getNexts().size() == 1) {
currentElement = currentElement.getNexts().firstElement();
allForLoopNextValues.putAll(forLoopNextValues);
}
}
return cpuTaskMap;
}
private void trackMultiNexts(String taskName, String eventName) {
// TODO Auto-generated method stub
if (currentElement.getReferenceObject() instanceof TMLADForStaticLoop || currentElement.getReferenceObject() instanceof TMLADForLoop) {
if (currentElement.getNexts().size() > 1) {
List<TGConnectingPoint> points = new ArrayList<TGConnectingPoint>();
List<TGConnector> getOutputConnectors = new ArrayList<TGConnector>();
if (currentElement.getReferenceObject() instanceof TMLADForStaticLoop) {
points = Arrays.asList(((TMLADForStaticLoop) (currentElement.getReferenceObject())).getConnectingPoints());
getOutputConnectors = ((TMLADForStaticLoop) (currentElement.getReferenceObject())).getOutputConnectors();
String loopValue = ((TMLADForStaticLoop) (currentElement.getReferenceObject())).getValue();
getvertex(eventName).setType(vertex.TYPE_STATIC_FOR_LOOP);
if ((loopValue != null) && (loopValue.length() > 0)) {
if ((loopValue.matches("\\d*"))) {
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
for (TMLAttribute att : taskAc.getAttributes()) {
if (loopValue.contains(att.getName())) {
loopValue = loopValue.replace(att.getName(), (att.getInitialValue()));
}
}
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
} else if (currentElement.getReferenceObject() instanceof TMLADForLoop) {
points = Arrays.asList(((TMLADForLoop) (currentElement.getReferenceObject())).getConnectingPoints());
getOutputConnectors = ((TMLADForLoop) (currentElement.getReferenceObject())).getOutputConnectors();
// String loopValue = ((TMLADForLoop)
// (currentElement.getReferenceObject())).getValue();
getvertex(eventName).setType(vertex.TYPE_FOR_LOOP);
String cond = ((TMLADForLoop) (currentElement.getReferenceObject())).getCondition();
String loopValue = val[2].toString();
if ((loopValue != null) && (loopValue.length() > 0)) {
if ((loopValue.matches("\\d*"))) {
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
} else {
for (TMLAttribute att : taskAc.getAttributes()) {
if (loopValue.contains(att.getName())) {
loopValue = loopValue.replace(att.getName(), (att.getInitialValue()));
}
}
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
} else if (cond.contains("<")) {
String[] val = cond.split("<");
String loopValue = val[1].toString();
if ((loopValue != null) && (loopValue.length() > 0)) {
if ((loopValue.matches("\\d*"))) {
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
} else {
for (TMLAttribute att : taskAc.getAttributes()) {
if (loopValue.contains(att.getName())) {
loopValue = loopValue.replace(att.getName(), (att.getInitialValue()));
}
}
if ((loopValue.matches("\\d*"))) {
getvertex(eventName).setTaintFixedNumber(Integer.valueOf(loopValue));
}
{
frameLatencyDetailedAnalysis.error(loopValue + " Expression in For Loop is not supported by Tainting");
TGConnector inputConnector = null, outputConnector = null;
for (TGConnector connector : getOutputConnectors) {
if (connector.getTGConnectingPointP1() == points.get(1)) {
inputConnector = connector;
} else if (connector.getTGConnectingPointP1() == points.get(2)) {
outputConnector = connector;
}
List<String> afterloopActivity = new ArrayList<String>(2);
String insideLoop = "", outsideLoop = "";
for (TMLActivityElement ae : currentElement.getNexts()) {
List<TGConnector> cg = (((TGComponent) ae.getReferenceObject()).getInputConnectors());
for (TGConnector afterloopcg : cg) {
if (afterloopcg == inputConnector) {
if (ae.getReferenceObject() instanceof TMLADRandom) {
insideLoop = taskName + "__" + ae.getName() + "__" + ae.getID();
} else if (ae.getReferenceObject() instanceof TMLADUnorderedSequence) {
insideLoop = taskName + "__" + "unOrderedSequence" + "__" + ae.getID();
} else {
insideLoop = taskName + "__" + ae.getReferenceObject().toString() + "__" + ae.getID();
if (ae.getReferenceObject() instanceof TMLADRandom) {
outsideLoop = taskName + "__" + ae.getName() + "__" + ae.getID();
} else if (ae.getReferenceObject() instanceof TMLADUnorderedSequence) {
outsideLoop = taskName + "__" + "unOrderedSequence" + "__" + ae.getID();
} else {
outsideLoop = taskName + "__" + ae.getReferenceObject().toString() + "__" + ae.getID();
}
afterloopActivity.add(0, insideLoop);
afterloopActivity.add(1, outsideLoop);
forLoopNextValues.put(eventName, afterloopActivity);
} else if (currentElement.getReferenceObject() instanceof TMLADSequence) {
getvertex(eventName).setType(vertex.TYPE_SEQ);
getvertex(eventName).setTaintFixedNumber(1);
String nextEventName = "";
for (TMLActivityElement seqListnextElement : currentElement.getNexts()) {
if (seqListnextElement.getReferenceObject() instanceof TMLADRandom) {
nextEventName = taskName + "__" + seqListnextElement.getName() + "__" + seqListnextElement.getID();
} else if (seqListnextElement.getReferenceObject() instanceof TMLADUnorderedSequence) {
nextEventName = taskName + "__" + "unOrderedSequence" + "__" + seqListnextElement.getID();
} else {
nextEventName = taskName + "__" + seqListnextElement.getReferenceObject().toString() + "__" + seqListnextElement.getID();
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
}
if (orderedSequenceList.containsKey(eventName)) {
if (!orderedSequenceList.get(eventName).contains(nextEventName)) {
orderedSequenceList.get(eventName).add(nextEventName);
}
} else {
ArrayList<String> seqListNextValues = new ArrayList<String>();
seqListNextValues.add(nextEventName);
orderedSequenceList.put(eventName, seqListNextValues);
}
}
} else if (currentElement.getReferenceObject() instanceof TMLADUnorderedSequence) {
getvertex(eventName).setType(vertex.TYPE_UNORDER_SEQ);
getvertex(eventName).setTaintFixedNumber(1);
String nextEventName = "";
for (TMLActivityElement seqListnextElement : currentElement.getNexts()) {
if (seqListnextElement.getReferenceObject() instanceof TMLADRandom) {
nextEventName = taskName + "__" + seqListnextElement.getName() + "__" + seqListnextElement.getID();
} else if (seqListnextElement.getReferenceObject() instanceof TMLADUnorderedSequence) {
nextEventName = taskName + "__" + "unOrderedSequence" + "__" + seqListnextElement.getID();
} else {
nextEventName = taskName + "__" + seqListnextElement.getReferenceObject().toString() + "__" + seqListnextElement.getID();
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
}
if (unOrderedSequenceList.containsKey(eventName)) {
if (!unOrderedSequenceList.get(eventName).contains(nextEventName)) {
unOrderedSequenceList.get(eventName).add(nextEventName);
}
} else {
ArrayList<String> seqListNextValues = new ArrayList<String>();
seqListNextValues.add(nextEventName);
unOrderedSequenceList.put(eventName, seqListNextValues);
}
}
}
List<TGConnector> cg = (((TGComponent) currentElement.getReferenceObject()).getInputConnectors());
}
private void addStartVertex(String taskName) {
// TODO Auto-generated method stub
taskStartName = taskName + "__" + currentElement.getName() + "__" + currentElement.getID();
vertex startv = vertex(taskStartName, currentElement.getID());
g.addVertex(startv);
// gVertecies.add(vertex(taskStartName));
getvertex(taskStartName).setType(vertex.TYPE_START);
getvertex(taskStartName).setTaintFixedNumber(1);
g.addEdge(getvertex(taskName), getvertex(taskStartName));
opCount++;
if (!nameIDTaskList.containsKey(currentElement.getID())) {
nameIDTaskList.put(String.valueOf(currentElement.getID()), taskStartName);
}
}
private void waitEventNames() {
// TODO Auto-generated method stub
for (TMLWaitEvent waitEvent : taskAc.getWaitEvents()) {
// TMLCPrimitivePort portdetails = waitEvent.getEvent().port;
TMLCPrimitivePort sendingPortdetails = waitEvent.getEvent().port;
TMLCPrimitivePort receivePortdetails = waitEvent.getEvent().port2;
if (!sendingPortdetails.isBlocking()) {
warnings.add(
"send event port:" + sendingPortdetails.getPortName() + " is non-blocking. Use tainting for an accurate latency analysis");
}
if (sendingPortdetails.isFinite()) {
warnings.add("send event port:" + sendingPortdetails.getPortName() + " is Finite. Event lost is not supported in latency analysis ");
}
String receivePortparams = waitEvent.getAllParams();
// tmlcdp.tmlctdp.getAllPortsConnectedTo(portdetails);
waitEvt.put("waitevent:" + receivePortdetails.getPortName() + "(" + receivePortparams + ")", new ArrayList<String>());
TMLTask originTasks = waitEvent.getEvent().getOriginTask();
for (TMLSendEvent wait_sendEvent : originTasks.getSendEvents()) {
String sendingPortparams = wait_sendEvent.getAllParams();
waitEvt.get("waitevent:" + receivePortdetails.getPortName() + "(" + receivePortparams + ")")
.add("sendevent:" + sendingPortdetails.getPortName() + "(" + sendingPortparams + ")");
}
}
}
private void writeChannelNames() {
// TODO Auto-generated method stub
for (TMLWriteChannel writeChannel : taskAc.getWriteChannels()) {
int i = writeChannel.getNbOfChannels();
for (int j = 0; j < i; j++) {
String sendingDataPortdetails = "";
String receiveDataPortdetails = "";
if ((writeChannel.getChannel(j)).originalDestinationTasks.size() > 0) {
String[] checkchannel;
if (writeChannel.getChannel(j).getOriginPort().getName().contains("FORKPORTORIGIN")) {
checkchannel = writeChannel.getChannel(j).getOriginPort().getName().split("_S_");
if (checkchannel.length > 2) {
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "FORKCHANNEL");
;
} else if (checkchannel.length < 2) {
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "");
;
sendingDataPortdetails = sendingDataPortdetails.replace("_S_", "");
;
}
} else if (writeChannel.getChannel(j).getOriginPort().getName().contains("JOINPORTORIGIN")) {
checkchannel = writeChannel.getChannel(j).getOriginPort().getName().split("_S_");
if (checkchannel.length > 2) {
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "JOINCHANNEL");
} else if (checkchannel.length <= 2) {
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "");
sendingDataPortdetails = sendingDataPortdetails.replace("_S_", "");
;
} else {
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName();
if (writeChannel.getChannel(j).getDestinationPort().getName().contains("FORKPORTDESTINATION")) {
checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split("_S_");
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION",
"FORKCHANNEL");
} else if (checkchannel.length <= 2) {
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", "");
receiveDataPortdetails = receiveDataPortdetails.replace("_S_", "");
} else if (writeChannel.getChannel(j).getDestinationPort().getName().contains("JOINPORTDESTINATION")) {
checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split("_S_");
receiveDataPortdetails = "JOINCHANNEL_S_" + checkchannel[1] + "__" + checkchannel[2];
} else if (checkchannel.length <= 2) {
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION", "");
receiveDataPortdetails = receiveDataPortdetails.replace("_S_", "");
}
} else {
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName();
// writeChannel.getChannel(j);
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName();
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName();
}
if (!sendingDataPortdetails.equals(receiveDataPortdetails)) {
sendData.put(sendingDataPortdetails, receiveDataPortdetails);
}
private void readChannelNames() {
// TODO Auto-generated method stub
for (TMLReadChannel readChannel : taskAc.getReadChannels()) {
// name = _ch.getOriginPorts().get(0).getName(); //return the name of the source
// port of the channel
String sendingDataPortdetails = "";
String receiveDataPortdetails = "";
if ((readChannel.getChannel(j)).originalDestinationTasks.size() > 0) {
String[] checkchannel;
if (readChannel.getChannel(j).getOriginPort().getName().contains("FORKPORTORIGIN")) {
checkchannel = readChannel.getChannel(j).getOriginPort().getName().split("_S_");
if (checkchannel.length > 2) {
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "FORKCHANNEL");
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "");
sendingDataPortdetails = sendingDataPortdetails.replace("_S_", "");
;
} else if (readChannel.getChannel(j).getOriginPort().getName().contains("JOINPORTORIGIN")) {
checkchannel = readChannel.getChannel(j).getOriginPort().getName().split("_S_");
if (checkchannel.length > 2) {
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "JOINCHANNEL");
} else if ((checkchannel.length) <= 2) {
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "");
sendingDataPortdetails = sendingDataPortdetails.replace("_S_", "");
}
} else {
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName();
}
if (readChannel.getChannel(j).getDestinationPort().getName().contains("FORKPORTDESTINATION")) {
checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split("_S_");
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION",
"FORKCHANNEL");
} else if (checkchannel.length <= 2) {
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", "");
receiveDataPortdetails = receiveDataPortdetails.replace("_S_", "");
}
} else if (readChannel.getChannel(j).getDestinationPort().getName().contains("JOINPORTDESTINATION")) {
checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split("_S_");
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION",
"JOINCHANNEL");
} else if (checkchannel.length <= 2) {
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION", "");
receiveDataPortdetails = receiveDataPortdetails.replace("_S_", "");
}
} else {
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName();
}
} else {
sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName();
receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName();
}
if (!sendingDataPortdetails.equals(receiveDataPortdetails)) {
receiveData.put(receiveDataPortdetails, sendingDataPortdetails);
if (readChannel.getChannel(j).getOriginPort().getReferenceObject() instanceof TMLCPrimitivePort) {
rp = (TMLCPrimitivePort) readChannel.getChannel(j).getOriginPort().getReferenceObject();
if (readChannel.getChannel(j).getOriginPort().getReferenceObject() instanceof TMLCPrimitivePort) {
sp = (TMLCPrimitivePort) readChannel.getChannel(j).getDestinationPort().getReferenceObject();
if (!sp.isBlocking() && !rp.isBlocking()) {
warnings.add("send data port:" + sp.getPortName() + " and read data port:" + rp.getPortName()
+ " are non-blocking. Use tainting for an accurate latency analysis.");
private void sendEventsNames() {
// TODO Auto-generated method stub
for (TMLSendEvent sendEvent : taskAc.getSendEvents()) {
TMLCPrimitivePort sendingPortdetails = sendEvent.getEvent().port;
TMLCPrimitivePort receivePortdetails = sendEvent.getEvent().port2;
String sendingPortparams = sendEvent.getAllParams();
TMLTask destinationTasks = sendEvent.getEvent().getDestinationTask();
sendEvt.put("sendevent:" + sendingPortdetails.getPortName() + "(" + sendingPortparams + ")", new ArrayList<String>());
for (TMLWaitEvent wait_sendEvent : destinationTasks.getWaitEvents()) {
String receivePortparams = wait_sendEvent.getAllParams();
sendEvt.get("sendevent:" + sendingPortdetails.getPortName() + "(" + sendingPortparams + ")")
.add("waitevent:" + receivePortdetails.getPortName() + "(" + receivePortparams + ")");
private void requestedTask(HashSet<TMLTask> value) {
// TODO Auto-generated method stub
for (TMLTask task : value) {
if (task.isRequested()) {
TMLRequest requestToTask = task.getRequest();
requestToTask.ports.get(0).getName();
requestToTask.getExtendedName();
String destinationRequest = requestToTask.getDestinationTask().getName() + "__"
+ requestToTask.getDestinationTask().getActivityDiagram().get(0).getName() + "__"
+ requestToTask.getDestinationTask().getActivityDiagram().get(0).getID();
String destinationRequestName = requestToTask.getDestinationTask().getName();
for (TMLTask originTask : requestToTask.getOriginTasks()) {
String requestOriginTaskName = originTask.getName();
if (requestsOriginDestination.containsKey(requestOriginTaskName)) {
if (!requestsOriginDestination.get(requestOriginTaskName).contains(destinationRequestName)) {
requestsOriginDestination.get(requestOriginTaskName).add(destinationRequestName);
}
} else {
ArrayList<String> destinationRequestNames = new ArrayList<String>();
destinationRequestNames.add(destinationRequestName);
requestsOriginDestination.put(requestOriginTaskName, destinationRequestNames);
}
for (TMLCPrimitivePort requestsPort : requestToTask.ports) {
String requestsPortName = requestsPort.getPortName();
if (requestsPorts.containsKey(task.getName())) {
if (!requestsPorts.get(task.getName()).contains(requestsPortName)) {
requestsPorts.get(task.getName()).add(requestsPortName);
}
} else {
ArrayList<String> requestsPortNames = new ArrayList<String>();
requestsPortNames.add(requestsPortName);
requestsPorts.put(task.getName(), requestsPortNames);
}
if (requestsDestination.containsKey(destinationRequestName)) {
if (!requestsDestination.get(destinationRequestName).contains(destinationRequest)) {
requestsDestination.get(destinationRequestName).add(destinationRequest);
}
} else {
ArrayList<String> destinationRequestNames = new ArrayList<String>();
destinationRequestNames.add(destinationRequest);
requestsDestination.put(destinationRequestName, destinationRequestNames);
}
private void addcurrentElementVertex(String taskName, String taskStartName) {
// TODO Auto-generated method stub
int preEventid;
String eventName = getEventName(taskName, currentElement);
if (activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADRandom) {
preEventName = taskName + "__" + activity.getPrevious(currentElement).getName() + "__" + activity.getPrevious(currentElement).getID();
preEventid = activity.getPrevious(currentElement).getID();
} else if (activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADUnorderedSequence) {
preEventName = taskName + "__" + "unOrderedSequence" + "__" + activity.getPrevious(currentElement).getID();
preEventid = activity.getPrevious(currentElement).getID();
} else {
preEventName = taskName + "__" + activity.getPrevious(currentElement).getReferenceObject().toString() + "__"
+ activity.getPrevious(currentElement).getID();
preEventid = activity.getPrevious(currentElement).getID();
if (((activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADExecI
|| activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADExecC)
&& activity.getPrevious(currentElement).getValue().equals("0"))
|| ((activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADDelay)
&& ((TMLADDelay) activity.getPrevious(currentElement).getReferenceObject()).getDelayValue().equals("0"))
|| ((activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADDelayInterval)
&& (((TMLADDelayInterval) activity.getPrevious(currentElement).getReferenceObject()).getMinDelayValue().equals("0")
&& ((TMLADDelayInterval) activity.getPrevious(currentElement).getReferenceObject()).getMaxDelayValue().equals("0")))
|| ((activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADExecCInterval)
&& (((TMLADExecCInterval) activity.getPrevious(currentElement).getReferenceObject()).getMinDelayValue().equals("0")
&& ((TMLADExecCInterval) activity.getPrevious(currentElement).getReferenceObject()).getMaxDelayValue().equals("0"))
|| ((activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADExecIInterval)
&& (((TMLADExecIInterval) activity.getPrevious(currentElement).getReferenceObject()).getMinDelayValue().equals("0")
&& ((TMLADExecIInterval) activity.getPrevious(currentElement).getReferenceObject()).getMaxDelayValue()
.equals("0")))))
if (activity.getPrevious(activity.getPrevious(currentElement)).getReferenceObject() instanceof TMLADRandom) {
preEventName = taskName + "__" + activity.getPrevious(activity.getPrevious(currentElement)).getName() + "__"
+ activity.getPrevious(activity.getPrevious(currentElement)).getID();
preEventid = activity.getPrevious(activity.getPrevious(currentElement)).getID();
} else if (activity.getPrevious(activity.getPrevious(currentElement)).getReferenceObject() instanceof TMLADUnorderedSequence) {
preEventName = taskName + "__" + "unOrderedSequence" + "__" + activity.getPrevious(activity.getPrevious(currentElement)).getID();
preEventid = activity.getPrevious(activity.getPrevious(currentElement)).getID();
} else {
preEventName = taskName + "__" + activity.getPrevious(activity.getPrevious(currentElement)).getReferenceObject().toString() + "__"
+ activity.getPrevious(activity.getPrevious(currentElement)).getID();
preEventid = activity.getPrevious(activity.getPrevious(currentElement)).getID();
if (!nameIDTaskList.containsKey(currentElement.getID())) {
nameIDTaskList.put(String.valueOf(currentElement.getID()), eventName);
}
if (g.containsVertex(getvertex(preEventName))) {
vertex preV = vertex(preEventName, preEventid);
g.addVertex(v);
// gVertecies.add(vertex(eventName));
} else if ((activity.getPrevious(currentElement).getName().equals("start")) && g.containsVertex(getvertex(taskStartName))) {
vertex v = vertex(eventName, eventid);
g.addVertex(v);
// gVertecies.add(vertex(eventName));
g.addEdge(getvertex(taskStartName), getvertex(eventName));
opCount++;
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
if (currentElement.getReferenceObject() instanceof TMLADSendEvent || currentElement.getReferenceObject() instanceof TMLADWaitEvent
|| currentElement.getReferenceObject() instanceof TMLADSendRequest
|| currentElement.getReferenceObject() instanceof TMLADNotifiedEvent
|| currentElement.getReferenceObject() instanceof TMLADReadChannel || currentElement.getReferenceObject() instanceof TMLADWriteChannel
|| (currentElement.getReferenceObject() instanceof TMLADExecI && !currentElement.getValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecC && !currentElement.getValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADDelay
&& !((TMLADDelay) currentElement.getReferenceObject()).getDelayValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADDelayInterval
&& !((TMLADDelayInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& !((TMLADDelayInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecCInterval
&& !((TMLADExecCInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& ((TMLADExecCInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| (currentElement.getReferenceObject() instanceof TMLADExecIInterval
&& !((TMLADExecIInterval) currentElement.getReferenceObject()).getMinDelayValue().equals("0")
&& !((TMLADExecIInterval) currentElement.getReferenceObject()).getMaxDelayValue().equals("0"))
|| currentElement.getReferenceObject() instanceof TMLADEncrypt || currentElement.getReferenceObject() instanceof TMLADDecrypt
|| currentElement.getReferenceObject() instanceof TMLADReadRequestArg) {
allLatencyTasks.add(eventName);
getvertex(eventName).setType(vertex.TYPE_TRANSACTION);
getvertex(eventName).setTaintFixedNumber(1);
} else if (currentElement.getReferenceObject() instanceof TMLADRandom) {
getvertex(eventName).setType(vertex.TYPE_CTRL);
getvertex(eventName).setTaintFixedNumber(1);
} else if (currentElement.getReferenceObject() instanceof TMLADSelectEvt) {
getvertex(eventName).setType(vertex.TYPE_CTRL);
getvertex(eventName).setTaintFixedNumber(1);
} else if (currentElement.getReferenceObject() instanceof TMLADActionState) {
getvertex(eventName).setType(vertex.TYPE_CTRL);
getvertex(eventName).setTaintFixedNumber(1);
if (currentElement.getReferenceObject() instanceof TMLADForEverLoop) {
forEverLoopList.add(eventName);
getvertex(eventName).setType(vertex.TYPE_FOR_EVER_LOOP);
getvertex(eventName).setTaintFixedNumber(Integer.MAX_VALUE);
if (currentElement.getReferenceObject() instanceof TMLADChoice) {
getvertex(eventName).setType(vertex.TYPE_CHOICE);
getvertex(eventName).setTaintFixedNumber(1);
if (currentElement.getReferenceObject() instanceof TMLADSendRequest) {
if (requestsOriginDestination.containsKey(taskName)) {
for (String destinationTask : requestsOriginDestination.get(taskName)) {
if (requestsPorts.containsKey(destinationTask)) {
for (String portNames : requestsPorts.get(destinationTask)) {
String[] requestName = currentElement.getReferenceObject().toString().split(":");
String[] portname = requestName[1].split("[(]");
if (portname[0].replaceAll(" ", "").equals(portNames.replaceAll(" ", ""))) {
for (String destinationTaskstartname : requestsDestination.get(destinationTask)) {
if (requestEdges.containsKey(eventName)) {
if (!requestEdges.get(eventName).contains(destinationTaskstartname)) {
requestEdges.get(eventName).add(destinationTaskstartname);
} else {
HashSet<String> destinationTaskoriginstart = new HashSet<String>();
destinationTaskoriginstart.add(destinationTaskstartname);
requestEdges.put(eventName, destinationTaskoriginstart);
}
}
if (currentElement.getReferenceObject() instanceof TMLADSendEvent) {
if (sendEvt.containsKey(currentElement.getReferenceObject().toString().replaceAll(" ", ""))) {
List<String> recieveEvt = sendEvt.get(currentElement.getReferenceObject().toString().replaceAll(" ", ""));
String[] vertexName = vertex.toString().split("__");
if ((n.replaceAll(" ", "").equals((vertexName[2].toString().replaceAll(" ", ""))))) {
HashSet<String> waitEventVertex = new HashSet<String>();
waitEventVertex.add(vertex.toString());
if (sendEventWaitEventEdges.containsKey(eventName)) {
if (!sendEventWaitEventEdges.get(eventName).contains(vertex.toString())) {
sendEventWaitEventEdges.get(eventName).add(vertex.toString());
sendEventWaitEventEdges.put(eventName, waitEventVertex);
if (currentElement.getReferenceObject() instanceof TMLADWaitEvent) {
if (waitEvt.containsKey(currentElement.getReferenceObject().toString().replaceAll(" ", ""))) {
List<String> sendevent = waitEvt.get(currentElement.getReferenceObject().toString().replaceAll(" ", ""));
String[] vertexName = vertex.toString().split("__");
for (String n : sendevent) {
if (vertexName.length >= 3) {
if ((n.replaceAll(" ", "").equals((vertexName[2].toString().replaceAll(" ", ""))))) {
HashSet<String> waitEventVertex = new HashSet<String>();
waitEventVertex.add(eventName);
if (sendEventWaitEventEdges.containsKey(vertex.toString())) {
if (!sendEventWaitEventEdges.get(vertex.toString()).contains(eventName)) {
sendEventWaitEventEdges.get(vertex.toString()).add(eventName);
}
sendEventWaitEventEdges.put(vertex.toString(), waitEventVertex);
if (currentElement.getReferenceObject() instanceof TMLADWriteChannel) {
String[] portname = removewrite[1].split("[(]");
String chwriteName = (name[0] + "__" + portname[0]).replaceAll(" ", "");
String portNameNoSpaces = portname[0].replaceAll(" ", "");
if (sendData.containsKey(portNameNoSpaces)) {
String sendDatachannels;
if (((TMLWriteChannel) currentElement).getChannel(0).getName().contains("FORKCHANNEL")
|| ((TMLWriteChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith("FORKTASK")
|| ((TMLWriteChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith("FORKTASK")
|| ((TMLWriteChannel) currentElement).getChannel(0).getName().contains("JOINCHANNEL")
|| ((TMLWriteChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith("JOINTASK")
|| ((TMLWriteChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith("JOINTASK")
) {
sendDatachannels = sendData.get(portNameNoSpaces);
} else {
// sendDatachannels = name[0] + "__" + sendData.get(portNameNoSpaces) + "__" +
// name[0] + "__" + portNameNoSpaces;
sendDatachannels = name[0] + "__" + portNameNoSpaces + "__" + name[0] + "__" + sendData.get(portNameNoSpaces);
}
// String sendDatachannels = name[0] + "__" + portNameNoSpaces + "__" + name[0]
// + "__" + sendData.get(portNameNoSpaces);
// if (sendDatachannels.contains("FORKPORTORIGIN")) {
// sendDatachannels= sendDatachannels.replace("FORKPORTORIGIN", "FORKCHANNEL");
//
// }
HashSet<String> writeChVertex = new HashSet<String>();
writeChVertex.add(sendDatachannels);
if (writeReadChannelEdges.containsKey(eventName)) {
if (!writeReadChannelEdges.get(eventName).contains(sendDatachannels)) {
writeReadChannelEdges.get(eventName).add(sendDatachannels);
writeReadChannelEdges.put(eventName, writeChVertex);
}
// getvertex(sendDatachannels).setTaintFixedNumber(getvertex(sendDatachannels).getTaintFixedNumber()
// + 1);
}
else {
HashSet<String> writeChVertex = new HashSet<String>();
writeChVertex.add(chwriteName);
if (writeReadChannelEdges.containsKey(eventName)) {
if (!writeReadChannelEdges.get(eventName).contains(chwriteName)) {
writeReadChannelEdges.get(eventName).add(chwriteName);
writeReadChannelEdges.put(eventName, writeChVertex);
// getvertex(chwriteName).setTaintFixedNumber(getvertex(chwriteName).getTaintFixedNumber()
// + 1);
}
if (currentElement.getReferenceObject() instanceof TMLADReadChannel) {
String[] portname = removewrite[1].split("[(]");
String chwriteName = (name[0] + "__" + portname[0]).replaceAll(" ", "");
String portNameNoSpaces = portname[0].replaceAll(" ", "");
if (receiveData.containsKey(portNameNoSpaces)) {
String sendDatachannels;
if (((TMLReadChannel) currentElement).getChannel(0).getName().contains("FORKCHANNEL")
|| ((TMLReadChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith("FORKTASK")
|| ((TMLReadChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith("FORKTASK")
|| ((TMLReadChannel) currentElement).getChannel(0).getName().contains("JOINCHANNEL")
|| ((TMLReadChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith("JOINTASK")
|| ((TMLReadChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith("JOINTASK")) {
sendDatachannels = receiveData.get(portNameNoSpaces);
} else {
sendDatachannels = name[0] + "__" + receiveData.get(portNameNoSpaces) + "__" + name[0] + "__" + portNameNoSpaces;
HashSet<String> readChVertex = new HashSet<String>();
readChVertex.add(eventName);
if (readWriteChannelEdges.containsKey(sendDatachannels)) {
if (!readWriteChannelEdges.get(sendDatachannels).contains(eventName)) {
readWriteChannelEdges.get(sendDatachannels).add(eventName);
}
readWriteChannelEdges.put(sendDatachannels, readChVertex);
}
// getvertex(sendDatachannels).setTaintFixedNumber(getvertex(sendDatachannels).getTaintFixedNumber()
// + 1);
/*
* if (g.containsVertex(chwriteName))
*
* { g.addEdge(chwriteName, eventName); }
*/
} else {
HashSet<String> readChVertex = new HashSet<String>();
readChVertex.add(eventName);
Loading
Loading full blame...