analysis: support sched_waking event
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.graph.core / src / org / eclipse / tracecompass / analysis / graph / core / base / TmfEdge.java
1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francis Giraldeau - Initial implementation and API
11 * Geneviève Bastien - Initial implementation and API
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.analysis.graph.core.base;
15
16 /**
17 * Edge of a TmfGraph
18 *
19 * @author Francis Giraldeau
20 * @author Geneviève Bastien
21 */
22 public class TmfEdge {
23
24 /**
25 * Enumeration of the different types of edges
26 *
27 * FIXME: this sounds very specific to kernel traces, maybe it shouldn't be
28 * here
29 *
30 * Comment by gbastien: I think the edge itself should be either a green
31 * light or a red light and there could be a context specific qualifier to
32 * go along
33 *
34 * How about something like this:
35 *
36 * <pre>
37 * public enum EdgeState {
38 * PASS,
39 * STOP
40 * [,EPS] (for "fake" edge to allow 2 vertices at the same timestamp to many vertical edges)
41 * }
42 *
43 * public ISomeInterface {
44 * }
45 *
46 * public enum KernelEdgeType implements ISomeInterface {
47 * RUNNING, BLOCKED, INTERRUPTED, ...
48 * }
49 *
50 * public class EdgeType {
51 * private EdgeState fState;
52 * private ISomeInterface fQualifier;
53 * }
54 * </pre>
55 */
56 public enum EdgeType {
57
58 /**
59 * Special edge, so it is possible to have two vertices at the same
60 * timestamp
61 */
62 EPS,
63 /** Unknown edge */
64 UNKNOWN,
65 /** Default type for an edge */
66 DEFAULT,
67 /** Worker is running */
68 RUNNING,
69 /** Worker is blocked */
70 BLOCKED,
71 /** Worker is in an interrupt state */
72 INTERRUPTED,
73 /** Worker is preempted */
74 PREEMPTED,
75 /** In a timer */
76 TIMER,
77 /** Edge represents a network communication */
78 NETWORK,
79 /** Worker is waiting for user input */
80 USER_INPUT,
81 /** Block device */
82 BLOCK_DEVICE,
83 /** inter-processor interrupt */
84 IPI,
85 }
86
87 private EdgeType fType;
88 private final TmfVertex fVertexFrom;
89 private final TmfVertex fVertexTo;
90
91 /**
92 * Constructor
93 *
94 * @param from
95 * The vertex this edge leaves from
96 * @param to
97 * The vertex the edge leads to
98 */
99 public TmfEdge(TmfVertex from, TmfVertex to) {
100 fVertexFrom = from;
101 fVertexTo = to;
102 fType = EdgeType.DEFAULT;
103 }
104
105 /*
106 * Getters
107 */
108
109 /**
110 * Get the origin vertex of this edge
111 *
112 * @return The origin vertex
113 */
114 public TmfVertex getVertexFrom() {
115 return fVertexFrom;
116 }
117
118 /**
119 * Get the destination vertex of this edge
120 *
121 * @return The destination vertex
122 */
123 public TmfVertex getVertexTo() {
124 return fVertexTo;
125 }
126
127 /**
128 * Get the edge type
129 *
130 * @return The type of the edge
131 */
132 public EdgeType getType() {
133 return fType;
134 }
135
136 /**
137 * Sets the edge type
138 *
139 * @param type
140 * The edge type
141 */
142 public void setType(final EdgeType type) {
143 fType = type;
144 }
145
146 /**
147 * Returns the duration of the edge
148 *
149 * @return The duration (in nanoseconds)
150 */
151 public long getDuration() {
152 return fVertexTo.getTs() - fVertexFrom.getTs();
153 }
154
155 @SuppressWarnings("nls")
156 @Override
157 public String toString() {
158 return "[" + fVertexFrom + "--" + fType + "->" + fVertexTo + "]";
159 }
160 }
This page took 0.039889 seconds and 5 git commands to generate.