Package: TraceEventManager

TraceEventManager

nameinstructionbranchcomplexitylinemethod
TraceEventManager(NextGenRTLogger)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getCurrentEventTime()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEventTimes()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEvents()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEvents(Long)
M: 21 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getLastEventTime()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
reset()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * RT Trace Viewer Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.rttraceviewer.data;
23:
24: import java.util.ArrayList;
25: import java.util.List;
26: import java.util.TreeMap;
27:
28: import org.overture.interpreter.messages.rtlog.nextgen.INextGenEvent;
29: import org.overture.interpreter.messages.rtlog.nextgen.NextGenRTLogger;
30:
31: public class TraceEventManager {
32:         private final TreeMap<Long, ArrayList<INextGenEvent>> events;
33:         private Long currentEventTime;
34:         
35:         public TraceEventManager(NextGenRTLogger logger) {
36:                 this.events = (TreeMap<Long, ArrayList<INextGenEvent>>) logger.getEvents();
37:         }
38:         
39:         /**
40:          * Get events from a specified start time. If no events at specified time the next series of
41:          * events is returned
42:          * @param startTime time to start searching for events
43:          * @return list of all events at this or the next event time
44:          */
45:         public List<INextGenEvent> getEvents(Long startTime) {
46:                 ArrayList<INextGenEvent> eventList = null;
47:                 
48:                 //Key events where key is equal to or greater (null if nothing is found)
49:                 Long eventKey = events.ceilingKey(startTime);
50:                 
51:•         if(eventKey != null) {
52:                  eventList = events.get(eventKey);
53:                  currentEventTime = eventKey;
54:          }                 
55:                 return eventList;
56:         }
57:         
58:         /**
59:          * Get events from the last referenced event time
60:          * @return List of events at the next referenced event time
61:          */
62:         public List<INextGenEvent> getEvents() {
63:                 return getEvents(getCurrentEventTime() + 1);
64:         }
65:         
66:         /**
67:          * Get a list of all event times
68:          * @return List of times
69:          */
70:         public List<Long> getEventTimes() {
71:                 return new ArrayList<Long>(events.keySet());
72:         }
73:         
74:         /**
75:          * get the current event time
76:          * @return Event time
77:          */
78:         public Long getCurrentEventTime() {
79:                 return currentEventTime;
80:         }
81:         
82:         /**
83:          * Get time of last event group
84:          * @return Event time
85:          */
86:         public Long getLastEventTime() {
87:                 return events.lastKey();
88:         }
89:         
90:         /**
91:          * Reset the internal state
92:          */
93:         public void reset() {
94:                 currentEventTime = null;
95:         }
96:         
97:         
98:
99: }