cd58cfc709e14070fcacde43f9888fbb3f52bda9
1 /*******************************************************************************
2 * Copyright (c) 2009, 2012 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.test
.stub
.model
;
14 import java
.util
.Date
;
16 @SuppressWarnings({"javadoc", "nls"})
17 public class TraceModelImplFactory
{
19 // ========================================================================
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
;
27 // ========================================================================
29 // ========================================================================
30 public TraceModelImplFactory() {
31 traceNames
= new TraceStrings
[17];
32 loadTraceNameStrings();
35 // ========================================================================
37 // ========================================================================
38 public TraceImpl
[] createTraces() {
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
);
52 * 5000 Events per Trace.
56 public TraceImpl
[] createLargeTraces(int number
) {
58 TraceImpl
[] traceArr
= new TraceImpl
[number
];
59 for (int i
= 0; i
< traceArr
.length
; i
++) {
61 long sTime
= i
* (long) 1E6
;
62 trace
= new TraceImpl(traceNames
[counter
].name
, sTime
, sTime
+ 20000,
63 traceNames
[counter
].classNmme
);
64 create5000Events(trace
);
70 private static void create5000Events(TraceImpl trace
) {
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: "
82 // duration = i * msTons + (long) ((i % 4));
84 event
= new EventImpl(eventTime
, trace
, getEventType(i
%16));
85 event
.setDuration(duration
);
86 trace
.addTraceEvent(event
);
90 private void createEvents(TraceImpl trace
) {
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
);
105 private static EventImpl
.Type
getEventType(int val
) {
106 if (EventImpl
.Type
.ALARM
.ordinal() == val
) {
107 return EventImpl
.Type
.ALARM
;
109 if (EventImpl
.Type
.ERROR
.ordinal() == val
) {
110 return EventImpl
.Type
.ERROR
;
112 if (EventImpl
.Type
.EVENT
.ordinal() == val
) {
113 return EventImpl
.Type
.EVENT
;
115 if (EventImpl
.Type
.INFORMATION
.ordinal() == val
) {
116 return EventImpl
.Type
.INFORMATION
;
118 if (EventImpl
.Type
.TIMEADJUSTMENT
.ordinal() == val
) {
119 return EventImpl
.Type
.TIMEADJUSTMENT
;
121 if (EventImpl
.Type
.WARNING
.ordinal() == val
) {
122 return EventImpl
.Type
.WARNING
;
124 if (EventImpl
.Type
.INFO1
.ordinal() == val
) {
125 return EventImpl
.Type
.INFO1
;
127 if (EventImpl
.Type
.INFO2
.ordinal() == val
) {
128 return EventImpl
.Type
.INFO2
;
130 if (EventImpl
.Type
.INFO3
.ordinal() == val
) {
131 return EventImpl
.Type
.INFO3
;
133 if (EventImpl
.Type
.INFO4
.ordinal() == val
) {
134 return EventImpl
.Type
.INFO4
;
136 if (EventImpl
.Type
.INFO5
.ordinal() == val
) {
137 return EventImpl
.Type
.INFO5
;
139 if (EventImpl
.Type
.INFO6
.ordinal() == val
) {
140 return EventImpl
.Type
.INFO6
;
142 if (EventImpl
.Type
.INFO7
.ordinal() == val
) {
143 return EventImpl
.Type
.INFO7
;
145 if (EventImpl
.Type
.INFO8
.ordinal() == val
) {
146 return EventImpl
.Type
.INFO8
;
148 if (EventImpl
.Type
.INFO9
.ordinal() == val
) {
149 return EventImpl
.Type
.INFO9
;
151 return EventImpl
.Type
.UNKNOWN
;
154 private void loadTraceNameStrings() {
155 traceNames
[0] = new TraceStrings();
156 traceNames
[0].name
= "TE Log - TATA BSC11";
157 traceNames
[0].classNmme
= "All Boards";
159 traceNames
[1] = new TraceStrings();
160 traceNames
[1].name
= "System Log";
161 traceNames
[1].classNmme
= "BSC11";
163 traceNames
[2] = new TraceStrings();
164 traceNames
[2].name
= "Alarm Log";
165 traceNames
[2].classNmme
= "BSC11";
167 traceNames
[3] = new TraceStrings();
168 traceNames
[3].name
= "Events Log";
169 traceNames
[3].classNmme
= "BSC 11";
171 traceNames
[4] = new TraceStrings();
172 traceNames
[4].name
= "CPU Load";
173 traceNames
[4].classNmme
= "All Boards";
175 traceNames
[5] = new TraceStrings();
176 traceNames
[5].name
= "Performance Log";
177 traceNames
[5].classNmme
= "BSC11";
179 traceNames
[6] = new TraceStrings();
180 traceNames
[6].name
= "TE Log - TATA BSC14";
181 traceNames
[6].classNmme
= "Board 24";
183 traceNames
[7] = new TraceStrings();
184 traceNames
[7].name
= "TE Log - TATA BSC14";
185 traceNames
[7].classNmme
= "Board 23";
187 traceNames
[8] = new TraceStrings();
188 traceNames
[8].name
= "TE Log - TATA BSC14";
189 traceNames
[8].classNmme
= "Board 11";
191 traceNames
[9] = new TraceStrings();
192 traceNames
[9].name
= "TE Log - TATA BSC14";
193 traceNames
[9].classNmme
= "Board 14, SPO";
195 traceNames
[10] = new TraceStrings();
196 traceNames
[10].name
= "INFO 1";
197 traceNames
[10].classNmme
= "All Boards";
199 traceNames
[11] = new TraceStrings();
200 traceNames
[11].name
= "INFO2";
201 traceNames
[11].classNmme
= "BSC11";
203 traceNames
[12] = new TraceStrings();
204 traceNames
[12].name
= "INFO3";
205 traceNames
[12].classNmme
= "Board 24";
207 traceNames
[13] = new TraceStrings();
208 traceNames
[13].name
= "MISC1";
209 traceNames
[13].classNmme
= "Board 23";
211 traceNames
[14] = new TraceStrings();
212 traceNames
[14].name
= "MISC2";
213 traceNames
[14].classNmme
= "Board 11";
215 traceNames
[15] = new TraceStrings();
216 traceNames
[15].name
= "MISC3";
217 traceNames
[15].classNmme
= "Board 23";
219 traceNames
[16] = new TraceStrings();
220 traceNames
[16].name
= "MISC4";
221 traceNames
[16].classNmme
= "Board 11";
225 // ========================================================================
227 // ========================================================================
228 private static class TraceStrings
{
229 public String name
= "";
230 public String classNmme
= name
+ " class";
This page took 0.038213 seconds and 5 git commands to generate.