1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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("nls")
17 public class TraceModelImplFactory
{
19 // ========================================================================
21 // ========================================================================
22 private int count
= 0;
23 private TraceStrings
[] traceNames
;
24 private static final long msTons
= 1000000;
25 private 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
[count
].name
, sTime
, sTime
+ 20000,
63 traceNames
[count
].classNmme
);
64 create5000Events(trace
);
70 private void create5000Events(TraceImpl trace
) {
74 long sTime
= trace
.getStartTime();
75 long eTime
= trace
.getStopTime();
76 long duration
= (long) ((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
+ (long) ((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 EventImpl
.Type
getEventType(int val
) {
106 if (EventImpl
.Type
.ALARM
.ordinal() == val
)
107 return EventImpl
.Type
.ALARM
;
108 if (EventImpl
.Type
.ERROR
.ordinal() == val
)
109 return EventImpl
.Type
.ERROR
;
110 if (EventImpl
.Type
.EVENT
.ordinal() == val
)
111 return EventImpl
.Type
.EVENT
;
112 if (EventImpl
.Type
.INFORMATION
.ordinal() == val
)
113 return EventImpl
.Type
.INFORMATION
;
114 if (EventImpl
.Type
.TIMEADJUSTMENT
.ordinal() == val
)
115 return EventImpl
.Type
.TIMEADJUSTMENT
;
116 if (EventImpl
.Type
.WARNING
.ordinal() == val
)
117 return EventImpl
.Type
.WARNING
;
118 if (EventImpl
.Type
.INFO1
.ordinal() == val
)
119 return EventImpl
.Type
.INFO1
;
120 if (EventImpl
.Type
.INFO2
.ordinal() == val
)
121 return EventImpl
.Type
.INFO2
;
122 if (EventImpl
.Type
.INFO3
.ordinal() == val
)
123 return EventImpl
.Type
.INFO3
;
124 if (EventImpl
.Type
.INFO4
.ordinal() == val
)
125 return EventImpl
.Type
.INFO4
;
126 if (EventImpl
.Type
.INFO5
.ordinal() == val
)
127 return EventImpl
.Type
.INFO5
;
128 if (EventImpl
.Type
.INFO6
.ordinal() == val
)
129 return EventImpl
.Type
.INFO6
;
130 if (EventImpl
.Type
.INFO7
.ordinal() == val
)
131 return EventImpl
.Type
.INFO7
;
132 if (EventImpl
.Type
.INFO8
.ordinal() == val
)
133 return EventImpl
.Type
.INFO8
;
134 if (EventImpl
.Type
.INFO9
.ordinal() == val
)
135 return EventImpl
.Type
.INFO9
;
136 return EventImpl
.Type
.UNKNOWN
;
139 private void loadTraceNameStrings() {
140 traceNames
[0] = new TraceStrings();
141 traceNames
[0].name
= "TE Log - TATA BSC11";
142 traceNames
[0].classNmme
= "All Boards";
144 traceNames
[1] = new TraceStrings();
145 traceNames
[1].name
= "System Log";
146 traceNames
[1].classNmme
= "BSC11";
148 traceNames
[2] = new TraceStrings();
149 traceNames
[2].name
= "Alarm Log";
150 traceNames
[2].classNmme
= "BSC11";
152 traceNames
[3] = new TraceStrings();
153 traceNames
[3].name
= "Events Log";
154 traceNames
[3].classNmme
= "BSC 11";
156 traceNames
[4] = new TraceStrings();
157 traceNames
[4].name
= "CPU Load";
158 traceNames
[4].classNmme
= "All Boards";
160 traceNames
[5] = new TraceStrings();
161 traceNames
[5].name
= "Performance Log";
162 traceNames
[5].classNmme
= "BSC11";
164 traceNames
[6] = new TraceStrings();
165 traceNames
[6].name
= "TE Log - TATA BSC14";
166 traceNames
[6].classNmme
= "Board 24";
168 traceNames
[7] = new TraceStrings();
169 traceNames
[7].name
= "TE Log - TATA BSC14";
170 traceNames
[7].classNmme
= "Board 23";
172 traceNames
[8] = new TraceStrings();
173 traceNames
[8].name
= "TE Log - TATA BSC14";
174 traceNames
[8].classNmme
= "Board 11";
176 traceNames
[9] = new TraceStrings();
177 traceNames
[9].name
= "TE Log - TATA BSC14";
178 traceNames
[9].classNmme
= "Board 14, SPO";
180 traceNames
[10] = new TraceStrings();
181 traceNames
[10].name
= "INFO 1";
182 traceNames
[10].classNmme
= "All Boards";
184 traceNames
[11] = new TraceStrings();
185 traceNames
[11].name
= "INFO2";
186 traceNames
[11].classNmme
= "BSC11";
188 traceNames
[12] = new TraceStrings();
189 traceNames
[12].name
= "INFO3";
190 traceNames
[12].classNmme
= "Board 24";
192 traceNames
[13] = new TraceStrings();
193 traceNames
[13].name
= "MISC1";
194 traceNames
[13].classNmme
= "Board 23";
196 traceNames
[14] = new TraceStrings();
197 traceNames
[14].name
= "MISC2";
198 traceNames
[14].classNmme
= "Board 11";
200 traceNames
[15] = new TraceStrings();
201 traceNames
[15].name
= "MISC3";
202 traceNames
[15].classNmme
= "Board 23";
204 traceNames
[16] = new TraceStrings();
205 traceNames
[16].name
= "MISC4";
206 traceNames
[16].classNmme
= "Board 11";
210 // ========================================================================
212 // ========================================================================
213 private static class TraceStrings
{
214 public String name
= "";
215 public String classNmme
= name
+ " class";
This page took 0.036103 seconds and 6 git commands to generate.