Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
11252342 | 2 | * Copyright (c) 2009, 2013 Ericsson |
be222f56 PT |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made 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 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model; | |
13 | ||
14 | import java.util.Date; | |
15 | ||
cad06250 | 16 | @SuppressWarnings("javadoc") |
be222f56 PT |
17 | public class TraceModelImplFactory { |
18 | ||
d5efe032 AF |
19 | // ======================================================================== |
20 | // Data | |
21 | // ======================================================================== | |
22 | private int count = 0; | |
23 | private final TraceStrings[] traceNames; | |
24 | private static final long msTons = 1000000; | |
25 | private final Long timeRef = new Date().getTime() * msTons; | |
26 | ||
27 | // ======================================================================== | |
28 | // Constructor | |
29 | // ======================================================================== | |
30 | public TraceModelImplFactory() { | |
31 | traceNames = new TraceStrings[17]; | |
32 | loadTraceNameStrings(); | |
33 | } | |
34 | ||
35 | // ======================================================================== | |
36 | // Methods | |
37 | // ======================================================================== | |
38 | public TraceImpl[] createTraces() { | |
39 | TraceImpl trace; | |
40 | TraceImpl[] traceArr = new TraceImpl[17]; | |
41 | for (int i = 0; i < traceArr.length; i++) { | |
42 | trace = new TraceImpl(traceNames[i].name, timeRef, timeRef + 40, | |
43 | traceNames[i].classNmme); | |
44 | count = i; | |
45 | createEvents(trace); | |
46 | traceArr[i] = trace; | |
47 | } | |
48 | return traceArr; | |
49 | } | |
50 | ||
51 | /** | |
52 | * 5000 Events per Trace. | |
53 | * @param number | |
54 | * @return | |
55 | */ | |
56 | public TraceImpl[] createLargeTraces(int number) { | |
57 | TraceImpl trace; | |
58 | TraceImpl[] traceArr = new TraceImpl[number]; | |
59 | for (int i = 0; i < traceArr.length; i++) { | |
60 | int counter = i%17; | |
61 | long sTime = i * (long) 1E6; | |
62 | trace = new TraceImpl(traceNames[counter].name, sTime , sTime + 20000, | |
63 | traceNames[counter].classNmme); | |
64 | create5000Events(trace); | |
65 | traceArr[i] = trace; | |
66 | } | |
67 | return traceArr; | |
68 | } | |
69 | ||
70 | private static void create5000Events(TraceImpl trace) { | |
71 | EventImpl event; | |
72 | Long eventTime; | |
73 | int numEvents = 5000; | |
74 | long sTime = trace.getStartTime(); | |
75 | long eTime = trace.getEndTime(); | |
76 | long duration = (eTime - sTime)/numEvents; | |
77 | for (int i = 0; i < numEvents; i++) { | |
78 | eventTime = sTime + (i * duration); | |
79 | // eventTime = timeRef + (5 * (count % 4) + (5 * (int) (i/2) )); | |
80 | // System.out.println("Trace: " + trace.getName() + " EventTime: " | |
81 | // + eventTime); | |
82 | // duration = i * msTons + (long) ((i % 4)); | |
83 | ||
84 | event = new EventImpl(eventTime, trace, getEventType(i%16)); | |
85 | event.setDuration(duration); | |
86 | trace.addTraceEvent(event); | |
87 | } | |
88 | } | |
89 | ||
90 | private void createEvents(TraceImpl trace) { | |
91 | EventImpl event; | |
92 | Long eventTime; | |
93 | int numEvents = 17; | |
94 | long duration = 0; | |
95 | for (int i = 0; i < numEvents; i++) { | |
96 | eventTime = timeRef + msTons * i + (5 * msTons * count) + (5 * i); | |
97 | duration = msTons + i * msTons + ((i % 4)); | |
98 | // duration = i + (long) ((i % 4)); | |
99 | event = new EventImpl(eventTime, trace, getEventType(i)); | |
100 | event.setDuration(duration); | |
101 | trace.addTraceEvent(event); | |
102 | } | |
103 | } | |
be222f56 PT |
104 | |
105 | private static EventImpl.Type getEventType(int val) { | |
106 | if (EventImpl.Type.ALARM.ordinal() == val) { | |
107 | return EventImpl.Type.ALARM; | |
108 | } | |
109 | if (EventImpl.Type.ERROR.ordinal() == val) { | |
110 | return EventImpl.Type.ERROR; | |
111 | } | |
112 | if (EventImpl.Type.EVENT.ordinal() == val) { | |
113 | return EventImpl.Type.EVENT; | |
114 | } | |
115 | if (EventImpl.Type.INFORMATION.ordinal() == val) { | |
116 | return EventImpl.Type.INFORMATION; | |
117 | } | |
118 | if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) { | |
119 | return EventImpl.Type.TIMEADJUSTMENT; | |
120 | } | |
121 | if (EventImpl.Type.WARNING.ordinal() == val) { | |
122 | return EventImpl.Type.WARNING; | |
123 | } | |
124 | if (EventImpl.Type.INFO1.ordinal() == val) { | |
125 | return EventImpl.Type.INFO1; | |
126 | } | |
127 | if (EventImpl.Type.INFO2.ordinal() == val) { | |
128 | return EventImpl.Type.INFO2; | |
129 | } | |
130 | if (EventImpl.Type.INFO3.ordinal() == val) { | |
131 | return EventImpl.Type.INFO3; | |
132 | } | |
133 | if (EventImpl.Type.INFO4.ordinal() == val) { | |
134 | return EventImpl.Type.INFO4; | |
135 | } | |
136 | if (EventImpl.Type.INFO5.ordinal() == val) { | |
137 | return EventImpl.Type.INFO5; | |
138 | } | |
139 | if (EventImpl.Type.INFO6.ordinal() == val) { | |
140 | return EventImpl.Type.INFO6; | |
141 | } | |
142 | if (EventImpl.Type.INFO7.ordinal() == val) { | |
143 | return EventImpl.Type.INFO7; | |
144 | } | |
145 | if (EventImpl.Type.INFO8.ordinal() == val) { | |
146 | return EventImpl.Type.INFO8; | |
147 | } | |
148 | if (EventImpl.Type.INFO9.ordinal() == val) { | |
149 | return EventImpl.Type.INFO9; | |
150 | } | |
151 | return EventImpl.Type.UNKNOWN; | |
152 | } | |
153 | ||
d5efe032 AF |
154 | private void loadTraceNameStrings() { |
155 | traceNames[0] = new TraceStrings(); | |
156 | traceNames[0].name = "TE Log - TATA BSC11"; | |
157 | traceNames[0].classNmme = "All Boards"; | |
be222f56 | 158 | |
d5efe032 AF |
159 | traceNames[1] = new TraceStrings(); |
160 | traceNames[1].name = "System Log"; | |
161 | traceNames[1].classNmme = "BSC11"; | |
be222f56 | 162 | |
d5efe032 AF |
163 | traceNames[2] = new TraceStrings(); |
164 | traceNames[2].name = "Alarm Log"; | |
165 | traceNames[2].classNmme = "BSC11"; | |
be222f56 | 166 | |
d5efe032 AF |
167 | traceNames[3] = new TraceStrings(); |
168 | traceNames[3].name = "Events Log"; | |
169 | traceNames[3].classNmme = "BSC 11"; | |
be222f56 | 170 | |
d5efe032 AF |
171 | traceNames[4] = new TraceStrings(); |
172 | traceNames[4].name = "CPU Load"; | |
173 | traceNames[4].classNmme = "All Boards"; | |
be222f56 | 174 | |
d5efe032 AF |
175 | traceNames[5] = new TraceStrings(); |
176 | traceNames[5].name = "Performance Log"; | |
177 | traceNames[5].classNmme = "BSC11"; | |
be222f56 | 178 | |
d5efe032 AF |
179 | traceNames[6] = new TraceStrings(); |
180 | traceNames[6].name = "TE Log - TATA BSC14"; | |
181 | traceNames[6].classNmme = "Board 24"; | |
be222f56 | 182 | |
d5efe032 AF |
183 | traceNames[7] = new TraceStrings(); |
184 | traceNames[7].name = "TE Log - TATA BSC14"; | |
185 | traceNames[7].classNmme = "Board 23"; | |
be222f56 | 186 | |
d5efe032 AF |
187 | traceNames[8] = new TraceStrings(); |
188 | traceNames[8].name = "TE Log - TATA BSC14"; | |
189 | traceNames[8].classNmme = "Board 11"; | |
be222f56 | 190 | |
d5efe032 AF |
191 | traceNames[9] = new TraceStrings(); |
192 | traceNames[9].name = "TE Log - TATA BSC14"; | |
193 | traceNames[9].classNmme = "Board 14, SPO"; | |
be222f56 | 194 | |
d5efe032 AF |
195 | traceNames[10] = new TraceStrings(); |
196 | traceNames[10].name = "INFO 1"; | |
197 | traceNames[10].classNmme = "All Boards"; | |
be222f56 | 198 | |
d5efe032 AF |
199 | traceNames[11] = new TraceStrings(); |
200 | traceNames[11].name = "INFO2"; | |
201 | traceNames[11].classNmme = "BSC11"; | |
be222f56 | 202 | |
d5efe032 AF |
203 | traceNames[12] = new TraceStrings(); |
204 | traceNames[12].name = "INFO3"; | |
205 | traceNames[12].classNmme = "Board 24"; | |
be222f56 | 206 | |
d5efe032 AF |
207 | traceNames[13] = new TraceStrings(); |
208 | traceNames[13].name = "MISC1"; | |
209 | traceNames[13].classNmme = "Board 23"; | |
be222f56 | 210 | |
d5efe032 AF |
211 | traceNames[14] = new TraceStrings(); |
212 | traceNames[14].name = "MISC2"; | |
213 | traceNames[14].classNmme = "Board 11"; | |
be222f56 | 214 | |
d5efe032 AF |
215 | traceNames[15] = new TraceStrings(); |
216 | traceNames[15].name = "MISC3"; | |
217 | traceNames[15].classNmme = "Board 23"; | |
be222f56 | 218 | |
d5efe032 AF |
219 | traceNames[16] = new TraceStrings(); |
220 | traceNames[16].name = "MISC4"; | |
221 | traceNames[16].classNmme = "Board 11"; | |
be222f56 | 222 | |
d5efe032 | 223 | } |
be222f56 | 224 | |
d5efe032 AF |
225 | // ======================================================================== |
226 | // Inner Class | |
227 | // ======================================================================== | |
228 | private static class TraceStrings { | |
229 | public String name = ""; | |
230 | public String classNmme = name + " class"; | |
231 | } | |
be222f56 | 232 | } |