From c8dfa8734cc36c91f414d6a5e1da987c17252c77 Mon Sep 17 00:00:00 2001 From: maysam zoor <maysam_zoor@hotmail.com> Date: Thu, 14 Jan 2021 14:23:12 +0100 Subject: [PATCH] updating code according to remarks --- .../DirectedGraphTranslator.java | 2651 ++--------------- .../JFrameCompareLatencyDetail.java | 296 +- .../JFrameLatencyComparedDetailedPopup.java | 236 +- .../JFrameLatencyDetailedAnalysis.java | 482 +-- .../JFrameLatencyDetailedPopup.java | 341 +-- .../JFrameListOfRules.java | 93 - .../LatencyAnalysisParallelAlgorithms.java | 29 +- .../LatencyDetailedAnalysisActions.java | 35 +- .../LatencyDetailedAnalysisBar.java | 2 - .../SaveGraphToolBar.java | 17 +- .../TableRenderer.java | 12 - .../latencyDetailedAnalysisMain.java | 156 +- .../ui/simulationtraceanalysis/vertex.java | 16 - .../ComparisonOfsimulationTraces.java | 8 +- .../GraphLatencyAnalysis.java | 74 +- .../NestedStructurePLAN.java | 72 +- 16 files changed, 398 insertions(+), 4122 deletions(-) diff --git a/src/main/java/ui/simulationtraceanalysis/DirectedGraphTranslator.java b/src/main/java/ui/simulationtraceanalysis/DirectedGraphTranslator.java index d3a410a872..ee780f3d73 100644 --- a/src/main/java/ui/simulationtraceanalysis/DirectedGraphTranslator.java +++ b/src/main/java/ui/simulationtraceanalysis/DirectedGraphTranslator.java @@ -35,14 +35,11 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; import com.mxgraph.swing.mxGraphComponent; - import avatartranslator.AvatarStateMachineElement; - import org.jgrapht.Graph; import org.jgrapht.GraphPath; import org.jgrapht.Graphs; @@ -55,7 +52,6 @@ import org.jgrapht.io.*; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; - import tmltranslator.*; import tmltranslator.tomappingsystemc2.DiploSimulatorCodeGenerator; import ui.TGComponent; @@ -67,7 +63,6 @@ import ui.ad.TADComponentWithoutSubcomponents; import ui.interactivesimulation.SimulationTransaction; import ui.tmlad.*; import ui.tmlcompd.TMLCPrimitivePort; - import javax.imageio.ImageIO; import javax.swing.*; import javax.xml.bind.JAXBContext; @@ -84,7 +79,6 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; @@ -102,76 +96,52 @@ import java.util.Map.Entry; * @author Maysam Zoor */ public class DirectedGraphTranslator extends JApplet { - private TMLTask taskAc, task1, task2; - 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 List<TMLComponentDesignPanel> cpanels; - 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 SysML 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; @@ -180,154 +150,148 @@ public class DirectedGraphTranslator extends JApplet { private String task2CoreNbr = ""; private String task1CoreNbr = ""; 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 static final String DATA = CHAR_LOWER + CHAR_UPPER; 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>> allSelectEvtValues = 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, Integer> fpgaIDs = 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 = ""; - private List<SimulationTransaction> onPath = new ArrayList<SimulationTransaction>(); private List<SimulationTransaction> offPath = new ArrayList<SimulationTransaction>(); private List<SimulationTransaction> offPathDelay = new ArrayList<SimulationTransaction>(); - - private static final String selectEventparam = "SelectEvent params:"; - private static final String selectEvent = "SelectEvent"; - private static final String transactions = "Transactions"; - private static final String mandatory = "Mandatory"; - private static final String operatorLabel = "operator"; - private static final String startTimeLabel = "starttime"; - private static final String endTimeLabel = "endtime"; - private static final String lengthLabel = "length"; - private static final String noContentionLabel = "NoContention"; - private static final String contentionLabel = "Contention"; - private static final String idLabel = "id"; - private static final String latencyTableLabel = "LatencyTable"; - private static final String latencyLabel = "Latency"; - private static final String rowLabel = "Row"; - private static final String minLabel = "Min"; - private static final String maxLabel = "Max"; - private static final String op1 = "op1"; - private static final String op2 = "op2"; - private static final String stLAbel = "st"; - private static final String waitLabel = "Wait"; - private static final String waitReqLabel = "Wait reqChannel_"; - private static final String getReqArgLabel = "getReqArg"; - private static final String waitSt = "Wait: "; - private static final String waitEvent = "wait event: "; + private static final String SELECT_EVENT_PARAM = "SelectEvent params:"; + private static final String SELECT_EVENT = "SelectEvent"; + private static final String TRANSACTIONS = "Transactions"; + private static final String MANDATORY = "Mandatory"; + private static final String OPERATOR_LABEL = "operator"; + private static final String START_TIME_LABEL = "starttime"; + private static final String END_TIME_LABEL = "endtime"; + private static final String LENGTH_LABEL = "length"; + private static final String NO_CONTENTION_LABEL = "NoContention"; + private static final String CONTENTION_LABEL = "Contention"; + private static final String ID_LABEL = "id"; + private static final String LATENCY_TABLE_LABEL = "LatencyTable"; + private static final String LATENCY_LABEL = "Latency"; + private static final String ROW_LABEL = "Row"; + private static final String MIN_LABEL = "Min"; + private static final String MAX_LABEL = "Max"; + private static final String OPERATOR_1 = "op1"; + private static final String OPERATOR_2 = "op2"; + private static final String ST_LABEL = "st"; + private static final String WAIT_LABEL = "Wait"; + private static final String WAIT_REQ_LABEL = "Wait reqChannel_"; + private static final String GET_REQ_ARG_LABEL = "getReqArg"; + private static final String WAIT_ST = "Wait: "; + private static final String WAIT_EVENT = "wait event: "; + private static final String STOP_AFTER_INFINITE_LOOP = "Stop after infinite loop"; + private static final String START_OF_FORK = "startOfFork"; + private static final String START_OF_JOIN = "startOfJoin"; + private static final String JUNCTION_OF_FORK = "junctionOfFork"; + private static final String JUNCTION_OF_JOIN = "junctionOfJoin"; + private static final String FORK_TASK_S = "FORKTASK_S"; + private static final String READ_OF_FORK = "ReadOfFork"; + private static final String WRITE_OF_FORK = "WriteOfFork_S"; + private static final String STOP_OF_FORK = "stopOfFork"; + private static final String STOP2_OF_FORK = "stop2OfFork"; + private static final String STOP_OF_JOIN = "stopOfJoin"; + private static final String JOIN_TASK_S = "JOINTASK_S_"; + private static final String READ_OF_JOIN = "ReadOfJoin"; + private static final String WRITE_OF_JOIN = "WriteOfJoin"; + private static final String WRITE_EVT_OF_FORK = "WriteEvtOfFork_S"; + private static final String WAIT_OF_FORK = "WaitOfFork"; + private static final String ZERO = "0"; + private static final String FORK_PORT_ORIGIN = "FORKPORTORIGIN"; + private static final String JOIN_PORT_ORIGIN = "JOINPORTORIGIN"; + private static final String JOIN_EVENT = "JOINEVENT"; + private static final String FORK_PORT_DESTINATION = "FORKPORTDESTINATION"; + private static final String FORK_EVENT = "FORKEVENT"; + private static final String S_LABEL = "_S_"; + private static final String JOIN_PORT_DESTINATION = "JOINPORTDESTINATION"; + private static final String FORK_CHANNEL = "FORKCHANNEL"; + private static final String JOIN_CHANNEL = "JOINCHANNEL"; + private static final String FORK_TASK = "FORKTASK"; + private static final String JOIN_TASK = "JOINTASK"; + private static final String WRITE = "Write"; + private static final String READ = "Read"; + private static final String UNORDERED_SEQUENCE = "unOrderedSequence"; + private static final String EXPRESSION_NOT_SUPPORTED = " Expression in For Loop is not supported by tainting"; + private static final String NO_TRANSACTION_FOUND = "no transaction was found for taint"; + private static final String PATH_EXISTS = "A path exists between operators"; + private static final String NO_PATH = "No path between operators"; + private static final String START = "start"; + private static final String WAITEVENT = "waitevent:"; + private static final String SENDEVENT = "sendevent:"; @SuppressWarnings("deprecation") public DirectedGraphTranslator(JFrameLatencyDetailedAnalysis jFrameLatencyDetailedAnalysis, JFrameCompareLatencyDetail jframeCompareLatencyDetail, TMLMapping<TGComponent> tmap1, List<TMLComponentDesignPanel> cpanels1, int i) { - tmap = tmap1; setCpanels(cpanels1); - links = tmap.getTMLArchitecture().getHwLinks(); - - // tmlcdp = getCpanels().get(0); - callingFrame = i; - - if (callingFrame == 0) - - { + 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 - public vertex vertex(String name, int id) { // TODO Auto-generated method stub - vertex v = new vertex(name, id); 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(); - expectedNumberofVertex(); - - if (callingFrame == 0) - - { + if (callingFrame == 0) { frameLatencyDetailedAnalysis.getPbar().setMaximum(nodeNbProgressBar); frameLatencyDetailedAnalysis.getPbar().setMinimum(0); - } - if (callingFrame == 1) - - { + if (callingFrame == 1) { frameCompareLatencyDetail.getPbar().setMaximum(nodeNbProgressBar); frameCompareLatencyDetail.getPbar().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); - buschannel = addBUSs(); bridgechannel = addBridge(); addHwAs(); @@ -347,7 +311,6 @@ public class DirectedGraphTranslator extends JApplet { addSeqEdges(); addunOrderedSeqEdges(); addRequestEdges(); - } private void addUnmappedchannel() { @@ -356,7 +319,6 @@ public class DirectedGraphTranslator extends JApplet { 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); @@ -365,12 +327,9 @@ public class DirectedGraphTranslator extends JApplet { getvertex(ch.getName()).setType(vertex.TYPE_CHANNEL); getvertex(ch.getName()).setTaintFixedNumber(0); updateMainBar(); - } - 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()); @@ -381,21 +340,14 @@ public class DirectedGraphTranslator extends JApplet { channelPaths.put(ch.getName(), pathNodeNames); } vertex v1 = vertex(node.getName(), node.getID()); - vertex v2 = vertex(ch.getName(), ch.getID()); - if (!g.containsEdge(v1, v2)) { g.addEdge(v1, v2); } - } - } - } - SummaryCommMapping = tmap.getSummaryCommMapping(); - } private void addCPUs() { @@ -406,16 +358,12 @@ public class DirectedGraphTranslator extends JApplet { 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)); - } if (cpuTask.size() > 0) { cpuTasks = getCPUTaskMap(cpuTask); } - } - } private void addMemorychannel(HashMap<String, HashSet<TMLElement>> memorychannel) { @@ -423,12 +371,9 @@ public class DirectedGraphTranslator extends JApplet { 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); updateMainBar(); @@ -436,45 +381,31 @@ public class DirectedGraphTranslator extends JApplet { // gVertecies.add(vertex(ChannelName)); getvertex(ChannelName).setTaintFixedNumber(0); updateMainBar(); - } - 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); updateMainBar(); getvertex(ChannelName).setType(vertex.TYPE_CHANNEL); // gVertecies.add(vertex(ChannelName)); - getvertex(ChannelName).setTaintFixedNumber(0); - updateMainBar(); - } - g.addEdge(getvertex(busName), getvertex(ChannelName)); } - } - } private void addBuschannel(HashMap<String, HashSet<TMLElement>> buschannel) { @@ -482,13 +413,9 @@ public class DirectedGraphTranslator extends JApplet { 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); updateMainBar(); @@ -496,43 +423,24 @@ public class DirectedGraphTranslator extends JApplet { // gVertecies.add(vertex(ChannelName)); getvertex(ChannelName).setTaintFixedNumber(0); updateMainBar(); - } - g.addEdge(getvertex(busName), getvertex(ChannelName)); - - // TMLChannel tmlch = (TMLChannel) busCh; - - // 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(); - } - if (tmap.getLisMappedChannels(node).size() > 0) { memorychannel.put(node.getName(), tmap.getLisMappedChannels(node)); - } - } - return memorychannel; } @@ -541,89 +449,59 @@ public class DirectedGraphTranslator extends JApplet { HashMap<String, HashSet<TMLTask>> cpuTask = new HashMap<String, HashSet<TMLTask>>(); HashMap<String, HashSet<String>> cpuTasks; for (HwA node : tmap.getArch().getHwA()) { - 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)); - } if (cpuTask.size() > 0) { cpuTasks = getCPUTaskMap(cpuTask); } - } - } 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(); - } - 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(); - } - 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() { @@ -631,56 +509,40 @@ public class DirectedGraphTranslator extends JApplet { 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)); - } } } @@ -688,245 +550,155 @@ public class DirectedGraphTranslator extends JApplet { } // 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()) { - for (String wch : writech) { - 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()) { - for (String sequenceEdge : edge.getValue()) - 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")) { - + 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")) { - + if (ae.getName().equals(STOP_AFTER_INFINITE_LOOP)) { } else { nodeNbProgressBar++; - } - } - } - } } 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++; - } - } - } private void updateMainBar() { - nbOfNodes++; - - if (callingFrame == 0) - - { + 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(); 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>>(); - // GEt List of all requests - requestedTask(value); - for (TMLTask task : value) { int taskID = task.getID(); String taskName = task.getName(); @@ -934,23 +706,16 @@ public class DirectedGraphTranslator extends JApplet { // events taskAc = task; sendEventsNames(); - // get the names of read channels per task and their corresponding write // channels - readChannelNames(); - // get the names of write channels per task and their corresponding read // channels - writeChannelNames(); - // get the names and params of wait events per task and their corresponding send // events waitEventNames(); - // add the name of the task as a vertex - if (!g.vertexSet().contains(getvertex(key))) { g.addVertex(vertex(key, keyID)); updateMainBar(); @@ -959,517 +724,329 @@ public class DirectedGraphTranslator extends JApplet { g.addVertex(vertex(taskName, taskID)); updateMainBar(); } - 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()) { - String eventName = null; - // int eventid = currentElement.getID(); - - if (currentElement.getName().equals("Stop after infinite loop")) { + if (currentElement.getName().equals(STOP_AFTER_INFINITE_LOOP)) { opCount++; updateMainBar(); if (opCount <= 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; } - } else if (currentElement.getName().equals("startOfFork") || currentElement.getName().equals("junctionOfFork") - || currentElement.getName().equals("startOfJoin") || currentElement.getName().equals("junctionOfJoin")) { + } else if (currentElement.getName().equals(START_OF_FORK) || currentElement.getName().equals(JUNCTION_OF_FORK) + || currentElement.getName().equals(START_OF_JOIN) || currentElement.getName().equals(JUNCTION_OF_JOIN)) { opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; - } else if (taskName.startsWith("FORKTASK_S_") && currentElement.getName().equals("ReadOfFork")) { - + } else if (taskName.startsWith(FORK_TASK_S) && currentElement.getName().equals(READ_OF_FORK)) { String name = ((TMLReadChannel) (currentElement)).getChannel(0).getName(); int id = ((TMLReadChannel) (currentElement)).getChannel(0).getID(); if (!g.containsVertex(getvertex(name))) { g.addVertex(vertex(name, id)); updateMainBar(); - } - 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.containsKey(taskName)) { - if (!forkreadEdges.get(taskName).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) { forkreadEdges.get(taskName).add(((TMLReadChannel) (currentElement)).getChannel(0).getName()); } - } else { - forkreadEdges.put(taskName, readForkVertex); - } - opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; - - } else if (taskName.startsWith("FORKTASK_S_") && currentElement.getName().startsWith("WriteOfFork_S")) { - + } else if (taskName.startsWith(FORK_TASK_S) && currentElement.getName().startsWith(WRITE_OF_FORK)) { 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)); updateMainBar(); - } - 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()); } - } else { - forkwriteEdges.put(taskName, writeForkVertex); - } - // g.addEdge(getvertex(taskName),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName())); - opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; - - } else if (currentElement.getName().equals("stopOfFork") || currentElement.getName().equals("stop2OfFork") - || currentElement.getName().equals("stopOfJoin")) { + } else if (currentElement.getName().equals(STOP_OF_FORK) || currentElement.getName().equals(STOP2_OF_FORK) + || currentElement.getName().equals(STOP_OF_JOIN)) { opCount++; updateMainBar(); // currentElement = currentElement.getNexts().firstElement(); continue; - } else if (taskName.startsWith("JOINTASK_S_") && currentElement.getName().startsWith("ReadOfJoin")) { - + } else if (taskName.startsWith(JOIN_TASK_S) && currentElement.getName().startsWith(READ_OF_JOIN)) { String vName = ((TMLReadChannel) (currentElement)).getChannel(0).getName(); int vid = ((TMLReadChannel) (currentElement)).getChannel(0).getID(); - if (!g.containsVertex(getvertex(vName))) { g.addVertex(vertex(vName, vid)); updateMainBar(); - } - HashSet<String> writeForkVertex = new HashSet<String>(); writeForkVertex.add(((TMLReadChannel) (currentElement)).getChannel(0).getName()); - if (joinreadEdges.containsKey(taskName)) { - if (!joinreadEdges.get(taskName).contains(((TMLReadChannel) (currentElement)).getChannel(0).getName())) { joinreadEdges.get(task.getName()).add(((TMLReadChannel) (currentElement)).getChannel(0).getName()); } - } else { - joinreadEdges.put(taskName, writeForkVertex); - } - // g.addEdge(getvertex(task.getName()),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName())); - opCount++; updateMainBar(); - currentElement = currentElement.getNexts().firstElement(); - continue; - } else if (taskName.startsWith("JOINTASK_S_") && currentElement.getName().equals("WriteOfJoin")) { - + } else if (taskName.startsWith(JOIN_TASK_S) && currentElement.getName().equals(WRITE_OF_JOIN)) { String vName = ((TMLWriteChannel) (currentElement)).getChannel(0).getName(); int vid = ((TMLWriteChannel) (currentElement)).getChannel(0).getID(); - if (!g.containsVertex(getvertex(vName))) { g.addVertex(vertex(vName, vid)); updateMainBar(); - } - 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.containsKey(taskName)) { - if (!joinwriteEdges.get(taskName).contains(((TMLWriteChannel) (currentElement)).getChannel(0).getName())) { joinwriteEdges.get(taskName).add(((TMLWriteChannel) (currentElement)).getChannel(0).getName()); } - } else { - joinwriteEdges.put(taskName, readForkVertex); - } - opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; - - } else if (taskName.startsWith("FORKTASK_S") && currentElement.getName().startsWith("WriteEvtOfFork_S")) { - + } else if (taskName.startsWith(FORK_TASK_S) && currentElement.getName().startsWith(WRITE_EVT_OF_FORK)) { String vName = ((TMLSendEvent) (currentElement)).getEvent().getName(); int vid = ((TMLSendEvent) (currentElement)).getEvent().getID(); - vertex v = getvertex(vName); if (!g.containsVertex(v)) { g.addVertex(vertex(vName, vid)); updateMainBar(); - } - HashSet<String> writeForkVertex = new HashSet<String>(); writeForkVertex.add(((TMLSendEvent) (currentElement)).getEvent().getName()); - if (forkwriteEdges.containsKey(taskName)) { - if (!forkwriteEdges.get(taskName).contains(((TMLSendEvent) (currentElement)).getEvent().getName())) { forkwriteEdges.get(taskName).add(((TMLSendEvent) (currentElement)).getEvent().getName()); } - } else { - forkwriteEdges.put(taskName, writeForkVertex); - } - // g.addEdge(getvertex(taskName),getvertex(((TMLWriteChannel)(currentElement)).getChannel(0).getName())); - opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; - - } else if (taskName.startsWith("FORKTASK_S") && currentElement.getName().equals("WaitOfFork")) { - + } else if (taskName.startsWith(FORK_TASK_S) && currentElement.getName().equals(WAIT_OF_FORK)) { String name = ((TMLWaitEvent) (currentElement)).getEvent().getName(); int id = ((TMLWaitEvent) (currentElement)).getEvent().getID(); if (!g.containsVertex(getvertex(name))) { g.addVertex(vertex(name, id)); updateMainBar(); - } - g.addEdge(getvertex(taskName), getvertex(((TMLWaitEvent) (currentElement)).getEvent().getName())); - HashSet<String> readForkVertex = new HashSet<String>(); readForkVertex.add(((TMLWaitEvent) (currentElement)).getEvent().getName()); - if (forkreadEdges.containsKey(taskName)) { - if (!forkreadEdges.get(taskName).contains(((TMLWaitEvent) (currentElement)).getEvent().getName())) { forkreadEdges.get(taskName).add(((TMLWaitEvent) (currentElement)).getEvent().getName()); } - } else { - forkreadEdges.put(taskName, readForkVertex); - } - opCount++; updateMainBar(); currentElement = currentElement.getNexts().firstElement(); - continue; } 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) { - addStopVertex(taskName); - } - // start activity is added as a vertex else if (currentElement.getReferenceObject() instanceof TMLADStartState) { - addStartVertex(taskName); - } - // 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 TADComponentWithoutSubcomponents || currentElement.getReferenceObject() instanceof TADComponentWithSubcomponents - || currentElement.getReferenceObject() instanceof TMLADActionState) - - { - + || currentElement.getReferenceObject() instanceof TMLADActionState) { 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(); - } else if (!multiNexts.isEmpty()) { - trackMultiNexts(taskName, eventName); currentElement = multiNexts.get(0); - multiNexts.remove(0); - } - 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)); } else { 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(); - if (cond.contains("<=")) { - String[] val = cond.split("<="); - String loopValue = val[2].toString(); - int loopVal = Integer.valueOf(loopValue); if ((loopValue != null) && (loopValue.length() > 0)) { - if ((loopValue.matches("\\d*"))) { getvertex(eventName).setTaintFixedNumber(loopVal); } else { for (TMLAttribute att : taskAc.getAttributes()) { - if (loopValue.contains(att.getName())) { loopValue = loopValue.replace(att.getName(), (att.getInitialValue())); } - } - getvertex(eventName).setTaintFixedNumber(loopVal); - } } - } else if (cond.contains("<")) { - String[] val = cond.split("<"); - String loopValue = val[1].toString(); int loopVal = Integer.valueOf(loopValue); - if ((loopValue != null) && (loopValue.length() > 0)) { - if ((loopValue.matches("\\d*"))) { getvertex(eventName).setTaintFixedNumber(loopVal); } 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(loopVal); } { - frameLatencyDetailedAnalysis.error(loopValue + " Expression in For Loop is not supported by Tainting"); + frameLatencyDetailedAnalysis.error(loopValue + EXPRESSION_NOT_SUPPORTED); } - } - } - } - } - 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(); - + insideLoop = taskName + "__" + UNORDERED_SEQUENCE + "__" + ae.getID(); } else { - insideLoop = taskName + "__" + ae.getReferenceObject().toString() + "__" + ae.getID(); - } - } else if (afterloopcg == outputConnector) { - if (ae.getReferenceObject() instanceof TMLADRandom) { - outsideLoop = taskName + "__" + ae.getName() + "__" + ae.getID(); - } else if (ae.getReferenceObject() instanceof TMLADUnorderedSequence) { - - outsideLoop = taskName + "__" + "unOrderedSequence" + "__" + ae.getID(); - + outsideLoop = taskName + "__" + UNORDERED_SEQUENCE + "__" + 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(); - + nextEventName = taskName + "__" + UNORDERED_SEQUENCE + "__" + seqListnextElement.getID(); } else { nextEventName = taskName + "__" + seqListnextElement.getReferenceObject().toString() + "__" + seqListnextElement.getID(); - } - if (orderedSequenceList.containsKey(eventName)) { if (!orderedSequenceList.get(eventName).contains(nextEventName)) { orderedSequenceList.get(eventName).add(nextEventName); @@ -1479,29 +1056,19 @@ public class DirectedGraphTranslator extends JApplet { 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(); - + nextEventName = taskName + "__" + UNORDERED_SEQUENCE + "__" + seqListnextElement.getID(); } else { nextEventName = taskName + "__" + seqListnextElement.getReferenceObject().toString() + "__" + seqListnextElement.getID(); - } - if (unOrderedSequenceList.containsKey(eventName)) { if (!unOrderedSequenceList.get(eventName).contains(nextEventName)) { unOrderedSequenceList.get(eventName).add(nextEventName); @@ -1511,32 +1078,24 @@ public class DirectedGraphTranslator extends JApplet { 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); updateMainBar(); // 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); - } } @@ -1546,401 +1105,258 @@ public class DirectedGraphTranslator extends JApplet { // TMLCPrimitivePort portdetails = waitEvent.getEvent().port; TMLCPrimitivePort sendingPortdetails = waitEvent.getEvent().port; TMLCPrimitivePort receivePortdetails = waitEvent.getEvent().port2; - if (sendingPortdetails != null && !sendingPortdetails.isBlocking()) { - warnings.add( - "Send event port:" + sendingPortdetails.getPortName() + " is non-blocking. Use tainting for an accurate latency analysis"); + warnings.add("Analysis may fail because the model contains non blocking sending port: " + sendingPortdetails.getPortName() + + " Use tainting analysis instead."); } if (sendingPortdetails != null && sendingPortdetails.isFinite()) { warnings.add("Send event port:" + sendingPortdetails.getPortName() + " is Finite. Event lost is not supported in latency analysis "); } String receivePortparams = waitEvent.getAllParams(); - String[] checkchannel; - String sendingDataPortdetails = ""; String receiveDataPortdetails = ""; - if (sendingPortdetails != null && receivePortdetails != null) { - waitEvt.put("waitevent:" + receivePortdetails.getPortName() + "(" + receivePortparams + ")", new ArrayList<String>()); - + 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 + ")"); - + waitEvt.get(WAITEVENT + receivePortdetails.getPortName() + "(" + receivePortparams + ")") + .add(SENDEVENT + sendingPortdetails.getPortName() + "(" + sendingPortparams + ")"); } - } else { String sendingPortparams = null; - if (waitEvent.getEvent().getOriginPort().getName().contains("FORKPORTORIGIN")) { - - checkchannel = waitEvent.getEvent().getOriginPort().getName().split("_S_"); - + if (waitEvent.getEvent().getOriginPort().getName().contains(FORK_PORT_ORIGIN)) { + checkchannel = waitEvent.getEvent().getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace("FORKPORTORIGIN", "FORKEVENT"); + sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace(FORK_PORT_ORIGIN, FORK_EVENT); sendingPortparams = waitEvent.getEvent().getParams().toString(); - } else if (checkchannel.length <= 2) { - - sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace("FORKPORTORIGIN", ""); - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); + sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace(FORK_PORT_ORIGIN, ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); sendingPortparams = waitEvent.getEvent().getParams().toString(); - } - - } else if (waitEvent.getEvent().getOriginPort().getName().contains("JOINPORTORIGIN")) { - - checkchannel = waitEvent.getEvent().getOriginPort().getName().split("_S_"); - + } else if (waitEvent.getEvent().getOriginPort().getName().contains(JOIN_PORT_ORIGIN)) { + checkchannel = waitEvent.getEvent().getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace("JOINPORTORIGIN", "JOINEVENT"); + sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace(JOIN_PORT_ORIGIN, JOIN_EVENT); sendingPortparams = waitEvent.getEvent().getParams().toString(); - } else if ((checkchannel.length) <= 2) { - sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace("JOINPORTORIGIN", ""); - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); + sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName().replace(JOIN_PORT_ORIGIN, ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); sendingPortparams = waitEvent.getEvent().getParams().toString(); - } } else { sendingDataPortdetails = waitEvent.getEvent().getOriginPort().getName(); sendingPortparams = waitEvent.getEvent().getParams().toString(); - } - if (waitEvent.getEvent().getDestinationPort().getName().contains("FORKPORTDESTINATION")) { - - checkchannel = waitEvent.getEvent().getDestinationPort().getName().split("_S_"); - + if (waitEvent.getEvent().getDestinationPort().getName().contains(FORK_PORT_DESTINATION)) { + checkchannel = waitEvent.getEvent().getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace("FORKPORTDESTINATION", "FORKEVENT"); + receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace(FORK_PORT_DESTINATION, FORK_EVENT); receivePortparams = waitEvent.getEvent().getParams().toString(); } else if (checkchannel.length <= 2) { - - receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace("FORKPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace(FORK_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); receivePortparams = waitEvent.getEvent().getParams().toString(); } - - } else if (waitEvent.getEvent().getDestinationPort().getName().contains("JOINPORTDESTINATION")) { - - checkchannel = waitEvent.getEvent().getDestinationPort().getName().split("_S_"); - + } else if (waitEvent.getEvent().getDestinationPort().getName().contains(JOIN_PORT_DESTINATION)) { + checkchannel = waitEvent.getEvent().getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace("JOINPORTDESTINATION", "JOINEVENT"); + receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace(JOIN_PORT_DESTINATION, JOIN_EVENT); } else if (checkchannel.length <= 2) { - - receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace("JOINPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName().replace(JOIN_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); receivePortparams = waitEvent.getEvent().getParams().toString(); } } else { receiveDataPortdetails = waitEvent.getEvent().getDestinationPort().getName(); receivePortparams = waitEvent.getEvent().getParams().toString(); } - if (sendingDataPortdetails != null && receiveDataPortdetails != null) { - waitEvt.put("waitevent:" + receiveDataPortdetails + "(" + receivePortparams + ")", new ArrayList<String>()); - - waitEvt.get("waitevent:" + receiveDataPortdetails + "(" + receivePortparams + ")") - .add("sendevent:" + sendingDataPortdetails + "(" + sendingPortparams + ")"); - + waitEvt.put(WAITEVENT + receiveDataPortdetails + "(" + receivePortparams + ")", new ArrayList<String>()); + waitEvt.get(WAITEVENT + receiveDataPortdetails + "(" + receivePortparams + ")") + .add(SENDEVENT + sendingDataPortdetails + "(" + 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 (writeChannel.getChannel(j).getOriginPort().getName().contains(FORK_PORT_ORIGIN)) { + checkchannel = writeChannel.getChannel(j).getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "FORKCHANNEL"); + sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace(FORK_PORT_ORIGIN, FORK_CHANNEL); ; - } else if (checkchannel.length < 2) { - - sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", ""); + sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace(FORK_PORT_ORIGIN, ""); ; - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); ; - } - - } else if (writeChannel.getChannel(j).getOriginPort().getName().contains("JOINPORTORIGIN")) { - - checkchannel = writeChannel.getChannel(j).getOriginPort().getName().split("_S_"); - + } else if (writeChannel.getChannel(j).getOriginPort().getName().contains(JOIN_PORT_ORIGIN)) { + checkchannel = writeChannel.getChannel(j).getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "JOINCHANNEL"); - + sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace(JOIN_PORT_ORIGIN, JOIN_CHANNEL); } else if (checkchannel.length <= 2) { - sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", ""); - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); + sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName().replace(JOIN_PORT_ORIGIN, ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); ; - } - } else { sendingDataPortdetails = writeChannel.getChannel(j).getOriginPort().getName(); } - - if (writeChannel.getChannel(j).getDestinationPort().getName().contains("FORKPORTDESTINATION")) { - - checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split("_S_"); - + if (writeChannel.getChannel(j).getDestinationPort().getName().contains(FORK_PORT_DESTINATION)) { + checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", - "FORKCHANNEL"); + receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace(FORK_PORT_DESTINATION, + FORK_CHANNEL); } else if (checkchannel.length <= 2) { - - receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace(FORK_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); } - - } else if (writeChannel.getChannel(j).getDestinationPort().getName().contains("JOINPORTDESTINATION")) { - - checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split("_S_"); - + } else if (writeChannel.getChannel(j).getDestinationPort().getName().contains(JOIN_PORT_DESTINATION)) { + checkchannel = writeChannel.getChannel(j).getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = "JOINCHANNEL_S_" + checkchannel[1] + "__" + checkchannel[2]; - + receiveDataPortdetails = JOIN_CHANNEL + S_LABEL + checkchannel[1] + "__" + checkchannel[2]; } else if (checkchannel.length <= 2) { - receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName().replace(JOIN_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); } - } else { receiveDataPortdetails = writeChannel.getChannel(j).getDestinationPort().getName(); - } - } else { - // 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()) { - 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++) { - 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 (readChannel.getChannel(j).getOriginPort().getName().contains(FORK_PORT_ORIGIN)) { + checkchannel = readChannel.getChannel(j).getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", "FORKCHANNEL"); - + sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace(FORK_PORT_ORIGIN, FORK_CHANNEL); } else if (checkchannel.length <= 2) { - - sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("FORKPORTORIGIN", ""); - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); + sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace(FORK_PORT_ORIGIN, ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); ; - } - - } else if (readChannel.getChannel(j).getOriginPort().getName().contains("JOINPORTORIGIN")) { - - checkchannel = readChannel.getChannel(j).getOriginPort().getName().split("_S_"); - + } else if (readChannel.getChannel(j).getOriginPort().getName().contains(JOIN_PORT_ORIGIN)) { + checkchannel = readChannel.getChannel(j).getOriginPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", "JOINCHANNEL"); - + sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace(JOIN_PORT_ORIGIN, JOIN_CHANNEL); } else if ((checkchannel.length) <= 2) { - sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace("JOINPORTORIGIN", ""); - - sendingDataPortdetails = sendingDataPortdetails.replace("_S_", ""); - + sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName().replace(JOIN_PORT_ORIGIN, ""); + sendingDataPortdetails = sendingDataPortdetails.replace(S_LABEL, ""); } } else { sendingDataPortdetails = readChannel.getChannel(j).getOriginPort().getName(); } - if (readChannel.getChannel(j).getDestinationPort().getName().contains("FORKPORTDESTINATION")) { - - checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split("_S_"); - + if (readChannel.getChannel(j).getDestinationPort().getName().contains(FORK_PORT_DESTINATION)) { + checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", - "FORKCHANNEL"); + receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace(FORK_PORT_DESTINATION, + FORK_CHANNEL); } else if (checkchannel.length <= 2) { - - receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("FORKPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace(FORK_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); } - - } else if (readChannel.getChannel(j).getDestinationPort().getName().contains("JOINPORTDESTINATION")) { - - checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split("_S_"); - + } else if (readChannel.getChannel(j).getDestinationPort().getName().contains(JOIN_PORT_DESTINATION)) { + checkchannel = readChannel.getChannel(j).getDestinationPort().getName().split(S_LABEL); if (checkchannel.length > 2) { - - receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION", - "JOINCHANNEL"); + receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace(JOIN_PORT_DESTINATION, + JOIN_CHANNEL); } else if (checkchannel.length <= 2) { - - receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace("JOINPORTDESTINATION", ""); - - receiveDataPortdetails = receiveDataPortdetails.replace("_S_", ""); + receiveDataPortdetails = readChannel.getChannel(j).getDestinationPort().getName().replace(JOIN_PORT_DESTINATION, ""); + receiveDataPortdetails = receiveDataPortdetails.replace(S_LABEL, ""); } } 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); - } - TMLCPrimitivePort sp = null, rp = null; - 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 != null && rp != null) { - 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."); - + warnings.add("Analysis may fail because the model contains non blocking sending port: " + sp.getPortName() + + " and non blocking read data port:" + rp.getPortName() + " Use tainting analysis instead."); } } - } - } - } private void sendEventsNames() { // TODO Auto-generated method stub for (TMLSendEvent sendEvent : taskAc.getSendEvents()) { - // int i = sendEvent.getEvents().size(); TMLCPrimitivePort sendingPortdetails = sendEvent.getEvent().port; TMLCPrimitivePort receivePortdetails = sendEvent.getEvent().port2; - String sendingPortparams = sendEvent.getAllParams(); - TMLTask destinationTasks = sendEvent.getEvent().getDestinationTask(); if (sendingPortdetails != null && receivePortdetails != null) { - sendEvt.put("sendevent:" + sendingPortdetails.getPortName() + "(" + sendingPortparams + ")", new ArrayList<String>()); - + 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 + ")"); - + 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.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); @@ -1950,13 +1366,9 @@ public class DirectedGraphTranslator extends JApplet { 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); @@ -1966,9 +1378,7 @@ public class DirectedGraphTranslator extends JApplet { requestsPortNames.add(requestsPortName); requestsPorts.put(task.getName(), requestsPortNames); } - } - if (requestsDestination.containsKey(destinationRequestName)) { if (!requestsDestination.get(destinationRequestName).contains(destinationRequest)) { requestsDestination.get(destinationRequestName).add(destinationRequest); @@ -1978,124 +1388,45 @@ public class DirectedGraphTranslator extends JApplet { destinationRequestNames.add(destinationRequest); requestsDestination.put(destinationRequestName, destinationRequestNames); } - } - } - } private void addcurrentElementVertex(String taskName, String taskStartName) { // TODO Auto-generated method stub - String preEventName; - int preEventid; String eventName = getEventName(taskName, currentElement); - int eventid = currentElement.getID(); - 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(); + preEventName = taskName + "__" + UNORDERED_SEQUENCE + "__" + 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 v = vertex(eventName, eventid); - vertex preV = vertex(preEventName, preEventid); - g.addVertex(v); updateMainBar(); g.addEdge(preV, v); opCount++; - - } else if ((activity.getPrevious(currentElement).getName().equals("start")) && g.containsVertex(getvertex(taskStartName))) { + } else if ((activity.getPrevious(currentElement).getName().equals(START)) && g.containsVertex(getvertex(taskStartName))) { vertex v = vertex(eventName, eventid); - g.addVertex(v); updateMainBar(); // gVertecies.add(vertex(eventName)); g.addEdge(getvertex(taskStartName), getvertex(eventName)); opCount++; - } - if (currentElement.getReferenceObject() instanceof TMLADSendEvent || currentElement.getReferenceObject() instanceof TMLADWaitEvent || currentElement.getReferenceObject() instanceof TMLADSendRequest || currentElement.getReferenceObject() instanceof TMLADNotifiedEvent @@ -2106,901 +1437,481 @@ public class DirectedGraphTranslator extends JApplet { || (currentElement.getReferenceObject() instanceof TMLADExecIInterval) || 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_SELECT_EVT); 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(" ", "")); - 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()); } - } 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)) { 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") - - ) { + if (((TMLWriteChannel) currentElement).getChannel(0).getName().contains(FORK_CHANNEL) + || ((TMLWriteChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith(FORK_TASK) + || ((TMLWriteChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith(FORK_TASK) + || ((TMLWriteChannel) currentElement).getChannel(0).getName().contains(JOIN_CHANNEL) + || ((TMLWriteChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith(JOIN_TASK) + || ((TMLWriteChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith(JOIN_TASK)) { 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); - - } - - else { + } 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); } - } 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") - || ((TMLReadChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith("JOINTASK")) { + if (((TMLReadChannel) currentElement).getChannel(0).getName().contains(FORK_CHANNEL) + || ((TMLReadChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith(FORK_TASK) + || ((TMLReadChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith(FORK_TASK) + || ((TMLReadChannel) currentElement).getChannel(0).getName().contains(JOIN_CHANNEL) + || ((TMLReadChannel) currentElement).getChannel(0).getDestinationTask().getName().startsWith(JOIN_TASK) + || ((TMLReadChannel) currentElement).getChannel(0).getOriginTask().getName().startsWith(JOIN_TASK)) { 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); } - } else { - 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); - if (readWriteChannelEdges.containsKey(chwriteName)) { - if (!readWriteChannelEdges.get(chwriteName).contains(eventName)) { readWriteChannelEdges.get(chwriteName).add(eventName); } - } else { - readWriteChannelEdges.put(chwriteName, readChVertex); - } - // } - } - } private void addStopVertex(String taskName) { // TODO Auto-generated method stub - String taskEndName = ""; int taskEndid; int preEventid; String preEventName; String eventName = null; - eventName = getEventName(taskName, currentElement); - taskEndid = currentElement.getID(); taskEndName = taskName + "__" + currentElement.getName() + "__" + taskEndid; - preEventid = activity.getPrevious(currentElement).getID(); if (activity.getPrevious(currentElement).getReferenceObject() instanceof TMLADRandom) { preEventName = taskName + "__" + activity.getPrevious(currentElement).getName() + "__" + preEventid; - } else if (currentElement.getReferenceObject() instanceof TMLADUnorderedSequence) { - - preEventName = taskName + "__" + "unOrderedSequence" + "__" + preEventid; - + preEventName = taskName + "__" + UNORDERED_SEQUENCE + "__" + preEventid; } else { preEventName = taskName + "__" + activity.getPrevious(currentElement).getReferenceObject().toString() + "__" + preEventid; - } - vertex taskEndVertex = vertex(taskEndName, taskEndid); - g.addVertex(taskEndVertex); updateMainBar(); // 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(getvertex(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)).getName() != 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))) { - 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()); - - if (pathToNextValue.size() > 0) - - { - + 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(getvertex(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)))) - - { + 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)))) - - { - + if (path.get(i).getVertexList().contains(getvertex(seqEntry.getValue().get(seqEntry.getValue().size() - 1)))) { } else { noForLoop++; } - } - } - if (noForLoop == 0) { - - // if (unOrderedSequenceEdges.containsKey(taskEndName)) { - - // if - // (!unOrderedSequenceEdges.get(taskEndName).contains(sequenceListEntry.getKey())) - // { - // unOrderedSequenceEdges.get(taskEndName).add(sequenceListEntry.getKey()); - // } - - // } else { - - // unOrderedSequenceEdges.put(eventName, endSequenceVertex); - for (String seqEntry : sequenceListEntry.getValue()) { GraphPath<vertex, DefaultEdge> pathToEnd = null; if (g.containsVertex(getvertex(seqEntry))) { pathToEnd = DijkstraShortestPath.findPathBetween(g, getvertex(seqEntry), getvertex(eventName)); - } - if (pathToEnd == null) { if (unOrderedSequenceEdges.containsKey(taskEndName)) { - if (!unOrderedSequenceEdges.get(taskEndName).contains(sequenceListEntry.getKey())) { unOrderedSequenceEdges.get(taskEndName).add(seqEntry); } - } else { - HashSet<String> endSequenceVertex = new HashSet<String>(); endSequenceVertex.add(seqEntry); - 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(getvertex(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)))) - - { - + 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()); - * - * - * //GraphPath<vertex, DefaultEdge> pathToEnd = null; - * - * if (unOrderedSequenceEdges.containsKey(taskEndName)) { - * - * if - * (!unOrderedSequenceEdges.get(taskEndName).contains(forloopListEntry.getKey()) - * ) { unOrderedSequenceEdges.get(taskEndName).add(forloopListEntry.getKey()); } - * - * } else { - * - * // HashSet<String> endSequenceVertex = new HashSet<String>(); // - * endSequenceVertex.add(unOrderedseqEntry); - * - * unOrderedSequenceEdges.put(eventName, forLoopName); - * - * } - * - * - * - * /* 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(getvertex(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(getvertex(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(getvertex(taskEndName), getvertex(forvertexName))) { - + if (forloopCount == 0 && !g.containsEdge(getvertex(taskEndName), getvertex(forvertexName))) { addedEdges.put(taskEndName, forvertexName); - } } } } } - } - } - } - - if (!forEverLoopList.isEmpty()) - - { - + 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)))) - - { - + .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()))) { 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); - } } } } - } - opCount++; - } private String getEventName(String taskName, TMLActivityElement currentElement2) { - String eventName = null; - if (currentElement.getReferenceObject() instanceof TMLADRandom) { - eventName = taskName + "__" + currentElement2.getName() + "__" + currentElement2.getID(); - } else if (currentElement.getReferenceObject() instanceof TMLADUnorderedSequence) { - - eventName = taskName + "__" + "unOrderedSequence" + "__" + currentElement2.getID(); - + eventName = taskName + "__" + UNORDERED_SEQUENCE + "__" + currentElement2.getID(); } else { eventName = taskName + "__" + currentElement2.getReferenceObject().toString() + "__" + currentElement2.getID(); - } - return eventName; } @@ -3016,26 +1927,17 @@ public class DirectedGraphTranslator extends JApplet { // open graph in a frame public void showGraph(DirectedGraphTranslator dgraph) { - JGraphXAdapter<vertex, DefaultEdge> graphAdapter = new JGraphXAdapter<vertex, DefaultEdge>(dgraph.getG()); - mxHierarchicalLayout layout = new mxHierarchicalLayout(graphAdapter); - layout.setInterHierarchySpacing(100); layout.setInterRankCellSpacing(100); layout.setIntraCellSpacing(100); - layout.execute(graphAdapter.getDefaultParent()); - dgraph.getScrollPane().setViewportView(new mxGraphComponent(graphAdapter)); - dgraph.getScrollPane().setVisible(true); - dgraph.getScrollPane().revalidate(); dgraph.getScrollPane().repaint(); - dgraph.getFrame().add(dgraph.getScrollPane()); - dgraph.getFrame().pack(); dgraph.getFrame().setLocationByPlatform(true); dgraph.getFrame().setVisible(true); @@ -3047,19 +1949,14 @@ public class DirectedGraphTranslator extends JApplet { // save graph in .graphml format public void exportGraph(String filename) throws ExportException, IOException { - @SuppressWarnings({ "rawtypes", "unchecked" }) GraphMLExporter<String, DefaultEdge> gmlExporter = new GraphMLExporter(); - ComponentNameProvider<vertex> vertexIDProvider = new ComponentNameProvider<vertex>() { - @Override public String getName(vertex vertex) { - String name; for (vertex v : g.vertexSet()) { if (v.getName().equals(vertex.getName())) { - name = vertex.getName().toString().replaceAll("\\s+", ""); name = vertex.getName().replaceAll("\\(", "\\u0028"); name = vertex.getName().replaceAll("\\)", "\\u0029"); @@ -3068,11 +1965,8 @@ public class DirectedGraphTranslator extends JApplet { } return null; } - }; - ComponentNameProvider<vertex> vertexNameProvider = new ComponentNameProvider<vertex>() { - @Override public String getName(vertex arg0) { for (vertex v : g.vertexSet()) { @@ -3082,67 +1976,46 @@ public class DirectedGraphTranslator extends JApplet { } return null; } - }; - ComponentNameProvider<DefaultEdge> edgeIDProvider = new ComponentNameProvider<DefaultEdge>() { - @Override public String getName(DefaultEdge edge) { String source = g.getEdgeSource(edge).toString().replaceAll("\\s+", ""); source = source.replaceAll("\\(", "\\u0028"); source = source.replaceAll("\\)", "\\u0029"); - - // .replaceAll("\\(", ""); - // source.replaceAll("\\)", ""); - String target = g.getEdgeTarget(edge).toString().replaceAll("\\s+", ""); target = target.replaceAll("\\(", "\\u0028"); target = target.replaceAll("\\)", "\\u0029"); - // target.replaceAll("\\(", ""); - // target.replaceAll("\\)", ""); - // TODO Auto-generated method stub return source + target; } }; - ComponentNameProvider<DefaultEdge> edgeLabelProvider = new ComponentNameProvider<DefaultEdge>() { - @Override public String getName(DefaultEdge edge) { // TODO Auto-generated method stub return Double.toString(g.getEdgeWeight(edge)); } }; - GraphMLExporter<vertex, DefaultEdge> exporter = new GraphMLExporter<vertex, DefaultEdge>(vertexIDProvider, vertexNameProvider, edgeIDProvider, edgeLabelProvider); - Writer fileWriter; - FileWriter PS = new FileWriter(filename + ".graphml"); // gmlExporter.exportGraph(g, PS); - // FileWriter PS2 = new FileWriter(filename + "test.graphml"); - exporter.exportGraph(g, PS); - } // save graph frame in .png format public void exportGraphAsImage(String filename) throws ExportException, IOException { - Container c = frame.getContentPane(); BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB); c.paint(im.getGraphics()); ImageIO.write(im, "PNG", new File(filename + ".png")); - } // return all vertices that can be checked for latency // used to fill drop down public Vector<String> getLatencyVertices() { - return allLatencyTasks; } @@ -3159,236 +2032,146 @@ public class DirectedGraphTranslator extends JApplet { // between the selected tasks public Object[][] latencyDetailedAnalysis(String task12ID, String task22ID, Vector<SimulationTransaction> transFile1, Boolean taint, Boolean considerAddedRules) { - for (vertex v : g.vertexSet()) { - v.setLabel(new ArrayList<String>()); v.setMaxTaintFixedNumber(new HashMap<String, Integer>()); v.setTaintConsideredNumber(new HashMap<String, Integer>()); v.setVirtualLengthAdded(0); v.setSampleNumber(0); } - transFile = transFile1; - - // AllDirectedPaths<String, DefaultEdge> allPaths = new AllDirectedPaths<String, - // DefaultEdge>(g); - String message = ""; - String[] task1 = task12ID.split("__"); - int task1index = task1.length; - idTask1 = task1[task1index - 1]; - String[] task2 = task22ID.split("__"); - int task2index = task2.length; - idTask2 = task2[task2index - 1]; - String task12 = nameIDTaskList.get(idTask1); String task22 = nameIDTaskList.get(idTask2); - vertex v1 = getvertex(task12); - Vector<SimulationTransaction> Task1Traces = new Vector<SimulationTransaction>(); Vector<SimulationTransaction> Task2Traces = new Vector<SimulationTransaction>(); - HashMap<String, Vector<String>> Task1TaintedTraces = new LinkedHashMap<String, Vector<String>>(); HashMap<String, Vector<String>> Task2TaintedTraces = new LinkedHashMap<String, Vector<String>>(); - GraphPath<vertex, DefaultEdge> path2 = DijkstraShortestPath.findPathBetween(g, v1, getvertex(task22)); - - // List<GraphPath<String, DefaultEdge>> path = allPaths.getAllPaths(task12, - // task22, false, 100); - - // int size = path.size(); times1.clear(); times2.clear(); - - // message = "there exists " +path.size()+" between: " + task12 + " and " + - // task22; - if (path2 != null && path2.getLength() > 0) { - for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) { - String ChannelName = entry.getKey(); ArrayList<String> busChList = entry.getValue(); - GraphPath<vertex, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, v1, getvertex(ChannelName)); GraphPath<vertex, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, getvertex(ChannelName), getvertex(task22)); - if (pathTochannel != null && pathTochannel.getLength() > 0 && pathFromChannel != null && pathFromChannel.getLength() > 0) { - devicesToBeConsidered.addAll(busChList); - } - } - } else { - for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) { - String ChannelName = entry.getKey(); ArrayList<String> busChList = entry.getValue(); - GraphPath<vertex, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, v1, getvertex(ChannelName)); GraphPath<vertex, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, getvertex(ChannelName), getvertex(task22)); - if ((pathTochannel != null && pathTochannel.getLength() > 0) || (pathFromChannel != null && pathFromChannel.getLength() > 0)) { - devicesToBeConsidered.addAll(busChList); - } - } - } - Collections.sort(transFile1, new Comparator<SimulationTransaction>() { public int compare(SimulationTransaction o1, SimulationTransaction o2) { BigDecimal t1 = new BigDecimal(o1.startTime); BigDecimal t2 = new BigDecimal(o2.startTime); - int startTimeEq = t1.compareTo(t2); - if (startTimeEq == 0) { BigDecimal t1End = new BigDecimal(o1.endTime); BigDecimal t2End = new BigDecimal(o2.endTime); return t1End.compareTo(t2End); } - return startTimeEq; - } }); - if (taint) { - for (SimulationTransaction st : transFile1) { - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - if (task1DeviceName.isEmpty()) { if (st.id.equals(idTask1)) { - task1DeviceName = st.deviceName; task1CoreNbr = st.coreNumber; - } } - if (task2DeviceName.isEmpty()) { if (st.id.equals(idTask2)) { - task2DeviceName = st.deviceName; - task2CoreNbr = st.coreNumber; - } } - if (!task1DeviceName.isEmpty() && !task2DeviceName.isEmpty()) { break; - } - } int j = 0; for (SimulationTransaction st : transFile1) { - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); int id = Integer.valueOf(st.id); if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - // ADD rules as edges if (considerAddedRules) { if (ruleAddedEdges.size() > 0) { - for (Entry<vertex, List<vertex>> rulevertex : ruleAddedEdges.entrySet()) { - vertex fromVertex = rulevertex.getKey(); - List<vertex> listOfToV = rulevertex.getValue(); - for (vertex toVertex : listOfToV) { if (g.containsVertex(toVertex) && g.containsVertex(fromVertex)) { g.addEdge(fromVertex, toVertex); } } - } - } } - // if st started and ended before the first call of operator- don't consider it // if (!(Integer.valueOf(st.startTime) < times1.get(0) && // Integer.valueOf(st.endTime) < times1.get(0))) { - String taskname = ""; - String tasknameCheckID = ""; - - if (st.command.contains(selectEventparam)) { - st.command = st.command.replace(selectEvent, waitSt + st.channelName); - + if (st.command.contains(SELECT_EVENT_PARAM)) { + st.command = st.command.replace(SELECT_EVENT, WAIT_ST + st.channelName); String[] chN = st.channelName.split("__"); - String eventN = chN[chN.length - 1]; - vertex v = getvertexFromID(id); String vName = v.getName(); - if (Graphs.vertexHasSuccessors(g, v)) { for (vertex vsec : Graphs.successorListOf(g, v)) { - - if (vsec.getName().contains(waitEvent + eventN + "(")) { + if (vsec.getName().contains(WAIT_EVENT + eventN + "(")) { st.id = String.valueOf(vsec.getId()); id = vsec.getId(); } - } - } - - } else if (st.command.contains(waitReqLabel)) { + } else if (st.command.contains(WAIT_REQ_LABEL)) { vertex v = getvertexFromID(id); if (v.getType() == vertex.TYPE_START) { if (Graphs.vertexHasSuccessors(g, v)) { - for (vertex vbefore : Graphs.successorListOf(g, v)) { - - if (vbefore.getName().contains(getReqArgLabel)) { + if (vbefore.getName().contains(GET_REQ_ARG_LABEL)) { st.id = String.valueOf(vbefore.getId()); id = vbefore.getId(); } - } - } } } - for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) { String ChannelName = entry.getKey(); ArrayList<String> busChList = entry.getValue(); String bus1 = ""; for (String busName : busChList) { - String[] bus = st.deviceName.split("_"); - if (bus.length > 2) { for (int i = 0; i < bus.length - 1; i++) { if (i == 0) { @@ -3396,76 +2179,46 @@ public class DirectedGraphTranslator extends JApplet { } else { bus1 = bus1 + "_" + bus[i]; } - } } else { bus1 = bus[0]; } - if (bus1.equals(busName) && st.channelName.equals(ChannelName)) { tasknameCheckID = ChannelName; taskname = getvertex(ChannelName).getName(); - } } - } - if (tasknameCheckID.isEmpty()) { - for (vertex tasknameCheck : g.vertexSet()) { - String[] taskToAdd = tasknameCheck.toString().replaceAll(" ", "").split("__"); - int taskToAddindex = taskToAdd.length; - String taskToAddid = taskToAdd[taskToAddindex - 1]; - if (isNumeric(taskToAddid)) { - if (Integer.valueOf(taskToAddid).equals(id)) { - taskname = tasknameCheck.toString(); - tasknameCheckID = tasknameCheck.getName(); - if (taskname.equals(task12) && task1DeviceName.equals(st.deviceName) && task1CoreNbr.equals(st.coreNumber)) { - addTaint(tasknameCheck); - if (Task1TaintedTraces.containsKey(tasknameCheck.getLastLabel())) { Task1TaintedTraces.get(tasknameCheck.getLastLabel()).add(st.startTime); } else { Vector<String> Task1TracesTD = new Vector<String>(); - Task1TracesTD.add(st.startTime); - Task1TaintedTraces.put(tasknameCheck.getLastLabel(), Task1TracesTD); - } - times1.add(startTime); Collections.sort(times1); - } - break; - } - } - } - } - if (Graphs.vertexHasSuccessors(g, getvertex(tasknameCheckID)) && !getvertex(tasknameCheckID).getLabel().isEmpty()) { - for (vertex v : Graphs.successorListOf(g, getvertex(tasknameCheckID))) { String labelToaAddtoV = getfirstCommonLabel(v, getvertex(tasknameCheckID)); - // removed after testing in for loop/ action/choice - /* * if (Graphs.vertexHasPredecessors(g, getvertex(tasknameCheckID))) { for * (vertex previousV : Graphs.predecessorListOf(g, getvertex(tasknameCheckID))) @@ -3504,9 +2257,7 @@ public class DirectedGraphTranslator extends JApplet { * * } } } */ - if (v.getType() == vertex.TYPE_CHANNEL || v.getType() == vertex.TYPE_TRANSACTION) { - if (v.getLabel().contains(labelToaAddtoV)) { if (v.getMaxTaintFixedNumber().containsKey(labelToaAddtoV)) { if (v.getMaxTaintFixedNumber().get(labelToaAddtoV) != v.getTaintFixedNumber()) { @@ -3514,386 +2265,249 @@ public class DirectedGraphTranslator extends JApplet { v.getMaxTaintFixedNumber().get(labelToaAddtoV) * v.getTaintFixedNumber()); } } - } else { v.addLabel(labelToaAddtoV); v.getMaxTaintFixedNumber().put(labelToaAddtoV, v.getTaintFixedNumber()); } - for (vertex subV : Graphs.successorListOf(g, v)) { - if (!subV.equals(v1)) { - if (!(subV.getType() == vertex.TYPE_TRANSACTION || subV.getType() == vertex.TYPE_CHANNEL)) { - HashMap<vertex, List<vertex>> NonTransVertexes = new LinkedHashMap<vertex, List<vertex>>(); HashMap<vertex, List<vertex>> NonTransVertexes2 = new LinkedHashMap<vertex, List<vertex>>(); HashMap<vertex, List<vertex>> NonTransVertexesAdded = new LinkedHashMap<vertex, List<vertex>>(); - NonTransVertexes.putAll(taintingNonTransVertexes(v, getvertex(tasknameCheckID), v1)); - int addeditems = 0; - for (Entry<vertex, List<vertex>> e : NonTransVertexes.entrySet()) { vertex vet = e.getKey(); List<vertex> vl = e.getValue(); - for (vertex ver : vl) { - NonTransVertexes2 = taintingNonTransVertexes(ver, vet, v1); - NonTransVertexesAdded.putAll(NonTransVertexes2); // NonTransVertexes.putAll(taintingNonTransVertexes(ver, vet, v1)); addeditems = addeditems + NonTransVertexes2.size(); - } } - while (addeditems > 0) { - NonTransVertexes = new LinkedHashMap<vertex, List<vertex>>(); NonTransVertexes.putAll(NonTransVertexesAdded); NonTransVertexesAdded = new LinkedHashMap<vertex, List<vertex>>(); - for (Entry<vertex, List<vertex>> e : NonTransVertexes.entrySet()) { vertex vet = e.getKey(); List<vertex> vl = e.getValue(); - for (vertex ver : vl) { - NonTransVertexesAdded.putAll(taintingNonTransVertexes(ver, vet, v1)); // NonTransVertexes.putAll(taintingNonTransVertexes(ver, vet, v1)); addeditems--; addeditems = addeditems + NonTransVertexesAdded.size(); - } - } } - } } - } - } else { - HashMap<vertex, List<vertex>> NonTransVertexes = new LinkedHashMap<vertex, List<vertex>>(); HashMap<vertex, List<vertex>> NonTransVertexes2 = new LinkedHashMap<vertex, List<vertex>>(); HashMap<vertex, List<vertex>> NonTransVertexesAdded = new LinkedHashMap<vertex, List<vertex>>(); - NonTransVertexes.putAll(taintingNonTransVertexes(v, getvertex(tasknameCheckID), v1)); - int addeditems = 0; - for (Entry<vertex, List<vertex>> e : NonTransVertexes.entrySet()) { vertex vet = e.getKey(); List<vertex> vl = e.getValue(); - for (vertex ver : vl) { - NonTransVertexes2 = taintingNonTransVertexes(ver, vet, v1); - NonTransVertexesAdded.putAll(NonTransVertexes2); // NonTransVertexes.putAll(taintingNonTransVertexes(ver, vet, v1)); addeditems = addeditems + NonTransVertexes2.size(); - } - } - while (addeditems > 0) { - NonTransVertexes = new LinkedHashMap<vertex, List<vertex>>(); NonTransVertexes.putAll(NonTransVertexesAdded); NonTransVertexesAdded = new LinkedHashMap<vertex, List<vertex>>(); - for (Entry<vertex, List<vertex>> e : NonTransVertexes.entrySet()) { vertex vet = e.getKey(); List<vertex> vl = e.getValue(); - for (vertex ver : vl) { - NonTransVertexesAdded.putAll(taintingNonTransVertexes(ver, vet, v1)); // NonTransVertexes.putAll(taintingNonTransVertexes(ver, vet, v1)); addeditems--; addeditems = addeditems + NonTransVertexesAdded.size(); - } - } } - } - } - } - Boolean hasLabelAstask12 = false; hasLabelAstask12 = considerVertex(task12, taskname, st.virtualLength, st.command); - // remove rules edges - if (considerAddedRules) { if (ruleAddedEdges.size() > 0) { - for (Entry<vertex, List<vertex>> rulevertex : ruleAddedEdges.entrySet()) { - vertex fromVertex = rulevertex.getKey(); - List<vertex> listOfToV = rulevertex.getValue(); - for (vertex toVertex : listOfToV) { if (g.containsVertex(fromVertex) && g.containsVertex(toVertex) && g.containsEdge(fromVertex, toVertex)) { - g.removeEdge(fromVertex, toVertex); } } - } - } } - String[] name = st.deviceName.split("_"); String deviceName = name[0]; // there is a path between task 1 and task 2 // if (path2 != null && path2.getLength() > 0) { - j++; - if (path2 != null && path2.getLength() > 0) { - GraphPath<vertex, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, v1, getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathToDestination = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (taskname.equals(task12) || (hasLabelAstask12 && taskname.equals(task22)) || (hasLabelAstask12 && (pathToOrigin != null && pathToOrigin.getLength() > 0 && pathToDestination != null && pathToDestination.getLength() > 0))) { - if (taskname.equals(task22)) { - if (Task2TaintedTraces.containsKey(taintLabel)) { Task2TaintedTraces.get(taintLabel).add(st.endTime); } else { Vector<String> Task2TracesTD = new Vector<String>(); - Task2TracesTD.add(st.endTime); - Task2TaintedTraces.put(taintLabel, Task2TracesTD); - } - task2DeviceName = st.deviceName; - task2CoreNbr = st.coreNumber; times2.add(endTime); Collections.sort(times2); - } - if (relatedsimTraceswithTaint.containsKey(taintLabel)) { relatedsimTraceswithTaint.get(taintLabel).add(st); } else { - ArrayList<SimulationTransaction> TaskST = new ArrayList<SimulationTransaction>(); - TaskST.add(st); relatedsimTraceswithTaint.put(taintLabel, TaskST); - } - ArrayList<Integer> timeValues = new ArrayList<Integer>(); timeValues.add(0, Integer.valueOf(st.runnableTime)); timeValues.add(1, startTime); - if (!(st.runnableTime).equals(st.startTime)) { - String dName = st.deviceName + "_" + st.coreNumber; - if (runnableTimePerDevice.containsKey(dName)) { - if (!runnableTimePerDevice.get(dName).contains(timeValues)) { runnableTimePerDevice.get(dName).add(timeValues); } } else { - ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>(); timeValuesList.add(timeValues); - runnableTimePerDevice.put(dName, timeValuesList); - } - } - } - - else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) + } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName))) { delayDueTosimTraces.add(st); - } - } else { - if (!taskname.equals(null) && !taskname.equals("")) { - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask1 = DijkstraShortestPath.findPathBetween(g, v1, getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask2 = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (taskname.equals(task12) || (hasLabelAstask12 && taskname.equals(task22)) || (hasLabelAstask12 && (pathExistsTestwithTask1 != null && pathExistsTestwithTask1.getLength() > 0 || pathExistsTestwithTask2 != null && pathExistsTestwithTask2.getLength() > 0))) { - if (taskname.equals(task22)) { - if (Task2TaintedTraces.containsKey(taintLabel)) { Task2TaintedTraces.get(taintLabel).add(st.endTime); } else { Vector<String> Task2TracesTD = new Vector<String>(); - Task2TracesTD.add(st.endTime); - Task2TaintedTraces.put(taintLabel, Task2TracesTD); - } - task2DeviceName = st.deviceName; - task2CoreNbr = st.coreNumber; times2.add(endTime); Collections.sort(times2); - } - if (relatedsimTraceswithTaint.containsKey(taintLabel)) { relatedsimTraceswithTaint.get(taintLabel).add(st); } else { - ArrayList<SimulationTransaction> TaskST = new ArrayList<SimulationTransaction>(); - TaskST.add(st); relatedsimTraceswithTaint.put(taintLabel, TaskST); - } - ArrayList<Integer> timeValues = new ArrayList<Integer>(); timeValues.add(0, Integer.valueOf(st.runnableTime)); timeValues.add(1, startTime); - if (!(st.runnableTime).equals(st.startTime)) { - String dName = st.deviceName + "_" + st.coreNumber; - if (runnableTimePerDevice.containsKey(dName)) { - if (!runnableTimePerDevice.get(dName).contains(timeValues)) { runnableTimePerDevice.get(dName).add(timeValues); } } else { - ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>(); timeValuesList.add(timeValues); - runnableTimePerDevice.put(dName, timeValuesList); - } - } - } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName))) { delayDueTosimTraces.add(st); - } - } } - // } - // } - } - int i = 0; - dataByTask = new Object[Task1TaintedTraces.size()][7]; for (Entry<String, Vector<String>> entry : Task1TaintedTraces.entrySet()) { String labeli = entry.getKey(); - dataByTask[i][0] = task12; dataByTask[i][1] = Task1TaintedTraces.get(labeli).get(0); - Boolean haslabelinTask2 = false; - for (Entry<String, Vector<String>> entry2 : Task2TaintedTraces.entrySet()) { - if (labeli.equals(entry2.getKey())) { dataByTask[i][2] = task22; dataByTask[i][3] = Task2TaintedTraces.get(labeli).get(entry2.getValue().size() - 1); haslabelinTask2 = true; - } } - if (!haslabelinTask2) { - dataByTask[i][2] = "no transaction was found for taint"; - dataByTask[i][3] = "0"; + dataByTask[i][2] = NO_TRANSACTION_FOUND; + dataByTask[i][3] = ZERO; } - int s1 = Integer.valueOf((String) dataByTask[i][1]); int s2 = Integer.valueOf((String) dataByTask[i][3]); - int val = s2 - s1; - if (val >= 0) { dataByTask[i][4] = val; - if (times2.size() <= i) { times2.add(i, s2); } - } else { dataByTask[i][4] = 0; times2.add(i, 0); } - dataByTask[i][5] = ""; - Vector<SimulationTransaction> relatedSTTaint = new Vector<SimulationTransaction>(); - if (relatedsimTraceswithTaint.containsKey(labeli)) { - for (SimulationTransaction st : relatedsimTraceswithTaint.get(labeli)) { - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); - if (!(startTime < s1 && endTime <= s1) && !(startTime >= s2 && endTime > s2)) { - // if (Integer.valueOf(st.startTime) >= minTime && Integer.valueOf(st.startTime) // < maxTime) { - if (endTime > s2) { - endTime = s2; st.endTime = String.valueOf(s2); st.length = String.valueOf(s2 - startTime); } - if (startTime < s1 && endTime != s1) { startTime = s1; st.startTime = String.valueOf(s1); st.length = String.valueOf(endTime - s1); } - if (startTime < s1 && endTime > s2) { endTime = s2; startTime = s1; @@ -3902,43 +2516,30 @@ public class DirectedGraphTranslator extends JApplet { st.length = String.valueOf(s2 - s1); } relatedSTTaint.add(st); - } - } } - dataByTaskR.put(i, relatedSTTaint); - timeDelayedPerRow.put(i, runnableTimePerDevice); - i++; - } - for (int row = 0; row < dataByTask.length; row++) { Vector<SimulationTransaction> delayDueTosimTracesTaint = new Vector<SimulationTransaction>(); - for (SimulationTransaction st : delayDueTosimTraces) { - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); - if (!(startTime < times1.get(row) && endTime <= times1.get(row)) && !(startTime >= times2.get(row) && endTime > times2.get(row))) { - if (endTime > times2.get(row)) { endTime = times2.get(row); st.endTime = times2.get(row).toString(); st.length = String.valueOf(times2.get(row) - startTime); } - if (startTime < times1.get(row)) { startTime = times1.get(row); st.startTime = times1.get(row).toString(); st.length = String.valueOf(endTime - times1.get(row)); } - if (startTime < times1.get(row) && endTime > times2.get(row)) { endTime = times2.get(row); startTime = times1.get(row); @@ -3947,74 +2548,50 @@ public class DirectedGraphTranslator extends JApplet { st.length = String.valueOf(times2.get(row) - times1.get(row)); } delayDueTosimTracesTaint.add(st); - } - } - dataBydelayedTasks.put(row, delayDueTosimTracesTaint); - } - } else - - { - + } else { for (SimulationTransaction st : transFile1) { - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); int selectID = Integer.valueOf(st.id); - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - - if (st.command.contains(selectEventparam) && getvertexFromID(selectID).getType() == 11) { - st.command = st.command.replace(selectEventparam, waitLabel + st.channelName); - + if (st.command.contains(SELECT_EVENT_PARAM) && getvertexFromID(selectID).getType() == 11) { + st.command = st.command.replace(SELECT_EVENT_PARAM, WAIT_LABEL + st.channelName); vertex selectV = getvertexFromID(selectID); - String[] chName = st.channelName.toString().split("__"); - int waitEvntName = chName.length; - String waitEvnt = chName[waitEvntName - 1]; - for (vertex nextV : Graphs.successorListOf(g, selectV)) { - if (nextV.getName().contains(waitEvnt)) { st.id = String.valueOf(nextV.getId()); selectID = nextV.getId(); } } - - } else if (st.command.contains(waitReqLabel)) { + } else if (st.command.contains(WAIT_REQ_LABEL)) { vertex v = getvertexFromID(selectID); if (v.getType() == vertex.TYPE_START) { if (Graphs.vertexHasSuccessors(g, v)) { - for (vertex vbefore : Graphs.successorListOf(g, v)) { - if (vbefore.getName().contains(getReqArgLabel)) { + if (vbefore.getName().contains(GET_REQ_ARG_LABEL)) { st.id = String.valueOf(vbefore.getId()); selectID = vbefore.getId(); } - } - } } } - if (st.id.equals(idTask1) && !times1.contains(startTime)) { Task1Traces.add(st); task1DeviceName = st.deviceName; task1CoreNbr = st.coreNumber; times1.add(startTime); Collections.sort(times1); - } - if (st.id.equals(idTask2) && !times2.contains(endTime)) { Task2Traces.add(st); task2DeviceName = st.deviceName; @@ -4022,7 +2599,6 @@ public class DirectedGraphTranslator extends JApplet { times2.add(endTime); Collections.sort(times1); } - } // one to one int minIndex = 0; @@ -4031,76 +2607,56 @@ public class DirectedGraphTranslator extends JApplet { } else { minIndex = times1.size(); } - dataByTask = new Object[minIndex][7]; dataByTaskBYRow = new Object[minIndex][2]; dataByTaskHWBYRow = new Object[minIndex][2]; - for (int i = 0; i < minIndex; i++) { - HashMap<String, ArrayList<SimulationTransaction>> relatedHWs = new HashMap<String, ArrayList<SimulationTransaction>>(); HashMap<String, ArrayList<SimulationTransaction>> relatedTasks = new HashMap<String, ArrayList<SimulationTransaction>>(); relatedsimTraces = new Vector<SimulationTransaction>(); delayDueTosimTraces = new Vector<SimulationTransaction>(); - runnableTimePerDevice = new HashMap<String, ArrayList<ArrayList<Integer>>>(); - for (SimulationTransaction st : transFile1) { - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); int selectID = Integer.valueOf(st.id); Boolean onPath = false; - if (!(startTime < times1.get(i) && endTime <= times1.get(i)) && !(startTime >= times2.get(i) && endTime > times2.get(i))) { - - if (st.command.contains(selectEventparam) && getvertexFromID(selectID).getType() == 11) { - st.command = st.command.replace(selectEventparam, waitLabel + st.channelName); - + if (st.command.contains(SELECT_EVENT_PARAM) && getvertexFromID(selectID).getType() == 11) { + st.command = st.command.replace(SELECT_EVENT_PARAM, WAIT_LABEL + st.channelName); vertex selectV = getvertexFromID(selectID); - String[] chName = st.channelName.toString().split("__"); - int waitEvntName = chName.length; - String waitEvnt = chName[waitEvntName - 1]; - for (vertex nextV : Graphs.successorListOf(g, selectV)) { - if (nextV.getName().contains(waitEvnt)) { st.id = String.valueOf(nextV.getId()); selectID = nextV.getId(); } } - } else if (st.command.contains(waitReqLabel)) { + } else if (st.command.contains(WAIT_REQ_LABEL)) { vertex v = getvertexFromID(selectID); if (v.getType() == vertex.TYPE_START) { if (Graphs.vertexHasSuccessors(g, v)) { - for (vertex vbefore : Graphs.successorListOf(g, v)) { - if (vbefore.getName().startsWith(getReqArgLabel)) { + if (vbefore.getName().startsWith(GET_REQ_ARG_LABEL)) { st.id = String.valueOf(vbefore.getId()); selectID = vbefore.getId(); } - } - } } } - if (endTime > times2.get(i)) { endTime = times2.get(i); st.endTime = times2.get(i).toString(); st.length = String.valueOf(times2.get(i) - startTime); } - if (startTime < times1.get(i) && endTime != times1.get(i)) { startTime = times1.get(i); st.startTime = String.valueOf(times1.get(i)); st.length = String.valueOf(endTime - times1.get(i)); } - if (startTime < times1.get(i) && endTime > times2.get(i)) { st.startTime = String.valueOf(times1.get(i)); st.endTime = times2.get(i).toString(); @@ -4108,243 +2664,172 @@ public class DirectedGraphTranslator extends JApplet { startTime = times1.get(i); endTime = times2.get(i); } - String taskname = ""; - for (vertex tasknameCheck : g.vertexSet()) { - String[] taskToAdd = tasknameCheck.toString().replaceAll(" ", "").split("__"); - int taskToAddindex = taskToAdd.length; - String taskToAddid = taskToAdd[taskToAddindex - 1]; if (isNumeric(taskToAddid)) { - if (Integer.valueOf(taskToAddid).equals(selectID)) { - taskname = tasknameCheck.toString(); break; - } - } - } String[] name = st.deviceName.split("_"); String deviceName = name[0]; // there is a path between task 1 and task 2 if (path2 != null && path2.getLength() > 0) { - if (!taskname.equals(null) && !taskname.equals("")) { - GraphPath<vertex, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, v1, getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathToDestination = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (taskname.equals(task12) || taskname.equals(task22) || (pathToOrigin != null && pathToOrigin.getLength() > 0 && pathToDestination != null && pathToDestination.getLength() > 0)) { - relatedsimTraces.add(st); ArrayList<Integer> timeValues = new ArrayList<Integer>(); timeValues.add(0, Integer.valueOf(st.runnableTime)); timeValues.add(1, startTime); - String dName = st.deviceName + "_" + st.coreNumber; - if (!(st.runnableTime).equals(st.startTime)) { - if (runnableTimePerDevice.containsKey(dName)) { - if (!runnableTimePerDevice.get(dName).contains(timeValues)) { runnableTimePerDevice.get(dName).add(timeValues); } } else { - ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>(); timeValuesList.add(timeValues); - runnableTimePerDevice.put(dName, timeValuesList); - } - } - } - - else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) + } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) { delayDueTosimTraces.add(st); - } - } - } else { if (!taskname.equals(null) && !taskname.equals("")) { - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask1 = DijkstraShortestPath.findPathBetween(g, v1, getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask2 = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (pathExistsTestwithTask1 != null && pathExistsTestwithTask1.getLength() > 0 || pathExistsTestwithTask2 != null && pathExistsTestwithTask2.getLength() > 0) { relatedsimTraces.add(st); - } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) { delayDueTosimTraces.add(st); - } - } - } - } } - dataByTask[i][0] = task12; dataByTask[i][1] = times1.get(i); dataByTask[i][2] = task22; dataByTask[i][3] = times2.get(i); - if (times2.get(i) - times1.get(i) >= 0) { - dataByTask[i][4] = times2.get(i) - times1.get(i); } else { dataByTask[i][4] = "Assumption Does Not Hold; Please try Tainting"; } dataByTask[i][5] = ""; - dataByTaskR.put(i, relatedsimTraces); dataBydelayedTasks.put(i, delayDueTosimTraces); timeDelayedPerRow.put(i, runnableTimePerDevice); // dataByTask[i][5] = list.getModel(); // dataByTask[i][6] = totalTime; - } - } - return dataByTask; - } public void saveDetailsToXML(String outputFile) { - DocumentBuilder builder; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document dom = builder.newDocument(); - - Element root2 = dom.createElement(transactions); + Element root2 = dom.createElement(TRANSACTIONS); dom.appendChild(root2); // write DOM to XML file - - Element root1 = dom.createElement(mandatory); + Element root1 = dom.createElement(MANDATORY); root2.appendChild(root1); // write DOM to XML file - for (int i = 0; i < onPath.size(); i++) { - SimulationTransaction st = onPath.get(i); - // first create root element - Element root = dom.createElement(stLAbel); + Element root = dom.createElement(ST_LABEL); root1.appendChild(root); - // set `id` attribute to root element - Attr attr = dom.createAttribute(idLabel); + Attr attr = dom.createAttribute(ID_LABEL); attr.setValue(st.id); root.setAttributeNode(attr); - // now create child elements - Element operator = dom.createElement(operatorLabel); + Element operator = dom.createElement(OPERATOR_LABEL); operator.setTextContent(st.command); - Element start = dom.createElement(startTimeLabel); + Element start = dom.createElement(START_TIME_LABEL); start.setTextContent(st.startTime); - Element et = dom.createElement(endTimeLabel); + Element et = dom.createElement(END_TIME_LABEL); et.setTextContent(st.endTime); - Element l = dom.createElement(lengthLabel); + Element l = dom.createElement(LENGTH_LABEL); l.setTextContent(st.length); - // add child nodes to root node root.appendChild(operator); root.appendChild(start); root.appendChild(et); root.appendChild(l); - } - - Element root3 = dom.createElement(noContentionLabel); + Element root3 = dom.createElement(NO_CONTENTION_LABEL); root2.appendChild(root3); // write DOM to XML file - for (int i = 0; i < offPath.size(); i++) { - SimulationTransaction st = offPath.get(i); - // first create root element - Element root5 = dom.createElement(stLAbel); + Element root5 = dom.createElement(ST_LABEL); root3.appendChild(root5); - // set `id` attribute to root element - Attr attr = dom.createAttribute(idLabel); + Attr attr = dom.createAttribute(ID_LABEL); attr.setValue(st.id); root5.setAttributeNode(attr); - // now create child elements - Element operator = dom.createElement(operatorLabel); + Element operator = dom.createElement(OPERATOR_LABEL); operator.setTextContent(st.command); - Element start = dom.createElement(startTimeLabel); + Element start = dom.createElement(START_TIME_LABEL); start.setTextContent(st.startTime); - Element et = dom.createElement(endTimeLabel); + Element et = dom.createElement(END_TIME_LABEL); et.setTextContent(st.endTime); - Element l = dom.createElement(lengthLabel); + Element l = dom.createElement(LENGTH_LABEL); l.setTextContent(st.length); - // add child nodes to root node root5.appendChild(operator); root5.appendChild(start); root5.appendChild(et); root5.appendChild(l); - } - - Element root4 = dom.createElement(contentionLabel); + Element root4 = dom.createElement(CONTENTION_LABEL); root2.appendChild(root4); // write DOM to XML file - for (int i = 0; i < offPathDelay.size(); i++) { - SimulationTransaction st = offPathDelay.get(i); - // first create root element - Element root6 = dom.createElement(stLAbel); + Element root6 = dom.createElement(ST_LABEL); root4.appendChild(root6); - // set `id` attribute to root element - Attr attr = dom.createAttribute(idLabel); + Attr attr = dom.createAttribute(ID_LABEL); attr.setValue(st.id); root6.setAttributeNode(attr); - // now create child elements - Element operator = dom.createElement(operatorLabel); + Element operator = dom.createElement(OPERATOR_LABEL); operator.setTextContent(st.command); - Element start = dom.createElement(startTimeLabel); + Element start = dom.createElement(START_TIME_LABEL); start.setTextContent(st.startTime); - Element et = dom.createElement(endTimeLabel); + Element et = dom.createElement(END_TIME_LABEL); et.setTextContent(st.endTime); - Element l = dom.createElement(lengthLabel); + Element l = dom.createElement(LENGTH_LABEL); l.setTextContent(st.length); - // add child nodes to root node root6.appendChild(operator); root6.appendChild(start); root6.appendChild(et); root6.appendChild(l); - } Transformer tr; try { @@ -4356,133 +2841,106 @@ public class DirectedGraphTranslator extends JApplet { // TODO Auto-generated catch block e.printStackTrace(); } - } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } - } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } public void saveLAtencyValuesToXML(String outputFile) { - DocumentBuilder builder; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document dom = builder.newDocument(); - - Element root1 = dom.createElement(latencyTableLabel); + Element root1 = dom.createElement(LATENCY_TABLE_LABEL); dom.appendChild(root1); - for (int id = 0; id < dataByTask.length; id++) { - String starttime = String.valueOf(dataByTask[id][1]); String endtime = String.valueOf(dataByTask[id][3]); String latency = String.valueOf(dataByTask[id][4]); - String op1 = String.valueOf(dataByTask[id][0]); String op2 = String.valueOf(dataByTask[id][2]); - // first create root element - Element root = dom.createElement(rowLabel); + Element root = dom.createElement(ROW_LABEL); root1.appendChild(root); - // set `id` attribute to root element - Attr attr = dom.createAttribute(idLabel); + Attr attr = dom.createAttribute(ID_LABEL); attr.setValue(String.valueOf(id)); root.setAttributeNode(attr); - // now create child elements - Element operator1 = dom.createElement(op1); + Element operator1 = dom.createElement(OPERATOR_1); operator1.setTextContent(op1); - Element operator2 = dom.createElement(op2); + Element operator2 = dom.createElement(OPERATOR_2); operator2.setTextContent(op2); - Element st = dom.createElement(startTimeLabel); + Element st = dom.createElement(START_TIME_LABEL); st.setTextContent(starttime); - Element et = dom.createElement(endTimeLabel); + Element et = dom.createElement(END_TIME_LABEL); et.setTextContent(endtime); - Element lat = dom.createElement(latencyLabel); + Element lat = dom.createElement(LATENCY_LABEL); lat.setTextContent(latency); - // add child nodes to root node root.appendChild(operator1); root.appendChild(st); root.appendChild(operator2); root.appendChild(et); root.appendChild(lat); - } - // for (int id = 0; id < dataByTaskMinMax.length; id++) { - String starttime = String.valueOf(dataByTaskMinMax[0][1]); String endtime = String.valueOf(dataByTaskMinMax[0][3]); String latency = String.valueOf(dataByTaskMinMax[0][4]); - String op1 = String.valueOf(dataByTaskMinMax[0][0]); String op2 = String.valueOf(dataByTaskMinMax[0][2]); - // first create root element - Element root = dom.createElement(minLabel); + Element root = dom.createElement(MIN_LABEL); root1.appendChild(root); - // now create child elements Element operator1 = dom.createElement(op1); operator1.setTextContent(op1); Element operator2 = dom.createElement(op2); operator2.setTextContent(op2); - Element st = dom.createElement(startTimeLabel); + Element st = dom.createElement(START_TIME_LABEL); st.setTextContent(starttime); - Element et = dom.createElement(endTimeLabel); + Element et = dom.createElement(END_TIME_LABEL); et.setTextContent(endtime); - Element lat = dom.createElement(latencyLabel); + Element lat = dom.createElement(LATENCY_LABEL); lat.setTextContent(latency); - // add child nodes to root node root.appendChild(operator1); root.appendChild(st); root.appendChild(operator2); root.appendChild(et); root.appendChild(lat); - String starttimeMax = String.valueOf(dataByTaskMinMax[1][1]); String endtimeMax = String.valueOf(dataByTaskMinMax[1][3]); String latencyMax = String.valueOf(dataByTaskMinMax[1][4]); - String op1Max = String.valueOf(dataByTaskMinMax[1][0]); String op2Max = String.valueOf(dataByTaskMinMax[1][2]); - // first create root element - Element rootMax = dom.createElement(maxLabel); + Element rootMax = dom.createElement(MAX_LABEL); root1.appendChild(rootMax); - // now create child elements Element operator1Max = dom.createElement(op1); operator1Max.setTextContent(op1Max); Element operator2Max = dom.createElement(op2); operator2Max.setTextContent(op2Max); - Element stMax = dom.createElement(startTimeLabel); + Element stMax = dom.createElement(START_TIME_LABEL); stMax.setTextContent(starttimeMax); - Element etMax = dom.createElement(endTimeLabel); + Element etMax = dom.createElement(END_TIME_LABEL); etMax.setTextContent(endtimeMax); - Element latMax = dom.createElement(latencyLabel); + Element latMax = dom.createElement(LATENCY_LABEL); latMax.setTextContent(latencyMax); - // add child nodes to root node rootMax.appendChild(operator1Max); rootMax.appendChild(stMax); rootMax.appendChild(operator2Max); rootMax.appendChild(etMax); rootMax.appendChild(latMax); - // } - // write DOM to XML file Transformer tr; try { @@ -4494,48 +2952,34 @@ public class DirectedGraphTranslator extends JApplet { // TODO Auto-generated catch block e.printStackTrace(); } - } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) { // TODO Auto-generated catch block e.printStackTrace(); } - } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } private String getfirstCommonLabel(vertex vertex, vertex v) { - for (int i = 0; i < v.getLabel().size(); i++) { if (!vertex.getLabel().contains(v.getLabel().get(i))) { return v.getLabel().get(i); - } } - for (int j = 0; j < v.getLabel().size(); j++) { if (vertex.getMaxTaintFixedNumber().containsKey(v.getLabel().get(j)) && vertex.getMaxTaintFixedNumber().get(v.getLabel().get(j)) == 0) { - return v.getLabel().get(j); - } - } - for (int j = 0; j < v.getLabel().size(); j++) { if (vertex.getTaintConsideredNumber().containsKey(v.getLabel().get(j)) && vertex.getTaintConsideredNumber().get(v.getLabel().get(j)) < vertex.getMaxTaintFixedNumber().get(v.getLabel().get(j))) { - return v.getLabel().get(j); - } - } // TODO Auto-generated method stub - if (v.getLabel().size() - 1 >= 0) { return v.getLabel().get(v.getLabel().size() - 1); } @@ -4543,365 +2987,222 @@ public class DirectedGraphTranslator extends JApplet { } private Boolean considerVertex(String task12, String taskname, String virtualLength, String command) { - boolean hasLabelAstask12 = false; - vertex v1 = getvertex(task12); vertex v = getvertex(taskname); String Label = null; - - if (command.contains("Write") || command.contains("Read")) { - + if (command.contains(WRITE) || command.contains(READ)) { String[] str = command.split(","); String[] str2 = null; - if (command.contains("Write")) { - str2 = str[0].split("Write"); - } else if (command.contains("Read")) { - str2 = str[0].split("Read"); + if (command.contains(WRITE)) { + str2 = str[0].split(WRITE); + } else if (command.contains(READ)) { + str2 = str[0].split(READ); } - if (str2[1].trim().matches("\\d*")) { - int snbr = Integer.parseInt(str2[1].trim()); - if (v.getSampleNumber() != snbr) { v.setSampleNumber(snbr); } } - if (v.getVirtualLengthAdded() < v.getSampleNumber()) { - v.setVirtualLengthAdded(v.getVirtualLengthAdded() + Integer.parseInt(virtualLength)); - } - } - for (int i = 0; i < v.getLabel().size(); i++) { - String labelConsidered = v.getLabel().get(i); - int consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); - if (Graphs.vertexHasPredecessors(g, v)) { for (vertex previousV : Graphs.predecessorListOf(g, v)) { if (previousV.getType() == vertex.TYPE_CHOICE) { - for (Entry<vertex, List<vertex>> vChoice : allChoiceValues.entrySet()) { - if (previousV.equals(vChoice.getKey())) { - if (v1.getLabel().contains(v.getLabel().get(i)) && consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { - consideredNbr = vChoice.getKey().getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - vChoice.getKey().getTaintConsideredNumber().put(labelConsidered, consideredNbr); - consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - Label = labelConsidered; hasLabelAstask12 = true; - v.setVirtualLengthAdded(0); } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } } - } if (previousV.getType() == vertex.TYPE_SELECT_EVT) { - for (Entry<vertex, List<vertex>> vChoice : allSelectEvtValues.entrySet()) { - if (previousV.equals(vChoice.getKey())) { - if (v1.getLabel().contains(v.getLabel().get(i)) && consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { - consideredNbr = vChoice.getKey().getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - vChoice.getKey().getTaintConsideredNumber().put(labelConsidered, consideredNbr); - consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - Label = labelConsidered; hasLabelAstask12 = true; - v.setVirtualLengthAdded(0); } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } } - } else if (previousV.getType() == vertex.TYPE_SEQ) { - for (Entry<vertex, List<vertex>> vSeq : allSeqValues.entrySet()) { - if (previousV.equals(vSeq.getKey())) { - if (v1.getLabel().contains(v.getLabel().get(i)) && consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { consideredNbr = vSeq.getKey().getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - vSeq.getKey().getTaintConsideredNumber().put(labelConsidered, consideredNbr); - consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); Label = labelConsidered; - hasLabelAstask12 = true; - v.setVirtualLengthAdded(0); - } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } - } } else if (previousV.getType() == vertex.TYPE_UNORDER_SEQ) { - if (v1.getLabel().contains(v.getLabel().get(i)) && consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { if (v.getVirtualLengthAdded() == v.getSampleNumber()) { consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - hasLabelAstask12 = true; - v.setVirtualLengthAdded(0); - for (Entry<vertex, List<vertex>> vSeq : allRandomSeqValues.entrySet()) { - if (previousV.equals(vSeq.getKey())) { - int count = 0; - for (vertex seqNext : vSeq.getValue()) { - if (seqNext.getTaintConsideredNumber().get(labelConsidered) != seqNext.getMaxTaintFixedNumber() .get(labelConsidered)) { count++; - } - } - if (count == 0) { - if (previousV.getLabel().contains(labelConsidered)) { - consideredNbr = previousV.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - previousV.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - } - } - } - } - } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } else if ((previousV.getType() == vertex.TYPE_FOR_LOOP || previousV.getType() == vertex.TYPE_STATIC_FOR_LOOP) && (previousV.getLabel().contains(labelConsidered))) { - if (v1.getLabel().contains(v.getLabel().get(i)) && (previousV.getTaintConsideredNumber() .get(labelConsidered) == previousV.getMaxTaintFixedNumber().get(labelConsidered) - 1)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { - for (Entry<String, List<String>> nextvertexOfLoop : allForLoopNextValues.entrySet()) { - vertex vFor1 = getvertex(nextvertexOfLoop.getValue().get(1)); - if (v.getName().equals(previousV.getName())) { consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - consideredNbr = previousV.getTaintConsideredNumber().get(labelConsidered); consideredNbr++; - previousV.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - hasLabelAstask12 = true; } - } - v.setVirtualLengthAdded(0); - } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } - } - } if (Graphs.vertexHasSuccessors(g, v)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { - for (vertex nextV : Graphs.successorListOf(g, v)) { - if (nextV.getType() == vertex.TYPE_END) { - if (nextV.getLabel().contains(labelConsidered)) { - consideredNbr = nextV.getTaintConsideredNumber().get(labelConsidered); - if (consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { consideredNbr++; - nextV.getTaintConsideredNumber().put(labelConsidered, consideredNbr); } - for (vertex subE : Graphs.successorListOf(g, nextV)) { - if (subE.getType() == vertex.TYPE_FOR_LOOP || subE.getType() == vertex.TYPE_STATIC_FOR_LOOP) { consideredNbr = subE.getTaintConsideredNumber().get(labelConsidered); - if (consideredNbr < subE.getMaxTaintFixedNumber().get(labelConsidered)) { consideredNbr++; - subE.getTaintConsideredNumber().put(labelConsidered, consideredNbr); } - } - } } - } else if (nextV.getType() == vertex.TYPE_START) { - consideredNbr = nextV.getTaintConsideredNumber().get(labelConsidered); - if (consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { consideredNbr++; - nextV.getTaintConsideredNumber().put(labelConsidered, consideredNbr); } - } - } - } } - - if (!hasLabelAstask12 && (v.getType() == vertex.TYPE_TRANSACTION || v.getType() == vertex.TYPE_CHANNEL)) - - { - + if (!hasLabelAstask12 && (v.getType() == vertex.TYPE_TRANSACTION || v.getType() == vertex.TYPE_CHANNEL)) { consideredNbr = v.getTaintConsideredNumber().get(labelConsidered); - if (v1.getLabel().contains(v.getLabel().get(i)) && consideredNbr < v.getMaxTaintFixedNumber().get(labelConsidered)) { - if (v.getVirtualLengthAdded() == v.getSampleNumber()) { - consideredNbr++; - v.getTaintConsideredNumber().put(labelConsidered, consideredNbr); - Label = labelConsidered; - hasLabelAstask12 = true; v.setVirtualLengthAdded(0); - } else { Label = labelConsidered; hasLabelAstask12 = true; - } - } - } - } - taintLabel = Label; return hasLabelAstask12; - } private HashMap<vertex, List<vertex>> taintingNonTransVertexes(vertex subV, vertex v, vertex v1) { - HashMap<vertex, List<vertex>> NonTransV = new LinkedHashMap<vertex, List<vertex>>(); String label = getfirstCommonLabel(subV, v); int i = v.getMaxTaintFixedNumber().get(label); ; - if (v.getType() == vertex.TYPE_FOR_EVER_LOOP || v.getType() == vertex.TYPE_STATIC_FOR_LOOP || v.getType() == vertex.TYPE_FOR_LOOP) { for (Entry<String, List<String>> nextvertexOfLoop : allForLoopNextValues.entrySet()) { - vertex vFor0 = getvertex(nextvertexOfLoop.getValue().get(0)); vertex vFor1 = getvertex(nextvertexOfLoop.getValue().get(1)); - if ((getvertex(nextvertexOfLoop.getKey())).equals(v)) { - if (subV.equals(vFor1)) { int max = subV.getMaxTaintFixedNumber().get(label) / subV.getTaintFixedNumber(); i = max; } } - } - } - if (subV.getType() == vertex.TYPE_FOR_EVER_LOOP) { - if (subV.getLabel().contains(label)) { if (subV.getMaxTaintFixedNumber().containsKey(label)) { if (subV.getMaxTaintFixedNumber().get(label) != i) { @@ -4911,16 +3212,12 @@ public class DirectedGraphTranslator extends JApplet { subV.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * i); } } - } else { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - for (vertex subFor : Graphs.successorListOf(g, subV)) { - if (!subFor.equals(v1)) { - /* * if (subFor.getLabel().contains(label)) { if * (subFor.getMaxTaintFixedNumber().containsKey(label)) { if @@ -4932,31 +3229,22 @@ public class DirectedGraphTranslator extends JApplet { * * } */ - if (!subFor.getLabel().contains(label)) { subFor.addLabel(label); subFor.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * subFor.getTaintFixedNumber()); } - if (subFor.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subFor); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subFor); NonTransV.put(subV, lv); - } - } } - } - } else if ((subV.getType() == vertex.TYPE_STATIC_FOR_LOOP || subV.getType() == vertex.TYPE_FOR_LOOP)) { - /* * if (subV.getLabel().contains(label)) { if * (subV.getMaxTaintFixedNumber().containsKey(label)) { if @@ -4969,21 +3257,15 @@ public class DirectedGraphTranslator extends JApplet { * * } */ - if (!subV.getLabel().contains(label)) { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - for (Entry<String, List<String>> nextvertexOfLoop : allForLoopNextValues.entrySet()) { - vertex vFor0 = getvertex(nextvertexOfLoop.getValue().get(0)); vertex vFor1 = getvertex(nextvertexOfLoop.getValue().get(1)); - if ((getvertex(nextvertexOfLoop.getKey())).equals(subV)) { - if (!vFor0.equals(v1)) { - /* * if (vFor0.getLabel().contains(label)) { if * (vFor0.getMaxTaintFixedNumber().containsKey(label)) { if @@ -4993,32 +3275,22 @@ public class DirectedGraphTranslator extends JApplet { * * } */ - if (!vFor0.getLabel().contains(label)) { vFor0.addLabel(label); vFor0.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * vFor0.getTaintFixedNumber()); } - if (vFor0.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(vFor0); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(vFor0); NonTransV.put(subV, lv); - } - } - } - if (!vFor1.equals(v1)) { - int max = subV.getMaxTaintFixedNumber().get(label) / subV.getTaintFixedNumber(); - /* * if (vFor1.getLabel().contains(label)) { if * (vFor1.getMaxTaintFixedNumber().containsKey(label)) { @@ -5033,28 +3305,19 @@ public class DirectedGraphTranslator extends JApplet { vFor1.addLabel(label); vFor1.getMaxTaintFixedNumber().put(label, vFor1.getTaintFixedNumber() * max); } - if (vFor1.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(vFor1); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(vFor1); NonTransV.put(subV, lv); - } - } - } - } } - } else if (subV.getType() == vertex.TYPE_CHOICE) { - /* * if (subV.getLabel().contains(label)) { if * (subV.getMaxTaintFixedNumber().containsKey(label)) { if @@ -5070,295 +3333,211 @@ public class DirectedGraphTranslator extends JApplet { subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } List<vertex> subChoice = new ArrayList<vertex>(); - for (vertex subCh : Graphs.successorListOf(g, subV)) { - subChoice.add(subCh); - if (!subCh.equals(v1)) { - if (subCh.getLabel().contains(label)) { if (subCh.getMaxTaintFixedNumber().containsKey(label)) { if (subCh.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subCh.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * subCh.getTaintFixedNumber())); - subCh.getMaxTaintFixedNumber().put(label, subCh.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } - } - } else { subCh.addLabel(label); subCh.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * subCh.getTaintFixedNumber()); } - if (subCh.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subCh); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subCh); NonTransV.put(subV, lv); - } - } } - } - allChoiceValues.put(subV, subChoice); - } else if (subV.getType() == vertex.TYPE_SELECT_EVT) { - if (!subV.getLabel().contains(label)) { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } List<vertex> subChoice = new ArrayList<vertex>(); - for (vertex subCh : Graphs.successorListOf(g, subV)) { - subChoice.add(subCh); - if (!subCh.equals(v1)) { - if (subCh.getLabel().contains(label)) { if (subCh.getMaxTaintFixedNumber().containsKey(label)) { if (subCh.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subCh.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * subCh.getTaintFixedNumber())); - subCh.getMaxTaintFixedNumber().put(label, subCh.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } - } - } else { subCh.addLabel(label); subCh.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * subCh.getTaintFixedNumber()); } - if (subCh.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subCh); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subCh); NonTransV.put(subV, lv); - } - } } - } - allSelectEvtValues.put(subV, subChoice); - } else if (subV.getType() == vertex.TYPE_END) { - if (subV.getLabel().contains(label)) { if (subV.getMaxTaintFixedNumber().containsKey(label)) { if (subV.getMaxTaintFixedNumber().get(label) != i) { // subV.getMaxTaintFixedNumber().put(label, // subV.getMaxTaintFixedNumber().get(label) * i * subV.getTaintFixedNumber()); - subV.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * i); } } - } else { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - for (vertex subSE : Graphs.successorListOf(g, subV)) { - if (!subSE.equals(v1)) { - if (subSE.getType() == vertex.TYPE_STATIC_FOR_LOOP || subSE.getType() == vertex.TYPE_FOR_LOOP) { - if (subSE.getLabel().contains(label)) { if (subSE.getMaxTaintFixedNumber().containsKey(label)) { if (subSE.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subSE.getMaxTaintFixedNumber().put(label, subSE.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } } - } else { subSE.addLabel(label); subSE.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label)); } - for (Entry<String, List<String>> nextvertexOfLoop : allForLoopNextValues.entrySet()) { if ((getvertex(nextvertexOfLoop.getKey())).equals(subSE)) { - vertex vFor1 = getvertex(nextvertexOfLoop.getValue().get(1)); - int max; - if (subSE.getMaxTaintFixedNumber().get(label) > 0 && subSE.getTaintFixedNumber() > 0) { max = subSE.getMaxTaintFixedNumber().get(label) / subSE.getTaintFixedNumber(); } else { max = subSE.getTaintFixedNumber(); } - if (!vFor1.equals(v1)) { - if (vFor1.getLabel().contains(label)) { if (vFor1.getMaxTaintFixedNumber().containsKey(label)) { - if (vFor1.getMaxTaintFixedNumber().get(label) != max) { vFor1.getMaxTaintFixedNumber().put(label, vFor1.getMaxTaintFixedNumber().get(label) * max); } } - } else { vFor1.addLabel(label); vFor1.getMaxTaintFixedNumber().put(label, vFor1.getTaintFixedNumber() * max); } - if (vFor1.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subSE)) { NonTransV.get(subSE).add(vFor1); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(vFor1); NonTransV.put(subSE, lv); - } - } } - } - } } else if (subSE.getType() == vertex.TYPE_TRANSACTION) { - if (subSE.getLabel().contains(label)) { if (subSE.getMaxTaintFixedNumber().containsKey(label)) { if (subSE.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subSE.getMaxTaintFixedNumber().put(label, subSE.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } } - } else { subSE.addLabel(label); subSE.getMaxTaintFixedNumber().put(label, subSE.getTaintFixedNumber() * subV.getMaxTaintFixedNumber().get(label)); } - } else if (subSE.getType() == vertex.TYPE_FOR_EVER_LOOP) { - if (subSE.getLabel().contains(label)) { if (subSE.getMaxTaintFixedNumber().containsKey(label)) { if (subSE.getMaxTaintFixedNumber().get(label) != subSE.getTaintFixedNumber()) { subSE.getMaxTaintFixedNumber().put(label, subSE.getTaintFixedNumber()); } } - } else { subSE.addLabel(label); subSE.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label)); } - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subSE); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subSE); NonTransV.put(subV, lv); - } - } else { - if (subSE.getLabel().contains(label)) { if (subSE.getMaxTaintFixedNumber().containsKey(label)) { if (subSE.getMaxTaintFixedNumber().get(label) != i * subSE.getTaintFixedNumber()) { subSE.getMaxTaintFixedNumber().put(label, i * subSE.getTaintFixedNumber()); } } - } else { subSE.addLabel(label); subSE.getMaxTaintFixedNumber().put(label, subSE.getTaintFixedNumber()); } - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subSE); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subSE); NonTransV.put(subV, lv); - } - } - } } } else if (subV.getType() == vertex.TYPE_START || subV.getType() == vertex.TYPE_CTRL) { - if (subV.getLabel().contains(label)) { if (subV.getMaxTaintFixedNumber().containsKey(label)) { if (subV.getMaxTaintFixedNumber().get(label) != i) { // subV.getMaxTaintFixedNumber().put(label, // subV.getMaxTaintFixedNumber().get(label) * i * subV.getTaintFixedNumber()); - subV.getMaxTaintFixedNumber().put(label, subV.getMaxTaintFixedNumber().get(label) * i); } } - } else { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - for (vertex subSE : Graphs.successorListOf(g, subV)) { - if (!subSE.equals(v1)) { - if (subSE.getLabel().contains(label)) { if (subSE.getMaxTaintFixedNumber().containsKey(label)) { if (subSE.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subSE.getMaxTaintFixedNumber().put(label, subSE.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } } - } else { subSE.addLabel(label); subSE.getMaxTaintFixedNumber().put(label, subSE.getTaintFixedNumber() * subV.getMaxTaintFixedNumber().get(label)); } - if (subSE.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subSE); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subSE); NonTransV.put(subV, lv); - } } - } } - } else if (subV.getType() == vertex.TYPE_SEQ) { - /* * if (subV.getLabel().contains(label)) { if * (subV.getMaxTaintFixedNumber().containsKey(label)) { if @@ -5373,47 +3552,33 @@ public class DirectedGraphTranslator extends JApplet { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - List<vertex> subSeq = new ArrayList<vertex>(); - for (vertex subSEQ : Graphs.successorListOf(g, subV)) { - if (!subSEQ.equals(v1)) { - if (subSEQ.getLabel().contains(label)) { if (subSEQ.getMaxTaintFixedNumber().containsKey(label)) { if (subSEQ.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { subSEQ.getMaxTaintFixedNumber().put(label, subSEQ.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } } - } else { subSEQ.addLabel(label); subSEQ.getMaxTaintFixedNumber().put(label, subSEQ.getTaintFixedNumber() * subV.getMaxTaintFixedNumber().get(label)); } - if (subSEQ.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(subSEQ); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(subSEQ); NonTransV.put(subV, lv); - } } - } - subSeq.add(subSEQ); - } - allSeqValues.put(subV, subSeq); } else if (subV.getType() == vertex.TYPE_UNORDER_SEQ) { - /* * if (subV.getLabel().contains(label)) { if * (subV.getMaxTaintFixedNumber().containsKey(label)) { if @@ -5428,20 +3593,13 @@ public class DirectedGraphTranslator extends JApplet { subV.addLabel(label); subV.getMaxTaintFixedNumber().put(label, i * subV.getTaintFixedNumber()); } - List<vertex> subSeq = new ArrayList<vertex>(); - List<vertex> preSeq = Graphs.predecessorListOf(g, subV); - for (vertex sub_UN_SEQ : Graphs.successorListOf(g, subV)) { - if (preSeq.contains(sub_UN_SEQ)) { continue; - } - if (!sub_UN_SEQ.equals(v1)) { - if (sub_UN_SEQ.getLabel().contains(label)) { if (sub_UN_SEQ.getMaxTaintFixedNumber().containsKey(label)) { if (sub_UN_SEQ.getMaxTaintFixedNumber().get(label) != subV.getMaxTaintFixedNumber().get(label)) { @@ -5449,67 +3607,49 @@ public class DirectedGraphTranslator extends JApplet { sub_UN_SEQ.getMaxTaintFixedNumber().get(label) * subV.getTaintFixedNumber()); } } - } else { sub_UN_SEQ.addLabel(label); sub_UN_SEQ.getMaxTaintFixedNumber().put(label, sub_UN_SEQ.getTaintFixedNumber() * subV.getMaxTaintFixedNumber().get(label)); } - if (sub_UN_SEQ.getType() != vertex.TYPE_TRANSACTION) { - if (NonTransV.containsKey(subV)) { NonTransV.get(subV).add(sub_UN_SEQ); } else { - List<vertex> lv = new ArrayList<vertex>(); lv.add(sub_UN_SEQ); NonTransV.put(subV, lv); - } } - } - subSeq.add(sub_UN_SEQ); - } - allRandomSeqValues.put(subV, subSeq); } - return NonTransV; - } protected vertex getvertex(String task12) { - for (vertex v : g.vertexSet()) { if (v.getName().equals(task12)) { return v; } } return null; - } protected vertex getvertexFromID(int id) { - for (vertex v : g.vertexSet()) { if (v.getId() == (id)) { return v; } } return null; - } private void addTaint(vertex currentVertex) { - String label = generateLabel(); boolean generatenewLabel = false; - while (!generatenewLabel) { - int count = 0; for (int i = 0; i < usedLabels.size(); i++) { if (usedLabels.contains(label.toString())) { @@ -5519,300 +3659,208 @@ public class DirectedGraphTranslator extends JApplet { } if (count > 0) { label = generateLabel(); - } else { generatenewLabel = true; - } } - usedLabels.add(label.toString()); currentVertex.addLabel(label.toString()); - currentVertex.getMaxTaintFixedNumber().put(label.toString(), currentVertex.getTaintFixedNumber()); - return; } private String generateLabel() { - StringBuilder label = new StringBuilder(8); - for (int i = 0; i < 8; i++) { - - char rndChar = data.charAt(random.nextInt(data.length())); + char rndChar = DATA.charAt(random.nextInt(DATA.length())); label.append(rndChar); - } - return label.toString(); - } // fill the detailed latency table once a row is selected public String[][] getTaskByRowDetails(int row) { - String[][] dataByTaskRowDetails = new String[dataByTaskR.get(row).size()][5]; - int i = 0; - for (SimulationTransaction st : dataByTaskR.get(row)) { dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); - dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; dataByTaskRowDetails[i][3] = st.startTime; dataByTaskRowDetails[i][4] = st.endTime; i++; } - return dataByTaskRowDetails; } // fill the detailed latency table once a row is selected public Object[][] getTaskByRowDetailsMinMaxTaint(int row) { - String task12 = (String) dataByTaskMinMax[row][0]; int maxStartTime = (int) dataByTaskMinMax[row][1]; String task22 = (String) dataByTaskMinMax[row][2]; int maxEndTime = (int) dataByTaskMinMax[row][3]; - int rowIndex = 0; - for (int i = 0; i < dataByTask.length; i++) { - int s1 = Integer.valueOf((String) dataByTask[i][1]); int s2 = Integer.valueOf((String) dataByTask[i][3]); - if (s1 == maxStartTime && s2 == maxEndTime) { rowIndex = i; break; - } - } - Object[][] dataByTaskRowDetails = new Object[dataByTaskR.get(rowIndex).size()][5]; - int i = 0; - for (SimulationTransaction st : dataByTaskR.get(rowIndex)) { dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); - dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime); dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime); i++; } - return dataByTaskRowDetails; } // fill the tasks that run on the same hardware but don't belong to the path // between selected activities public Object[][] getTaskHWByRowDetailsMinMaxTaint(int row) { - String task12 = (String) dataByTaskMinMax[row][0]; int maxStartTime = (int) dataByTaskMinMax[row][1]; String task22 = (String) dataByTaskMinMax[row][2]; int maxEndTime = (int) dataByTaskMinMax[row][3]; - int rowIndex = 0; - for (int i = 0; i < dataByTask.length; i++) { - int s1 = Integer.valueOf((String) dataByTask[i][1]); int s2 = Integer.valueOf((String) dataByTask[i][3]); - if (s1 == maxStartTime && s2 == maxEndTime) { rowIndex = i; break; - } - } - Object[][] dataByTaskRowDetails = new Object[dataBydelayedTasks.get(rowIndex).size()][5]; - int i = 0; - for (SimulationTransaction st : dataBydelayedTasks.get(rowIndex)) { - dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime); dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime); - i++; } - return dataByTaskRowDetails; } // fill the detailed latency table once a row is selected public List<SimulationTransaction> getRowDetailsTaks(int row) { - return dataByTaskR.get(row); } public Vector<SimulationTransaction> getMinMaxTasksByRowTainted(int row) { - int maxStartTime = (int) dataByTaskMinMax[row][1]; - int maxEndTime = (int) dataByTaskMinMax[row][3]; - int rowIndex = 0; - for (int i = 0; i < dataByTask.length; i++) { - int s1 = Integer.valueOf((String) dataByTask[i][1]); int s2 = Integer.valueOf((String) dataByTask[i][3]); - if (s1 == maxStartTime && s2 == maxEndTime) { rowIndex = i; break; - } - } - return dataByTaskR.get(rowIndex); } // between selected activities public List<SimulationTransaction> getTaskMinMaxHWByRowDetailsTainted(int row) { - int maxStartTime = (int) dataByTaskMinMax[row][1]; - int maxEndTime = (int) dataByTaskMinMax[row][3]; - int rowIndex = 0; - for (int i = 0; i < dataByTask.length; i++) { - int s1 = Integer.valueOf((String) dataByTask[i][1]); int s2 = Integer.valueOf((String) dataByTask[i][3]); - if (s1 == maxStartTime && s2 == maxEndTime) { rowIndex = i; break; - } - } - return dataBydelayedTasks.get(rowIndex); } // fill the detailed latency table once a row is selected public List<SimulationTransaction> getRowDetailsByHW(int row) { - return dataBydelayedTasks.get(row); } // fill the detailed latency table once a row is selected public HashMap<String, ArrayList<ArrayList<Integer>>> getRowDelayDetailsByHW(int row) { - return timeDelayedPerRow.get(row); } // fill the detailed latency table once a row is selected from min/max table public Vector<SimulationTransaction> getMinMaxTasksByRow(int row) { - return relatedsimTraces; } // fill the tasks that run on the same hardware but don't belong to the path // between selected activities public Vector<SimulationTransaction> getTaskMinMaxHWByRowDetails(int row) { - return delayDueTosimTraces; } // get the details of the delay for a selected min or max delay row public void getRowDetailsMinMax(int row) { - String task12 = (String) dataByTaskMinMax[row][0]; int minTime = (int) dataByTaskMinMax[row][1]; String task22 = (String) dataByTaskMinMax[row][2]; int maxTime = (int) dataByTaskMinMax[row][3]; - HashMap<String, ArrayList<SimulationTransaction>> relatedHWs = new HashMap<String, ArrayList<SimulationTransaction>>(); HashMap<String, ArrayList<SimulationTransaction>> relatedTasks = new HashMap<String, ArrayList<SimulationTransaction>>(); relatedsimTraces = new Vector<SimulationTransaction>(); delayDueTosimTraces = new Vector<SimulationTransaction>(); runnableTimePerDevice = new HashMap<String, ArrayList<ArrayList<Integer>>>(); - // AllDirectedPaths<String, DefaultEdge> allPaths = new AllDirectedPaths<String, // DefaultEdge>(g); - // List<GraphPath<String, DefaultEdge>> path = allPaths.getAllPaths(task12, // task22, false, g.vertexSet().size()); - // int size = path.size(); - GraphPath<vertex, DefaultEdge> path2 = DijkstraShortestPath.findPathBetween(g, getvertex(task12), getvertex(task22)); - if (path2 != null && path2.getLength() > 0) { - for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) { - String ChannelName = entry.getKey(); ArrayList<String> busChList = entry.getValue(); - GraphPath<vertex, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, getvertex(task12), getvertex(ChannelName)); GraphPath<vertex, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, getvertex(ChannelName), getvertex(task22)); - if (pathTochannel != null && pathTochannel.getLength() > 0 && pathFromChannel != null && pathFromChannel.getLength() > 0) { - devicesToBeConsidered.addAll(busChList); - } - } - } else { - for (Entry<String, ArrayList<String>> entry : channelPaths.entrySet()) { - String ChannelName = entry.getKey(); ArrayList<String> busChList = entry.getValue(); - GraphPath<vertex, DefaultEdge> pathTochannel = DijkstraShortestPath.findPathBetween(g, getvertex(task12), getvertex(ChannelName)); GraphPath<vertex, DefaultEdge> pathFromChannel = DijkstraShortestPath.findPathBetween(g, getvertex(ChannelName), getvertex(task22)); - if ((pathTochannel != null && pathTochannel.getLength() > 0) || (pathFromChannel != null && pathFromChannel.getLength() > 0)) { - devicesToBeConsidered.addAll(busChList); - } - } - } - for (SimulationTransaction st : transFile) { Boolean onPath = false; - int startTime = Integer.valueOf(st.startTime); int endTime = Integer.valueOf(st.endTime); int id = Integer.valueOf(st.id); if (!(startTime < minTime && endTime < minTime) && !(startTime > maxTime && endTime > maxTime)) { - if (endTime > maxTime) { endTime = maxTime; st.endTime = String.valueOf(maxTime); st.length = String.valueOf(maxTime - startTime); } - if (startTime < minTime) { startTime = minTime; st.startTime = String.valueOf(minTime); st.length = String.valueOf(endTime - minTime); } - if (startTime < minTime && endTime > maxTime) { endTime = maxTime; startTime = minTime; @@ -5820,159 +3868,84 @@ public class DirectedGraphTranslator extends JApplet { st.endTime = String.valueOf(maxTime); st.length = String.valueOf(maxTime - minTime); } - String taskname = ""; - for (vertex tasknameCheck : g.vertexSet()) { String[] taskToAdd = tasknameCheck.toString().split("__"); - int taskToAddindex = taskToAdd.length; - String taskToAddid = taskToAdd[taskToAddindex - 1]; if (isNumeric(taskToAddid)) { if (Integer.valueOf(taskToAddid).equals(id)) { - taskname = tasknameCheck.toString(); - break; - } - } } - String[] name = st.deviceName.split("_"); String deviceName = name[0]; - // there is a path between task 1 and task 2 if (path2 != null && path2.getLength() > 0) { if (!taskname.equals(null) && !taskname.equals("")) { - GraphPath<vertex, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, getvertex(task12), getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathToDestination = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (taskname.equals(task12) || taskname.equals(task22) || (pathToOrigin != null && pathToOrigin.getLength() > 0 && pathToDestination != null && pathToDestination.getLength() > 0)) { - relatedsimTraces.add(st); - ArrayList<Integer> timeValues = new ArrayList<Integer>(); timeValues.add(0, Integer.valueOf(st.runnableTime)); timeValues.add(1, startTime); - if (!(st.runnableTime).equals(st.startTime)) { - String dName = st.deviceName + "_" + st.coreNumber; - if (runnableTimePerDevice.containsKey(dName)) { - if (!runnableTimePerDevice.get(dName).contains(timeValues)) { runnableTimePerDevice.get(dName).add(timeValues); } } else { - ArrayList<ArrayList<Integer>> timeValuesList = new ArrayList<ArrayList<Integer>>(); timeValuesList.add(timeValues); - runnableTimePerDevice.put(dName, timeValuesList); - } - } - - } - - else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) + } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) { delayDueTosimTraces.add(st); - } - } - timeDelayedPerRow.put(row, runnableTimePerDevice); - } else { if (!taskname.equals(null) && !taskname.equals("")) { - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask1 = DijkstraShortestPath.findPathBetween(g, getvertex(task12), getvertex(taskname)); - GraphPath<vertex, DefaultEdge> pathExistsTestwithTask2 = DijkstraShortestPath.findPathBetween(g, getvertex(taskname), getvertex(task22)); - if (pathExistsTestwithTask1 != null && pathExistsTestwithTask1.getLength() > 0 || pathExistsTestwithTask2 != null && pathExistsTestwithTask2.getLength() > 0) { relatedsimTraces.add(st); - } else if (((st.deviceName.equals(task2DeviceName) && task2CoreNbr.equals(st.coreNumber)) || (st.deviceName.equals(task1DeviceName) && task1CoreNbr.equals(st.coreNumber)) || devicesToBeConsidered.contains(deviceName)) && !st.id.equals(idTask1) && !st.id.equals(idTask2)) { delayDueTosimTraces.add(st); - } - } - } - } } - } // fill the tasks that run on the same hardware but don't belong to the path // between selected activities public Object[][] getTaskHWByRowDetails(int row) { - Object[][] dataByTaskRowDetails = new Object[dataBydelayedTasks.get(row).size()][6]; - int i = 0; - for (SimulationTransaction st : dataBydelayedTasks.get(row)) { - dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime); dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime); i++; - /* - * HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = - * timeDelayedPerRow.get(row); - * - * boolean causeDelay = false; - * - * if (delayTime.containsKey(st.deviceName)) { - * - * for (Entry<String, ArrayList<ArrayList<Integer>>> entry : - * delayTime.entrySet()) { if (entry.getKey().equals(st.deviceName)) { - * ArrayList<ArrayList<Integer>> timeList = entry.getValue(); - * - * for (int j = 0; j < timeList.size(); j++) { - * - * if (Integer.valueOf(st.startTime) > timeList.get(j).get(0) && - * Integer.valueOf(st.startTime) < timeList.get(j).get(1)) { - * - * causeDelay = true; - * - * } } - * - * } - * - * } - * - * } - * - * dataByTaskRowDetails[i][5] = causeDelay; - * - * - */ } - return dataByTaskRowDetails; } @@ -5980,33 +3953,22 @@ public class DirectedGraphTranslator extends JApplet { public Object[][] latencyMinMaxAnalysis(String task12ID, String task22ID, Vector<SimulationTransaction> transFile1) { List<Integer> times1MinMAx = new ArrayList<Integer>(); List<Integer> times2MinMAx = new ArrayList<Integer>(); - String[] task1 = task12ID.split("__"); - int task1index = task1.length; - idTask1 = task1[task1index - 1]; - String[] task2 = task22ID.split("__"); - int task2index = task2.length; - idTask2 = task2[task2index - 1]; - String task12 = nameIDTaskList.get(idTask1); String task22 = nameIDTaskList.get(idTask2); - times1MinMAx = times1; times2MinMAx = times2; - HashMap<Integer, ArrayList<Integer>> minTimes = new HashMap<Integer, ArrayList<Integer>>(); - for (int time1 : times1MinMAx) { int match = Integer.MAX_VALUE; // Find the first subsequent transaction int time = Integer.MAX_VALUE; for (int time2 : times2MinMAx) { - int diff = time2 - time1; if (diff < time && diff >= 0) { time = diff; @@ -6027,30 +3989,23 @@ public class DirectedGraphTranslator extends JApplet { } } dataByTaskMinMax = new Object[2][5]; - if (minTimes.size() > 0) { Integer min = Collections.min(minTimes.keySet()); Integer max = Collections.max(minTimes.keySet()); - dataByTaskMinMax = new Object[2][5]; - ArrayList<Integer> numMax = minTimes.get(max); ArrayList<Integer> numMin = minTimes.get(min); - dataByTaskMinMax[0][0] = task12; dataByTaskMinMax[0][1] = numMin.get(0); dataByTaskMinMax[0][2] = task22; dataByTaskMinMax[0][3] = numMin.get(1); dataByTaskMinMax[0][4] = min; - dataByTaskMinMax[1][0] = task12; dataByTaskMinMax[1][1] = numMax.get(0); dataByTaskMinMax[1][2] = task22; dataByTaskMinMax[1][3] = numMax.get(1); dataByTaskMinMax[1][4] = max; - } - return dataByTaskMinMax; } @@ -6058,89 +4013,64 @@ public class DirectedGraphTranslator extends JApplet { public Object[][] latencyMinMaxAnalysisTaintedData(String task12ID, String task22ID, Vector<SimulationTransaction> transFile1) { List<Integer> times1MinMAx = new ArrayList<Integer>(); List<Integer> times2MinMAx = new ArrayList<Integer>(); - String[] task1 = task12ID.split("__"); - int task1index = task1.length; - idTask1 = task1[task1index - 1]; - String[] task2 = task22ID.split("__"); - int task2index = task2.length; - idTask2 = task2[task2index - 1]; - String task12 = nameIDTaskList.get(idTask1); String task22 = nameIDTaskList.get(idTask2); - times1MinMAx = times1; times2MinMAx = times2; - HashMap<Integer, ArrayList<Integer>> minTimes = new HashMap<Integer, ArrayList<Integer>>(); - int index = 0; for (int time1 : times1MinMAx) { int match = Integer.MAX_VALUE; // Find the first subsequent transaction int time = Integer.MAX_VALUE; - if (times2MinMAx.get(index) > 0) { - int time2 = times2MinMAx.get(index); int diff = time2 - time1; if (diff < time && diff >= 0) { time = diff; match = time2; } - } - if (time != Integer.MAX_VALUE) { ArrayList<Integer> startEndT = new ArrayList<Integer>(); startEndT.add(time1); startEndT.add(match); minTimes.put(time, startEndT); } - index++; } dataByTaskMinMax = new Object[2][5]; - if (minTimes.size() > 0) { Integer min = Collections.min(minTimes.keySet()); Integer max = Collections.max(minTimes.keySet()); - dataByTaskMinMax = new Object[2][5]; - ArrayList<Integer> numMax = minTimes.get(max); ArrayList<Integer> numMin = minTimes.get(min); - dataByTaskMinMax[0][0] = task12; dataByTaskMinMax[0][1] = numMin.get(0); dataByTaskMinMax[0][2] = task22; dataByTaskMinMax[0][3] = numMin.get(1); dataByTaskMinMax[0][4] = min; - dataByTaskMinMax[1][0] = task12; dataByTaskMinMax[1][1] = numMax.get(0); dataByTaskMinMax[1][2] = task22; dataByTaskMinMax[1][3] = numMax.get(1); dataByTaskMinMax[1][4] = max; - } - return dataByTaskMinMax; } // fill the detailed latency table once a row is selected from min/max table public Object[][] getTasksByRowMinMax(int row) { Object[][] dataByTaskRowDetails = new Object[relatedsimTraces.size()][5]; - int i = 0; - for (SimulationTransaction st : relatedsimTraces) { - dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; @@ -6148,7 +4078,6 @@ public class DirectedGraphTranslator extends JApplet { dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime); i++; } - return dataByTaskRowDetails; } @@ -6156,44 +4085,31 @@ public class DirectedGraphTranslator extends JApplet { // between selected activities public Object[][] getTaskHWByRowDetailsMinMax(int row) { Object[][] dataByTaskRowDetails = new Object[delayDueTosimTraces.size()][5]; - int i = 0; - for (SimulationTransaction st : delayDueTosimTraces) { - dataByTaskRowDetails[i][0] = st.command; dataByTaskRowDetails[i][1] = nameIDTaskList.get(st.id); dataByTaskRowDetails[i][2] = st.deviceName + "_" + st.coreNumber; dataByTaskRowDetails[i][3] = Integer.valueOf(st.startTime); dataByTaskRowDetails[i][4] = Integer.valueOf(st.endTime); - i++; } - return dataByTaskRowDetails; } // import graph in .graphml format public void importGraph(String filename) throws ExportException, IOException, ImportException { - FileReader ps = new FileReader(filename + ".graphml"); // gmlExporter.exportGraph(g, PS); - // FileWriter PS2 = new FileWriter(filename + "test.graphml"); - VertexProvider<String> vertexProvider = (id, attributes) -> { String cv = new String(id); return cv; }; - EdgeProvider<String, DefaultEdge> edgeProvider = (from, to, label, attributes) -> new DefaultEdge(); - GraphMLImporter<String, DefaultEdge> importer = new GraphMLImporter<String, DefaultEdge>(vertexProvider, edgeProvider); - Graph<String, DefaultEdge> importedGraph = null; - importer.importGraph(importedGraph, ps); - } public List<TMLComponentDesignPanel> getCpanels() { @@ -6217,159 +4133,105 @@ public class DirectedGraphTranslator extends JApplet { } public String checkPath(String task12ID, String task22ID) { - Boolean isPath = false; - String result = ""; - String[] task1 = task12ID.split("__"); - int task1index = task1.length; - idTask1 = task1[task1index - 1]; - String[] task2 = task22ID.split("__"); - int task2index = task2.length; - idTask2 = task2[task2index - 1]; - String task12 = nameIDTaskList.get(idTask1); String task22 = nameIDTaskList.get(idTask2); - vertex v1 = getvertex(task12); vertex v2 = getvertex(task22); - GraphPath<vertex, DefaultEdge> pathToOrigin = DijkstraShortestPath.findPathBetween(g, v1, v2); - if (pathToOrigin != null && pathToOrigin.getLength() > 0) { - isPath = true; - } - if (isPath) { - - result = "A path exists between operators"; + result = PATH_EXISTS; } else { - result = "No path between operators"; + result = NO_PATH; } - return result; } public Vector<String> getreadChannelNodes() { - return readChannelTransactions; } public Vector<String> getwriteChannelNodes() { - return writeChannelTransactions; } public String addRule(String node1, String node2, Vector<String> writeChannelTransactions, String ruleDirection) { - vertex v1 = getvertex(node1); vertex v2 = getvertex(node2); - vertex v1Channel = null, v2Channel = null; - String message = ""; - if (v2Channel == null && Graphs.vertexHasSuccessors(g, v2)) { for (vertex n : Graphs.successorListOf(g, v2)) { if (n.getType() == vertex.TYPE_CHANNEL) { v2Channel = n; break; - } } } - Boolean hasWriteVertex = false; if (Graphs.vertexHasPredecessors(g, v1)) { for (vertex n : Graphs.predecessorListOf(g, v1)) { - if (n.getType() == vertex.TYPE_CHANNEL) { - if (Graphs.vertexHasPredecessors(g, n)) { for (vertex writenode : Graphs.predecessorListOf(g, n)) { - if (writeChannelTransactions.contains(writenode.getName())) { hasWriteVertex = true; break; } - } - } - if (hasWriteVertex) { v1Channel = n; break; } else { v1Channel = v1; - } - } } } - if (v1Channel != null && v2Channel != null) { - if (ruleDirection.equals("After")) { - if (ruleAddedEdges.containsKey(v2Channel)) { ruleAddedEdges.get(v2Channel).add(v1Channel); - message = "Rule between " + v1Channel + " and " + v2Channel + " was added"; - } else { List<vertex> sendVertex = new ArrayList<vertex>(); sendVertex.add(v1Channel); - ruleAddedEdges.put(v2Channel, sendVertex); - message = "Rule between " + v1Channel + " and " + v2Channel + " was added"; - } - if (ruleAddedEdgesChannels.containsKey(v2)) { ruleAddedEdgesChannels.get(v2).add(v1); - } else { List<vertex> sendVertex = new ArrayList<vertex>(); sendVertex.add(v1); - ruleAddedEdgesChannels.put(v2, sendVertex); - } - } } - - if (message.isEmpty()) - - { + if (message.isEmpty()) { message = "Couln't add rule between " + v1 + " and " + v2 + ""; - } - // TODO Auto-generated method stub return message; } public Boolean edgeExists(int vID1, int vID2) { - vertex v1 = getvertexFromID(vID1); vertex v2 = getvertexFromID(vID2); - if (g.containsEdge(v1, v2)) { return true; } - return false; } @@ -6424,5 +4286,4 @@ public class DirectedGraphTranslator extends JApplet { public void setOffPathDelay(List<SimulationTransaction> offPathDelay) { this.offPathDelay = offPathDelay; } - } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/JFrameCompareLatencyDetail.java b/src/main/java/ui/simulationtraceanalysis/JFrameCompareLatencyDetail.java index 2abae0a061..73be09cf54 100644 --- a/src/main/java/ui/simulationtraceanalysis/JFrameCompareLatencyDetail.java +++ b/src/main/java/ui/simulationtraceanalysis/JFrameCompareLatencyDetail.java @@ -15,7 +15,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Vector; - import javax.swing.BorderFactory; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; @@ -40,9 +39,7 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.xpath.XPathExpressionException; - import org.xml.sax.SAXException; - import common.ConfigurationTTool; import myutil.GraphicLib; import myutil.ScrolledJTextArea; @@ -57,16 +54,13 @@ import ui.interactivesimulation.SimulationTransaction; import ui.interactivesimulation.SimulationTransactionParser; public class JFrameCompareLatencyDetail extends JFrame implements ActionListener { - private JButton buttonClose, buttonShowDGraph1, buttonShowDGraph2, buttonDetailedAnalysis, buttonCompareInDetails; private LatencyDetailedAnalysisActions[] actions; private DirectedGraphTranslator dgraph1, dgraph2; - private JPanel loadxml, commandTab, jp05, graphAnalysisResult, jp03, jp04, loadmodel, progressBarpanel; private JTextArea jta; private JScrollPane jsp; private JTabbedPane resultTab; - private JComboBox<String> tasksDropDownCombo1 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo2 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo3 = new JComboBox<String>(); @@ -74,7 +68,6 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener private Vector<String> checkedTransactionsFile1 = new Vector<String>(); private Vector<String> checkedTransactionsFile2 = new Vector<String>(); private Vector<String> checkedTransactionsFile = new Vector<String>(); - private static JTable table11, table12, table21, table22; private String[] columnNames = new String[5]; private String[] columnMinMaxNames = new String[5]; @@ -82,44 +75,34 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener private Object[][] dataDetailedMinMax; private JTextField secondFile = new JTextField(); private JButton browse; - private File file1, file2; private JFileChooser fc, fc2; private boolean visible; // private Thread t, t1; - private Object[][] tableData2MinMax, tableData1MinMax, tableData2, tableData = null; - private JScrollPane scrollPane11, scrollPane12, scrollPane21, scrollPane22; - private MainGUI mainGUI; private latencyDetailedAnalysisMain latencyDetailedAnalysisMain; private JFrameLatencyDetailedAnalysis jFrameLatencyDetailedAnalysis; private JFrameCompareLatencyDetail jFrameCompareLatencyDetail; - private JProgressBar pbar; - private JLabel pBarLabel; private TMLMapping<TGComponent> map; private List<TMLComponentDesignPanel> cpanels; private DirectedGraphTranslator dgraph; - private LatencyAnalysisParallelAlgorithms tc; private JCheckBox taintFirstOp, considerRules; - - private static final String startTimeColName = "Start Time "; - private static final String endTimeColName = "End Time "; - private static final String latencyColName = "Latency "; - private static final String opAColName = "OPERATOR A"; - private static final String opBColName = "OPERATOR B "; + private static final String START_TIME_COL_NAME = "Start Time "; + private static final String END_TIME_COL_NAME = "End Time "; + private static final String LATENCY_COLNAME = "Latency "; + private static final String OP_A_COLNAME = "OPERATOR A"; + private static final String OP_B_COLNAME = "OPERATOR B "; // private DirectedGraphTranslator dgraph; public JFrameCompareLatencyDetail(latencyDetailedAnalysisMain latencyDetailedAnaly, MainGUI mgui, final Vector<String> checkedTransactionsFile1, TMLMapping<TGComponent> map1, List<TMLComponentDesignPanel> cpanels1, final SimulationTrace selectedST1, boolean b, LatencyAnalysisParallelAlgorithms tc1) throws InterruptedException { - super("Latency Comparision"); - this.setVisible(b); tc = tc1; mainGUI = mgui; @@ -131,57 +114,41 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener // file2 = new File(selectedST2.getFullPath()); visible = b; setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - initActions(); - GridBagLayout gridbagmain = new GridBagLayout(); - GridBagConstraints mainConstraint = new GridBagConstraints(); - Container framePanel = getContentPane(); framePanel.setLayout(gridbagmain); - mainConstraint.gridx = 0; mainConstraint.gridy = 0; // mainConstraint.fill = GridBagConstraints.HORIZONTAL; mainConstraint.fill = GridBagConstraints.HORIZONTAL; - buttonShowDGraph1 = new JButton(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH_FILE_1]); buttonDetailedAnalysis = new JButton(actions[LatencyDetailedAnalysisActions.ACT_LATENCY]); buttonShowDGraph2 = new JButton(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH_FILE_2]); buttonClose = new JButton(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_ALL]); - buttonCompareInDetails = new JButton(actions[LatencyDetailedAnalysisActions.ACT_COMPARE_IN_DETAILS]); - JPanel jp = new JPanel(); jp.add(buttonClose); jp.add(buttonShowDGraph1); jp.add(buttonShowDGraph2); jp.add(buttonDetailedAnalysis); jp.add(buttonCompareInDetails); - buttonShowDGraph1.setEnabled(false); buttonShowDGraph2.setEnabled(false); buttonDetailedAnalysis.setEnabled(false); buttonCompareInDetails.setEnabled(false); framePanel.add(jp, mainConstraint); - mainConstraint.gridheight = 1; - // mainConstraint.weighty = 0.5; - // mainConstraint.weightx = 0.5; mainConstraint.gridx = 0; mainConstraint.gridy = 1; mainConstraint.gridwidth = 1; // end row mainConstraint.fill = GridBagConstraints.BOTH; - GridBagLayout gridbag02 = new GridBagLayout(); GridBagConstraints c02 = new GridBagConstraints(); loadmodel = new JPanel(new BorderLayout()); - loadmodel.setLayout(gridbag02); - framePanel.add(loadmodel, mainConstraint); - c02.gridheight = 1; c02.weighty = 1.0; c02.weightx = 1.0; @@ -189,110 +156,63 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener c02.gridx = 0; c02.gridy = 0; c02.anchor = GridBagConstraints.WEST; - JLabel xmlLabel = new JLabel("Secound Simulation Traces ", JLabel.LEFT); loadmodel.add(xmlLabel, c02); - secondFile.setMinimumSize(new Dimension(300, 30)); secondFile.setEditable(false); secondFile.setText("file 2 name"); secondFile.setBorder(new LineBorder(Color.BLACK)); - c02.gridx = 1; c02.gridy = 0; - c02.weightx = 1; - c02.weighty = 1; loadmodel.add(secondFile, c02); - browse = new JButton("Browse"); browse.addActionListener(this); browse.setEnabled(false); c02.gridx = 2; c02.gridy = 0; - c02.weightx = 1; - c02.weighty = 1; loadmodel.add(browse, c02); loadmodel.setBorder(new javax.swing.border.TitledBorder("Simulation Traces File")); - GridBagLayout gridbag01 = new GridBagLayout(); GridBagConstraints c01 = new GridBagConstraints(); loadxml = new JPanel(new BorderLayout()); - loadxml.setLayout(gridbag01); - - mainConstraint.gridheight = 1; - // mainConstraint.weighty = 0.5; - // mainConstraint.weightx = 0.5; mainConstraint.gridx = 0; mainConstraint.gridy = 2; mainConstraint.gridwidth = 1; // end row mainConstraint.fill = GridBagConstraints.BOTH; loadxml.setBorder(new javax.swing.border.TitledBorder("chose Latency Operators")); framePanel.add(loadxml, mainConstraint); - c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 1; - JLabel tasksLabel1 = new JLabel("Operators of Simulation Traces File 1 ", JLabel.LEFT); loadxml.add(tasksLabel1, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 2; - JLabel tasksLabel2 = new JLabel("Operators of Simulation Traces File 2 ", JLabel.LEFT); loadxml.add(tasksLabel2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 1; tasksDropDownCombo1 = new JComboBox<String>(checkedTransactionsFile1); loadxml.add(tasksDropDownCombo1, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 1; - tasksDropDownCombo2 = new JComboBox<String>(checkedTransactionsFile1); loadxml.add(tasksDropDownCombo2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 3; tasksDropDownCombo3 = new JComboBox<String>(checkedTransactionsFile2); loadxml.add(tasksDropDownCombo3, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 3; - tasksDropDownCombo4 = new JComboBox<String>(checkedTransactionsFile2); - loadxml.add(tasksDropDownCombo4, c01); - gridbag01 = new GridBagLayout(); c01 = new GridBagConstraints(); progressBarpanel = new JPanel(gridbag01); - c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; @@ -300,35 +220,20 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener c01.gridx = 0; c01.gridy = 0; // c01.fill = GridBagConstraints.BOTH; - pBarLabel = new JLabel("Progress of Graph Generation", JLabel.LEFT); progressBarpanel.add(pBarLabel, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 0; - pbar = new JProgressBar(); pbar.setForeground(Color.GREEN); - progressBarpanel.add(pbar, c01); - - mainConstraint.gridheight = 1; mainConstraint.gridx = 0; mainConstraint.gridy = 5; mainConstraint.ipady = 40; mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(progressBarpanel, mainConstraint); - graphAnalysisResult = new JPanel(new BorderLayout()); graphAnalysisResult.setBorder(new javax.swing.border.TitledBorder("Latency Analysis ")); - mainConstraint.gridheight = 1; - // .weighty =0.5; - // mainConstraint.weightx = 0.5; mainConstraint.weighty = 1.0; mainConstraint.weightx = 1.0; mainConstraint.gridx = 0; @@ -337,146 +242,94 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener mainConstraint.gridwidth = 1; // end row // mainConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row mainConstraint.fill = GridBagConstraints.BOTH; - framePanel.add(graphAnalysisResult, mainConstraint); - - columnNames[0] = opAColName; - columnNames[1] = startTimeColName; - columnNames[2] = opBColName; - columnNames[3] = endTimeColName; - columnNames[4] = latencyColName; - + columnNames[0] = OP_A_COLNAME; + columnNames[1] = START_TIME_COL_NAME; + columnNames[2] = OP_B_COLNAME; + columnNames[3] = END_TIME_COL_NAME; + columnNames[4] = LATENCY_COLNAME; // columnNames[5] = "Related Tasks Details "; // columnNames[6] = "Total time- Related Tasks "; - dataDetailedByTask = new Object[0][0]; - jp03 = new JPanel(new BorderLayout()); jp03.setLayout(gridbag01); - DefaultTableModel tableModel1 = new DefaultTableModel(dataDetailedByTask, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table11 = new JTable(tableModel1); // table11.setBackground(Color.red); scrollPane11 = new JScrollPane(table11, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // scrollPane11.setBackground(Color.red); scrollPane11.setVisible(b); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 0; c01.fill = GridBagConstraints.BOTH; - jp03.add(scrollPane11, c01); - DefaultTableModel tableModel2 = new DefaultTableModel(dataDetailedByTask, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table12 = new JTable(tableModel2); // table12.setBackground(Color.blue); scrollPane12 = new JScrollPane(table12, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // scrollPane11.setBackground(Color.blue); scrollPane12.setVisible(b); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 1; c01.fill = GridBagConstraints.BOTH; - jp03.add(scrollPane12, c01); - jp04 = new JPanel(new BorderLayout()); - jp04.setLayout(gridbag01); - - columnMinMaxNames[0] = opAColName; - columnMinMaxNames[1] = startTimeColName; - columnMinMaxNames[2] = opBColName; - columnMinMaxNames[3] = endTimeColName; - columnMinMaxNames[4] = latencyColName; - + columnMinMaxNames[0] = OP_A_COLNAME; + columnMinMaxNames[1] = START_TIME_COL_NAME; + columnMinMaxNames[2] = OP_B_COLNAME; + columnMinMaxNames[3] = END_TIME_COL_NAME; + columnMinMaxNames[4] = LATENCY_COLNAME; dataDetailedMinMax = new Object[0][0]; - DefaultTableModel tableModel3 = new DefaultTableModel(dataDetailedMinMax, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table21 = new JTable(tableModel3); scrollPane21 = new JScrollPane(table21, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane21.setVisible(b); - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 0; c01.fill = GridBagConstraints.BOTH; - jp04.add(scrollPane21, c01); - DefaultTableModel tableModel4 = new DefaultTableModel(dataDetailedMinMax, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table22 = new JTable(tableModel4); // table12.setBackground(Color.blue); scrollPane22 = new JScrollPane(table22, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane22.setVisible(b); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 1; c01.fill = GridBagConstraints.BOTH; - jp04.add(scrollPane22, c01); - resultTab = GraphicLib.createTabbedPaneRegular();// new JTabbedPane(); - resultTab.addTab("Latency Values", null, jp03, "Latency detailed By Tasks "); + resultTab.addTab("Latency Values", null, jp03, "Latency Detailed by Tasks "); resultTab.addTab("Min/Max Latency", null, jp04, "Min and Max Latency"); - graphAnalysisResult.add(resultTab, BorderLayout.CENTER); - jp05 = new JPanel(new BorderLayout()); // mainpanel.add(split, BorderLayout.SOUTH); mainConstraint.weighty = 00; mainConstraint.ipady = 200; - mainConstraint.gridx = 0; mainConstraint.gridy = 6; - mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(jp05, mainConstraint); - // Ouput textArea jta = new ScrolledJTextArea(); jta.setBackground(ColorManager.InteractiveSimulationJTABackground); @@ -492,53 +345,41 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener jta.setFont(f); jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setViewportBorder(BorderFactory.createLineBorder(ColorManager.InteractiveSimulationBackground)); - jsp.setMaximumSize(new Dimension(800, 500)); - jp05.setMaximumSize(new Dimension(800, 500)); jp05.add(jsp, BorderLayout.CENTER); - this.pack(); this.setVisible(b); tc.setCld(this); tc.setMap(map); - tc.start(10); tc.run(); - } protected void generateDirectedGraph1(TMLMapping<TGComponent> map, List<TMLComponentDesignPanel> cpanels) { try { dgraph = new DirectedGraphTranslator(jFrameLatencyDetailedAnalysis, this, map, cpanels, 1); dgraph1 = dgraph; - jta.append("A Directed Graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); + jta.append("A directed graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); // buttonSaveDGraph.setEnabled(true); - if (dgraph.getWarnings().size() > 0) { jta.append("Warnings: \n "); - for (int i = 0; i < dgraph.getWarnings().size(); i++) { jta.append(" - " + dgraph.getWarnings().get(i) + "\n "); } - } - buttonShowDGraph1.setEnabled(true); if (pbar.getValue() == pbar.getMaximum()) { updateBar(0); - } jta.append("Browse the second simulation trace to generate the second graph \n"); browse.setEnabled(true); - } catch (Exception e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); // buttonSaveDGraph.setEnabled(false); buttonShowDGraph1.setEnabled(false); } - } private void initActions() { @@ -548,16 +389,13 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener actions[i].addActionListener(this); // actions[i].addKeyListener(this); } - } protected void generateDirectedGraph2(TMLMapping<TGComponent> map, List<TMLComponentDesignPanel> cpanels) { // TODO Auto-generated method stub try { dgraph = null; - dgraph = tc.getDgraph(); - dgraph2 = dgraph; String[] checkTransactionStrTable = new String[checkedTransactionsFile2.size()]; int idx = 0; @@ -565,35 +403,26 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener checkTransactionStrTable[idx] = str; idx++; } - ComboBoxModel<String> aModel = new DefaultComboBoxModel<String>(checkTransactionStrTable); ComboBoxModel<String> aModel1 = new DefaultComboBoxModel<String>(checkTransactionStrTable); - tasksDropDownCombo3.setModel(aModel); tasksDropDownCombo4.setModel(aModel1); - if (dgraph.getWarnings().size() > 0) { jta.append("Warnings: \n "); - for (int i = 0; i < dgraph.getWarnings().size(); i++) { jta.append(" - " + dgraph.getWarnings().get(i) + "\n "); } - } - buttonShowDGraph2.setEnabled(true); buttonDetailedAnalysis.setEnabled(true); buttonCompareInDetails.setEnabled(true); if (pbar.getValue() == pbar.getMaximum()) { updateBar(0); - } this.pack(); this.revalidate(); this.repaint(); - - jta.append("A Directed Graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); - + jta.append("A directed graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); } catch (Exception e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); @@ -605,22 +434,16 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener @Override public void actionPerformed(ActionEvent evt) { // TODO Auto-generated method stub - String command = evt.getActionCommand(); // TraceManager.addDev("Command:" + command); - if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH_FILE_1].getActionCommand())) { - tc.setDgraph(dgraph1); tc.start(14); tc.run(); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH_FILE_2].getActionCommand())) { - tc.setDgraph2(dgraph2); tc.start(17); tc.run(); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_ALL].getActionCommand())) { // jta.setText(""); dispose(); @@ -628,57 +451,43 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener } else if (evt.getSource() == browse) { try { pBarLabel.setText("Progress of Graph 2 Generation"); - updateBar(0); if (ConfigurationTTool.SystemCCodeDirectory.length() > 0) { fc = new JFileChooser(ConfigurationTTool.SystemCCodeDirectory); } else { fc = new JFileChooser(); } - FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files", "xml"); fc.setFileFilter(filter); int returnVal = fc.showOpenDialog(mainGUI.frame); - if (returnVal == JFileChooser.APPROVE_OPTION) { File filefc = fc.getSelectedFile(); - latencyDetailedAnalysisMain.setCheckedTransactionsFile(new Vector<String>()); SimulationTrace STfile2 = new SimulationTrace(filefc.getName(), 6, filefc.getAbsolutePath()); secondFile.setText(filefc.getAbsolutePath()); - if (STfile2 instanceof SimulationTrace) { - file2 = new File(STfile2.getFullPath()); - try { latencyDetailedAnalysisMain.latencyDetailedAnalysisForXML(mainGUI, STfile2, false, true, 2); } catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - checkedTransactionsFile2 = latencyDetailedAnalysisMain.getCheckedTransactionsFile(); map = latencyDetailedAnalysisMain.getMap1(); cpanels = latencyDetailedAnalysisMain.getCpanels1(); - this.toFront(); this.requestFocus(); - this.pack(); this.revalidate(); this.repaint(); - tc.setCld(this); tc.setMap(map); // tc.setCld(jFrameCompareLatencyDetail); tc.setjFrameLDA(jFrameLatencyDetailedAnalysis); - tc.start(15); tc.run(); - } - } } catch (Exception e1) { // TODO Auto-generated catch block @@ -688,28 +497,20 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_LATENCY].getActionCommand())) { jta.append("Simulation Trace 1 : the Latency Between: \n " + tasksDropDownCombo1.getSelectedItem() + " and \n" + tasksDropDownCombo2.getSelectedItem() + " is studied \n"); - jta.append("Simulation Trace 2 : the Latency Between: \n " + tasksDropDownCombo3.getSelectedItem() + " and \n" + tasksDropDownCombo4.getSelectedItem() + " is studied \n"); - String task1 = tasksDropDownCombo1.getSelectedItem().toString(); String task2 = tasksDropDownCombo2.getSelectedItem().toString(); - String task3 = tasksDropDownCombo3.getSelectedItem().toString(); String task4 = tasksDropDownCombo4.getSelectedItem().toString(); - // Boolean taint = taintFirstOp.isSelected(); - // Boolean considerAddedRules = considerRules.isSelected(); - Vector<SimulationTransaction> transFile1, transFile2; transFile1 = parseFile(file1); transFile2 = parseFile(file2); - tc.latencyDetailedAnalysis(this, task1, task2, task3, task4, transFile1, transFile2); tc.start(18); tc.run(); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_COMPARE_IN_DETAILS].getActionCommand())) { jta.append("the Latency Between: \n " + tasksDropDownCombo1.getSelectedItem() + " and \n" + tasksDropDownCombo2.getSelectedItem() + " is studied \n"); @@ -727,22 +528,17 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener } else { jta.append("Please select a row from each table to proceed \n"); } - } - } private void showgraphFrame(DirectedGraphTranslator dgraph) { try { dgraph.showGraph(dgraph); - // jta.append("Refer to the generatd dialog to view the graph.\n"); - } catch (Exception e) { // jta.append("An Error has occurred \n"); // jta.append(e.getMessage() + "\n"); } - } public Vector<SimulationTransaction> parseFile(File file2) { @@ -756,7 +552,6 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener error(e.getMessage()); } SimulationTransactionParser handler = new SimulationTransactionParser(); - try { saxParser.parse(file2, handler); } catch (SAXException e) { @@ -769,139 +564,89 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener public void latencyDetailedAnalysis(String task1, String task2, String task3, String task4, Vector<SimulationTransaction> transFile1, Vector<SimulationTransaction> transFile2, boolean b, boolean taint, boolean considerAddedRules) { - tableData = dgraph1.latencyDetailedAnalysis(task1, task2, transFile1, taint, considerAddedRules); - // DefaultTableModel model = new DefaultTableModel(); - table11.removeAll(); - DefaultTableModel tableModel1 = new DefaultTableModel(tableData, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table11 = new JTable(tableModel1); - table11.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - tableData2 = dgraph2.latencyDetailedAnalysis(task3, task4, transFile2, taint, considerAddedRules); - // DefaultTableModel model2 = new DefaultTableModel(); - table12.removeAll(); - DefaultTableModel tableModel2 = new DefaultTableModel(tableData2, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table12 = new JTable(tableModel2); - table12.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - tableData1MinMax = dgraph1.latencyMinMaxAnalysis(task1, task2, transFile1); - // DefaultTableModel model2 = new DefaultTableModel(); - table21.removeAll(); - DefaultTableModel tableModel3 = new DefaultTableModel(tableData1MinMax, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table21 = new JTable(tableModel3); - table21.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - tableData2MinMax = dgraph2.latencyMinMaxAnalysis(task3, task4, transFile2); - // DefaultTableModel model2 = new DefaultTableModel(); - table22.removeAll(); - DefaultTableModel tableModel4 = new DefaultTableModel(tableData2MinMax, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table22 = new JTable(tableModel4); - table22.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - table22.repaint(); table22.revalidate(); - scrollPane22.setViewportView(table22); scrollPane22.revalidate(); scrollPane22.repaint(); - table21.repaint(); table21.revalidate(); - scrollPane21.setViewportView(table21); scrollPane21.revalidate(); scrollPane21.repaint(); - table12.repaint(); table12.revalidate(); - scrollPane12.setViewportView(table12); scrollPane12.revalidate(); scrollPane12.repaint(); - // scrollPane12.setVisible(true); - table11.repaint(); table11.revalidate(); - scrollPane11.setViewportView(table11); scrollPane11.revalidate(); scrollPane11.repaint(); - // scrollPane11.setVisible(true); jta.append("Latency has been computed...Please refer to the tables in the Latency Analysis section for the results \n"); - this.pack(); this.setVisible(b); - // jta.append("Message: " + tableData.length + "\n"); - } protected void compareLatencyInDetails(int row1, int row2, int row3, int row4, int selectedIndex) throws InterruptedException { // TODO Auto-generated method stub - if (selectedIndex == 0) { - jta.append("the latency for row : " + row1 + ": and row: " + row2 + " will be studied\n"); - new JFrameLatencyComparedDetailedPopup(dgraph1, dgraph2, row1, row2, true, tc); - } else if (selectedIndex == 1) { jta.append("the latency for row : " + row3 + ": and row: " + row4 + " will be studied\n"); - new JFrameLatencyComparedDetailedPopup(dgraph1, dgraph2, row3, row4, false, tc); - } else { - error("Select a panel"); - } - } public void error(String error) { @@ -933,9 +678,7 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener } public void updateBar(int newValue) { - pbar.setValue(newValue); - } public JProgressBar getPbar() { @@ -953,13 +696,10 @@ public class JFrameCompareLatencyDetail extends JFrame implements ActionListener public void setDgraph(DirectedGraphTranslator dgraph) { this.dgraph = dgraph; } - // public Thread getT() { // return t; // } - // public void setT(Thread t) { // this.t = t; // } - } diff --git a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyComparedDetailedPopup.java b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyComparedDetailedPopup.java index ea1cd82bf1..aa64bfc567 100644 --- a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyComparedDetailedPopup.java +++ b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyComparedDetailedPopup.java @@ -35,7 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import java.awt.BorderLayout; @@ -48,7 +47,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.Vector; - import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -59,7 +57,6 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; - import ui.interactivesimulation.SimulationTransaction; /** @@ -71,7 +68,6 @@ import ui.interactivesimulation.SimulationTransaction; * @author Maysam Zoor */ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableModelListener { - private String[] columnByTaskNames = new String[5]; private String[] columnByHWNames = new String[5]; private JScrollPane scrollPane11, scrollPane12, scrollPane13, scrollPane14, scrollPane15, scrollPane16; @@ -79,73 +75,57 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM private Object[][] dataDetailedByTask, dataDetailedByTask2; private String[] columnNames; // private Thread t, t1; - private JPanel jp02; private LatencyAnalysisParallelAlgorithms tc; - private Object[][] dataHWDelayByTask, dataHWDelayByTask2; - - private static final String transactionList = "Transaction List "; - private static final String transactionDiagramName = "Transaction Diagram Name "; - private static final String hardware = "Hardware "; - private static final String startTime = "Start Time "; - private static final String endTime = "End Time "; + private static final String TRANSACTION_LIST = "Transaction List "; + private static final String TRANSACTION_DIAGRAM_NAME = "Transaction Diagram Name "; + private static final String HARDWARE = "Hardware "; + private static final String START_TIME = "Start Time "; + private static final String END_TIME = "End Time "; + private static final String TASKS_SAME_DEVICE = "Tasks on Same device"; + private static final String DEVICE_NAME = "Device Name"; public JFrameLatencyComparedDetailedPopup(DirectedGraphTranslator dgraph1, DirectedGraphTranslator dgraph2, int row, int row2, boolean firstTable, LatencyAnalysisParallelAlgorithms tc2) throws InterruptedException { - super("Detailed Latency By Row"); tc = tc2; GridBagLayout gridbagmain = new GridBagLayout(); - GridBagConstraints mainConstraint = new GridBagConstraints(); - Container framePanel = getContentPane(); framePanel.setLayout(gridbagmain); - GridBagLayout gridbag02 = new GridBagLayout(); GridBagConstraints c02 = new GridBagConstraints(); // Save jp02 = new JPanel(gridbag02); - mainConstraint.gridx = 0; mainConstraint.gridy = 0; mainConstraint.fill = GridBagConstraints.HORIZONTAL; // framePanel.setBackground(Color.red); framePanel.add(jp02, mainConstraint); - - columnByTaskNames[0] = transactionList; - columnByTaskNames[1] = transactionDiagramName; - columnByTaskNames[2] = hardware; - columnByTaskNames[3] = startTime; - columnByTaskNames[4] = endTime; - + columnByTaskNames[0] = TRANSACTION_LIST; + columnByTaskNames[1] = TRANSACTION_DIAGRAM_NAME; + columnByTaskNames[2] = HARDWARE; + columnByTaskNames[3] = START_TIME; + columnByTaskNames[4] = END_TIME; JPanel jp04 = new JPanel(new BorderLayout()); - tc.setDgraph1(dgraph1); tc.setDgraph2(dgraph2); tc.setRow(row); tc.setRow2(row2); - if (firstTable) { - tc.start(20); tc.run(); // tc.getT().join(); dataDetailedByTask = tc.getDataDetailedByTask(); - dataDetailedByTask2 = tc.getDataDetailedByTask2(); } else { - tc.start(21); tc.run(); // tc.getT().join(); dataDetailedByTask = tc.getDataDetailedByTask(); - dataDetailedByTask2 = tc.getDataDetailedByTask2(); - } - DefaultTableModel model = new DefaultTableModel(dataDetailedByTask, columnByTaskNames) { @Override public Class getColumnClass(int column) { @@ -170,15 +150,11 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM return false; } }; - // taskNames = new JTable(dataDetailedByTask, columnByTaskNames); - JTable taskNames = new JTable(model); taskNames.setAutoCreateRowSorter(true); scrollPane11 = new JScrollPane(taskNames, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane11.setVisible(true); - c02.gridheight = 1; c02.weighty = 1.0; c02.weightx = 1.0; @@ -186,13 +162,9 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM c02.gridx = 0; c02.gridy = 0; c02.fill = GridBagConstraints.BOTH; - // c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane11, c02); - DefaultTableModel model12 = new DefaultTableModel(dataDetailedByTask2, columnByTaskNames) { - @Override public boolean isCellEditable(int row, int column) { return false; @@ -216,50 +188,33 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM } } }; - JTable taskNames12 = new JTable(model12); taskNames12.setAutoCreateRowSorter(true); scrollPane12 = new JScrollPane(taskNames12, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane12.setVisible(true); - - c02.gridheight = 1; - c02.weighty = 1.0; - c02.weightx = 1.0; - c02.gridwidth = 1; c02.gridx = 1; c02.gridy = 0; c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane12, c02); - - columnByHWNames[0] = "Task on Same device"; - columnByHWNames[1] = transactionDiagramName; - columnByHWNames[2] = hardware; - columnByHWNames[3] = startTime; - columnByHWNames[4] = endTime; - + columnByHWNames[0] = TASKS_SAME_DEVICE; + columnByHWNames[1] = TRANSACTION_DIAGRAM_NAME; + columnByHWNames[2] = HARDWARE; + columnByHWNames[3] = START_TIME; + columnByHWNames[4] = END_TIME; if (firstTable) { - tc.start(22); tc.run(); // tc.getT().join(); dataHWDelayByTask = tc.getDataDetailedByTask(); - dataHWDelayByTask2 = tc.getDataDetailedByTask2(); } else { - tc.start(23); tc.run(); // tc.getT().join(); dataHWDelayByTask = tc.getDataDetailedByTask(); - dataHWDelayByTask2 = tc.getDataDetailedByTask2(); - } - DefaultTableModel model2 = new DefaultTableModel(dataHWDelayByTask, columnByHWNames) { - @Override public boolean isCellEditable(int row, int column) { return false; @@ -283,26 +238,15 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM } } }; - JTable hardwareNames = new JTable(model2); hardwareNames.setAutoCreateRowSorter(true); - scrollPane13 = new JScrollPane(hardwareNames, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane13.setVisible(true); - - c02.gridheight = 1; - c02.weighty = 1.0; - c02.weightx = 1.0; - c02.gridwidth = 1; c02.gridx = 0; c02.gridy = 1; c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane13, c02); - DefaultTableModel model3 = new DefaultTableModel(dataHWDelayByTask2, columnByHWNames) { - @Override public boolean isCellEditable(int row, int column) { return false; @@ -326,53 +270,29 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM } } }; - JTable hardwareNames2 = new JTable(model3); hardwareNames2.setAutoCreateRowSorter(true); - scrollPane14 = new JScrollPane(hardwareNames2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane14.setVisible(true); - - c02.gridheight = 1; - c02.weighty = 1.0; - c02.weightx = 1.0; - c02.gridwidth = 1; c02.gridx = 1; c02.gridy = 1; c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane14, c02); - scrollPane15 = new JScrollPane(LatencyTable(dgraph1, row, firstTable), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane15.setVisible(true); - - c02.gridheight = 1; - c02.weighty = 1.0; - c02.weightx = 1.0; c02.gridwidth = 2; c02.gridx = 0; c02.gridy = 3; c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane15, c02); - scrollPane16 = new JScrollPane(LatencyTable(dgraph2, row2, firstTable), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane16.setVisible(true); - c02.gridheight = 1; - c02.weighty = 1.0; - c02.weightx = 1.0; - c02.gridwidth = 2; c02.gridx = 0; c02.gridy = 4; c02.fill = GridBagConstraints.BOTH; - framePanel.add(scrollPane16, c02); - this.pack(); this.setVisible(true); // TODO Auto-generated constructor stub @@ -381,333 +301,216 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM @Override public void tableChanged(TableModelEvent e) { // TODO Auto-generated method stub - } public JTable LatencyTable(DirectedGraphTranslator dgraph, int row, boolean firstTable) { - List<String> onPathBehavior = new ArrayList<String>(); List<String> offPathBehavior = new ArrayList<String>(); List<String> offPathBehaviorCausingDelay = new ArrayList<String>(); - int maxTime = -1; - int minTime = Integer.MAX_VALUE; int tmpEnd, tmpStart; - Vector<String> deviceNames1 = new Vector<String>(); - if (firstTable) { - for (SimulationTransaction st : dgraph.getRowDetailsTaks(row)) { - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } if (!deviceNames1.contains(st.deviceName)) { deviceNames1.add(st.deviceName); - } - } - for (SimulationTransaction st : dgraph.getRowDetailsByHW(row)) { - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } if (!deviceNames1.contains(st.deviceName)) { deviceNames1.add(st.deviceName); - } - } - int timeInterval = (maxTime - minTime); columnNames = new String[timeInterval + 1]; - - columnNames[0] = "Device Name"; + columnNames[0] = DEVICE_NAME; for (int i = 0; i < timeInterval; i++) { - columnNames[i + 1] = Integer.toString(minTime + i); - } - dataDetailedByTask = new Object[deviceNames1.size()][timeInterval + 1]; - for (SimulationTransaction st : dgraph.getRowDetailsTaks(row)) { - for (String dName : deviceNames1) { - if (st.deviceName.equals(dName)) { - for (int i = 0; i < Integer.parseInt(st.length); i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - onPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); - } } - } - } - HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = dgraph.getRowDelayDetailsByHW(row); - for (SimulationTransaction st : dgraph.getRowDetailsByHW(row)) { - for (String dName : deviceNames1) { - if (st.deviceName.equals(dName)) { - for (int i = 0; i < Integer.parseInt(st.length); i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - boolean causeDelay = false; - if (delayTime.containsKey(st.deviceName)) { - for (Entry<String, ArrayList<ArrayList<Integer>>> entry : delayTime.entrySet()) { if (entry.getKey().equals(st.deviceName)) { ArrayList<ArrayList<Integer>> timeList = entry.getValue(); - for (int j = 0; j < timeList.size(); j++) { - if (Integer.valueOf(st.startTime) >= timeList.get(j).get(0) && Integer.valueOf(st.startTime) <= timeList.get(j).get(1)) { - causeDelay = true; - } } - } - } - } - if (causeDelay) { offPathBehaviorCausingDelay.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); } else { offPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); } - } } - } - } - for (String dName : deviceNames1) { dataDetailedByTask[deviceNames1.indexOf(dName)][0] = dName; ; } } else { // min/max table row selected - for (SimulationTransaction st : dgraph.getMinMaxTasksByRow(row)) { - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } if (!deviceNames1.contains(st.deviceName)) { deviceNames1.add(st.deviceName); - } - } - for (SimulationTransaction st : dgraph.getTaskMinMaxHWByRowDetails(row)) { - tmpEnd = Integer.parseInt(st.endTime); if (tmpEnd > maxTime) { maxTime = tmpEnd; } tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } if (!deviceNames1.contains(st.deviceName)) { deviceNames1.add(st.deviceName); - } - } - int timeInterval = (maxTime - minTime); columnNames = new String[timeInterval + 1]; - - columnNames[0] = "Device Name"; + columnNames[0] = DEVICE_NAME; for (int i = 0; i < timeInterval; i++) { - columnNames[i + 1] = Integer.toString(minTime + i); - } - dataDetailedByTask = new Object[deviceNames1.size()][timeInterval + 1]; - for (SimulationTransaction st : dgraph.getMinMaxTasksByRow(row)) { - for (String dName : deviceNames1) { - if (st.deviceName.equals(dName)) { - for (int i = 0; i < Integer.parseInt(st.length); i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - onPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); - } } - } - } HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = dgraph.getRowDelayDetailsByHW(row); - for (SimulationTransaction st : dgraph.getTaskMinMaxHWByRowDetails(row)) { - for (String dName : deviceNames1) { - if (st.deviceName.equals(dName)) { - for (int i = 0; i < Integer.parseInt(st.length); i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - boolean causeDelay = false; - if (delayTime.containsKey(st.deviceName)) { - for (Entry<String, ArrayList<ArrayList<Integer>>> entry : delayTime.entrySet()) { if (entry.getKey().equals(st.deviceName)) { ArrayList<ArrayList<Integer>> timeList = entry.getValue(); - for (int j = 0; j < timeList.size(); j++) { - if (Integer.valueOf(st.startTime) >= timeList.get(j).get(0) && Integer.valueOf(st.startTime) <= timeList.get(j).get(1)) { - causeDelay = true; - } } - } - } - } - if (causeDelay) { offPathBehaviorCausingDelay.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); } else { offPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); } - } } - } - } - for (String dName : deviceNames1) { dataDetailedByTask[deviceNames1.indexOf(dName)][0] = dName; ; } - } - DefaultTableModel tableModel = new DefaultTableModel(dataDetailedByTask, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - JTable table = new JTable(tableModel); table.setFillsViewportHeight(true); - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - table.setAutoCreateRowSorter(true); - TableRenderer tr = new TableRenderer(onPathBehavior, offPathBehaviorCausingDelay, offPathBehavior); int ncols = table.getColumnCount(); - table.getModel().addTableModelListener(this); - TableColumnModel tcm = table.getColumnModel(); - for (int c = 0; c < ncols; c++) { TableColumn tc = tcm.getColumn(c); tc.setCellRenderer(tr); } - for (int column = 0; column < table.getColumnCount(); column++) { TableColumn tableColumn = table.getColumnModel().getColumn(column); int preferredWidth = 100 + tableColumn.getMinWidth(); int maxWidth = tableColumn.getMaxWidth(); - for (int row1 = 0; row1 < table.getRowCount(); row1++) { TableCellRenderer cellRenderer = table.getCellRenderer(row1, column); Component c = table.prepareRenderer(cellRenderer, row1, column); int width = c.getPreferredSize().width + table.getIntercellSpacing().width; preferredWidth = Math.max(preferredWidth, width); - // We've exceeded the maximum width, no need to check other rows - if (preferredWidth >= maxWidth) { preferredWidth = maxWidth; break; } } - tableColumn.setPreferredWidth(preferredWidth); } - return table; - } public Object[][] getDataDetailedByTask() { @@ -717,5 +520,4 @@ public class JFrameLatencyComparedDetailedPopup extends JFrame implements TableM public Object[][] getDataHWDelayByTask() { return dataHWDelayByTask; } - } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedAnalysis.java b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedAnalysis.java index 46c594a5b8..b70abffd7e 100644 --- a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedAnalysis.java +++ b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedAnalysis.java @@ -35,7 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import java.awt.BorderLayout; @@ -62,7 +61,6 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; import java.util.Map.Entry; - import javax.swing.BorderFactory; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; @@ -90,7 +88,6 @@ import javax.swing.table.DefaultTableModel; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; - import org.jgrapht.Graph; import org.jgrapht.graph.DefaultDirectedGraph; import org.jgrapht.graph.DefaultEdge; @@ -100,7 +97,6 @@ import org.jgrapht.io.GraphMLImporter; import org.jgrapht.io.ImportException; import org.jgrapht.io.VertexProvider; import org.xml.sax.SAXException; - import common.ConfigurationTTool; import common.SpecConfigTTool; import myutil.GraphicLib; @@ -128,9 +124,7 @@ import ui.tmlad.TMLActivityDiagramPanel; * * @author Maysam Zoor */ - public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListener, Runnable, MouseListener, ItemListener, ChangeListener { - // private JButton saveGraph, viewGraph; private JTextArea jta; private JScrollPane jsp; @@ -138,65 +132,46 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe private JPanel loadxml, commands, jp01, jp02, /* activities, */ graphAnalysisResult, jp03, jp04, jp05, jp06, progressBarpanel, addRules; // ,graphAnalysisResultDetailed; private JButton buttonClose, buttonShowDGraph, buttonSaveDGraph, buttonBrowse, latencybutton, buttonCheckPath, addRulebutton, viewRulesbutton, preciseAnalysisbutton, showAllOp; - private Vector<String> checkedTransactions = new Vector<String>(); private Vector<String> allTasks = new Vector<String>(); private HashMap<String, Integer> checkedT = new HashMap<String, Integer>(); - private JTextField saveDirName; private JTextField saveFileName; - private JComboBox<String> tasksDropDownCombo1 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo2 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo3 = new JComboBox<String>(); private JComboBox<String> tasksDropDownCombo4 = new JComboBox<String>(); - private JComboBox<String> tasksDropDownCombo5 = new JComboBox<String>(); - private JComboBox<String> tasksDropDownCombo6 = new JComboBox<String>(); - private JComboBox<String> tasksDropDownCombo7 = new JComboBox<String>(); - private Vector<String> readChannelTransactions = new Vector<String>(); private Vector<String> writeChannelTransactions = new Vector<String>(); - private Vector<String> ruleDirection = new Vector<String>(); - private SaveGraphToolBar sgtb; - private LatencyDetailedAnalysisActions[] actions; - private JFileChooser fc, fc2; - private String[] columnNames = new String[5]; private String[] columnMinMaxNames = new String[5]; - private Object[][] dataDetailedByTask; private Object[][] dataDetailedMinMax; - private static JTable table11, table12; private JTextField file1; private File file; private static Vector<SimulationTransaction> transFile1; private JLabel task2, taskL; private DirectedGraphTranslator dgraph; - private JScrollPane scrollPane11, scrollPane12;// , scrollPane13; - private LatencyAnalysisParallelAlgorithms tc; private Boolean allop = false; private TMLMapping<TGComponent> tmap1; - public static final String[] helpStrings = { "considerRule.html", "taint.html", "addRule.html" }; - private static final String startTimeColName = "Start Time "; - private static final String endTimeColName = "End Time "; - private static final String latencyColName = "Latency "; - private static final String opAColName = "OPERATOR A"; - private static final String opBColName = "OPERATOR B "; - private static final String progressBar = "Progress of Graph Generation"; - + private static final String START_TIME_COL_NAME = "Start Time "; + private static final String END_TIME_COL_NAME = "End Time "; + private static final String LATENCY_COL_NAME = "Latency "; + private static final String OP_A_COL_NAME = "OPERATOR A"; + private static final String OP_B_COL_NAME = "OPERATOR B "; + private static final String PROGRESS_BAR = "Progress of Graph Generation"; // @SuppressWarnings("deprecation") - private JProgressBar pbar; private JFrameCompareLatencyDetail jframeCompareLatencyDetail; private JCheckBox taintFirstOp, considerRules; @@ -209,16 +184,12 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe tmap1 = tmap; fillCheckedTrans(tmap); tc = tc1; - file = new File(selectedST.getFullPath()); // ruleDirection.add("Before"); ruleDirection.add("After"); - GridBagLayout gridbagmain = new GridBagLayout(); - GridBagConstraints mainConstraint = new GridBagConstraints(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - Container framePanel = getContentPane(); framePanel.setLayout(gridbagmain); // mainConstraint.weighty = 1.0; @@ -227,35 +198,24 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe mainConstraint.gridy = 0; // mainConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row mainConstraint.fill = GridBagConstraints.HORIZONTAL; - buttonShowDGraph = new JButton(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH]); - latencybutton = new JButton(actions[LatencyDetailedAnalysisActions.ACT_LATENCY]); - preciseAnalysisbutton = new JButton(actions[LatencyDetailedAnalysisActions.ACT_LATENCY_PRECISE_ANALYSIS]); buttonClose = new JButton(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_ALL]); buttonCheckPath = new JButton(actions[LatencyDetailedAnalysisActions.ACT_CHECK_PATH]); - JPanel jp = new JPanel(); - jp.add(buttonShowDGraph); - jp.add(latencybutton); jp.add(preciseAnalysisbutton); jp.add(buttonCheckPath); - jp.add(buttonClose); - latencybutton.setEnabled(false); buttonShowDGraph.setEnabled(false); preciseAnalysisbutton.setEnabled(false); - framePanel.add(jp, mainConstraint); - GridBagLayout gridbag01 = new GridBagLayout(); GridBagConstraints c01 = new GridBagConstraints(); progressBarpanel = new JPanel(gridbag01); - c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; @@ -263,349 +223,173 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe c01.gridx = 0; c01.gridy = 0; // c01.fill = GridBagConstraints.BOTH; - - JLabel pBarLabel = new JLabel(progressBar, JLabel.LEFT); + JLabel pBarLabel = new JLabel(PROGRESS_BAR, JLabel.LEFT); progressBarpanel.add(pBarLabel, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 0; - pbar = new JProgressBar(); pbar.setForeground(Color.GREEN); - progressBarpanel.add(pbar, c01); - mainConstraint.gridheight = 1; mainConstraint.gridx = 0; mainConstraint.gridy = 3; mainConstraint.ipady = 40; mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(progressBarpanel, mainConstraint); - commands = new JPanel(new BorderLayout()); commands.setBorder(new javax.swing.border.TitledBorder("load/Save")); - - mainConstraint.gridheight = 1; - mainConstraint.gridx = 0; mainConstraint.gridy = 1; mainConstraint.gridwidth = 1; // end row mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(commands, mainConstraint); - graphAnalysisResult = new JPanel(new BorderLayout()); graphAnalysisResult.setBorder(new javax.swing.border.TitledBorder("Latency Analysis ")); - mainConstraint.gridheight = 1; - // .weighty =0.5; - // mainConstraint.weightx = 0.5; mainConstraint.weighty = 1.0; mainConstraint.weightx = 1.0; mainConstraint.gridx = 0; mainConstraint.gridy = 2; mainConstraint.ipady = 200; - mainConstraint.gridwidth = 1; // end row - // mainConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row mainConstraint.fill = GridBagConstraints.BOTH; - framePanel.add(graphAnalysisResult, mainConstraint); - jp05 = new JPanel(new BorderLayout()); // mainpanel.add(split, BorderLayout.SOUTH); mainConstraint.weighty = 00; mainConstraint.ipady = 100; - mainConstraint.gridx = 0; mainConstraint.gridy = 4; - mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(jp05, mainConstraint); commandTab = GraphicLib.createTabbedPaneRegular();// new JTabbedPane(); - gridbag01 = new GridBagLayout(); c01 = new GridBagConstraints(); loadxml = new JPanel(gridbag01); - commandTab.addTab("load XML", null, loadxml, "load XML"); - + commandTab.addTab("Load XML", null, loadxml, "Load XML"); c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 0; - // c01.fill = GridBagConstraints.BOTH; - - JLabel xmlLabel = new JLabel("Simulation trace as XML File ", JLabel.LEFT); + JLabel xmlLabel = new JLabel("Simulation Trace as XML File ", JLabel.LEFT); loadxml.add(xmlLabel, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 2; - // c01.fill = GridBagConstraints.BOTH; - JLabel tasksLabel = new JLabel("Study Latency Between ", JLabel.LEFT); loadxml.add(tasksLabel, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 1; - // c01.fill = GridBagConstraints.BOTH; - taskL = new JLabel("Select Task 1 ", JLabel.LEFT); loadxml.add(taskL, c01); - file1 = new JTextField(40); file1.setMinimumSize(new Dimension(300, 30)); file1.setText(selectedST.getFullPath()); file1.setEditable(false); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 0; - loadxml.add(file1, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 1; tasksDropDownCombo6 = new JComboBox<String>(checkedTransactions); loadxml.add(tasksDropDownCombo6, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 2; tasksDropDownCombo1 = new JComboBox<String>(checkedTransactions); loadxml.add(tasksDropDownCombo1, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; c01.weightx = 0.2; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 1; - task2 = new JLabel("And task 2 ", JLabel.LEFT); - + task2 = new JLabel("and Task 2 ", JLabel.LEFT); loadxml.add(task2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 0.2; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 2; - JLabel op2 = new JLabel("And ", JLabel.LEFT); + JLabel op2 = new JLabel("and ", JLabel.LEFT); loadxml.add(op2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 4; c01.gridy = 2; - tasksDropDownCombo2 = new JComboBox<String>(checkedTransactions); - loadxml.add(tasksDropDownCombo2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 4; c01.gridy = 1; - tasksDropDownCombo7 = new JComboBox<String>(checkedTransactions); - loadxml.add(tasksDropDownCombo7, c01); - task2.setVisible(false); taskL.setVisible(false); tasksDropDownCombo6.setVisible(false); tasksDropDownCombo7.setVisible(false); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 5; c01.gridy = 2; - showAllOp = new JButton(actions[LatencyDetailedAnalysisActions.ACT_SHOW_ALL_OP]); loadxml.add(showAllOp, c01); - /* - * c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; c01.gridwidth = 1; - * c01.gridx = 0; c01.gridy = 3; - * - * JLabel taintLabel = new JLabel("Taint ", JLabel.LEFT); - * loadxml.add(taintLabel, c01); - */ - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 4; - considerRules = new JCheckBox("Consider Rules"); - loadxml.add(considerRules, c01); checkRuleHelp = new TGTextFieldWithHelp("", 0); checkRuleHelp.setEditable(false); // loadxml.add(sliceTime, c01); - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 4; c01.anchor = GridBagConstraints.WEST; checkRuleHelp.makeEndHelpButton(helpStrings[0], tc.getMainGUI(), tc.getMainGUI().getHelpManager(), loadxml, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 4; c01.anchor = GridBagConstraints.EAST; - taintFirstOp = new JCheckBox("Taint First Operator "); loadxml.add(taintFirstOp, c01); - taintHelp = new TGTextFieldWithHelp("", 0); taintHelp.setEditable(false); - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 4; c01.anchor = GridBagConstraints.WEST; taintHelp.makeEndHelpButton(helpStrings[1], tc.getMainGUI(), tc.getMainGUI().getHelpManager(), loadxml, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 3; c01.gridy = 4; - GridBagLayout gridbag05 = new GridBagLayout(); GridBagConstraints c05 = new GridBagConstraints(); // Save jp06 = new JPanel(gridbag05); - JLabel tasksRules = new JLabel("ADD Rule : ", JLabel.LEFT); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 0; - jp06.add(tasksRules, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 0; tasksDropDownCombo3 = new JComboBox<String>(readChannelTransactions); jp06.add(tasksDropDownCombo3, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 0; - tasksDropDownCombo5 = new JComboBox<String>(ruleDirection); - jp06.add(tasksDropDownCombo5, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 3; c01.gridy = 0; - tasksDropDownCombo4 = new JComboBox<String>(writeChannelTransactions); - jp06.add(tasksDropDownCombo4, c01); - addRulebutton = new JButton(actions[LatencyDetailedAnalysisActions.ACT_ADD_RULE]); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 4; c01.gridy = 0; - jp06.add(addRulebutton, c01); - viewRulesbutton = new JButton(actions[LatencyDetailedAnalysisActions.ACT_VIEW_RULE]); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 4; c01.gridy = 2; - jp06.add(viewRulesbutton, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 0; c01.gridy = 0; - ruleHelp = new TGTextFieldWithHelp("", 0); ruleHelp.setEditable(false); - c01.anchor = GridBagConstraints.EAST; ruleHelp.makeEndHelpButton(helpStrings[2], tc.getMainGUI(), tc.getMainGUI().getHelpManager(), jp06, c01); - JScrollPane scrollPane = new JScrollPane(jp06); - commandTab.addTab("Add Rules", null, scrollPane, "Add Rules"); GridBagLayout gridbag04 = new GridBagLayout(); GridBagConstraints c04 = new GridBagConstraints(); // Save jp01 = new JPanel(gridbag04); - - commandTab.addTab("Save Graph", null, jp01, "Save graph"); - + commandTab.addTab("Save Graph", null, jp01, "Save Graph"); c04.anchor = GridBagConstraints.FIRST_LINE_START; - c04.gridheight = 1; c04.weighty = 1.0; c04.weightx = 1.0; @@ -614,22 +398,17 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe c04.gridwidth = GridBagConstraints.REMAINDER; // end row c04.fill = GridBagConstraints.HORIZONTAL; c04.gridheight = 1; - sgtb = new SaveGraphToolBar(this); jp01.add(sgtb, c04); - jp02 = new JPanel(gridbag04); gridbag01 = new GridBagLayout(); c01 = new GridBagConstraints(); jp02.setLayout(gridbag01); - c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; c01.gridwidth = GridBagConstraints.REMAINDER; // end row c01.fill = GridBagConstraints.HORIZONTAL; - c01.gridheight = 1; - jp02.add(new JLabel("Directory:"), c01); saveDirName = new JTextField(30); // saveDirName.setMinimumSize(new Dimension(100, 100)); @@ -639,9 +418,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jp02.add(saveDirName, c01); jp02.add(new JLabel("File name:"), c01); saveFileName = new JTextField(30); - jp02.add(saveFileName, c01); - c04.gridheight = 1; c04.weighty = 1.0; c04.weightx = 1.0; @@ -650,68 +427,49 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe c04.gridwidth = GridBagConstraints.REMAINDER; // end row c04.fill = GridBagConstraints.HORIZONTAL; c04.gridheight = 1; - jp01.add(jp02, c04); - // mainTop.add(loadxml, c02); - commands.add(commandTab, BorderLayout.NORTH); - - columnNames[0] = opAColName; - columnNames[1] = startTimeColName; - columnNames[2] = opBColName; - columnNames[3] = endTimeColName; - columnNames[4] = latencyColName; - + columnNames[0] = OP_A_COL_NAME; + columnNames[1] = START_TIME_COL_NAME; + columnNames[2] = OP_B_COL_NAME; + columnNames[3] = END_TIME_COL_NAME; + columnNames[4] = LATENCY_COL_NAME; // columnNames[5] = "Related Tasks Details "; // columnNames[6] = "Total time- Related Tasks "; - dataDetailedByTask = new Object[0][0]; - jp03 = new JPanel(new BorderLayout()); DefaultTableModel tableModel = new DefaultTableModel(dataDetailedByTask, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table11 = new JTable(tableModel); - scrollPane11 = new JScrollPane(table11, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane11.setVisible(true); jp03.add(scrollPane11, BorderLayout.CENTER); - - columnMinMaxNames[0] = opAColName; - columnMinMaxNames[1] = startTimeColName; - columnMinMaxNames[2] = opBColName; - columnMinMaxNames[3] = endTimeColName; - columnMinMaxNames[4] = latencyColName; - + columnMinMaxNames[0] = OP_A_COL_NAME; + columnMinMaxNames[1] = START_TIME_COL_NAME; + columnMinMaxNames[2] = OP_B_COL_NAME; + columnMinMaxNames[3] = END_TIME_COL_NAME; + columnMinMaxNames[4] = LATENCY_COL_NAME; dataDetailedMinMax = new Object[0][0]; - jp04 = new JPanel(new BorderLayout()); - DefaultTableModel tableModel2 = new DefaultTableModel(dataDetailedMinMax, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table12 = new JTable(tableModel2); scrollPane12 = new JScrollPane(table12, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane12.setVisible(true); jp04.add(scrollPane12, BorderLayout.CENTER); - resultTab = GraphicLib.createTabbedPaneRegular();// new JTabbedPane(); - resultTab.addTab("Latency Values", null, jp03, "Latency detailed By Tasks "); + resultTab.addTab("Latency Values", null, jp03, "Latency Detailed by Tasks "); resultTab.addTab("Min/Max Latency", null, jp04, "Min and Max Latency"); - graphAnalysisResult.add(resultTab, BorderLayout.CENTER); - jta = new ScrolledJTextArea(); jta.setBackground(ColorManager.InteractiveSimulationJTABackground); jta.setForeground(ColorManager.InteractiveSimulationJTAForeground); @@ -727,19 +485,15 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setViewportBorder(BorderFactory.createLineBorder(ColorManager.InteractiveSimulationBackground)); jsp.setVisible(true); - jp05.setMaximumSize(new Dimension(800, 500)); jp05.add(jsp, BorderLayout.CENTER); - this.pack(); this.setVisible(true); - tc.setjFrameLDA(this); tc.setCpanels(cpanels); tc.setTmap(tmap); tc.start(1); tc.run(); - } public JProgressBar getPbar() { @@ -755,47 +509,36 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe } protected void generateDirectedGraph(TMLMapping<TGComponent> tmap, List<TMLComponentDesignPanel> cpanels) { - try { dgraph = new DirectedGraphTranslator(this, jframeCompareLatencyDetail, tmap, cpanels, 0); - jta.append("A Directed Graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); + jta.append("A directed graph with " + dgraph.getGraphsize() + " vertices and " + dgraph.getGraphEdgeSet() + " edges was generated.\n"); // buttonSaveDGraph.setEnabled(true); - if (dgraph.getWarnings().size() > 0) { jta.append("Warnings: \n "); - for (int i = 0; i < dgraph.getWarnings().size(); i++) { jta.append(" - " + dgraph.getWarnings().get(i) + "\n "); } - } buttonShowDGraph.setEnabled(true); - readChannelTransactions.addAll(dgraph.getreadChannelNodes()); writeChannelTransactions.addAll(dgraph.getwriteChannelNodes()); - ComboBoxModel<String> aModel = new DefaultComboBoxModel<String>(readChannelTransactions); ComboBoxModel<String> aModel1 = new DefaultComboBoxModel<String>(writeChannelTransactions); - tasksDropDownCombo3.setModel(aModel); tasksDropDownCombo4.setModel(aModel1); - if (pbar.getValue() == pbar.getMaximum()) { updateBar(0); - } latencybutton.setEnabled(true); this.pack(); this.revalidate(); this.repaint(); - } catch (Exception e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); // buttonSaveDGraph.setEnabled(false); buttonShowDGraph.setEnabled(false); } - } private void initActions() { @@ -805,7 +548,6 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe actions[i].addActionListener(this); // actions[i].addKeyListener(this); } - } @SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) @@ -813,17 +555,12 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); // TraceManager.addDev("Command:" + command); - if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_PNG].getActionCommand())) { - try { String filename = ""; - final String directory = saveDirName.getText().trim(); - String param = saveFileName.getText().trim(); if (param.length() > 0) { - if (!directory.isEmpty()) { if (!directory.endsWith(File.separator)) filename = directory + File.separator + param; @@ -831,11 +568,10 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe filename = directory + param; } dgraph.exportGraphAsImage(filename); - jta.append("Directed Graph Save in" + filename + ".png \n"); + jta.append("Directed graph save in" + filename + ".png \n"); } else { error("Wrong parameter: must be a file name"); } - } catch (ExportException e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); @@ -843,17 +579,12 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); } - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_GRAPHML].getActionCommand())) { try { - String filename = ""; - final String directory = saveDirName.getText().trim(); - String param = saveFileName.getText().trim(); if (param.length() > 0) { - if (!directory.isEmpty()) { if (!directory.endsWith(File.separator)) filename = directory + File.separator + param; @@ -861,12 +592,10 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe filename = directory + param; } dgraph.exportGraph(filename); - jta.append("Directed Graph Save in" + filename + ".graphml \n"); - + jta.append("Directed graph saved in" + filename + ".graphml \n"); } else { error("Wrong parameter: must be a file name"); } - } catch (ExportException e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); @@ -874,13 +603,11 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); } - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SHOW_GRAPH].getActionCommand())) { tc.setjFrameLDA(this); tc.start(12); tc.run(); // tc.showgraphFrame(); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_ALL].getActionCommand())) { jta.setText(""); dispose(); @@ -889,19 +616,15 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jta.append("The Latency Between: \n " + tasksDropDownCombo1.getSelectedItem() + " and \n" + tasksDropDownCombo2.getSelectedItem() + " is studied \n"); latencybutton.setEnabled(false); - this.pack(); this.revalidate(); this.repaint(); - if (taintFirstOp.isSelected()) { jta.append("Operator 1 is tainted \n "); } - if (considerRules.isSelected()) { jta.append("Rules are considered in the graph \n "); } - try { tc.getT().join(); } catch (InterruptedException e) { @@ -912,24 +635,18 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe tc.setjFrameLDA(this); tc.start(13); tc.run(); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_Import_ANALYSIS].getActionCommand())) { if (ConfigurationTTool.SystemCCodeDirectory.length() > 0) { fc2 = new JFileChooser(ConfigurationTTool.SystemCCodeDirectory); } else { fc2 = new JFileChooser(); } - FileNameExtensionFilter filter = new FileNameExtensionFilter("graphml files", "graphml"); fc2.setFileFilter(filter); - int returnVal = fc2.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc2.getSelectedFile(); - } - FileReader ps = null; try { ps = new FileReader(file); @@ -937,54 +654,37 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe // TODO Auto-generated catch block e1.printStackTrace(); } - VertexProvider<String> vertexProvider = (label, attributes) -> { String cv = new String(label); cv.replaceAll("\\s+", ""); // cv.replaceAll("(", ""); // cv.replaceAll(")", ""); return cv; - }; - EdgeProvider<String, DefaultEdge> edgeProvider = (from, to, label, attributes) -> new DefaultEdge(); - GraphMLImporter<String, DefaultEdge> importer = new GraphMLImporter<String, DefaultEdge>(vertexProvider, edgeProvider); - try { Graph<String, DefaultEdge> importedGraph = new DefaultDirectedGraph<>(DefaultEdge.class); ; importer.importGraph(importedGraph, ps); - } catch (ImportException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_CHECK_PATH].getActionCommand())) { - String task1 = tasksDropDownCombo1.getSelectedItem().toString(); String task2 = tasksDropDownCombo2.getSelectedItem().toString(); - String message = dgraph.checkPath(task1, task2); - jta.append(message + " :" + task1 + " and " + task2 + " \n"); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_ADD_RULE].getActionCommand())) { - String node1 = tasksDropDownCombo3.getSelectedItem().toString(); String node2 = tasksDropDownCombo4.getSelectedItem().toString(); String ruleDirection = tasksDropDownCombo5.getSelectedItem().toString(); - String message = dgraph.addRule(node1, node2, writeChannelTransactions, ruleDirection); - jta.append(message + " \n"); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_VIEW_RULE].getActionCommand())) { - new JFrameListOfRules(dgraph); } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_LATENCY_PRECISE_ANALYSIS].getActionCommand())) { - int row1 = 0; String noLatValue = null; int selectedIndex = resultTab.getSelectedIndex(); @@ -994,24 +694,17 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe noLatValue = table11.getValueAt(row1, 4).toString(); } else { jta.append("Please select a row before precise analysis" + " \n"); - } - } else if (selectedIndex == 1) { row1 = table12.getSelectedRow(); if (row1 > -1) { - noLatValue = table12.getValueAt(row1, 4).toString(); } else { jta.append("Please select a row before precise analysis" + " \n"); - } - } - if (noLatValue.startsWith("Assumption Does Not Hold;")) { jta.append("Can not run latency when the one-to-one assumption does not hold" + " \n"); - } else { tc.setjFrameLDA(this); tc.setRow(row1); @@ -1020,37 +713,26 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe // tc.getT().join(); } } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_SHOW_ALL_OP].getActionCommand())) { - if (!allop) { - for (TMLTask tmltask : tmap1.getTMLModeling().getTasks()) { - allTasks.add(tmltask.getName()); - } - ComboBoxModel<String> taskModel = new DefaultComboBoxModel<String>(allTasks); tasksDropDownCombo6.setModel(taskModel); tasksDropDownCombo6.addActionListener(actions[LatencyDetailedAnalysisActions.ACT_LOAD_ALL_OP]); - ComboBoxModel<String> taskModel2 = new DefaultComboBoxModel<String>(allTasks); tasksDropDownCombo7.setModel(taskModel2); tasksDropDownCombo7.addActionListener(actions[LatencyDetailedAnalysisActions.ACT_LOAD_ALL_OP2]); - ComboBoxModel<String> aModel1 = new DefaultComboBoxModel<String>(checkedTransactions); tasksDropDownCombo2.setModel(aModel1); - tasksDropDownCombo1.setModel(getAlloperators(tasksDropDownCombo6.getItemAt(0))); tasksDropDownCombo2.setModel(getAlloperators(tasksDropDownCombo7.getItemAt(0))); - // ComboBoxModel<String> aModel2 = new // DefaultComboBoxModel<String>(checkedTransactions); // tasksDropDownCombo1.setModel(aModel2); - allop = true; showAllOp.setLabel("Show checkpoints operators"); jta.append("Show latency checkpoints operators" + " \n"); - task2.setVisible(true); taskL.setVisible(true); tasksDropDownCombo6.setVisible(true); @@ -1058,73 +740,52 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe this.pack(); this.revalidate(); this.repaint(); - } else { checkedTransactions = new Vector<String>(); checkedT = new HashMap<String, Integer>(); fillCheckedTrans(tmap1); ComboBoxModel<String> aModel = new DefaultComboBoxModel<String>(checkedTransactions); ComboBoxModel<String> aModel1 = new DefaultComboBoxModel<String>(checkedTransactions); - tasksDropDownCombo1.setModel(aModel); - tasksDropDownCombo2.setModel(aModel1); task2.setVisible(false); taskL.setVisible(false); tasksDropDownCombo6.setVisible(false); tasksDropDownCombo7.setVisible(false); - this.pack(); this.revalidate(); this.repaint(); - allop = false; showAllOp.setLabel("Show all operators"); - jta.append("Show latency all operators" + " \n"); - + jta.append("Show all operators" + " \n"); } - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_LOAD_ALL_OP].getActionCommand())) { - tasksDropDownCombo1.setModel(getAlloperators(tasksDropDownCombo6.getSelectedItem())); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_LOAD_ALL_OP2].getActionCommand())) { - tasksDropDownCombo2.setModel(getAlloperators(tasksDropDownCombo7.getSelectedItem())); - } - } private ComboBoxModel<String> getAlloperators(Object object) { - TMLActivity activity; checkedTransactions = new Vector<String>(); allTasks = new Vector<String>(); checkedT = new HashMap<String, Integer>(); - for (TMLTask tmltask : tmap1.getTMLModeling().getTasks()) { - int opCount = 0; - if (tmltask.getName().equals(object)) { - activity = tmltask.getActivityDiagram(); TMLActivityDiagramPanel tadp = (TMLActivityDiagramPanel) (activity.getReferenceObject()); List<TGComponent> list = tadp.getComponentList(); // Iterator<TGComponent> iterator = list.listIterator(); // TGComponent tgc; opCount = 0; - for (TGComponent tgc : list) { - String compName = ""; if (tgc.isEnabled()) { if (tgc instanceof CheckableLatency) { - compName = tmltask.getName() + ":" + tgc.getName(); compName = compName.replaceAll(" ", ""); - if (tgc.getValue().contains("(")) { compName = compName + ":" + tgc.getValue().split("\\(")[0]; } else { @@ -1133,65 +794,43 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe } } checkedT.put(compName + "__" + tgc.getDIPLOID(), tgc.getDIPLOID()); - } } - } - } - } for (Entry<String, Integer> cT : checkedT.entrySet()) { - String name = cT.getKey(); int id = cT.getValue(); - if (!checkedTransactions.contains(name)) { if (checkedTransactions.size() > 0) { Boolean inserted = false; - for (int j = 0; j < checkedTransactions.size(); j++) { - - if (id < checkedT.get(checkedTransactions.get(j)) && !checkedTransactions.contains(name)) - - { + if (id < checkedT.get(checkedTransactions.get(j)) && !checkedTransactions.contains(name)) { checkedTransactions.insertElementAt(name, j); inserted = true; - } - } - if (!inserted) { checkedTransactions.insertElementAt(name, checkedTransactions.size()); } } else { checkedTransactions.add(name); - } - } - } - ComboBoxModel<String> aModel = new DefaultComboBoxModel<String>(checkedTransactions); return aModel; - } protected void preciselatencyAnalysis(int row1) throws InterruptedException { - tc.getT().join(); Boolean taint = taintFirstOp.isSelected(); - int selectedIndex = resultTab.getSelectedIndex(); int row = -1; if (selectedIndex == 0) { row = table11.getSelectedRow(); - if (row >= 0) { - try { new JFrameLatencyDetailedPopup(dgraph, row, true, taint, tc, true); } catch (Exception e) { @@ -1202,7 +841,6 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jta.append("Please select a row to analyze \n"); } } else if (selectedIndex == 1) { - row = table12.getSelectedRow(); if (row >= 0) { try { @@ -1215,7 +853,6 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe jta.append("Please select a row to analyze \n"); } } - } public Vector<SimulationTransaction> parseFile(File file2) { @@ -1229,7 +866,6 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe error(e.getMessage()); } SimulationTransactionParser handler = new SimulationTransactionParser(); - try { saxParser.parse(file2, handler); } catch (SAXException e) { @@ -1245,113 +881,80 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe preciseAnalysisbutton.setEnabled(false); String task1 = tasksDropDownCombo1.getSelectedItem().toString(); String task2 = tasksDropDownCombo2.getSelectedItem().toString(); - Object[][] tableData = null; Boolean taint = taintFirstOp.isSelected(); Boolean considerAddedRules = considerRules.isSelected(); - tableData = dgraph.latencyDetailedAnalysis(task1, task2, transFile1, taint, considerAddedRules); - table11.removeAll(); - DefaultTableModel tableModel = new DefaultTableModel(tableData, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table11 = new JTable(tableModel); - table11.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - table11.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { preciseAnalysisbutton.setEnabled(true); } }); - Object[][] tableData2 = null; - if (taint) { - tableData2 = dgraph.latencyMinMaxAnalysisTaintedData(task1, task2, transFile1); - table12.removeAll(); - DefaultTableModel tableModel2 = new DefaultTableModel(tableData2, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table12 = new JTable(tableModel2); - table12.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table12.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { preciseAnalysisbutton.setEnabled(true); } }); - } else { tableData2 = dgraph.latencyMinMaxAnalysis(task1, task2, transFile1); - table12.removeAll(); - DefaultTableModel tableModel2 = new DefaultTableModel(tableData2, columnMinMaxNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } }; - table12 = new JTable(tableModel2); - // table12 = new JTable(tableData2, columnMinMaxNames); - table12.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table12.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { preciseAnalysisbutton.setEnabled(true); } }); - } - table12.repaint(); table12.revalidate(); - scrollPane12.setViewportView(table12); scrollPane12.revalidate(); scrollPane12.repaint(); - // scrollPane12.setVisible(true); - table11.repaint(); table11.revalidate(); - scrollPane11.setViewportView(table11); scrollPane11.revalidate(); scrollPane11.repaint(); - // scrollPane11.setVisible(true); jta.append("Latency has been computed...Please refer to the tables in the Latency Analysis section for the results \n"); - latencybutton.setEnabled(true); this.pack(); this.setVisible(true); - } catch (Exception e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); latencybutton.setEnabled(true); } - } public void error(String error) { @@ -1361,14 +964,11 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe protected void showgraphFrame() { try { dgraph.showGraph(dgraph); - jta.append("Refer to the generatd dialog to view the graph.\n"); - } catch (Exception e) { jta.append("An error has occurred \n"); jta.append(e.getMessage() + "\n"); } - } public void fillCheckedTrans(TMLMapping<TGComponent> tmap) { @@ -1379,42 +979,27 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe String compName = tmap.getTMLModeling().getCheckedComps().get(tgc); // TraceManager.addDev(compName + "__" + tgc.getDIPLOID()); checkedT.put(compName + "__" + tgc.getDIPLOID(), tgc.getDIPLOID()); - } - for (Entry<String, Integer> cT : checkedT.entrySet()) { - String name = cT.getKey(); int id = cT.getValue(); - if (!checkedTransactions.contains(name)) { if (checkedTransactions.size() > 0) { Boolean inserted = false; - for (int j = 0; j < checkedTransactions.size(); j++) { - - if (id < checkedT.get(checkedTransactions.get(j)) && !checkedTransactions.contains(name)) - - { + if (id < checkedT.get(checkedTransactions.get(j)) && !checkedTransactions.contains(name)) { checkedTransactions.insertElementAt(name, j); inserted = true; - } - } - if (!inserted) { checkedTransactions.insertElementAt(name, checkedTransactions.size()); } } else { checkedTransactions.add(name); - } - } - } - } public Vector<String> getCheckedTransactions() { @@ -1424,49 +1009,41 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe @Override public void stateChanged(ChangeEvent e) { // TODO Auto-generated method stub - } @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub - } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub - } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub - } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub - } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub - } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub - } @Override public void run() { // TODO Auto-generated method stub - } public Thread getT() { @@ -1492,5 +1069,4 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe public TMLMapping<TGComponent> getTmap1() { return tmap1; } - } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedPopup.java b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedPopup.java index 69bbee14c5..a9935d0e45 100644 --- a/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedPopup.java +++ b/src/main/java/ui/simulationtraceanalysis/JFrameLatencyDetailedPopup.java @@ -35,7 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import java.awt.BorderLayout; @@ -49,7 +48,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.Vector; - import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; @@ -62,7 +60,6 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; - import ui.interactivesimulation.SimulationTransaction; /** @@ -74,7 +71,6 @@ import ui.interactivesimulation.SimulationTransaction; * @author Maysam Zoor */ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelListener { - private String[] columnByTaskNames = new String[5]; private String[] columnByHWNames = new String[5]; private JScrollPane scrollPane12, scrollPane13, scrollPane14; @@ -85,75 +81,55 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList private List<String> offPathBehavior = new ArrayList<String>(); private List<String> offPathBehaviorCausingDelay = new ArrayList<String>(); // private Thread t, t1; - private Object[][] dataHWDelayByTask; - - private static final String transactionList = "Transaction List "; - private static final String transactionDiagramName = "Transaction Diagram Name "; - private static final String hardware = "Hardware "; - private static final String startTime = "Start Time "; - private static final String endTime = "End Time "; - private static final String mandatoryTransactions = "Mandatory Transactions "; - private static final String tasksonSameDevice = "Tasks on the Same Device "; - private static final String nonMandatoryTransactions = "Non-Mandatory Transactions"; - private static final String nonMandNoContTran = "Non-Mandatory Transactions No-Contention"; + private static final String TRANSACTION_LIST = "Transaction List "; + private static final String TRANSACTION_DIAGRAM_NAME = "Transaction Diagram Name "; + private static final String HARDWARE = "Hardware "; + private static final String START_TIME = "Start Time "; + private static final String END_TIME = "End Time "; + private static final String MANDATORY_TRANSACTIONS = "Mandatory Transactions "; + private static final String TASKS_ON_SAME_DEVICE = "Tasks on the Same Device "; + private static final String NON_MANDATORY_TRANSACTIONS = "Non-Mandatory Transactions"; + private static final String NON_MAND_NO_CONT_TRAN = "Non-Mandatory Transactions No-Contention"; + private static final String DEVICE_NAME = "Device Name"; + private static final String ZERO = "0"; public JFrameLatencyDetailedPopup(DirectedGraphTranslator dgraph, int row, boolean firstTable, Boolean taint, LatencyAnalysisParallelAlgorithms th, boolean visible) throws InterruptedException { - super("Precise Latency By Row"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); GridLayout myLayout = new GridLayout(4, 1); - this.setLayout(myLayout); - - columnByTaskNames[0] = transactionList; - columnByTaskNames[1] = transactionDiagramName; - columnByTaskNames[2] = hardware; - columnByTaskNames[3] = startTime; - columnByTaskNames[4] = endTime; - + columnByTaskNames[0] = TRANSACTION_LIST; + columnByTaskNames[1] = TRANSACTION_DIAGRAM_NAME; + columnByTaskNames[2] = HARDWARE; + columnByTaskNames[3] = START_TIME; + columnByTaskNames[4] = END_TIME; JPanel jp04 = new JPanel(new BorderLayout()); - - jp04.setBorder(new javax.swing.border.TitledBorder(mandatoryTransactions)); - + jp04.setBorder(new javax.swing.border.TitledBorder(MANDATORY_TRANSACTIONS)); if (firstTable) { - th.setDgraph(dgraph); th.setRow(row); th.start(2); th.run(); - dataDetailedByTask = th.getDataDetailedByTask(); - } else { if (taint) { - th.setDgraph(dgraph); th.setRow(row); - th.start(3); th.run(); // th.getT().join(); - dataDetailedByTask = th.getDataDetailedByTask(); - } else { - th.setDgraph(dgraph); th.setRow(row); - th.start(4); th.run(); - dataDetailedByTask = th.getDataDetailedByTask(); - } - } - DefaultTableModel model = new DefaultTableModel(dataDetailedByTask, columnByTaskNames) { - @Override public boolean isCellEditable(int row, int column) { return false; @@ -177,61 +153,40 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList } } }; - JTable taskNames = new JTable(model); taskNames.setAutoCreateRowSorter(true); scrollPane12 = new JScrollPane(taskNames, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane12.setVisible(visible); - jp04.add(scrollPane12); - this.add(jp04); - - columnByHWNames[0] = tasksonSameDevice; - columnByHWNames[1] = transactionDiagramName; - columnByHWNames[2] = hardware; - columnByHWNames[3] = startTime; - columnByHWNames[4] = endTime; - + columnByHWNames[0] = TASKS_ON_SAME_DEVICE; + columnByHWNames[1] = TRANSACTION_DIAGRAM_NAME; + columnByHWNames[2] = HARDWARE; + columnByHWNames[3] = START_TIME; + columnByHWNames[4] = END_TIME; if (firstTable) { - th.setDgraph(dgraph); th.setRow(row); - th.start(5); th.run(); // th.getT().join(); - dataHWDelayByTask = th.getDataDetailedByTask(); - } else { - if (taint) { - th.setDgraph(dgraph); th.setRow(row); - th.start(6); th.run(); - dataHWDelayByTask = th.getDataDetailedByTask(); - } else { - th.setDgraph(dgraph); th.setRow(row); - th.start(7); th.run(); - dataHWDelayByTask = th.getDataDetailedByTask(); - } } - DefaultTableModel model2 = new DefaultTableModel(dataHWDelayByTask, columnByHWNames) { - @Override public boolean isCellEditable(int row, int column) { return false; @@ -256,178 +211,111 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList } }; JPanel jp05 = new JPanel(new BorderLayout()); - - jp05.setBorder(new javax.swing.border.TitledBorder(nonMandatoryTransactions)); + jp05.setBorder(new javax.swing.border.TitledBorder(NON_MANDATORY_TRANSACTIONS)); JTable hardwareNames = new JTable(model2); hardwareNames.setAutoCreateRowSorter(true); - scrollPane13 = new JScrollPane(hardwareNames, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane13.setVisible(visible); jp05.add(scrollPane13); this.add(jp05); - int maxTime = -1; - int minTime = Integer.MAX_VALUE; int tmpEnd, tmpStart, length; - Vector<String> deviceNames1 = new Vector<String>(); - if (firstTable) { - for (SimulationTransaction st : dgraph.getRowDetailsTaks(row)) { - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } - for (SimulationTransaction st : dgraph.getRowDetailsByHW(row)) { - tmpEnd = Integer.parseInt(st.endTime); if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } String deviceNameandcore = st.deviceName + "_" + st.coreNumber; if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } - int timeInterval = 0; if (maxTime > -1 && minTime < Integer.MAX_VALUE) { timeInterval = (maxTime - minTime); } - columnNames = new String[timeInterval + 1]; - - columnNames[0] = "Device Name"; + columnNames[0] = DEVICE_NAME; for (int i = 0; i < timeInterval; i++) { - columnNames[i + 1] = Integer.toString(minTime + i); - } - dataDetailedByTask = new Object[deviceNames1.size()][timeInterval + 1]; - for (SimulationTransaction st : dgraph.getRowDetailsTaks(row)) { if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - for (String dName : deviceNames1) { - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (deviceNameandcore.equals(dName)) { - length = Integer.parseInt(st.length); - for (int i = 0; i < length; i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - onPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); if (!dgraph.getOnPath().contains(st)) { dgraph.getOnPath().add(st); } - } - } - } - } - HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = dgraph.getRowDelayDetailsByHW(row); - for (SimulationTransaction st : dgraph.getRowDetailsByHW(row)) { - int startTime = Integer.valueOf(st.startTime); - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - for (String dName : deviceNames1) { - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (deviceNameandcore.equals(dName)) { - length = Integer.parseInt(st.length); - for (int i = 0; i < length; i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - boolean causeDelay = false; - if (delayTime.containsKey(deviceNameandcore)) { - for (Entry<String, ArrayList<ArrayList<Integer>>> entry : delayTime.entrySet()) { if (entry.getKey().equals(deviceNameandcore)) { ArrayList<ArrayList<Integer>> timeList = entry.getValue(); - for (int j = 0; j < timeList.size(); j++) { - if (startTime >= timeList.get(j).get(0) && startTime <= timeList.get(j).get(1)) { - causeDelay = true; - } } - } - } - } - if (causeDelay) { offPathBehaviorCausingDelay.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); - if (!dgraph.getOffPathDelay().contains(st)) { dgraph.getOffPathDelay().add(st); } @@ -437,329 +325,213 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList dgraph.getOffPath().add(st); } } - } } - } - } - for (String dName : deviceNames1) { dataDetailedByTask[deviceNames1.indexOf(dName)][0] = dName; ; } } else { - Vector<SimulationTransaction> minMaxTasksByRow; List<SimulationTransaction> minMaxHWByRowDetails; - // min/max table row selected - if (taint) { - minMaxTasksByRow = dgraph.getMinMaxTasksByRowTainted(row); minMaxHWByRowDetails = dgraph.getTaskMinMaxHWByRowDetailsTainted(row); - for (SimulationTransaction st : minMaxTasksByRow) { - tmpEnd = Integer.parseInt(st.endTime); if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } - for (SimulationTransaction st : minMaxHWByRowDetails) { - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } - } else { - minMaxTasksByRow = dgraph.getMinMaxTasksByRow(row); minMaxHWByRowDetails = dgraph.getTaskMinMaxHWByRowDetails(row); - for (SimulationTransaction st : minMaxTasksByRow) { if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } - for (SimulationTransaction st : minMaxHWByRowDetails) { if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - tmpEnd = Integer.parseInt(st.endTime); - if (tmpEnd > maxTime) { maxTime = tmpEnd; } - tmpStart = Integer.parseInt(st.startTime); - if (tmpStart < minTime) { minTime = tmpStart; } - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (!deviceNames1.contains(deviceNameandcore)) { deviceNames1.add(deviceNameandcore); - } - } } - int timeInterval = 0; if (maxTime > -1 && minTime < Integer.MAX_VALUE) { timeInterval = (maxTime - minTime); } - columnNames = new String[timeInterval + 1]; - - columnNames[0] = "Device Name"; + columnNames[0] = DEVICE_NAME; for (int i = 0; i < timeInterval; i++) { - columnNames[i + 1] = Integer.toString(minTime + i); - } - dataDetailedByTask = new Object[deviceNames1.size()][timeInterval + 1]; - for (SimulationTransaction st : minMaxTasksByRow) { - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - for (String dName : deviceNames1) { - String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (deviceNameandcore.equals(dName)) { - length = Integer.parseInt(st.length); - for (int i = 0; i < length; i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - onPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); if (!dgraph.getOnPath().contains(st)) { dgraph.getOnPath().add(st); } } } - } - } - HashMap<String, ArrayList<ArrayList<Integer>>> delayTime = dgraph.getRowDelayDetailsByHW(row); - for (SimulationTransaction st : minMaxHWByRowDetails) { - int startTime = Integer.valueOf(st.startTime); - if (st.coreNumber == null) { - st.coreNumber = "0"; - + st.coreNumber = ZERO; } - for (String dName : deviceNames1) { String deviceNameandcore = st.deviceName + "_" + st.coreNumber; - if (deviceNameandcore.equals(dName)) { - length = Integer.parseInt(st.length); - for (int i = 0; i < length; i++) { - int columnnmber = Integer.parseInt(st.endTime) - minTime - i; dataDetailedByTask[deviceNames1.indexOf(dName)][columnnmber] = dgraph.getNameIDTaskList().get(st.id); ; - boolean causeDelay = false; - if (delayTime.containsKey(deviceNameandcore)) { - for (Entry<String, ArrayList<ArrayList<Integer>>> entry : delayTime.entrySet()) { if (entry.getKey().equals(deviceNameandcore)) { ArrayList<ArrayList<Integer>> timeList = entry.getValue(); - for (int j = 0; j < timeList.size(); j++) { - if (startTime >= timeList.get(j).get(0) && startTime <= timeList.get(j).get(1)) { - causeDelay = true; - } } - } - } - } - if (causeDelay) { offPathBehaviorCausingDelay.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); if (!dgraph.getOffPathDelay().contains(st)) { dgraph.getOffPathDelay().add(st); } - } else { offPathBehavior.add(dgraph.getNameIDTaskList().get(st.id) + columnNames[columnnmber]); - if (!dgraph.getOffPath().contains(st)) { dgraph.getOffPath().add(st); } } - } } - } - } - for (String dName : deviceNames1) { dataDetailedByTask[deviceNames1.indexOf(dName)][0] = dName; ; } - } - DefaultTableModel model3 = new DefaultTableModel(dataDetailedByTask, columnNames) { - @Override public boolean isCellEditable(int row, int column) { return false; } - }; - JTable table = new JTable(model3); table.setFillsViewportHeight(true); - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - table.setAutoCreateRowSorter(true); - TableRenderer tr = new TableRenderer(onPathBehavior, offPathBehaviorCausingDelay, offPathBehavior); int ncols = table.getColumnCount(); - table.getModel().addTableModelListener(this); - TableColumnModel tcm = table.getColumnModel(); - for (int c = 0; c < ncols; c++) { TableColumn tc = tcm.getColumn(c); tc.setCellRenderer(tr); - } - // set the column width for small tables/ performance issue with big tables if (ncols < 1000) { - for (int c = 0; c < ncols; c++) { TableColumn tc = tcm.getColumn(c); tc.setCellRenderer(tr); tc.setPreferredWidth(100); - TableColumn tableColumn = table.getColumnModel().getColumn(c); int preferredWidth = 100 + tableColumn.getMinWidth(); int maxWidth = tableColumn.getMaxWidth(); - for (int row1 = 0; row1 < table.getRowCount(); row1++) { TableCellRenderer cellRenderer = table.getCellRenderer(row1, c); Component c1 = table.prepareRenderer(cellRenderer, row1, c); int width = c1.getPreferredSize().width + table.getIntercellSpacing().width; preferredWidth = Math.max(preferredWidth, width); - // We've exceeded the maximum width, no need to check other rows - if (preferredWidth >= maxWidth) { preferredWidth = maxWidth; break; } } - tableColumn.setPreferredWidth(preferredWidth); } } scrollPane14 = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane14.setVisible(visible); this.add(scrollPane14); - GridBagLayout gridbag01 = new GridBagLayout(); GridBagConstraints c01 = new GridBagConstraints(); - c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; @@ -769,87 +541,45 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList JLabel pBarLabel0 = new JLabel("Table Lenged: "); JPanel lengedpanel = new JPanel(gridbag01); lengedpanel.add(pBarLabel0, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 2; c01.gridy = 0; - JLabel pBarLabel = new JLabel("Mandatory Transaction", JLabel.RIGHT); - lengedpanel.add(pBarLabel, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 1; c01.gridy = 0; - JLabel pBarLabel2 = new JLabel(" ", JLabel.LEFT); pBarLabel2.setOpaque(true); pBarLabel2.setBackground(Color.GREEN); lengedpanel.add(pBarLabel2, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 4; c01.gridy = 0; - JLabel pBarLabel3 = new JLabel("Non-Mandatory Transactions Causing Contention", JLabel.RIGHT); - lengedpanel.add(pBarLabel3, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 3; c01.gridy = 0; - JLabel pBarLabel4 = new JLabel(" ", JLabel.LEFT); pBarLabel4.setOpaque(true); pBarLabel4.setBackground(Color.RED); lengedpanel.add(pBarLabel4, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 6; c01.gridy = 0; - - JLabel pBarLabel5 = new JLabel(nonMandNoContTran, JLabel.RIGHT); - + JLabel pBarLabel5 = new JLabel(NON_MAND_NO_CONT_TRAN, JLabel.RIGHT); lengedpanel.add(pBarLabel5, c01); - - c01.gridheight = 1; - c01.weighty = 1.0; - c01.weightx = 1.0; - c01.gridwidth = 1; c01.gridx = 5; c01.gridy = 0; - JLabel pBarLabel6 = new JLabel(" ", JLabel.LEFT); pBarLabel6.setOpaque(true); pBarLabel6.setBackground(Color.ORANGE); lengedpanel.add(pBarLabel6, c01); this.add(lengedpanel); - this.pack(); this.setVisible(visible); - // TODO Auto-generated constructor stub } @Override public void tableChanged(TableModelEvent e) { // TODO Auto-generated method stub - } public Object[][] getDataDetailedByTask() { @@ -859,5 +589,4 @@ public class JFrameLatencyDetailedPopup extends JFrame implements TableModelList public Object[][] getDataHWDelayByTask() { return dataHWDelayByTask; } - } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/JFrameListOfRules.java b/src/main/java/ui/simulationtraceanalysis/JFrameListOfRules.java index b7b248453d..382189df20 100644 --- a/src/main/java/ui/simulationtraceanalysis/JFrameListOfRules.java +++ b/src/main/java/ui/simulationtraceanalysis/JFrameListOfRules.java @@ -35,7 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import java.awt.BorderLayout; @@ -53,7 +52,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; - import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; @@ -66,9 +64,7 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; - import org.jgrapht.Graphs; - import myutil.ScrolledJTextArea; import ui.ColorManager; @@ -82,7 +78,6 @@ import ui.ColorManager; * */ public class JFrameListOfRules extends JFrame implements TableModelListener, ActionListener { - private String[] columnByTaskNames = new String[3]; private HashMap<vertex, List<vertex>> ruleAddedEdges = new HashMap<vertex, List<vertex>>(); private HashMap<vertex, List<vertex>> ruleAddedEdgesChannels = new HashMap<vertex, List<vertex>>(); @@ -98,59 +93,41 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act private DefaultTableModel model; public JFrameListOfRules(DirectedGraphTranslator dgraph) { - super("All Added Rules"); initActions(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - directedGraph = dgraph; GridBagLayout gridbagmain = new GridBagLayout(); - GridBagConstraints mainConstraint = new GridBagConstraints(); - Container framePanel = getContentPane(); framePanel.setLayout(gridbagmain); - GridBagLayout gridbag02 = new GridBagLayout(); GridBagConstraints c02 = new GridBagConstraints(); - // Save jp = new JPanel(); - mainConstraint.gridx = 0; mainConstraint.gridy = 0; mainConstraint.fill = GridBagConstraints.HORIZONTAL; - // framePanel.setBackground(Color.red); - buttonDeleteRule = new JButton(actions[LatencyDetailedAnalysisActions.ACT_DELETE_SELECTED_RULE]); buttonDeleteALLRules = new JButton(actions[LatencyDetailedAnalysisActions.ACT_DELETE_ALL_RULE]); buttonClose = new JButton(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_RULE]); - jp.add(buttonDeleteRule); jp.add(buttonDeleteALLRules); jp.add(buttonClose); // jp.setBackground(Color.red); framePanel.add(jp, mainConstraint); - buttonClose.setEnabled(true); buttonDeleteRule.setEnabled(false); - columnByTaskNames[0] = "Operator 2"; columnByTaskNames[1] = "After "; columnByTaskNames[2] = "Operator 1 "; - ruleAddedEdgesChannels = dgraph.getRuleAddedEdgesChannels(); - fillRuleTables(); - scrollPane12 = new JScrollPane(taskNames, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane12.setVisible(true); - rulesList = new JPanel(new BorderLayout()); rulesList.setBorder(new javax.swing.border.TitledBorder("All Added Rules ")); - // mainConstraint.gridheight = 1; // mainConstraint.weighty = 5; // mainConstraint.weightx = 5; @@ -160,11 +137,8 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act mainConstraint.ipady = 200; // mainConstraint.ipady = 500; mainConstraint.fill = GridBagConstraints.BOTH; - rulesList.add(scrollPane12); - framePanel.add(rulesList, mainConstraint); - jp05 = new JPanel(new BorderLayout()); mainConstraint.gridheight = 1; // .weighty =0.5; @@ -177,9 +151,7 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act mainConstraint.gridwidth = 1; // end row // mainConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row mainConstraint.fill = GridBagConstraints.HORIZONTAL; - framePanel.add(jp05, mainConstraint); - jta = new ScrolledJTextArea(); jta.setBackground(ColorManager.InteractiveSimulationJTABackground); jta.setForeground(ColorManager.InteractiveSimulationJTAForeground); @@ -198,10 +170,8 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act jsp.setVisible(true); // jsp.setColumnHeaderView(100); // jsp.setRowHeaderView(30); - jp05.setMaximumSize(new Dimension(800, 500)); jp05.add(jsp, BorderLayout.CENTER); - this.pack(); this.setVisible(true); } @@ -212,29 +182,20 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act for (Entry<vertex, List<vertex>> v : ruleAddedEdgesChannels.entrySet()) { vertex v1 = v.getKey(); List<vertex> lv = v.getValue(); - size = size + lv.size(); } - tableData = new Object[size][3]; - int j = 0; for (Entry<vertex, List<vertex>> v : ruleAddedEdgesChannels.entrySet()) { vertex v1 = v.getKey(); List<vertex> lv = v.getValue(); - for (int i = 0; i < lv.size(); i++) { - tableData[j][0] = lv.get(i).getName(); tableData[j][1] = "After"; tableData[j][2] = v1.getName(); - j++; - } - } - model = new DefaultTableModel(tableData, columnByTaskNames) { @Override public Class getColumnClass(int column) { @@ -254,27 +215,19 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act } } }; - // taskNames = new JTable(dataDetailedByTask, columnByTaskNames); - taskNames = new JTable(model); taskNames.setAutoCreateRowSorter(true); - taskNames.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { buttonDeleteRule.setEnabled(true); - } - }); - } @Override public void tableChanged(TableModelEvent e) { // TODO Auto-generated method stub - } private void initActions() { @@ -284,7 +237,6 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act actions[i].addActionListener(this); // actions[i].addKeyListener(this); } - } @Override @@ -292,124 +244,79 @@ public class JFrameListOfRules extends JFrame implements TableModelListener, Act // TODO Auto-generated method stub String command = evt.getActionCommand(); // TraceManager.addDev("Command:" + command); - if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_STOP_AND_CLOSE_RULE].getActionCommand())) { jta.setText(""); dispose(); setVisible(false); } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_DELETE_ALL_RULE].getActionCommand())) { - directedGraph.setRuleAddedEdges(new HashMap<vertex, List<vertex>>()); directedGraph.setRuleAddedEdgesChannels(new HashMap<vertex, List<vertex>>()); - model.setRowCount(0); - taskNames.setModel(model); - jta.append("All Rules are deleted \n"); - model.fireTableDataChanged(); - taskNames.revalidate(); taskNames.repaint(); - scrollPane12.revalidate(); scrollPane12.repaint(); - this.revalidate(); this.pack(); - this.repaint(); - this.setVisible(true); - } else if (command.equals(actions[LatencyDetailedAnalysisActions.ACT_DELETE_SELECTED_RULE].getActionCommand())) { - int i = taskNames.getSelectedRow(); - vertex v1 = directedGraph.getvertex(model.getValueAt(i, 0).toString()); vertex v2 = directedGraph.getvertex(model.getValueAt(i, 2).toString()); - ruleAddedEdges = directedGraph.getRuleAddedEdges(); - // remove rule and its channel - removeRule(v1, v2, i); - model.removeRow(i); - taskNames.setModel(model); - model.fireTableDataChanged(); - buttonDeleteRule.setEnabled(false); - taskNames.revalidate(); taskNames.repaint(); - scrollPane12.revalidate(); scrollPane12.repaint(); - this.revalidate(); this.pack(); - this.repaint(); - this.setVisible(true); - jta.append("All Rule between: " + v1.getName() + " and " + v2.getName() + " is deleted.\n"); - } - } private void removeRule(vertex v1, vertex v2, int i) { - vertex v1Channel = null, v2Channel = null; - if (v2Channel == null && Graphs.vertexHasSuccessors(directedGraph.getG(), v2)) { for (vertex n : Graphs.successorListOf(directedGraph.getG(), v2)) { if (n.getType() == vertex.TYPE_CHANNEL) { v2Channel = n; break; - } } } - if (Graphs.vertexHasPredecessors(directedGraph.getG(), v1)) { for (vertex n : Graphs.predecessorListOf(directedGraph.getG(), v1)) { if (n.getType() == vertex.TYPE_CHANNEL) { v1Channel = n; break; - } } } - if (v1Channel != null && v2Channel != null) { - if (model.getValueAt(i, 1).equals("After")) { - if (ruleAddedEdges.containsKey(v2Channel)) { - if (ruleAddedEdges.get(v2Channel).contains(v1Channel)) { ruleAddedEdges.get(v2Channel).remove(v1Channel); } - } - if (ruleAddedEdgesChannels.containsKey(v2)) { - if (ruleAddedEdgesChannels.get(v2).contains(v1)) { ruleAddedEdgesChannels.get(v2).remove(v1); } - } - } } - } - } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/LatencyAnalysisParallelAlgorithms.java b/src/main/java/ui/simulationtraceanalysis/LatencyAnalysisParallelAlgorithms.java index fa20111df6..a8cbac4616 100644 --- a/src/main/java/ui/simulationtraceanalysis/LatencyAnalysisParallelAlgorithms.java +++ b/src/main/java/ui/simulationtraceanalysis/LatencyAnalysisParallelAlgorithms.java @@ -3,12 +3,9 @@ package ui.simulationtraceanalysis; import java.io.IOException; import java.util.List; import java.util.Vector; - import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathExpressionException; - import org.xml.sax.SAXException; - import tmltranslator.TMLMapping; import ui.MainGUI; import ui.SimulationTrace; @@ -25,38 +22,27 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { private TMLMapping<TGComponent> tmap; private List<TMLComponentDesignPanel> cpanels; private DirectedGraphTranslator dgraph, dgraph1, dgraph2; - private int row, row1, row2, row3, row4, selectedIndex; - private Object[][] dataDetailedByTask, dataDetailedByTask2; - private latencyDetailedAnalysisMain main; - private MainGUI mainGUI; - - private SimulationTrace selectedST; private boolean b; private boolean compare; private int j; private TMLMapping<TGComponent> map; private Vector<SimulationTransaction> transFile1, transFile2; - private String task1, task2, task3, task4; public LatencyAnalysisParallelAlgorithms(latencyDetailedAnalysisMain latencyDetailedAnalysisMain) { main = latencyDetailedAnalysisMain; - } public void run() { - if (algorithmId == 1) { jFrameLDA.generateDirectedGraph(tmap, cpanels); - } else if (algorithmId == 2) { dataDetailedByTask = dgraph.getTaskByRowDetails(row); - } else if (algorithmId == 3) { dataDetailedByTask = dgraph.getTaskByRowDetailsMinMaxTaint(row); } else if (algorithmId == 4) { @@ -69,7 +55,6 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { } else if (algorithmId == 7) { dataDetailedByTask = dgraph.getTaskHWByRowDetailsMinMax(row); } else if (algorithmId == 8) { - try { main.latencyDetailedAnalysisForXML(mainGUI, selectedST, b, compare, j); } catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) { @@ -78,7 +63,6 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { } } else if (algorithmId == 9) { try { - main.compareLatencyForXML(mainGUI, selectedST, b); } catch (InterruptedException e) { // TODO Auto-generated catch block @@ -101,10 +85,8 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { dgraph.showGraph(dgraph); } else if (algorithmId == 15) { dgraph = new DirectedGraphTranslator(jFrameLDA, cld, map, cpanels, 1); - generateDirectedGraph2(map, cpanels); } else if (algorithmId == 16) { - cld.generateDirectedGraph2(map, cpanels); } else if (algorithmId == 17) { dgraph2.showGraph(dgraph2); @@ -119,26 +101,21 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { } } else if (algorithmId == 20) { dataDetailedByTask = dgraph1.getTaskByRowDetails(row); - dataDetailedByTask2 = dgraph2.getTaskByRowDetails(row2); } else if (algorithmId == 21) { dgraph1.getRowDetailsMinMax(row); dataDetailedByTask = dgraph1.getTasksByRowMinMax(row); - dgraph2.getRowDetailsMinMax(row2); dataDetailedByTask2 = dgraph2.getTasksByRowMinMax(row2); } else if (algorithmId == 22) { dataDetailedByTask = dgraph1.getTaskHWByRowDetails(row); - dataDetailedByTask2 = dgraph2.getTaskHWByRowDetails(row2); } else if (algorithmId == 23) { dgraph1.getRowDetailsMinMax(row); dataDetailedByTask = dgraph1.getTaskHWByRowDetailsMinMax(row); - dgraph2.getRowDetailsMinMax(row2); dataDetailedByTask2 = dgraph2.getTaskHWByRowDetailsMinMax(row2); } - } public Object[][] getDataDetailedByTask2() { @@ -153,11 +130,9 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { public void start(int id) { algorithmId = id; - if (t == null) { t = new Thread(this); t.start(); - } } @@ -247,7 +222,6 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { public void latencyDetailedAnalysis(JFrameCompareLatencyDetail jFrameCompareLatencyDetail, String task12, String task22, String task32, String task42, Vector<SimulationTransaction> transFile12, Vector<SimulationTransaction> transFile22) { - cld = jFrameCompareLatencyDetail; task1 = task12; task2 = task22; @@ -255,7 +229,6 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { task4 = task42; transFile1 = transFile12; transFile2 = transFile22; - } public void compareLatencyInDetails(JFrameCompareLatencyDetail jFrameCompareLatencyDetail, int row11, int row22, int row33, int row44, @@ -267,8 +240,8 @@ public class LatencyAnalysisParallelAlgorithms implements Runnable { row3 = row33; row4 = row44; selectedIndex = selectedIndex1; - } + public MainGUI getMainGUI() { return mainGUI; } diff --git a/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisActions.java b/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisActions.java index 0bc9a78caa..8eff120207 100644 --- a/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisActions.java +++ b/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisActions.java @@ -35,17 +35,14 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.KeyStroke; import javax.swing.event.EventListenerList; - import ui.TAction; import ui.util.IconManager; @@ -59,7 +56,6 @@ import ui.util.IconManager; */ public class LatencyDetailedAnalysisActions extends AbstractAction { // Actions - public static final int ACT_SHOW_GRAPH = 0; public static final int ACT_SAVE_TRACE_PNG = 1; public static final int ACT_STOP_AND_CLOSE_ALL = 2; @@ -67,15 +63,12 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { public static final int ACT_LOAD_SIMULATION_TRACES = 4; public static final int ACT_LATENCY = 5; public static final int ACT_Import_ANALYSIS = 6; - public static final int ACT_SHOW_GRAPH_FILE_1 = 7; public static final int ACT_SHOW_GRAPH_FILE_2 = 8; public static final int ACT_COMPARE_IN_DETAILS = 9; public static final int ACT_CHECK_PATH = 10; - public static final int ACT_ADD_RULE = 11; public static final int ACT_VIEW_RULE = 12; - public static final int ACT_STOP_AND_CLOSE_RULE = 13; public static final int ACT_DELETE_SELECTED_RULE = 14; public static final int ACT_DELETE_ALL_RULE = 15; @@ -83,15 +76,10 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { public static final int ACT_SHOW_ALL_OP = 17; public static final int ACT_LOAD_ALL_OP = 18; public static final int ACT_LOAD_ALL_OP2 = 19; - public static final int NB_ACTION = 20; - private static final TAction[] actions = new TAction[NB_ACTION]; - private EventListenerList listeners; - public static final String JLF_IMAGE_DIR = ""; - public static final String LARGE_ICON = "LargeIcon"; public LatencyDetailedAnalysisActions(int id) { @@ -101,7 +89,6 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { if (actions[id] == null) { return; } - putValue(Action.NAME, actions[id].NAME); putValue(Action.SMALL_ICON, actions[id].SMALL_ICON); putValue(LARGE_ICON, actions[id].LARGE_ICON); @@ -112,7 +99,6 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].MNEMONIC_KEY, java.awt.event.InputEvent.CTRL_MASK)); } putValue(Action.ACTION_COMMAND_KEY, actions[id].ACTION_COMMAND_KEY); - } public void setName(int index, String name) { @@ -125,7 +111,6 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { "Save Directed Graph", "Save Directed Graph", 'S'); actions[ACT_SAVE_TRACE_GRAPHML] = new TAction("save-trace_as_graphml", "Save Directed Graph as graphml", IconManager.imgic341, IconManager.imgic341, "Save Directed Graph as graphml", "Save Directed Graph as graphml", 'S'); - actions[ACT_SHOW_GRAPH] = new TAction("show_graph", "Show Directed Graph", IconManager.imgic53, IconManager.imgic53, "Show Directed Graph", "Show Directed Graph", 'C'); actions[ACT_STOP_AND_CLOSE_ALL] = new TAction("stop-and-close-all", "Terminate Latency Analysis", IconManager.imgic27, IconManager.imgic27, @@ -136,45 +121,30 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { "show latency tables", "show latency tables", 'T'); actions[ACT_Import_ANALYSIS] = new TAction("import-trace", "Save Directed Graph", IconManager.imgic341, IconManager.imgic341, "import Directed Graph", "Import Directed Graph", 'S'); - actions[ACT_SHOW_GRAPH_FILE_1] = new TAction("show_graph_file_1", "Show Directed Graph 1", IconManager.imgic341, IconManager.imgic341, "Show Directed Graph", "Show Directed Graph", 'S'); - actions[ACT_SHOW_GRAPH_FILE_2] = new TAction("show_graph_file_2", "Show Directed Graph 2", IconManager.imgic341, IconManager.imgic341, "Show Directed Graph", "Show Directed Graph", 'S'); - actions[ACT_COMPARE_IN_DETAILS] = new TAction("compare_in_details", "Compare In Details", IconManager.imgic53, IconManager.imgic53, "Compare In Details", "Compare In Details", 'S'); - actions[ACT_LATENCY_PRECISE_ANALYSIS] = new TAction("precise_latency_analysis", "Precise Analysis", IconManager.imgic53, IconManager.imgic53, "Precise Latency Analysis", "Precise Latency Analysis", 'S'); - actions[ACT_CHECK_PATH] = new TAction("check_path", "Check Path Between Operators", IconManager.imgic53, IconManager.imgic53, "Check Path Between Operators", "Check Path Between Operators", 'C'); - actions[ACT_ADD_RULE] = new TAction("add_rule", "Add Rule", IconManager.imgic53, IconManager.imgic53, "Add Rule", "Add Rule", 'C'); - actions[ACT_VIEW_RULE] = new TAction("view_rules", "View Rules", IconManager.imgic29, IconManager.imgic29, "View Rules", "View Rules", 'T'); - actions[ACT_STOP_AND_CLOSE_RULE] = new TAction("stop-and-close-all", "Terminate Rules Management", IconManager.imgic27, IconManager.imgic27, "Terminate Rules Management", "Terminate Rules Management window", 'T'); - actions[ACT_DELETE_SELECTED_RULE] = new TAction("delete_selected_rules", "Delete Selected Rules", IconManager.imgic53, IconManager.imgic53, "Delete Selected Rules", "Delete Selected Rules", 'C'); - actions[ACT_DELETE_ALL_RULE] = new TAction("delete_all_rules", "Delete All Rules", IconManager.imgic53, IconManager.imgic53, "Delete All Rules", "Delete All Rules", 'C'); - actions[ACT_SHOW_ALL_OP] = new TAction("show-operators", "Show All Operators", IconManager.imgic29, IconManager.imgic29, - "Show All Operators", "Show All Operators", 'T'); + actions[ACT_SHOW_ALL_OP] = new TAction("show-operators", "Show All Operators", IconManager.imgic29, IconManager.imgic29, "Show All Operators", + "Show All Operators", 'T'); actions[ACT_LOAD_ALL_OP] = new TAction("load-operators", "Load Task Operators", IconManager.imgic29, IconManager.imgic29, "Load Task Operators", "Load Task Operators", 'T'); actions[ACT_LOAD_ALL_OP2] = new TAction("load-operators_list2", "Load Task Operators", IconManager.imgic29, IconManager.imgic29, "Load Task Operators", "Load Task Operators", 'T'); - - - - - } public String getActionCommand() { @@ -193,7 +163,6 @@ public class LatencyDetailedAnalysisActions extends AbstractAction { // if (listeners != null) { Object[] listenerList = listeners.getListenerList(); - // Recreate the ActionEvent and stuff the value of the ACTION_COMMAND_KEY ActionEvent e = new ActionEvent(evt.getSource(), evt.getID(), (String) getValue(Action.ACTION_COMMAND_KEY)); for (int i = 0; i <= listenerList.length - 2; i += 2) { diff --git a/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisBar.java b/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisBar.java index 5bfd934d6b..3f3144f6a7 100644 --- a/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisBar.java +++ b/src/main/java/ui/simulationtraceanalysis/LatencyDetailedAnalysisBar.java @@ -35,7 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import javax.swing.JToolBar; @@ -68,5 +67,4 @@ public abstract class LatencyDetailedAnalysisBar extends JToolBar { public JFrameLatencyDetailedAnalysis getLatencyDetailedAnalysisF() { return latencyDetailedAnalysisF; } - } // Class \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/SaveGraphToolBar.java b/src/main/java/ui/simulationtraceanalysis/SaveGraphToolBar.java index 48a658c4e1..cc6dc8233a 100644 --- a/src/main/java/ui/simulationtraceanalysis/SaveGraphToolBar.java +++ b/src/main/java/ui/simulationtraceanalysis/SaveGraphToolBar.java @@ -35,14 +35,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - package ui.simulationtraceanalysis; import javax.swing.JButton; //import java.awt.*; //import java.awt.event.*; - /** * Class SaveGraphToolBar: toolbar used to save the directed graph in different * formats @@ -52,31 +50,24 @@ import javax.swing.JButton; * @author Maysam Zoor */ public class SaveGraphToolBar extends LatencyDetailedAnalysisBar { - protected void setActive(boolean b) { getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_PNG].setEnabled(b); getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_GRAPHML].setEnabled(b); - // getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_Import_ANALYSIS].setEnabled(b); - + // getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_Import_ANALYSIS].setEnabled(b); } protected void setButtons() { JButton button; - button = this.add(getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_PNG]); // button.addMouseListener(jflda.mouseHandler); - this.addSeparator(); - button = this.add(getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_SAVE_TRACE_GRAPHML]); this.addSeparator(); - - // button = this.add(getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_Import_ANALYSIS]); - + // button = + // this.add(getLatencyDetailedAnalysisF().getActions()[LatencyDetailedAnalysisActions.ACT_Import_ANALYSIS]); } protected SaveGraphToolBar(JFrameLatencyDetailedAnalysis _jflda) { super(_jflda); } - -} // Class \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/TableRenderer.java b/src/main/java/ui/simulationtraceanalysis/TableRenderer.java index 0a2a5c5a8c..407d06889b 100644 --- a/src/main/java/ui/simulationtraceanalysis/TableRenderer.java +++ b/src/main/java/ui/simulationtraceanalysis/TableRenderer.java @@ -4,17 +4,14 @@ import java.awt.Color; import java.awt.Component; import java.util.List; import java.util.Vector; - import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; class TableRenderer extends DefaultTableCellRenderer { - private int row, col; private Color randomColour; private boolean colorCell = true; - private Vector<Object> allCommands = new Vector<Object>(); private Vector<Color> allColors = new Vector<Color>(); private List<String> onPathBehaviors = new Vector<String>(); @@ -22,27 +19,22 @@ class TableRenderer extends DefaultTableCellRenderer { private List<String> offPathBehaviorCausingDelay = new Vector<String>(); public TableRenderer(List<String> onPathBehavior, List<String> offPathBehaviorCausingDelay, List<String> offPathBehavior) { - this.onPathBehaviors = new Vector<String>(); this.offPathBehaviorCausingDelay = new Vector<String>(); this.offPathBehaviors = new Vector<String>(); - this.onPathBehaviors = onPathBehavior; this.offPathBehaviorCausingDelay = offPathBehaviorCausingDelay; this.offPathBehaviors = offPathBehavior; } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - this.row = row; this.col = column; - if (this.col == 0) { this.colorCell = false; } else { this.colorCell = true; } - if (value != null && value != "") { if (onPathBehaviors.contains(value.toString() + table.getColumnName(column))) { this.colorCell = true; @@ -57,20 +49,16 @@ class TableRenderer extends DefaultTableCellRenderer { this.colorCell = false; } // Allow superclass to return rendering component. - return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } protected void setValue(Object v) { - super.setValue(v); - if (this.colorCell) { setBackground(randomColour); } else { setForeground(UIManager.getColor("Table.foreground")); setBackground(UIManager.getColor("Table.background")); } - } } \ No newline at end of file diff --git a/src/main/java/ui/simulationtraceanalysis/latencyDetailedAnalysisMain.java b/src/main/java/ui/simulationtraceanalysis/latencyDetailedAnalysisMain.java index d2ffc5e291..2a2ba077a5 100644 --- a/src/main/java/ui/simulationtraceanalysis/latencyDetailedAnalysisMain.java +++ b/src/main/java/ui/simulationtraceanalysis/latencyDetailedAnalysisMain.java @@ -8,7 +8,6 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; import java.util.Map.Entry; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -16,10 +15,8 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; - import org.w3c.dom.Document; import org.xml.sax.SAXException; - import myutil.GraphicLib; import myutil.TraceManager; import tmltranslator.TMLMapping; @@ -36,74 +33,57 @@ import ui.window.JDialogToChosePanel; public class latencyDetailedAnalysisMain { - // public DirectedGraphTranslator dgraph; private Vector<String> checkedTransactionsFile1 = new Vector<String>(); private Vector<String> checkedTransactionsFile2 = new Vector<String>(); private Vector<String> checkedTransactionsFile = new Vector<String>(); private HashMap<String, Integer> checkedT1 = new HashMap<String, Integer>(); - private HashMap<String, Integer> checkedT2 = new HashMap<String, Integer>(); private MainGUI mainGUI_compare2, mainGUI_compare; - private JFrameLatencyDetailedAnalysis latencyDetailedAnalysis; private JFrameCompareLatencyDetail cld; - - // private Thread t, t1; private TMLMapping<TGComponent> map1; - private List<TMLComponentDesignPanel> cpanels1; - private LatencyAnalysisParallelAlgorithms tc; + public static final String DIPLODOCUS_ARCHI_MAPPING = "DIPLODOCUS architecture and mapping Diagram"; + public static final String TML_COMP_TASK_DIAGRAM = "TML Component Task Diagram"; + public latencyDetailedAnalysisMain(int callerId, MainGUI mainGUI, SimulationTrace selectedST, boolean b, boolean compare, int j) throws InterruptedException { try { setTc(new LatencyAnalysisParallelAlgorithms(this)); - if (callerId == 2) { - tc.setMainGUI(mainGUI); tc.setSelectedST(selectedST); tc.setB(b); tc.setJ(j); tc.setCompare(compare); tc.start(8); - } else if (callerId == 1) { - tc.setMainGUI(mainGUI); tc.setSelectedST(selectedST); tc.setB(b); tc.setJ(j); tc.setCompare(compare); tc.start(9); - } } catch (Exception e1) { // TODO Auto-generated catch block TraceManager.addDev("Error: " + e1.getMessage()); } - } public void latencyDetailedAnalysis(SimulationTrace selectedST, TURTLEPanel selectedTab, boolean b, boolean compare, MainGUI mainGUI_compare) { - Vector<TGComponent> tmlNodesToValidate = new Vector<TGComponent>(); List<TMLComponentDesignPanel> cpanels; TMLComponentDesignPanel compdp; TURTLEPanel tp = selectedTab; - // tmlap = (TMLArchiPanel) tp; - if (mainGUI_compare.gtm == null) { - } else { - if (mainGUI_compare.gtm.getTMLMapping() != null) { - TMLArchiPanel tmlap = (TMLArchiPanel) tp; TMLMapping<TGComponent> map = mainGUI_compare.gtm.getTMLMapping(); - for (TGComponent component : tmlap.tmlap.getComponentList()) { tmlNodesToValidate.add(component); } @@ -113,17 +93,14 @@ public class latencyDetailedAnalysisMain { TURTLEPanel tup; Iterator<? extends TGComponent> iterator = tmlNodesToValidate.listIterator(); cpanels = new ArrayList<TMLComponentDesignPanel>(); - while (iterator.hasNext()) { tgc = iterator.next(); - if (tgc instanceof TMLArchiNode) { artifacts = ((TMLArchiNode) (tgc)).getAllTMLArchiArtifacts(); for (TMLArchiArtifact artifact : artifacts) { namePanel = artifact.getReferenceTaskName(); try { tup = mainGUI_compare.getTURTLEPanel(namePanel); - if (tup instanceof TMLComponentDesignPanel) { compdp = (TMLComponentDesignPanel) (tup); if (!cpanels.contains(compdp)) { @@ -134,67 +111,44 @@ public class latencyDetailedAnalysisMain { // Just in case the mentionned panel is not a TML design Panel TraceManager.addDev("Error: " + e.getMessage()); } - } } } if (compare) { - map1 = map; setCpanels1(cpanels); - for (TGComponent tgc1 : map.getTMLModeling().getCheckedComps().keySet()) { String compName = map.getTMLModeling().getCheckedComps().get(tgc1); - // TraceManager.addDev(compName + "__" + tgc1.getDIPLOID()); checkedT1.put(compName + "__" + tgc1.getDIPLOID(), tgc1.getDIPLOID()); - // checkedTransactionsFile.add(compName + "__" + tgc1.getDIPLOID()); - } - for (Entry<String, Integer> cT : checkedT1.entrySet()) { - String name = cT.getKey(); int id = cT.getValue(); - if (!checkedTransactionsFile.contains(name)) { if (checkedTransactionsFile.size() > 0) { - Boolean inserted = false; - for (int j = 0; j < checkedTransactionsFile.size(); j++) { - - if (id < checkedT1.get(checkedTransactionsFile.get(j)) && !checkedTransactionsFile.contains(name)) - - { + if (id < checkedT1.get(checkedTransactionsFile.get(j)) && !checkedTransactionsFile.contains(name)) { checkedTransactionsFile.insertElementAt(name, j); - inserted = true; - } - } - if (!inserted) { checkedTransactionsFile.insertElementAt(name, checkedTransactionsFile.size()); } } else { checkedTransactionsFile.add(name); } - } - } } else { latencyDetailedAnalysis = new JFrameLatencyDetailedAnalysis(map, cpanels, selectedST, tc); latencyDetailedAnalysis.setIconImage(IconManager.img9); GraphicLib.centerOnParent(latencyDetailedAnalysis, 900, 600); latencyDetailedAnalysis.setVisible(b); - } } else { - if (mainGUI_compare.gtm.getArtificialTMLMapping() != null) { - TMLMapping<TGComponent> map = mainGUI_compare.gtm.getArtificialTMLMapping(); TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) tp; cpanels = new ArrayList<TMLComponentDesignPanel>(); @@ -202,83 +156,55 @@ public class latencyDetailedAnalysisMain { if (compare) { // dgraph = new DirectedGraphTranslator(latencyDetailedAnalysis,cld,map, // cpanels,1); - map1 = map; setCpanels1(cpanels); - for (TGComponent tgc : map.getTMLModeling().getCheckedComps().keySet()) { String compName = map.getTMLModeling().getCheckedComps().get(tgc); // TraceManager.addDev(compName + "__" + tgc.getDIPLOID()); - checkedT2.put(compName + "__" + tgc.getDIPLOID(), tgc.getDIPLOID()); // checkedTransactionsFile.add(compName + "__" + tgc1.getDIPLOID()); - } - for (Entry<String, Integer> cT : checkedT2.entrySet()) { - String name = cT.getKey(); int id = cT.getValue(); - if (!checkedTransactionsFile.contains(name)) { if (checkedTransactionsFile.size() > 0) { - Boolean inserted = false; - for (int j = 0; j < checkedTransactionsFile.size(); j++) { - - if (id < checkedT2.get(checkedTransactionsFile.get(j)) && !checkedTransactionsFile.contains(name)) - - { + if (id < checkedT2.get(checkedTransactionsFile.get(j)) && !checkedTransactionsFile.contains(name)) { checkedTransactionsFile.insertElementAt(name, j); - inserted = true; - } - } - if (!inserted) { checkedTransactionsFile.insertElementAt(name, checkedTransactionsFile.size()); } } else { checkedTransactionsFile.add(name); } - } - } - } else { latencyDetailedAnalysis = new JFrameLatencyDetailedAnalysis(map, cpanels, selectedST, tc); latencyDetailedAnalysis.setIconImage(IconManager.img9); GraphicLib.centerOnParent(latencyDetailedAnalysis, 900, 600); latencyDetailedAnalysis.setVisible(b); - } } else { - } } } - // dp.getPanels(); - } public void compareLatencyForXML(MainGUI mainGUI, SimulationTrace selectedST, boolean b) throws InterruptedException { - final DirectedGraphTranslator dgraph1, dgraph2; try { - checkedTransactionsFile = new Vector<String>(); latencyDetailedAnalysisForXML(mainGUI, selectedST, false, true, 1); - checkedTransactionsFile1 = checkedTransactionsFile; - } catch (XPathExpressionException e1) { // TODO Auto-generated catch block - TraceManager.addDev("Error: " + e1.getMessage()); } catch (ParserConfigurationException e1) { // TODO Auto-generated catch block @@ -293,167 +219,111 @@ public class latencyDetailedAnalysisMain { // e1.printStackTrace(); TraceManager.addDev("Error: " + e1.getMessage()); } - cld = new JFrameCompareLatencyDetail(this, mainGUI, checkedTransactionsFile1, map1, cpanels1, selectedST, true, tc); - } public void latencyDetailedAnalysisForXML(MainGUI mainGUI, SimulationTrace selectedST, boolean b, boolean compare, int j) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { - try { String xml = ""; // Populated XML String.... - DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = domFactory.newDocumentBuilder(); Document dDoc = builder.parse(selectedST.getFullPath()); - XPath xPath = XPathFactory.newInstance().newXPath(); - String modelNode = (String) xPath.evaluate("/siminfo/global/model", dDoc, XPathConstants.STRING); TURTLEPanel panel = null; Vector<TURTLEPanel> allTabs = new Vector<TURTLEPanel>(); - if (j == 1) { mainGUI_compare = mainGUI; - } else if (j == 2) { String fileName = null; - Document dDoc1 = null; - - if (modelNode.contains("DIPLODOCUS architecture and mapping Diagram")) { - - fileName = modelNode.replace(" / DIPLODOCUS architecture and mapping Diagram", ""); + if (modelNode.contains(DIPLODOCUS_ARCHI_MAPPING)) { + fileName = modelNode.replace(" / " + DIPLODOCUS_ARCHI_MAPPING, ""); } - - if (modelNode.contains("TML Component Task Diagram")) { - - fileName = modelNode.replace(" / TML Component Task Diagram", ""); + if (modelNode.contains(TML_COMP_TASK_DIAGRAM)) { + fileName = modelNode.replace(" / " + TML_COMP_TASK_DIAGRAM, ""); } - try { mainGUI_compare = null; mainGUI_compare = new MainGUI(false, false, false, false, false, false, false, false, false, false, true, false, false); mainGUI_compare.build(); - mainGUI_compare.openProjectFromFile(new File(fileName)); - mainGUI_compare.frame.setVisible(false); mainGUI_compare2 = mainGUI_compare; - } catch (Exception e1) { // TODO Auto-generated catch block - //e1.printStackTrace(); + // e1.printStackTrace(); TraceManager.addDev("Error: " + e1.getMessage()); } } - - if (modelNode.contains("DIPLODOCUS architecture and mapping Diagram")) { - + if (modelNode.contains(DIPLODOCUS_ARCHI_MAPPING)) { for (int i = 0; i < mainGUI_compare.tabs.size(); i++) { - if (mainGUI_compare.tabs.get(i) instanceof TMLArchiPanel) { - allTabs.add(mainGUI_compare.tabs.get(i)); - } - } - if (allTabs.size() == 1) { mainGUI_compare.checkModelingSyntax(allTabs.get(0), true); TURTLEPanel selectedTab = allTabs.get(0); - if (compare) { - latencyDetailedAnalysis(selectedST, selectedTab, b, true, mainGUI_compare); - } else { latencyDetailedAnalysis(selectedST, selectedTab, b, false, mainGUI_compare); - } - mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); - } else if (allTabs.size() > 1) { - JDialogToChosePanel jdmc = new JDialogToChosePanel(mainGUI_compare.frame, allTabs, "Choosing panel to validate"); // if (b) { GraphicLib.centerOnParent(jdmc); jdmc.setVisible(true); // blocked until dialog has been closed - // } mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); TURTLEPanel selectedTab = jdmc.getSelectedTab(); if (selectedTab != null) { - mainGUI_compare.checkModelingSyntax(selectedTab, true); - if (compare) { - latencyDetailedAnalysis(selectedST, selectedTab, b, true, mainGUI_compare); - } else { latencyDetailedAnalysis(selectedST, selectedTab, b, false, mainGUI_compare); } mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); - } } - - } else if (modelNode.contains("TML Component Task Diagram")) { - + } else if (modelNode.contains(TML_COMP_TASK_DIAGRAM)) { for (int i = 0; i < mainGUI_compare.tabs.size(); i++) { panel = mainGUI_compare.tabs.get(i); - if (mainGUI_compare.tabs.get(i) instanceof TMLComponentDesignPanel) { allTabs.add(mainGUI_compare.tabs.get(i)); } - } - if (allTabs.size() == 1) { mainGUI_compare.checkModelingSyntax(allTabs.get(0), true); - TURTLEPanel selectedTab = allTabs.get(0); if (compare) { - latencyDetailedAnalysis(selectedST, selectedTab, b, true, mainGUI_compare); - } else { latencyDetailedAnalysis(selectedST, selectedTab, b, false, mainGUI_compare); } mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); - } else if (allTabs.size() > 1) { - JDialogToChosePanel jdmc = new JDialogToChosePanel(mainGUI_compare.frame, allTabs, "Choosing panel to validate"); - // if (b) { GraphicLib.centerOnParent(jdmc); jdmc.setVisible(true); // blocked until dialog has been closed - // } - mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); TURTLEPanel selectedTab = jdmc.getSelectedTab(); if (selectedTab != null) { - mainGUI_compare.checkModelingSyntax(selectedTab, true); if (compare) { - latencyDetailedAnalysis(selectedST, selectedTab, b, true, mainGUI_compare); - } else { latencyDetailedAnalysis(selectedST, selectedTab, b, false, mainGUI_compare); } mainGUI_compare.setMode(mainGUI_compare.MODEL_CHANGED); - } } - } } catch (Exception e1) { // TODO Auto-generated catch block @@ -476,11 +346,9 @@ public class latencyDetailedAnalysisMain { protected static String getBaseResourcesDir() { final String systemPropResDir = System.getProperty("resources_dir"); - if (systemPropResDir == null) { return "resources/test/"; } - return systemPropResDir; } diff --git a/src/main/java/ui/simulationtraceanalysis/vertex.java b/src/main/java/ui/simulationtraceanalysis/vertex.java index 6d15ead9a1..164e0f808a 100644 --- a/src/main/java/ui/simulationtraceanalysis/vertex.java +++ b/src/main/java/ui/simulationtraceanalysis/vertex.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.List; public class vertex { - protected static final int TYPE_CHANNEL = 11; protected static final int TYPE_FOR_EVER_LOOP = 1; protected static final int TYPE_STATIC_FOR_LOOP = 2; @@ -18,21 +17,15 @@ public class vertex { protected static final int TYPE_TRANSACTION = 9; protected static final int TYPE_CTRL = 10; protected static final int TYPE_SELECT_EVT = 11; - private String name; private int id; // identifier - private Boolean skipVertex = false; // to skip vertex in case value =0 - private List<String> label = new ArrayList<String>();// will be used for store data taint private int type; // To know the if the vertex is a for lopp, data channel private int taintFixedNumber; // the number of times the taint should be considered - private int sampleNumber; // the number of samples to write or read private int virtualLengthAdded; // the number of samples to write or read - private HashMap<String, Integer> taintConsideredNumber = new HashMap<String, Integer>();; // the number of times the taint should be considered - private HashMap<String, Integer> maxTaintFixedNumber = new HashMap<String, Integer>(); public vertex(String name, int id) { @@ -41,7 +34,6 @@ public class vertex { this.label = this.getLabel(); this.sampleNumber = 0; this.virtualLengthAdded = 0; - } public HashMap<String, Integer> getMaxTaintFixedNumber() { @@ -86,23 +78,16 @@ public class vertex { public void addLabel(String l) { this.label.add(l); - this.getTaintConsideredNumber().put(l, 0); } public String getLastLabel() { - for (int i = 0; i < this.getLabel().size(); i++) { if (this.getMaxTaintFixedNumber().get(this.label.get(i)) == 0) { - return this.label.get(i); - } - } - return this.label.get(this.label.size() - 1); - } public int getTaintFixedNumber() { @@ -148,5 +133,4 @@ public class vertex { public int getId() { return id; } - } \ No newline at end of file diff --git a/ttool/src/test/java/ui/ComparisonOfsimulationTracesInXML/ComparisonOfsimulationTraces.java b/ttool/src/test/java/ui/ComparisonOfsimulationTracesInXML/ComparisonOfsimulationTraces.java index eb8b921362..19746511f6 100644 --- a/ttool/src/test/java/ui/ComparisonOfsimulationTracesInXML/ComparisonOfsimulationTraces.java +++ b/ttool/src/test/java/ui/ComparisonOfsimulationTracesInXML/ComparisonOfsimulationTraces.java @@ -27,14 +27,14 @@ public class ComparisonOfsimulationTraces extends AbstractUITest { private static JFrameCompareSimulationTraces cSimTrace; private static JPanelCompareXmlGraph newContentPane; private static JFrameShowLatencyDetails showLatencyDetails; - private static final String path1 = "/ui/xmlCompare/input/simple.xml"; - private static final String path2 = "/ui/xmlCompare/input/simplifiedWithSecurity.xml"; + private static final String PATH1 = "/ui/xmlCompare/input/simple.xml"; + private static final String PATH2 = "/ui/xmlCompare/input/simplifiedWithSecurity.xml"; @BeforeClass public static void setUpBeforeClass() throws Exception { - STfilePath1 = getBaseResourcesDir() + path1; - STfilePath2 = getBaseResourcesDir() + path2; + STfilePath1 = getBaseResourcesDir() + PATH1; + STfilePath2 = getBaseResourcesDir() + PATH2; selectedST1 = new SimulationTrace("simple.xml", 6, STfilePath1); selectedST2 = new SimulationTrace("simplifiedWithSecurity.xml", 6, STfilePath2); diff --git a/ttool/src/test/java/ui/GraphLatencyAnalysis/GraphLatencyAnalysis.java b/ttool/src/test/java/ui/GraphLatencyAnalysis/GraphLatencyAnalysis.java index 72f9d2f28d..b3ae083d47 100644 --- a/ttool/src/test/java/ui/GraphLatencyAnalysis/GraphLatencyAnalysis.java +++ b/ttool/src/test/java/ui/GraphLatencyAnalysis/GraphLatencyAnalysis.java @@ -2,15 +2,12 @@ package ui.GraphLatencyAnalysis; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.io.File; import java.util.HashMap; import java.util.Vector; import java.util.Map.Entry; - import org.junit.Before; import org.junit.Test; - import ui.AbstractUITest; import ui.SimulationTrace; import ui.TMLArchiPanel; @@ -20,58 +17,38 @@ import ui.simulationtraceanalysis.JFrameLatencyDetailedAnalysis; import ui.simulationtraceanalysis.latencyDetailedAnalysisMain; public class GraphLatencyAnalysis extends AbstractUITest { - private static final String INPUT_PATH = "/ui/graphLatencyAnalysis/input"; - - private static final String simulationTracePath = INPUT_PATH + "/graphTestSimulationTrace.xml"; + private static final String SIMULATIONTRACE_PATH = INPUT_PATH + "/graphTestSimulationTrace.xml"; private static final String modelPath = INPUT_PATH + "/GraphTestModel.xml"; - private static final String mappingDiagName = "Architecture2"; private Vector<SimulationTransaction> transFile1; // private Vector<String> dropDown; private HashMap<String, Integer> checkedDropDown = new HashMap<String, Integer>(); - - private static final int operator1ID = 44; - private static final int operator2ID = 26; - + private static final int OPERATOR1_ID = 44; + private static final int OPERATOR2_ID = 26; private static String task1; private static String task2; private static DirectedGraphTranslator dgt; - private static Object[][] allLatencies, minMaxArray, taskHWByRowDetails, detailedLatency; private JFrameLatencyDetailedAnalysis latencyDetailedAnalysis; private latencyDetailedAnalysisMain latencyDetailedAnalysisMain; @Before public void GraphLatencyAnalysis() throws InterruptedException { - mainGUI.openProjectFromFile(new File(getBaseResourcesDir() + modelPath)); // mainGUI.openProjectFromFile(new File( modelPath)); - final TMLArchiPanel panel = findArchiPanel(mappingDiagName); - - if (panel == null) { System.out.println("NULL Panel"); } else { System.out.println("Non NULL Panel"); } - mainGUI.checkModelingSyntax(panel, true); - - - SimulationTrace file2 = new SimulationTrace("graphTestSimulationTrace", 6, simulationTracePath); + SimulationTrace file2 = new SimulationTrace("graphTestSimulationTrace", 6, SIMULATIONTRACE_PATH); latencyDetailedAnalysisMain = new latencyDetailedAnalysisMain(3, mainGUI, file2, false, false, 3); latencyDetailedAnalysisMain.getTc().setMainGUI(mainGUI); - - - // latencyDetailedAnalysisMain.setTc(); - - latencyDetailedAnalysisMain.latencyDetailedAnalysis(file2, panel, false, false, mainGUI); - latencyDetailedAnalysis = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis(); - if (latencyDetailedAnalysis != null) { latencyDetailedAnalysis.setVisible(false); try { @@ -80,77 +57,40 @@ public class GraphLatencyAnalysis extends AbstractUITest { // TODO Auto-generated catch block e.printStackTrace(); } - - // if (latencyDetailedAnalysis.graphStatus() == Thread.State.TERMINATED) { dgt = latencyDetailedAnalysis.getDgraph(); - // } - // while (latencyDetailedAnalysis.graphStatus() != Thread.State.TERMINATED) { - // dgt = latencyDetailedAnalysis.getDgraph(); - // } } - } @Test public void parseFile() { - assertNotNull(latencyDetailedAnalysis); - int graphsize = dgt.getGraphsize(); - assertTrue(graphsize == 40); - - // dropDown = latencyDetailedAnalysis.getCheckedTransactions(); checkedDropDown = latencyDetailedAnalysis.getCheckedT(); - assertTrue(checkedDropDown.size() == 3); - - transFile1 = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis().parseFile(new File(getBaseResourcesDir() + simulationTracePath)); - - // transFile1 = mainGUI.getLatencyDetailedAnalysis() .parseFile(new File( - // simulationTracePath)); - + transFile1 = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis().parseFile(new File(getBaseResourcesDir() + SIMULATIONTRACE_PATH)); assertTrue(transFile1.size() == 175); - for (Entry<String, Integer> cT : checkedDropDown.entrySet()) { - int id = cT.getValue(); String taskName = cT.getKey(); - if (id == operator1ID) { + if (id == OPERATOR1_ID) { task1 = taskName; - - } else if (id == operator2ID) { + } else if (id == OPERATOR2_ID) { task2 = taskName; - } } - - // int i = dropDown.indexOf(checkedDropDown.get); - // int j = dropDown.indexOf(t2); - - // task1 = dropDown.get(i); - // task2 = dropDown.get(j); - allLatencies = dgt.latencyDetailedAnalysis(task1, task2, transFile1, false, false); - assertTrue(allLatencies.length == 10); - minMaxArray = dgt.latencyMinMaxAnalysis(task1, task2, transFile1); dgt.getRowDetailsMinMax(1); taskHWByRowDetails = dgt.getTasksByRowMinMax(1); - assertTrue(minMaxArray.length > 0); - assertTrue(taskHWByRowDetails.length == 15); taskHWByRowDetails = dgt.getTaskHWByRowDetailsMinMax(1); assertTrue(taskHWByRowDetails.length == 13); - detailedLatency = dgt.getTaskByRowDetails(7); assertTrue(detailedLatency.length == 14); - detailedLatency = dgt.getTaskHWByRowDetails(7); assertTrue(detailedLatency.length == 14); - } - } \ No newline at end of file diff --git a/ttool/src/test/java/ui/GraphLatencyAnalysis/NestedStructurePLAN.java b/ttool/src/test/java/ui/GraphLatencyAnalysis/NestedStructurePLAN.java index 1edd3a3b69..a723594ff0 100644 --- a/ttool/src/test/java/ui/GraphLatencyAnalysis/NestedStructurePLAN.java +++ b/ttool/src/test/java/ui/GraphLatencyAnalysis/NestedStructurePLAN.java @@ -3,15 +3,12 @@ package ui.GraphLatencyAnalysis; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.io.File; import java.util.HashMap; import java.util.Vector; import java.util.Map.Entry; - import org.junit.Before; import org.junit.Test; - import ui.TMLArchiPanel; import ui.interactivesimulation.SimulationTransaction; import ui.simulationtraceanalysis.DirectedGraphTranslator; @@ -21,47 +18,37 @@ import ui.AbstractUITest; import ui.SimulationTrace; public class NestedStructurePLAN extends AbstractUITest { - - private static final String mappingDiagName = "Architecture"; + private static final String mapping_Diag_Name = "Architecture"; private static final String INPUT_PATH = "/ui/graphLatencyAnalysis/input"; - - private static final String simulationTracePathFile = INPUT_PATH + "/loopseqTrace.xml"; - private static final String modelPath = INPUT_PATH + "/loopseqgraph.xml"; - + private static final String SIMULATIONTRACE_PATH_FILE = INPUT_PATH + "/loopseqTrace.xml"; + private static final String MODEL_PATH = INPUT_PATH + "/loopseqgraph.xml"; private latencyDetailedAnalysisMain latencyDetailedAnalysisMain; private JFrameLatencyDetailedAnalysis latencyDetailedAnalysis; private static DirectedGraphTranslator dgt; private Vector<SimulationTransaction> transFile1; private HashMap<String, Integer> checkedDropDown = new HashMap<String, Integer>(); - - private static final int operator1ID = 69; - private static final int operator2ID = 53; + private static final int OPERATOR1_ID = 69; + private static final int OPERATOR2_ID = 53; private static String task1; private static String task2; - private static Object[][] allLatencies; @Before public void NestedStructurePLAN() throws InterruptedException { - mainGUI.openProjectFromFile(new File(getBaseResourcesDir() + modelPath)); + mainGUI.openProjectFromFile(new File(getBaseResourcesDir() + MODEL_PATH)); // mainGUI.openProjectFromFile(new File(modelPath)); - - final TMLArchiPanel panel = findArchiPanel(mappingDiagName); - + final TMLArchiPanel panel = findArchiPanel(mapping_Diag_Name); if (panel == null) { System.out.println("NULL Panel"); } else { System.out.println("Non NULL Panel"); } - mainGUI.checkModelingSyntax(panel, true); - SimulationTrace file2 = new SimulationTrace("graphTestSimulationTrace", 6, simulationTracePathFile); + SimulationTrace file2 = new SimulationTrace("graphTestSimulationTrace", 6, SIMULATIONTRACE_PATH_FILE); latencyDetailedAnalysisMain = new latencyDetailedAnalysisMain(3, mainGUI, file2, false, false, 3); latencyDetailedAnalysisMain.getTc().setMainGUI(mainGUI); latencyDetailedAnalysisMain.latencyDetailedAnalysis(file2, panel, false, false, mainGUI); - latencyDetailedAnalysis = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis(); - if (latencyDetailedAnalysis != null) { latencyDetailedAnalysis.setVisible(false); try { @@ -70,22 +57,15 @@ public class NestedStructurePLAN extends AbstractUITest { // TODO Auto-generated catch block e.printStackTrace(); } - dgt = latencyDetailedAnalysis.getDgraph(); - } - } @Test public void parseFile() { - assertNotNull(latencyDetailedAnalysis); - int graphsize = dgt.getGraphsize(); - assertTrue(graphsize == 57); - // test sequence to all its nexts assertTrue(dgt.edgeExists(66, 65)); assertTrue(dgt.edgeExists(66, 63)); @@ -98,20 +78,16 @@ public class NestedStructurePLAN extends AbstractUITest { // test nested sequence to unordered sequence assertTrue(dgt.edgeExists(57, 60)); assertTrue(dgt.edgeExists(68, 60)); - // test unordered sequence nexts assertTrue(dgt.edgeExists(61, 67)); assertTrue(dgt.edgeExists(61, 58)); assertTrue(dgt.edgeExists(68, 58)); assertTrue(dgt.edgeExists(57, 67)); - // test ordered sequence nexts assertTrue(dgt.edgeExists(26, 25)); assertTrue(dgt.edgeExists(26, 21)); assertTrue(dgt.edgeExists(26, 23)); - // test ordered sequence ends - assertTrue(dgt.edgeExists(24, 21)); // nested seq loop assertTrue(dgt.edgeExists(27, 23)); @@ -120,15 +96,11 @@ public class NestedStructurePLAN extends AbstractUITest { // inside loop only connected to loop vertex assertFalse(dgt.edgeExists(30, 22)); assertFalse(dgt.edgeExists(29, 22)); - // sequence last branch end not connected to other branches assertFalse(dgt.edgeExists(22, 25)); assertFalse(dgt.edgeExists(22, 21)); - // sequence branches not connected backward - assertFalse(dgt.edgeExists(27, 25)); - // loop for ever edges+ nested loops and seq assertTrue(dgt.edgeExists(44, 49)); assertTrue(dgt.edgeExists(44, 51)); @@ -137,55 +109,33 @@ public class NestedStructurePLAN extends AbstractUITest { assertTrue(dgt.edgeExists(43, 41)); assertTrue(dgt.edgeExists(45, 41)); assertTrue(dgt.edgeExists(40, 49)); - assertTrue(dgt.edgeExists(48, 54)); assertTrue(dgt.edgeExists(48, 51)); assertTrue(dgt.edgeExists(48, 53)); - assertTrue(dgt.edgeExists(50, 49)); assertTrue(dgt.edgeExists(50, 53)); assertTrue(dgt.edgeExists(50, 54)); assertTrue(dgt.edgeExists(52, 51)); assertTrue(dgt.edgeExists(52, 49)); assertTrue(dgt.edgeExists(52, 54)); - assertFalse(dgt.edgeExists(40, 54)); assertFalse(dgt.edgeExists(40, 42)); - - transFile1 = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis().parseFile(new File(getBaseResourcesDir() + simulationTracePathFile)); - - // transFile1 = - // latencyDetailedAnalysisMain.getLatencyDetailedAnalysis().parseFile(new - // File(simulationTracePathFile)); - + transFile1 = latencyDetailedAnalysisMain.getLatencyDetailedAnalysis().parseFile(new File(getBaseResourcesDir() + SIMULATIONTRACE_PATH_FILE)); assertTrue(transFile1.size() == 38); checkedDropDown = latencyDetailedAnalysis.getCheckedT(); - for (Entry<String, Integer> cT : checkedDropDown.entrySet()) { - int id = cT.getValue(); String taskName = cT.getKey(); - if (id == operator1ID) { + if (id == OPERATOR1_ID) { task1 = taskName; - - } else if (id == operator2ID) { + } else if (id == OPERATOR2_ID) { task2 = taskName; - } } - - // int i = dropDown.indexOf(checkedDropDown.get); - // int j = dropDown.indexOf(t2); - - // task1 = dropDown.get(i); - // task2 = dropDown.get(j); - allLatencies = dgt.latencyDetailedAnalysis(task1, task2, transFile1, false, false); - assertTrue(allLatencies.length == 1); assertTrue((int) allLatencies[0][1] == 60); assertTrue((int) allLatencies[0][3] == 212); assertTrue((int) allLatencies[0][4] == 152); } - } -- GitLab