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 TMLTask task, task1, task2;
protected TMLActivity activity;
// List<HwNode> path;
private TMLActivityElement currentElement;
private TMLActivityElement backwardElement;
private ArrayList<String> SummaryCommMapping;
private Graph<vertex, DefaultEdge> g;
public Graph<vertex, DefaultEdge> getG() {
return g;
}
public void setG(Graph<vertex, DefaultEdge> g) {
this.g = 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;
HashMap<Integer, Vector<SimulationTransaction>> dataByTaskR = new HashMap<Integer, Vector<SimulationTransaction>>();
HashMap<Integer, List<SimulationTransaction>> dataBydelayedTasks = new HashMap<Integer, List<SimulationTransaction>>();
HashMap<Integer, HashMap<String, ArrayList<ArrayList<Integer>>>> timeDelayedPerRow = new HashMap<Integer, HashMap<String, ArrayList<ArrayList<Integer>>>>();
HashMap<Integer, List<String>> detailsOfMinMaxRow = new HashMap<Integer, List<String>>();
HashMap<Integer, List<SimulationTransaction>> dataBydelayedTasksOfMinMAx = new HashMap<Integer, List<SimulationTransaction>>();
private final JFrame frame = new JFrame("The Sys-ML Model As Directed Graph");
List<Integer> times1 = new ArrayList<Integer>();
List<Integer> times2 = new ArrayList<Integer>();
Vector<SimulationTransaction> transFile;
String idTask1;
String idTask2;
String task2DeviceName = "";
String task1DeviceName = "";
ArrayList<String> devicesToBeConsidered = new ArrayList<String>();
Vector<SimulationTransaction> relatedsimTraces = new Vector<SimulationTransaction>();
Vector<SimulationTransaction> delayDueTosimTraces = new Vector<SimulationTransaction>();
HashMap<String, ArrayList<SimulationTransaction>> relatedsimTraceswithTaint = new HashMap<String, ArrayList<SimulationTransaction>>();
JFrameLatencyDetailedAnalysis frameLatencyDetailedAnalysis;
JFrameCompareLatencyDetail frameCompareLatencyDetail;
int callingFrame;
int nbOfNodes = 0;
List<String> usedLabels = 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>();
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>>();
@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;
// frameCompareLatencyDetail.pack();
// frameCompareLatencyDetail.revalidate();
// frameCompareLatencyDetail.repaint();
DrawDirectedGraph();
/*
* JGraphXAdapter<String, DefaultEdge> graphAdapter = new JGraphXAdapter<String,
* DefaultEdge>(g);
* mxHierarchicalLayout layout = new mxHierarchicalLayout(graphAdapter);
* layout.setInterHierarchySpacing(100); layout.setInterRankCellSpacing(100);
* layout.setIntraCellSpacing(100);
* layout.execute(graphAdapter.getDefaultParent());
* scrollPane.setViewportView(new mxGraphComponent(graphAdapter));
* scrollPane.setVisible(true);
* scrollPane.revalidate(); scrollPane.repaint(); frame = new
* JFrame("The Sys-ML Model As Directed Graph"); frame.add(scrollPane);
* frame.pack();
*/
// frame.setVisible(false);
}
// The main function to add the vertices and edges according to the model
public vertex vertex(String name) {
// TODO Auto-generated method stub
vertex v = new vertex(name);
return v;
}
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();
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")) {
} else {
nodeNbProgressBar++;
}
}
}
}
}
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")) {
} else {
nodeNbProgressBar++;
}
}
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
}
}
}
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());
nodeNbProgressBar++;
}
}
if (callingFrame == 0)
{
frameLatencyDetailedAnalysis.pbar.setMaximum(nodeNbProgressBar);
frameLatencyDetailedAnalysis.pbar.setMinimum(0);
}
if (callingFrame == 1)
{
frameCompareLatencyDetail.pbar.setMaximum(nodeNbProgressBar);
frameCompareLatencyDetail.pbar.setMinimum(0);
}
nbOfNodes = 0;
HashMap<String, HashSet<String>> cpuTasks;
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);
for (HwNode node : tmap.getArch().getBUSs()) {
if (!g.containsVertex(vertex(node.getName()))) {
g.addVertex(vertex(node.getName()));
if (tmap.getLisMappedChannels(node).size() > 0) {
buschannel.put(node.getName(), tmap.getLisMappedChannels(node));
}
}
for (HwNode node : tmap.getArch().getHwBridge()) {
if (!g.containsVertex(vertex(node.getName()))) {
g.addVertex(vertex(node.getName()));
if (tmap.getLisMappedChannels(node).size() > 0) {
bridgechannel.put(node.getName(), tmap.getLisMappedChannels(node));
}
}
for (HwA node : tmap.getArch().getHwA()) {
if (tmap.getLisMappedTasks(node).size() > 0) {
cpuTask.put(node.getName(), tmap.getLisMappedTasks(node));
}
cpuTasks = getCPUTaskMap(cpuTask);
// if (tmap.getLisMappedChannels(node).size() > 0) {
// bridgechannel.put(node.getName(), tmap.getLisMappedChannels(node));
// }
}
for (HwNode node : tmap.getArch().getMemories()) {
if (!g.containsVertex(vertex(node.getName()))) {
g.addVertex(vertex(node.getName()));
if (tmap.getLisMappedChannels(node).size() > 0) {
memorychannel.put(node.getName(), tmap.getLisMappedChannels(node));
}
}
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();
if (!g.containsVertex(vertex(ChannelName))) {
g.addVertex(vertex(ChannelName));
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
// TMLChannel tmlch = (TMLChannel) busCh;
// String writeChannel = tmlch.getDestinationTask().getName() + "__" +
// "writechannel:" + tmlch.getDestinationPort();
// String readChannel;
}
}
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();
if (!g.containsVertex(vertex(ChannelName))) {
g.addVertex(vertex(ChannelName));
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
}
}
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();
if (!g.containsVertex(vertex(ChannelName))) {
g.addVertex(vertex(ChannelName));
getvertex(ChannelName).setType(vertex.TYPE_CHANNEL);
// gVertecies.add(vertex(ChannelName));
getvertex(ChannelName).setTaintFixedNumber(0);
g.addEdge(getvertex(busName), getvertex(ChannelName));
}
}
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()))) {
g.addVertex(vertex(ch.getName()));
// gVertecies.add(vertex(ch.getName()));
getvertex(ch.getName()).setType(vertex.TYPE_CHANNEL);
getvertex(ch.getName()).setTaintFixedNumber(0);
}
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);
}
if (!g.containsEdge(vertex(node.getName()), vertex(ch.getName()))) {
g.addEdge(getvertex(node.getName()), getvertex(ch.getName()));
}
}
}
}
SummaryCommMapping = tmap.getSummaryCommMapping();
for (HwNode node : tmap.getArch().getCPUs()) {
if (tmap.getLisMappedTasks(node).size() > 0) {
cpuTask.put(node.getName(), tmap.getLisMappedTasks(node));
}
cpuTasks = getCPUTaskMap(cpuTask);
}
for (HwLink link : links) {
if (g.containsVertex(vertex(link.hwnode.getName())) && g.containsVertex(vertex(link.bus.getName()))) {
g.addEdge(getvertex(link.hwnode.getName()), getvertex(link.bus.getName()));
g.addEdge(getvertex(link.bus.getName()), getvertex(link.hwnode.getName()));
}
}
if (addedEdges.size() > 0) {
for (Entry<String, String> edge : addedEdges.entrySet()) {
g.addEdge(getvertex(edge.getKey()), getvertex(edge.getValue()));
}
}
if (sendEventWaitEventEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : sendEventWaitEventEdges.entrySet()) {
for (String waitEventEdge : edge.getValue())
g.addEdge(getvertex(edge.getKey()), getvertex(waitEventEdge));
}
}
if (readWriteChannelEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : readWriteChannelEdges.entrySet()) {
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
for (String readChannelEdge : edge.getValue()) {
g.addEdge(getvertex(edge.getKey()), getvertex(readChannelEdge));
getvertex(edge.getKey()).setTaintFixedNumber(getvertex(edge.getKey()).getTaintFixedNumber() + 1);
}
}
}
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));
}
}
}
}
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));
}
}
}
}
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);
}
}
if (sequenceEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : sequenceEdges.entrySet()) {
for (String sequenceEdge : edge.getValue())
g.addEdge(getvertex(edge.getKey()), getvertex(sequenceEdge));
}
}
if (unOrderedSequenceEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : unOrderedSequenceEdges.entrySet()) {
for (String sequenceEdge : edge.getValue())
g.addEdge(getvertex(edge.getKey()), getvertex(sequenceEdge));
}
}
if (requestEdges.size() > 0) {
for (Entry<String, HashSet<String>> edge : requestEdges.entrySet()) {
for (String requestsingleEdges : edge.getValue()) {
g.addEdge(getvertex(edge.getKey()), getvertex(requestsingleEdges));
}
}
}
}
// draw the vertices and edges for the tasks mapped to the CPUs
private void updatemainBar(String string) {
nbOfNodes++;
if (callingFrame == 0)
{
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();
HashSet<TMLTask> value = entry.getValue();
Vector<TMLActivityElement> multiNexts = new Vector<TMLActivityElement>();
// Map <String, String> sendEvt;
HashMap<String, List<String>> sendEvt = new HashMap<String, List<String>>();
HashMap<String, List<String>> waitEvt = new HashMap<String, List<String>>();
HashMap<String, String> sendData = new HashMap<String, String>();
HashMap<String, String> receiveData = new HashMap<String, String>();
// HashMap<String, List<String>> sendEvt = new HashMap<String, List<String>>();
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
// GEt List of all requests
for (TMLTask task : value) {
if (task.isRequested()) {
TMLRequest requestToTask = task.getRequest();
requestToTask.getReferenceObject();
requestToTask.getDestinationTask();
requestToTask.getOriginTasks().get(0);
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);
}
}
}
for (TMLTask task : value) {
/*
* for (TMLComponentDesignPanel dpPanel : getCpanels()) { String[] taskpanel =
* task.getName().split("__");
* if (dpPanel.getNameOfTab().equals(taskpanel[0])) { tmlcdp = dpPanel; }
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
// get the names and params of send events per task and their corresponding wait
// events
for (TMLSendEvent sendEvent : task.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 + ")");
}
}
// get the names of read channels per task and their corresponding write
// channels
for (TMLReadChannel readChannel : task.getReadChannels()) {
int i = readChannel.getNbOfChannels();
// name = _ch.getOriginPorts().get(0).getName(); //return the name of the source
// port of the channel
for (int j = 0; j < i; j++) {
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
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");
} else if (checkchannel.length <= 2) {
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_");
if (checkchannel.length > 2) {
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_");
if (checkchannel.length > 2) {
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);
}
}
}
// get the names of write channels per task and their corresponding read
// channels
for (TMLWriteChannel writeChannel : task.getWriteChannels()) {
int i = writeChannel.getNbOfChannels();
for (int j = 0; j < i; j++) {
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
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_");
if (checkchannel.length > 2) {
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_");
if (checkchannel.length > 2) {
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();
}
} else {
// writeChannel.getChannel(j);
sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName();
receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName();
}
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
if (!sendingDataPortdetails.equals(receiveDataPortdetails)) {
sendData.put(sendingDataPortdetails, receiveDataPortdetails);
}
}
}
// get the names and params of wait events per task and their corresponding send
// events
for (TMLWaitEvent waitEvent : task.getWaitEvents()) {
// TMLCPrimitivePort portdetails = waitEvent.getEvent().port;
TMLCPrimitivePort sendingPortdetails = waitEvent.getEvent().port;
TMLCPrimitivePort receivePortdetails = waitEvent.getEvent().port2;
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 + ")");
}
}
// add the name of the task as a vertex
if (!g.vertexSet().contains(getvertex(key))) {
g.addVertex(vertex(key));
if (!g.vertexSet().contains(getvertex(task.getName()))) {
g.addVertex(vertex(task.getName()));
g.addEdge(getvertex(key), getvertex(task.getName()));
activity = task.getActivityDiagram();
int count = 1;
currentElement = activity.getFirst();
String taskStartName = "";
String taskEndName = "";
HashMap<String, List<String>> forLoopNextValues = new HashMap<String, List<String>>();
// loop over all the activites corresponding to a task
while (count <= activity.nElements()) {
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
String preEventName;
if (currentElement.getName().equals("Stop after infinite loop")) {
count++;
if (count <= activity.nElements()) {
if (currentElement.getNexts().size() == 1) {
currentElement = currentElement.getNexts().firstElement();
} else if (!multiNexts.isEmpty()) {
currentElement = multiNexts.get(0);
multiNexts.remove(0);
}
continue;
} else {
break;
}
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
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
} else if (currentElement.getName().equals("startOfFork") || currentElement.getName().equals("junctionOfFork")
|| currentElement.getName().equals("startOfJoin") || currentElement.getName().equals("junctionOfJoin")) {
count++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (task.getName().startsWith("FORKTASK_S_") && currentElement.getName().equals("ReadOfFork")) {
if (!g.containsVertex(getvertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()))) {
g.addVertex(vertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()));
}
g.addEdge(getvertex(task.getName()), getvertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()));
HashSet<String> readForkVertex = new HashSet<String>();
readForkVertex.add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
if (forkreadEdges.containsKey(task.getName())) {
if (!forkreadEdges.get(task.getName()).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) {
forkreadEdges.get(task.getName()).add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
}
} else {
forkreadEdges.put(task.getName(), readForkVertex);
}
count++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (task.getName().startsWith("FORKTASK_S_") && currentElement.getName().startsWith("WriteOfFork_S")) {
if (!g.containsVertex(getvertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()))) {
g.addVertex(vertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()));
}
HashSet<String> writeForkVertex = new HashSet<String>();
writeForkVertex.add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
if (forkwriteEdges.containsKey(task.getName())) {
if (!forkwriteEdges.get(task.getName()).contains(((TMLWriteChannel) (currentElement)).getChannel(0).getName())) {
forkwriteEdges.get(task.getName()).add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
}
} else {
forkwriteEdges.put(task.getName(), writeForkVertex);
}
// g.addEdge(getvertex(task.getName()),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName()));
count++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (currentElement.getName().equals("stopOfFork") || currentElement.getName().equals("stop2OfFork")
|| currentElement.getName().equals("stopOfJoin")) {
count++;
continue;
} else if (task.getName().startsWith("JOINTASK_S_") && currentElement.getName().startsWith("ReadOfJoin")) {
if (!g.containsVertex(getvertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()))) {
g.addVertex(vertex(((TMLReadChannel) (currentElement)).getChannel(0).getName()));
}
HashSet<String> writeForkVertex = new HashSet<String>();
writeForkVertex.add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
if (joinreadEdges.containsKey(task.getName())) {
if (!joinreadEdges.get(task.getName()).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) {
joinreadEdges.get(task.getName()).add(((TMLReadChannel) (currentElement)).getChannel(0).getName());
}
} else {
joinreadEdges.put(task.getName(), writeForkVertex);
}
// g.addEdge(getvertex(task.getName()),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName()));
count++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (task.getName().startsWith("JOINTASK_S_") && currentElement.getName().equals("WriteOfJoin")) {
if (!g.containsVertex(getvertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()))) {
g.addVertex(vertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()));
}
g.addEdge(getvertex(task.getName()), getvertex(((TMLWriteChannel) (currentElement)).getChannel(0).getName()));
HashSet<String> readForkVertex = new HashSet<String>();
readForkVertex.add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
if (joinwriteEdges.containsKey(task.getName())) {
if (!joinwriteEdges.get(task.getName()).contains(((TMLWriteChannel) (currentElement)).getChannel(0).getName())) {
joinwriteEdges.get(task.getName()).add(((TMLWriteChannel) (currentElement)).getChannel(0).getName());
}
} else {
joinwriteEdges.put(task.getName(), readForkVertex);
}
count++;
currentElement = currentElement.getNexts().firstElement();
continue;
} else if (currentElement.getReferenceObject() instanceof TMLADRandom) {
eventName = task.getName() + "__" + currentElement.getName() + "__" + currentElement.getID();
} else {
eventName = task.getName() + "__" + currentElement.getReferenceObject().toString() + "__" + currentElement.getID();
}
if (currentElement.getNexts().size() > 1) {
for (TMLActivityElement ae : currentElement.getNexts()) {
multiNexts.add(ae);
}
}
// 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) {
taskEndName = task.getName() + "__" + currentElement.getName() + "__" + currentElement.getID();
if (activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADRandom) {
preEventName = task.getName() + "__" + activity.getPrevious(currentElement).getName() + "__"
+ activity.getPrevious(currentElement).getID();
} else {
preEventName = task.getName() + "__" + activity.getPrevious(currentElement).getReferenceObject().toString() + "__"
+ activity.getPrevious(currentElement).getID();
g.addVertex(vertex(taskEndName));
// gVertecies.add(vertex(taskEndName));
getvertex(eventName).setType(vertex.TYPE_END);
getvertex(eventName).setTaintFixedNumber(1);
// allTasks.add(taskEndName);
if (!(activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADSequence)) {
g.addEdge(getvertex(preEventName), getvertex(taskEndName));
@SuppressWarnings({ "unchecked", "rawtypes" })
AllDirectedPaths<vertex, DefaultEdge> allPaths = new AllDirectedPaths<vertex, DefaultEdge>(g);
if (orderedSequenceList.size() > 0) {
int noForLoop = 0;
// get path from sequence to end
for (Entry<String, ArrayList<String>> sequenceListEntry : orderedSequenceList.entrySet()) {
int directlyConnectedSeq = 0;
if (g.containsVertex(vertex(sequenceListEntry.getKey()))) {
List<GraphPath<vertex, DefaultEdge>> path = allPaths.getAllPaths(getvertex(sequenceListEntry.getKey()),
getvertex(taskEndName), false, g.vertexSet().size());
for (Entry<String, ArrayList<String>> othersequenceListEntryValue : orderedSequenceList.entrySet()) {
for (int i = 0; i < path.size(); i++) {
if (!othersequenceListEntryValue.getKey().equals(sequenceListEntry.getKey())) {
if (path.get(i).getVertexList().contains(getvertex(othersequenceListEntryValue.getKey()))) {
directlyConnectedSeq++;
}
}
}
}
if (path.size() > 0 && sequenceListEntry.getValue().size() > 0 && directlyConnectedSeq == 0) {
for (int i = 0; i < path.size(); i++) {
for (String sequenceListEntryValue : sequenceListEntry.getValue()) {
if (g.containsVertex(getvertex(sequenceListEntryValue))) {
if (path.get(i).getVertexList().contains(getvertex(sequenceListEntryValue))) {
if (forLoopNextValues.size() > 0) {
for (Entry<String, List<String>> forloopListEntry : forLoopNextValues.entrySet()) {
if ((path.get(i).getVertexList()
.contains(getvertex(forloopListEntry.getValue().get(0)))
&& getvertex(forloopListEntry.getValue().get(0))
.getId() != sequenceListEntry.getKey())
|| path.get(i).getVertexList().contains(getvertex(sequenceListEntry.getValue()
.get(sequenceListEntry.getValue().size() - 1)))) {
noForLoop++;
}
}
}
if (forEverLoopList.size() > 0) {
for (String forloopListEntry : forEverLoopList) {
if (path.get(i).getVertexList().contains(getvertex(forloopListEntry))) {
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
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
noForLoop++;
}
}
}
if (noForLoop == 0) {
int nextIndex = sequenceListEntry.getValue().indexOf(sequenceListEntryValue) + 1;
if (nextIndex < sequenceListEntry.getValue().size()) {
HashSet<String> endSequenceVertex = new HashSet<String>();
endSequenceVertex.add(sequenceListEntry.getValue().get(nextIndex));
if (sequenceEdges.containsKey(taskEndName)) {
if (!sequenceEdges.get(taskEndName)
.contains(sequenceListEntry.getValue().get(nextIndex))) {
sequenceEdges.get(taskEndName)
.add(sequenceListEntry.getValue().get(nextIndex));
}
} else {
sequenceEdges.put(eventName, endSequenceVertex);
}
} else if (nextIndex == sequenceListEntry.getValue().size()
&& orderedSequenceList.size() > 1) {
for (Entry<String, ArrayList<String>> othersequenceListEntryValue : orderedSequenceList
.entrySet()) {
if (!othersequenceListEntryValue.getKey().equals(sequenceListEntry.getKey())) {
int connectedSeq = 0;
List<GraphPath<vertex, DefaultEdge>> pathBetweenSeq = allPaths.getAllPaths(
getvertex(othersequenceListEntryValue.getKey()),
getvertex(taskEndName), false, g.vertexSet().size());
for (int j = 0; j < pathBetweenSeq.size(); j++) {
for (Entry<String, ArrayList<String>> adjacentsequenceListEntryValue : orderedSequenceList
.entrySet()) {
if (!adjacentsequenceListEntryValue.getKey()
.equals(sequenceListEntry.getKey())
&& !adjacentsequenceListEntryValue.getKey()
.equals(othersequenceListEntryValue.getKey())) {
if (path.get(i).getVertexList().contains(
getvertex(adjacentsequenceListEntryValue.getKey()))) {
connectedSeq++;
}
}
}
}
if (connectedSeq == 0 && pathBetweenSeq.size() > 0) {
for (String othersequenceListValue : othersequenceListEntryValue
.getValue()) {
List<GraphPath<vertex, DefaultEdge>> pathToNextValue = allPaths
.getAllPaths(getvertex(othersequenceListValue),
getvertex(taskEndName), false, g.vertexSet().size());
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
if (pathToNextValue.size() > 0)
{
int nextAdjIndex = othersequenceListEntryValue.getValue()
.indexOf(othersequenceListValue) + 1;
if (nextAdjIndex < othersequenceListEntryValue.getValue()
.size()) {
HashSet<String> nextSequenceVertex = new HashSet<String>();
nextSequenceVertex.add(othersequenceListEntryValue.getValue()
.get(nextAdjIndex));
if (sequenceEdges.containsKey(taskEndName)) {
if (!sequenceEdges.get(taskEndName)
.contains(othersequenceListEntryValue.getValue()
.get(nextAdjIndex))) {
sequenceEdges.get(taskEndName)
.add(othersequenceListEntryValue.getValue()
.get(nextAdjIndex));
}
} else {
sequenceEdges.put(eventName, nextSequenceVertex);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if (unOrderedSequenceList.size() > 0) {
// get path from sequence to end
for (Entry<String, ArrayList<String>> sequenceListEntry : unOrderedSequenceList.entrySet()) {
if (g.containsVertex(vertex(sequenceListEntry.getKey()))) {
int noForLoop = 0;
List<GraphPath<vertex, DefaultEdge>> path = allPaths.getAllPaths(getvertex(sequenceListEntry.getKey()),
getvertex(taskEndName), false, g.vertexSet().size());
for (int i = 0; i < path.size(); i++) {
if (path.size() > 0 && sequenceListEntry.getValue().size() > 0) {
if (forLoopNextValues.size() > 0) {
for (Entry<String, List<String>> forloopListEntry : forLoopNextValues.entrySet()) {
if (path.get(i).getVertexList().contains(getvertex(forloopListEntry.getKey()))) {
if (path.get(i).getVertexList().contains(getvertex(forloopListEntry.getValue().get(0))))
{
noForLoop++;
}
}
}
}
if (forEverLoopList.size() > 0) {
for (String forloopListEntry : forEverLoopList) {
if (path.get(i).getVertexList().contains(getvertex(forloopListEntry))) {
noForLoop++;
}
}
}
for (Entry<String, ArrayList<String>> seqEntry : orderedSequenceList.entrySet()) {
if (path.get(i).getVertexList().contains(getvertex(seqEntry.getKey()))) {
if (path.get(i).getVertexList()
.contains(getvertex(seqEntry.getValue().get(seqEntry.getValue().size() - 1))))
{
} else {
noForLoop++;
}
}
}
if (noForLoop == 0) {
HashSet<String> endSequenceVertex = new HashSet<String>();
endSequenceVertex.add(sequenceListEntry.getKey());
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
if (unOrderedSequenceEdges.containsKey(taskEndName)) {
if (!unOrderedSequenceEdges.get(taskEndName).contains(sequenceListEntry.getKey())) {
unOrderedSequenceEdges.get(taskEndName).add(sequenceListEntry.getKey());
}
} else {
unOrderedSequenceEdges.put(eventName, endSequenceVertex);
}
}
}
}
}
}
}
// add if sequence on path of multiple for
if (forLoopNextValues.size() > 0) {
for (Entry<String, List<String>> forloopListEntry : forLoopNextValues.entrySet()) {
if (g.containsVertex(vertex(forloopListEntry.getValue().get(0)))) {
List<GraphPath<vertex, DefaultEdge>> path = allPaths.getAllPaths(getvertex(forloopListEntry.getValue().get(0)),
getvertex(taskEndName), false, g.vertexSet().size());
for (int i = 0; i < path.size(); i++) {
int forloopCount = 0;
for (Entry<String, List<String>> forEntry : forLoopNextValues.entrySet()) {
if (!forloopListEntry.getKey().equals(forEntry.getKey())) {
if (path.get(i).getVertexList().contains(getvertex(forEntry.getKey()))) {
forloopCount++;
}
}
}
for (Entry<String, ArrayList<String>> seqEntry : orderedSequenceList.entrySet()) {
if (path.get(i).getVertexList().contains(getvertex(seqEntry.getKey()))) {
if (path.get(i).getVertexList()
.contains(getvertex(seqEntry.getValue().get(seqEntry.getValue().size() - 1))))
{
} else {
forloopCount++;
}
}
}
for (Entry<String, ArrayList<String>> unOrderedseqEntry : unOrderedSequenceList.entrySet()) {
if (path.get(i).getVertexList().contains(getvertex(unOrderedseqEntry.getKey()))) {
forloopCount++;
HashSet<String> forLoopName = new HashSet<String>();
forLoopName.add(forloopListEntry.getKey());
if (unOrderedSequenceEdges.containsKey(unOrderedseqEntry.getKey())) {
if (unOrderedSequenceEdges.get(unOrderedseqEntry.getKey()).contains(forloopListEntry.getKey())) {
unOrderedSequenceEdges.get(unOrderedseqEntry.getKey()).add(forloopListEntry.getKey());
}
} else {
unOrderedSequenceEdges.put(unOrderedseqEntry.getKey(), forLoopName);
}
}
}
String forvertexName = forloopListEntry.getKey();
if (forloopCount == 0 && !g.containsEdge(getvertex(taskEndName), getvertex(forvertexName))) {
addedEdges.put(taskEndName, forvertexName);
}
}
}
if (g.containsVertex(vertex(forloopListEntry.getValue().get(1))) && forLoopNextValues.size() > 1) {
List<GraphPath<vertex, DefaultEdge>> path = allPaths.getAllPaths(getvertex(forloopListEntry.getValue().get(1)),
getvertex(taskEndName), false, g.vertexSet().size());
if (path.size() > 0) {
for (Entry<String, List<String>> previousForLoop : forLoopNextValues.entrySet()) {
if (g.containsVertex(vertex(previousForLoop.getValue().get(0)))
&& !previousForLoop.getKey().equals(forloopListEntry.getKey())) {
List<GraphPath<vertex, DefaultEdge>> previousForpath = allPaths.getAllPaths(
getvertex(previousForLoop.getValue().get(0)), getvertex(taskEndName), false,
g.vertexSet().size());
for (int i = 0; i < previousForpath.size(); i++) {
int forloopCount = 0;
for (Entry<String, List<String>> forEntry : forLoopNextValues.entrySet()) {
if (previousForpath.get(i).getVertexList().contains(getvertex(forEntry.getKey()))
&& !forloopListEntry.getKey().equals(forEntry.getKey())) {
forloopCount++;
}
}
String forvertexName = previousForLoop.getKey();
if (forloopCount == 0
&& !g.containsEdge(vertex(taskEndName), vertex(forvertexName))) {
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
addedEdges.put(taskEndName, forvertexName);
}
}
}
}
}
}
}
}
if (!forEverLoopList.isEmpty())
{
for (String loopforEver : forEverLoopList) {
List<GraphPath<vertex, DefaultEdge>> pathforloopforever = allPaths.getAllPaths(getvertex(loopforEver),
getvertex(taskEndName), false, g.vertexSet().size());
if (pathforloopforever.size() > 0) {
for (int i = 0; i < pathforloopforever.size(); i++) {
int forloopCount = 0;
for (Entry<String, List<String>> previousForLoop : forLoopNextValues.entrySet()) {
if (pathforloopforever.get(i).getVertexList().contains(getvertex(previousForLoop.getValue().get(0)))) {
forloopCount++;
}
}
for (Entry<String, ArrayList<String>> seqEntry : orderedSequenceList.entrySet()) {
if (pathforloopforever.get(i).getVertexList().contains(getvertex(seqEntry.getKey()))) {
if (pathforloopforever.get(i).getVertexList()
.contains(getvertex(seqEntry.getValue().get(seqEntry.getValue().size() - 1))))
{
} else {
forloopCount++;
}
}
}
for (Entry<String, ArrayList<String>> unOrderedseqEntry : unOrderedSequenceList.entrySet()) {
if (pathforloopforever.get(i).getVertexList().contains(getvertex(unOrderedseqEntry.getKey()))) {
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
forloopCount++;
HashSet<String> forLoopName = new HashSet<String>();
forLoopName.add(loopforEver);
if (unOrderedSequenceEdges.containsKey(unOrderedseqEntry.getKey())) {
if (unOrderedSequenceEdges.get(unOrderedseqEntry.getKey()).contains(loopforEver)) {
unOrderedSequenceEdges.get(unOrderedseqEntry.getKey()).add(loopforEver);
}
} else {
unOrderedSequenceEdges.put(unOrderedseqEntry.getKey(), forLoopName);
}
}
}
if (forloopCount == 0) {
addedEdges.put(taskEndName, loopforEver);
}
}
}
}
}
count++;
}
// start activity is added as a vertex
if (currentElement.getReferenceObject() instanceof TMLADStartState) {
taskStartName = task.getName() + "__" + currentElement.getName() + "__" + currentElement.getID();
g.addVertex(vertex(taskStartName));
// gVertecies.add(vertex(taskStartName));
getvertex(taskStartName).setType(vertex.TYPE_START);
getvertex(taskStartName).setTaintFixedNumber(1);
g.addEdge(getvertex(task.getName()), getvertex(taskStartName));
count++;
if (!nameIDTaskList.containsKey(currentElement.getID())) {
nameIDTaskList.put(String.valueOf(currentElement.getID()), eventName);
}
}
// 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) {
if (activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADRandom) {
preEventName = task.getName() + "__" + activity.getPrevious(currentElement).getName() + "__"
+ activity.getPrevious(currentElement).getID();
} else {
preEventName = task.getName() + "__" + activity.getPrevious(currentElement).getReferenceObject().toString() + "__"
+ activity.getPrevious(currentElement).getID();
}
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
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 = task.getName() + "__" + activity.getPrevious(activity.getPrevious(currentElement)).getName() + "__"
+ activity.getPrevious(activity.getPrevious(currentElement)).getID();
} else {
preEventName = task.getName() + "__"
+ activity.getPrevious(activity.getPrevious(currentElement)).getReferenceObject().toString() + "__"
+ activity.getPrevious(activity.getPrevious(currentElement)).getID();
}
}
if (!nameIDTaskList.containsKey(currentElement.getID())) {
nameIDTaskList.put(String.valueOf(currentElement.getID()), eventName);
}
if (g.containsVertex(getvertex(preEventName))) {
g.addVertex(vertex(eventName));
// gVertecies.add(vertex(eventName));
g.addEdge(getvertex(preEventName), getvertex(eventName));
} else if ((activity.getPrevious(currentElement).getName().equals("start")) && g.containsVertex(vertex(taskStartName))) {
g.addVertex(vertex(eventName));
// gVertecies.add(vertex(eventName));
g.addEdge(getvertex(taskStartName), getvertex(eventName));
count++;
}
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);
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
}
if (currentElement.getReferenceObject() instanceof TMLADSendRequest) {
if (requestsOriginDestination.containsKey(task.getName())) {
for (String destinationTask : requestsOriginDestination.get(task.getName())) {
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(" ", ""));
for (vertex vertex : g.vertexSet()) {
String[] vertexName = vertex.toString().split("__");
for (String n : recieveEvt) {
if (vertexName.length >= 3) {
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());
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
}
} else {
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(" ", ""));
for (vertex vertex : g.vertexSet()) {
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);
}
} else {
sendEventWaitEventEdges.put(vertex.toString(), waitEventVertex);
}
}
}
}
}
}
}
if (currentElement.getReferenceObject() instanceof TMLADWriteChannel) {
writeChannelTransactions.add(eventName);
String[] name = eventName.split("__");
String[] removewrite = name[2].split(":");
String[] portname = removewrite[1].split("[(]");
String chwriteName = (name[0] + "__" + portname[0]).replaceAll(" ", "");
String portNameNoSpaces = portname[0].replaceAll(" ", "");
if (sendData.containsKey(portNameNoSpaces)) {
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
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);
}
} else {
writeReadChannelEdges.put(eventName, writeChVertex);
// getvertex(sendDatachannels).setTaintFixedNumber(getvertex(sendDatachannels).getTaintFixedNumber()
// + 1);
HashSet<String> writeChVertex = new HashSet<String>();
writeChVertex.add(chwriteName);
if (writeReadChannelEdges.containsKey(eventName)) {
if (!writeReadChannelEdges.get(eventName).contains(chwriteName)) {
writeReadChannelEdges.get(eventName).add(chwriteName);
}
} else {
writeReadChannelEdges.put(eventName, writeChVertex);
// getvertex(chwriteName).setTaintFixedNumber(getvertex(chwriteName).getTaintFixedNumber()
// + 1);
}
}
if (currentElement.getReferenceObject() instanceof TMLADReadChannel) {
readChannelTransactions.add(eventName);
String[] name = eventName.split("__");
String[] removewrite = name[2].split(":");
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")
Loading
Loading full blame...