Revision 842775ab

View differences:

src/eventlog/event.cc
41 41
    numEventLogMessages = -1;
42 42
    numBeginSendEntries = -1;
43 43
    eventEntry = NULL;
44
    eventEndEntry = NULL;
45 44
    moduleCreatedEntry = NULL;
46 45
    cause = NULL;
47 46
    causes = NULL;
48 47
    consequences = NULL;
49 48
    eventLogEntries.clear();
50

  
51
    _earliestProcessingTime = 0;
52 49
}
53 50

  
54 51
void Event::deleteConsequences()
......
139 136

  
140 137
        EventLogEntry *eventLogEntry = EventLogEntry::parseEntry(eventLog, this, index, reader->getCurrentLineStartOffset(), line, reader->getCurrentLineLength());
141 138

  
142
        // check for eventEndEntries. We do not include such entries in the eventLogEntries
143
        // for backwards compatibility with other plugins (e.g., eventTable)
144
        EventEndEntry * readEventEndEntry = dynamic_cast<EventEndEntry*>(eventLogEntry);
145
        if(readEventEndEntry) {
146
            eventEndEntry = readEventEndEntry;
147
            continue;
148
        }
149

  
150 139
        // skip empty lines
151 140
        if (!eventLogEntry)
152 141
            continue;
......
191 180
        if (dynamic_cast<BeginSendEntry *>(eventLogEntry))
192 181
            numBeginSendEntries++;
193 182
    }
183

  
194 184
    Assert(eventEntry);
195 185
    return endOffset = reader->getCurrentLineStartOffset();
196 186
}
......
306 296
    return (Event *)nextEvent;
307 297
}
308 298

  
309
Event *Event::getPreviousEventRealTime()
310
{
311
    if (eventLog->getFirstEventRealTime() == this) {
312
        return NULL;
313
    }
314
    Assert(previousEventRealTime != NULL);
315
    return (Event*)previousEventRealTime;
316
}
317

  
318
Event *Event::getNextEventRealTime()
319
{
320
    if (eventLog->getLastEventRealTime() == this) {
321
        return NULL;
322
    }
323
    Assert(nextEventRealTime != NULL);
324
    return (Event*)nextEventRealTime;
325
}
326

  
327 299
Event *Event::getCauseEvent()
328 300
{
329 301
    int causeEventNumber = getCauseEventNumber();
......
396 368
    }
397 369
    return consequences;
398 370
}
399

  
400
long Event::getEarliestProcessingTime() {
401
    return _earliestProcessingTime;
402
}
403
long Event::getEarliestStartTime() {
404
    return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
405
}
src/eventlog/event.h
43 43
        file_offset_t beginOffset; // file offset where the event starts
44 44
        file_offset_t endOffset; // file offset where the event ends (ie. begin of next event)
45 45
        EventEntry *eventEntry; // the event log entry that corresponds to the actual event ("E" line)
46
        EventEndEntry* eventEndEntry; //the event end entry that stores the measured complexity
47 46
        ModuleCreatedEntry *moduleCreatedEntry;
48 47
        int numEventLogMessages;
49 48
        int numBeginSendEntries;
......
59 58
        IMessageDependencyList *consequences; // message sends in this event
60 59

  
61 60
    public:
62

  
63 61
        Event(EventLog *eventLog);
64 62
        virtual ~Event();
65 63

  
......
78 76
        virtual file_offset_t getEndOffset() { return endOffset; }
79 77

  
80 78
        virtual EventEntry *getEventEntry() { return eventEntry; }
81
        virtual EventEndEntry *getEventEndEntry() { return eventEndEntry; }
82 79
        virtual int getNumEventLogEntries() { return eventLogEntries.size(); }
83 80
        virtual EventLogEntry *getEventLogEntry(int index) { return eventLogEntries[index]; }
84 81

  
......
88 85

  
89 86
        virtual eventnumber_t getEventNumber() { return eventEntry->eventNumber; }
90 87
        virtual simtime_t getSimulationTime() { return eventEntry->simulationTime; }
91
        virtual long getComplexity() { return !eventEndEntry ? 0 : eventEndEntry->complexity; }
92 88
        virtual int getModuleId() { return eventEntry->moduleId; }
93 89
        virtual long getMessageId() { return eventEntry->messageId; }
94 90
        virtual eventnumber_t getCauseEventNumber() { return eventEntry->causeEventNumber; }
......
100 96
        virtual Event *getPreviousEvent();
101 97
        virtual Event *getNextEvent();
102 98

  
103
        virtual Event *getPreviousEventRealTime();
104
        virtual Event *getNextEventRealTime();
105

  
106 99
        virtual Event *getCauseEvent();
107 100
        virtual BeginSendEntry *getCauseBeginSendEntry();
108 101
        virtual MessageSendDependency *getCause();
......
111 104

  
112 105
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
113 106

  
114
        virtual long getEarliestProcessingTime();
115
        virtual long getEarliestStartTime();
116

  
117

  
118 107
    protected:
119 108
        void clearInternalState();
120 109
        void deleteConsequences();
src/eventlog/eventlog.cc
55 55
    endOffsetToEventMap.clear();
56 56
    consequenceLookaheadLimits.clear();
57 57
    previousEventNumberToMessageEntriesMap.clear();
58
    legacyTrace = true;
59 58
}
60 59

  
61 60
void EventLog::deleteAllocatedObjects()
......
284 283
    return lastEvent;
285 284
}
286 285

  
287
Event *EventLog::getFirstEventRealTime()
288
{
289
    Assert(firstEventRealTime != NULL);
290
    return firstEventRealTime;
291
}
292

  
293
Event *EventLog::getLastEventRealTime()
294
{
295
    Assert(lastEventRealTime != NULL);
296
    return lastEventRealTime;
297
}
298

  
299 286
Event *EventLog::getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind, bool useCacheOnly)
300 287
{
301 288
    Assert(eventNumber >= 0);
......
424 411
void EventLog::parseEvent(Event *event, file_offset_t beginOffset)
425 412
{
426 413
    event->parse(reader, beginOffset);
427
    if(event->getEventEndEntry() != NULL)
428
        legacyTrace = false;
429

  
430 414
    cacheEntry(event->getEventNumber(), event->getSimulationTime(), event->getBeginOffset(), event->getEndOffset());
431 415
    cacheEventLogEntries(event);
432 416
    numParsedEvents++;
src/eventlog/eventlog.h
52 52
        Event *firstEvent;
53 53
        Event *lastEvent;
54 54

  
55
        Event *firstEventRealTime;
56
        Event *lastEventRealTime;
57

  
58
        bool legacyTrace; // is legacy trace that does not contain EventEndEntries
59

  
60 55
        SimulationBeginEntry *simulationBeginEntry;
61 56
        SimulationEndEntry *simulationEndEntry;
62 57

  
......
87 82
        virtual ProgressMonitor setProgressMonitor(ProgressMonitor newProgressMonitor);
88 83
        virtual void setProgressCallInterval(double seconds) { progressCallInterval = (long)(seconds * CLOCKS_PER_SEC); lastProgressCall = clock(); }
89 84
        virtual void progress();
90
        virtual bool isLegacyTrace() { return legacyTrace; }
91 85

  
92 86
        int getKeyframeBlockSize() { return keyframeBlockSize; }
93 87
        eventnumber_t getConsequenceLookahead(eventnumber_t eventNumber) { return consequenceLookaheadLimits[eventNumber / keyframeBlockSize]; }
......
117 111

  
118 112
        virtual Event *getFirstEvent();
119 113
        virtual Event *getLastEvent();
120

  
121
        virtual Event *getFirstEventRealTime();
122
        virtual Event *getLastEventRealTime();
123

  
124
        virtual void setFirstEventRealTime(Event* e) {
125
            firstEventRealTime = e;;
126
        }
127
        virtual void setLastEventRealTime(Event* e){
128
            lastEventRealTime = e;
129
        }
130

  
131 114
        virtual Event *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
132 115
        virtual Event *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT, bool useCacheOnly = false);
133 116
        virtual Event *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT, bool useCacheOnly = false);
src/eventlog/eventlogdefs.h
103 103
    SIMULATION_TIME,
104 104
    EVENT_NUMBER,
105 105
    STEP,
106
    NONLINEAR,
107
    REAL_TIME
106
    NONLINEAR
108 107
};
109 108

  
110 109
NAMESPACE_END
src/eventlog/eventlogentries.txt
102 102
   m int moduleId                    // id of the processing module
103 103
   ce eventnumber_t causeEventNumber // event number from which the message being processed was sent, or -1 if the message was sent from initialize
104 104
   msg long messageId                // lifetime-unique id of the message being processed
105
   d simtime_t duration               0 // duration of the event
106
}
107

  
108
EE EventEndEntry //indicates end of an event
109
{
110
   e eventnumber_t eventNumber          // event number of the corresponding event
111
   c long complexity                    // measured complexity of event in microseconds (stored in simtime_t for compatibility issues)
112 105
}
113 106

  
114 107
KF KeyframeEntry
src/eventlog/filteredevent.cc
335 335

  
336 336
    messageDependencies->push_back(newMessageDependency);
337 337
}
338
long FilteredEvent::getEarliestProcessingTime() {
339
    return _earliestProcessingTime;
340
}
341
long FilteredEvent::getEarliestStartTime() {
342
    return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
343
}
src/eventlog/filteredevent.h
75 75
        virtual file_offset_t getEndOffset() { return getEvent()->getEndOffset(); }
76 76

  
77 77
        virtual EventEntry *getEventEntry() { return getEvent()->getEventEntry(); }
78
        virtual EventEndEntry *getEventEndEntry() { return getEvent()->getEventEndEntry(); }
79 78
        virtual int getNumEventLogEntries() { return getEvent()->getNumEventLogEntries(); }
80 79
        virtual EventLogEntry *getEventLogEntry(int index) { return getEvent()->getEventLogEntry(index); }
81 80

  
......
85 84

  
86 85
        virtual eventnumber_t getEventNumber() { return eventNumber; }
87 86
        virtual simtime_t getSimulationTime() { return getEvent()->getSimulationTime(); }
88
	virtual long getComplexity() { return getEvent()->getComplexity(); }
89 87
        virtual int getModuleId() { return getEvent()->getModuleId(); }
90 88
        virtual long getMessageId() { return getEvent()->getMessageId(); }
91 89
        virtual eventnumber_t getCauseEventNumber() { return getEvent()->getCauseEventNumber(); }
......
96 94
        virtual FilteredEvent *getPreviousEvent();
97 95
        virtual FilteredEvent *getNextEvent();
98 96

  
99
        virtual FilteredEvent *getPreviousEventRealTime() {
100
            Assert(false);
101
            return NULL; //Not Supported
102

  
103
        }
104

  
105
        virtual FilteredEvent *getNextEventRealTime() {
106
            Assert(false);
107
            return NULL;//Not Supported
108
        }
109

  
110
        virtual void setNextEventRealTime(IEvent* e) {
111
            nextEventRealTime = e;
112
        }
113

  
114
        virtual void setPreviousEventRealTime(IEvent* e) {
115
            previousEventRealTime = e;
116
        }
117

  
118 97
        virtual FilteredEvent *getCauseEvent();
119 98
        virtual IMessageDependency *getCause();
120 99
        virtual BeginSendEntry *getCauseBeginSendEntry();
......
132 111
        void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool IsMixed, int level);
133 112
        int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
134 113
        void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, FilteredMessageDependency::Kind kind, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
135
        virtual long getEarliestProcessingTime();
136
        virtual long getEarliestStartTime();
137

  
138 114
};
139 115

  
140 116
NAMESPACE_END
src/eventlog/filteredeventlog.h
167 167
        virtual bool isEmpty();
168 168
        virtual FilteredEvent *getFirstEvent();
169 169
        virtual FilteredEvent *getLastEvent();
170

  
171
        virtual Event *getFirstEventRealTime() {
172
            Assert(false);
173
            return NULL;
174
        }
175
        virtual Event *getLastEventRealTime() {
176
            Assert(false);
177
            return NULL;
178
        }
179

  
180
        virtual void setFirstEventRealTime(Event* e) {
181
            Assert(false);
182
        }
183
        virtual void setLastEventRealTime(Event* e){
184
            Assert(false);
185
        }
186

  
187 170
        virtual FilteredEvent *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
188 171
        virtual FilteredEvent *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT, bool useCacheOnly = false);
189 172
        virtual FilteredEvent *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT, bool useCacheOnly = false);
......
194 177
        virtual double getApproximatePercentageForEventNumber(eventnumber_t eventNumber);
195 178
        virtual FilteredEvent *getApproximateEventAt(double percentage);
196 179

  
197
        virtual bool isLegacyTrace()  { return eventLog->isLegacyTrace(); }
198

  
199 180
    protected:
200 181
        /**
201 182
         * Caches the given filtered event in the event cache if not present yet.
src/eventlog/ievent.cc
28 28
{
29 29
    nextEvent = NULL;
30 30
    previousEvent = NULL;
31
    criticalPredecessor = NULL;
32 31
    cachedTimelineCoordinate = -1;
33 32
    cachedTimelineCoordinateSystemVersion = -1;
34
    _earliestProcessingTime = 0;
35 33
}
36 34

  
37 35
void IEvent::synchronize(FileReader::FileChangedState change)
src/eventlog/ievent.h
30 30
        IEvent *previousEvent;
31 31
        IEvent *nextEvent;
32 32

  
33
        IEvent *previousEventRealTime;
34
        IEvent *nextEventRealTime;
35

  
36
        IEvent* criticalPredecessor;
37

  
38 33
    public:
39 34
        // gui state for SequenceChart
40 35
        double cachedTimelineCoordinate;
41 36
        long cachedTimelineCoordinateSystemVersion;
42 37

  
43
        long _earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
44

  
45

  
46

  
47 38
    public:
48 39
        IEvent();
49 40
        virtual ~IEvent() {}
......
72 63
         */
73 64
        virtual EventEntry *getEventEntry() = 0;
74 65
        /**
75
         * Returns the 'EE' entry (line) corresponding to this event.
76
         */
77
        virtual EventEndEntry *getEventEndEntry() = 0;
78
        /**
79 66
         * Returns the number of log file entries (lines) for this event.
80 67
         */
81 68
        virtual int getNumEventLogEntries() = 0;
......
92 79
        // some of the data found in the 'E' entry (line), to get additional data query the entries
93 80
        virtual eventnumber_t getEventNumber() = 0;
94 81
        virtual simtime_t getSimulationTime() = 0;
95
	virtual long getComplexity() = 0;
96 82
        virtual int getModuleId() = 0;
97 83
        virtual long getMessageId() = 0;
98 84
        virtual eventnumber_t getCauseEventNumber() = 0;
......
107 93
        virtual IEvent *getNextEvent() = 0;
108 94

  
109 95
        /**
110
         * Returns the immediately preceding event in RealTime or NULL if there is no such event.
111
         */
112
        virtual IEvent *getPreviousEventRealTime() = 0;
113
        /**
114
         * Returns the immediately following event in RealTime or NULL if there is no such event.
115
         */
116
        virtual IEvent *getNextEventRealTime() = 0;
117

  
118
        virtual void setNextEventRealTime(IEvent* e) {
119
            nextEventRealTime = e;
120
        }
121

  
122
        virtual void setPreviousEventRealTime(IEvent* e) {
123
            previousEventRealTime = e;
124
        }
125

  
126
        /**
127 96
         * Returns the closest preceding event which caused this event by sending a message.
128 97
         */
129 98
        virtual IEvent *getCauseEvent() = 0;
......
132 101
        virtual IMessageDependencyList *getCauses() = 0;
133 102
        virtual IMessageDependencyList *getConsequences() = 0;
134 103

  
135
        /**  public int getEarliestProcessingTime() {
136
    return EventLogEngineJNI.IEvent_earliestProcessingTime_get(swigCPtr, this);
137
  }
104
        /**
138 105
         * Print all entries of this event.
139 106
         */
140 107
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
......
169 136
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
170 137
        static void unlinkNeighbourEvents(IEvent *nextEvent);
171 138

  
172
        virtual long getEarliestProcessingTime() = 0;
173
        virtual long getEarliestStartTime() = 0;
174

  
175
        IEvent* getCriticalPredecessor() {
176
            return criticalPredecessor;
177
        }
178

  
179
        void setCriticalPredecessor(IEvent* e) {
180
            criticalPredecessor = e;
181
        }
182

  
183 139
    protected:
184 140
        void clearInternalState();
185 141
};
src/eventlog/ieventlog.h
90 90
        virtual FileReader *getFileReader() = 0;
91 91

  
92 92
        /**
93
         * Returns the distance between subsequent keyframes in terms of event numbers.
94
         */
95
        virtual int getKeyframeBlockSize() = 0;
96

  
97
        /**
93 98
         * Returns the number of events parsed so far.
94 99
         */
95 100
        virtual eventnumber_t getNumParsedEvents() = 0;
......
139 144
         * Returns the requested event or NULL if there is no such event included in the log.
140 145
         * The given event number may not be included in the log.
141 146
         */
142
        virtual IEvent *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT) = 0;
147
        virtual IEvent *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT, bool useCacheOnly = false) = 0;
143 148
        /**
144 149
         * Returns the requested event or NULL if there is no such event included in the log.
145 150
         * The given simulation time may not be included in the log.
146 151
         */
147
        virtual IEvent *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT) = 0;
152
        virtual IEvent *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT, bool useCacheOnly = false) = 0;
148 153

  
149 154
        /**
150 155
         * Finds the closest event log entry containing the given text.
......
161 166
         */
162 167
        virtual IEvent *getApproximateEventAt(double percentage) = 0;
163 168

  
164
        /**
165
         * returns true if the trace file includes EventEndEntries
166
         */
167
        virtual bool isLegacyTrace() = 0;
168 169
    public:
169 170
        /**
170
         * Returns the event at the given instance. 0 means the parameter event will be returned.
171
         * Returns the event at the given distance. 0 means the parameter event will be returned.
171 172
         */
172 173
        virtual IEvent *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
173 174

  
......
183 184
        virtual double getApproximatePercentageForEventNumber(eventnumber_t eventNumber);
184 185

  
185 186
        /**
186
         * Prints all or only the events in the requested range from the log.
187
         * The given event numbers may not be included in the log.
187
         * Prints the contents into specified file.
188
         * The given event numbers may not be present in the log.
188 189
         */
189
        virtual void printEvents(FILE *file = stdout, eventnumber_t fromEventNumber = -1, eventnumber_t toEventNumber = -1, bool outputEventLogMessages = true);
190
        /**
191
         * Prints initialization entries and calls printEvents.
192
         * The given event numbers may not be included in the log.
193
         */
194
        virtual void print(FILE *file = stdout, eventnumber_t fromEventNumber = -1, eventnumber_t toEventNumber = -1, bool outputInitializationEntries = true, bool outputEventLogMessages = true);
190
        virtual void print(FILE *file = stdout, eventnumber_t fromEventNumber = -1, eventnumber_t toEventNumber = -1, bool outputEventLogMessages = true);
191

  
192
    protected:
193
        void clearInternalState();
195 194
};
196 195

  
197 196
NAMESPACE_END
src/eventlog/sequencechartfacade.cc
17 17
#include <stdio.h>
18 18
#include <algorithm>
19 19
#include <set>
20
#include <list>
21 20
#include <math.h>
22 21
#include "lcgrandom.h"
23 22
#include "ievent.h"
......
35 34
    timelineMode = NONLINEAR;
36 35
    timelineCoordinateSystemVersion = -1;
37 36
    undefineTimelineCoordinateSystem();
38

  
39
    smallestComplexity = -1;
40
    largestComplexity = -1;
41

  
42
    smallestDuration = -1;
43
    largestDuration = -1;
44

  
45
    maximumOverlapping = -1;
46

  
47
    biggestEarliestProcessingTime = 0;
48

  
49
    biggestEndTimeEvent = NULL;
50

  
51
    cachedParallelSet.clear();
52
    cachedCriticalPath.clear();
53 37
}
54 38

  
55 39
void SequenceChartFacade::synchronize(FileReader::FileChangedState change)
......
117 101
    timelineCoordinateSystemVersion++;
118 102
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = -1;
119 103
    timelineCoordinateOriginSimulationTime = simtime_nil;
120
    timelineCoordinateOriginRealTime = 0;
121 104
}
122 105

  
123 106
void SequenceChartFacade::relocateTimelineCoordinateSystem(IEvent *event)
......
126 109
    timelineCoordinateSystemVersion++;
127 110
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = event->getEventNumber();
128 111
    timelineCoordinateOriginSimulationTime = event->getSimulationTime();
129
    timelineCoordinateOriginRealTime = event->getEarliestStartTime() / 1000000.0;
130 112
    event->cachedTimelineCoordinate = 0;
131 113
    event->cachedTimelineCoordinateSystemVersion = timelineCoordinateSystemVersion;
132 114
}
......
145 127
    return getTimelineCoordinate((IEvent*)ptr);
146 128
}
147 129

  
148
double SequenceChartFacade::IEvent_getTimelineEventEndCoordinate(ptr_t ptr)
149
{
150
    IEVENT_PTR(ptr);
151
    return getTimelineEventEndCoordinate((IEvent*)ptr);
152
}
153

  
154 130
double SequenceChartFacade::getTimelineCoordinateDelta(double simulationTimeDelta)
155 131
{
156 132
    Assert(getNonLinearFocus() > 0);
......
167 143
    return getTimelineCoordinate((IEvent *)ptr, lowerTimelineCoordinateCalculationLimit, upperTimelineCoordinateCalculationLimit);
168 144
}
169 145

  
170
double SequenceChartFacade::getTimelineEventEndCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit, double upperTimelineCoordinateCalculationLimit)
171
{
172
    IEVENT_PTR(ptr);
173
    return getTimelineEventEndCoordinate((IEvent *)ptr, lowerTimelineCoordinateCalculationLimit, upperTimelineCoordinateCalculationLimit);
174
}
175

  
176 146
double SequenceChartFacade::getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit, double upperTimelineCoordinateCalculationLimit)
177 147
{
178 148
    Assert(event);
......
184 154
        double timelineCoordinate;
185 155

  
186 156
        switch (timelineMode) {
187
            case REAL_TIME:
188
                timelineCoordinate = ((event->getEarliestStartTime()/1000000.0 - timelineCoordinateOriginRealTime));
189
                break;
190 157
            case SIMULATION_TIME:
191 158
                timelineCoordinate = (event->getSimulationTime() - timelineCoordinateOriginSimulationTime).dbl();
192 159
                break;
......
253 220
    return event->cachedTimelineCoordinate;
254 221
}
255 222

  
256
double SequenceChartFacade::getTimelineEventEndCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit, double upperTimelineCoordinateCalculationLimit)
257
{
258
    Assert(event);
259
    Assert(event->getEventLog() == eventLog);
260
    if(!eventLog->isLegacyTrace()) {
261
        return getTimelineCoordinate(event);
262
    }
263
        double timelineEventEndCoordinate;
264
        switch (timelineMode) {
265
            case REAL_TIME:
266
                timelineEventEndCoordinate = (event->getEarliestProcessingTime()/ 1000000.0 - timelineCoordinateOriginRealTime) ;
267
                break;
268
            case SIMULATION_TIME:
269
                timelineEventEndCoordinate = (event->getSimulationTime()+event->getEventEntry()->duration - timelineCoordinateOriginSimulationTime).dbl();
270
                break;
271
            default:
272
                return getTimelineCoordinate(event);
273
        }
274
    return timelineEventEndCoordinate;
275
}
276

  
277 223
double SequenceChartFacade::getCachedTimelineCoordinate(IEvent *event)
278 224
{
279 225
    Assert(event);
......
326 272
        return NULL;
327 273

  
328 274
    switch (timelineMode) {
329
        case REAL_TIME:
330
        {
331
            IEvent* res = eventLog->getFirstEventRealTime();
332
            for (IEvent *current = eventLog->getFirstEventRealTime(); current; current = current->getNextEventRealTime()) {
333
                if ((double) current->getEarliestProcessingTime() / 1000000.0 < timelineCoordinate + timelineCoordinateOriginRealTime) {
334
                    if (current->getEarliestProcessingTime() > res->getEarliestProcessingTime()) {
335
                        res = current;
336
                    }
337
                } else {
338
                    break;
339
                }
340
            }
341
            return res;
342
        }
343 275
        case SIMULATION_TIME:
344 276
            return eventLog->getLastEventNotAfterSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
345 277
        case EVENT_NUMBER:
......
372 304
        return NULL;
373 305

  
374 306
    switch (timelineMode) {
375
        case REAL_TIME:
376
        {
377
            IEvent* res = eventLog->getLastEventRealTime();
378
            for (IEvent *current = eventLog->getLastEventRealTime(); current; current = current->getPreviousEventRealTime()) {
379
                if ((double) current->getEarliestStartTime() / 1000000.0 > timelineCoordinate + timelineCoordinateOriginRealTime) {
380
                    if (current->getEarliestStartTime() < res->getEarliestStartTime()) {
381
                        res = current;
382
                    }
383
                } else {
384
                    break;
385
                }
386
            }
387
            return res;
388
        }
389 307
        case SIMULATION_TIME:
390 308
            return eventLog->getFirstEventNotBeforeSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
391 309
        case EVENT_NUMBER:
......
420 338
{
421 339
    // if before the first event
422 340
    if (event) {
423
        if (timelineMode==REAL_TIME) {
424
            eventSimulationTime = event->getEarliestStartTime() / 1000000.0;
425
        } else {
426
            eventSimulationTime = event->getSimulationTime();
427
        }
341
        eventSimulationTime = event->getSimulationTime();
428 342
        eventTimelineCoordinate = getTimelineCoordinate(event);
429 343
    }
430 344
    else {
......
434 348

  
435 349
        if (timelineMode == EVENT_NUMBER)
436 350
            eventTimelineCoordinate -= 1;
437
        else if (timelineMode == REAL_TIME)
438
            eventTimelineCoordinate -= getTimelineCoordinateDelta(0);
439 351
        else
440 352
            eventTimelineCoordinate -= getTimelineCoordinateDelta(firstEvent->getSimulationTime().dbl());
441 353
    }
442 354

  
443 355
    // linear approximation between two enclosing events
444
    if(timelineMode==REAL_TIME) {
445
        nextEvent = event ? event->getNextEventRealTime() : eventLog->getFirstEventRealTime();
446
    } else {
447
        nextEvent = event ? event->getNextEvent() : eventLog->getFirstEvent();
448
    }
356
    nextEvent = event ? event->getNextEvent() : eventLog->getFirstEvent();
449 357

  
450 358
    if (nextEvent) {
451
        if(timelineMode==REAL_TIME) {
452
            nextEventSimulationTime = nextEvent->getEarliestStartTime() / 1000000.0;
453
        } else {
454
            nextEventSimulationTime = nextEvent->getSimulationTime();
455
        }
456

  
359
        nextEventSimulationTime = nextEvent->getSimulationTime();
457 360
        nextEventTimelineCoordinate = getTimelineCoordinate(nextEvent);
458 361

  
459 362
        simulationTimeDelta = nextEventSimulationTime - eventSimulationTime;
......
472 375

  
473 376
    switch (timelineMode)
474 377
    {
475
        case REAL_TIME:
476
        {
477
            simulationTime = max(BigDecimal::Zero, min(biggestEarliestProcessingTime, (timelineCoordinate + timelineCoordinateOriginRealTime)));
478
        }
479
        break;
480 378
        case SIMULATION_TIME:
481 379
            {
482
                IEvent* largestEvent = (IEvent*) getLargestEndtimeInEventRange((ptr_t)(eventLog->getFirstEvent()),(ptr_t)(eventLog->getLastEvent()), upperLimit);
483
                simtime_t lastEventSimulationTime= largestEvent->getSimulationTime() + largestEvent->getEventEntry()->duration;
380
                simtime_t lastEventSimulationTime = eventLog->getLastEvent()->getSimulationTime();
484 381
                simulationTime = max(BigDecimal::Zero, min(lastEventSimulationTime, timelineCoordinate + timelineCoordinateOriginSimulationTime));
485 382
            }
486 383
            break;
......
522 419

  
523 420
    Assert(!simulationTime.isNaN());
524 421
    Assert(simulationTime >= BigDecimal::Zero);
525
    /*if (timelineMode != REAL_TIME)
526
        Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
527
    */
422
    Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
423

  
528 424
    return simulationTime;
529 425
}
530 426

  
......
536 432
        return 0;
537 433

  
538 434
    Assert(simulationTime >= BigDecimal::Zero);
539
    /*if (timelineMode != REAL_TIME)
540
        Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
541
    */
435
    Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
542 436

  
543 437
    double timelineCoordinate;
544 438

  
545 439
    switch (timelineMode)
546 440
    {
547
        case REAL_TIME:
548
            //treat simulationTime as real time:
549
            timelineCoordinate = simulationTime.dbl() - timelineCoordinateOriginRealTime;
550
            break;
551 441
        case SIMULATION_TIME:
552 442
            timelineCoordinate = (simulationTime - timelineCoordinateOriginSimulationTime).dbl();
553 443
            break;
......
614 504
    Assert(endEvent);
615 505
    std::vector<ptr_t> *moduleMethodBeginEntries = new std::vector<ptr_t>();
616 506

  
617
    for (IEvent *event = startEvent; event; event = timelineMode==REAL_TIME ? event->getNextEventRealTime() : event->getNextEvent()) {
507
    for (IEvent *event = startEvent;; event = event->getNextEvent()) {
618 508
        eventLog->progress();
619 509

  
620 510
        for (int i = 0; i < event->getNumEventLogEntries(); i++) {
......
639 529
    Assert(endEvent);
640 530
    std::set<ptr_t> messageDependencies;
641 531
    eventnumber_t startEventNumber = startEvent->getEventNumber();
532

  
642 533
    // TODO: LONG RUNNING OPERATION
643 534
    // this might take a while if start and end events are far away from each other
644 535
    // if not completed then some dependencies will not be included
645
    for (IEvent *event = startEvent; event; event = timelineMode==REAL_TIME ? event->getNextEventRealTime() : event->getNextEvent()) {
536
    for (IEvent *event = startEvent;; event = event->getNextEvent()) {
646 537
        eventLog->progress();
647 538
        IMessageDependencyList *causes = event->getCauses();
539

  
648 540
        for (IMessageDependencyList::iterator it = causes->begin(); it != causes->end(); it++) {
649 541
            IMessageDependency *messageDependency = *it;
542

  
650 543
            if (messageDependency->getCauseEventNumber() < startEventNumber)
651 544
                messageDependencies.insert((ptr_t)messageDependency);
652 545
        }
546

  
653 547
        IMessageDependencyList *consequences = event->getConsequences();
548

  
654 549
        for (IMessageDependencyList::iterator it = consequences->begin(); it != consequences->end(); it++)
655 550
            messageDependencies.insert((ptr_t)*it);
551

  
656 552
        if (event == endEvent)
657 553
            break;
658 554
    }
555

  
659 556
    std::vector<ptr_t> *result = new std::vector<ptr_t>;
660 557
    result->resize(messageDependencies.size());
661 558
    std::copy(messageDependencies.begin(), messageDependencies.end(), result->begin());
559

  
662 560
    return result;
663 561
}
664 562

  
......
726 624

  
727 625
    return adjacencyMatrix;
728 626
}
729

  
730

  
731
long SequenceChartFacade::getSmallestEventComplexity() {
732
    long complexity = 0;
733
    if (smallestComplexity < 0) {
734
        for (IEvent *event = eventLog->getFirstEvent();event != eventLog->getLastEvent(); event = event->getNextEvent()) {
735
             if (event->getEventEndEntry()) {
736
                 complexity = event->getEventEndEntry()->complexity;
737
             } else {
738
                 continue;
739
             }
740
             if (complexity < smallestComplexity || smallestComplexity < 0) {
741
                 smallestComplexity = complexity;
742
             }
743
             if (complexity > largestComplexity || largestComplexity < 0) {
744
                 largestComplexity = complexity;
745
             }
746
        }
747
    }
748
    if (smallestComplexity < 0) {
749
        smallestComplexity = 0;
750
    }
751
    return smallestComplexity;
752
}
753

  
754
long SequenceChartFacade::getLargestEventComplexity() {
755
    if (largestComplexity < 0) {
756
        getSmallestEventComplexity();
757
    }
758
    if (largestComplexity < 0) {
759
        largestComplexity = 0;
760
    }
761
    return largestComplexity;
762
}
763

  
764
simtime_t SequenceChartFacade::getSmallestEventDuration() {
765
    simtime_t duration = 0;
766
    if (smallestDuration < 0) {
767
        for (IEvent *event = eventLog->getFirstEvent();event != eventLog->getLastEvent(); event = event->getNextEvent()) {
768
             if (event->getEventEntry()) {
769
                 duration = event->getEventEntry()->duration;
770
             } else {
771
                 continue;
772
             }
773
             if (duration < smallestDuration || smallestDuration < 0) {
774
                 smallestDuration = duration;
775
             }
776
             if (duration > largestDuration || largestDuration < 0) {
777
                 largestDuration = duration;
778
             }
779
        }
780
    }
781
    if (smallestDuration < 0) {
782
        smallestDuration = 0;
783
    }
784
    return smallestDuration;
785
}
786

  
787
simtime_t SequenceChartFacade::getLargestEventDuration() {
788
    if (largestDuration < 0) {
789
        getSmallestEventComplexity();
790
    }
791
    if (largestDuration < 0) {
792
        largestDuration = 0;
793
    }
794
    return largestDuration;
795
}
796

  
797

  
798
IEvent* SequenceChartFacade::getPreviousBottleneck(IEvent* e, double threshold) {
799
    IEvent* next = e->getPreviousEventRealTime();
800
    while (next) {
801
        if (isBottleneck(next,threshold)) {
802
            return next;
803
        }
804
        next = next->getPreviousEventRealTime();
805
    }
806
    return e;
807
}
808

  
809
IEvent* SequenceChartFacade::getNextBottleneck(IEvent* e, double threshold) {
810
    IEvent* next = e->getNextEventRealTime();
811
    while (next) {
812
        if (isBottleneck(next,threshold)) {
813
            return next;
814
        }
815
        next = next->getNextEventRealTime();
816
    }
817
    return e;
818
}
819

  
820
/*
821
 * Returns whether an event not part of a set of parallel events with more than treshold elements.
822
 */
823
bool SequenceChartFacade::isBottleneck(IEvent* event, double threshold)
824
{
825
    if (isOnCriticalPath(event)) {
826
        return getOverlappingQuotient((ptr_t)event) <= threshold;
827
    }
828
    return false;
829
}
830
/*
831
 * Returns whether event is in the largest parallel set of selected.
832
 */
833
bool SequenceChartFacade::isParallelWithEvent(IEvent* event, IEvent* selected) {
834

  
835
    if (lastSelected != selected) {
836
        getLargestParallelSet(selected, &cachedParallelSet);
837
    }
838
    return cachedParallelSet.find((ptr_t)event) != cachedParallelSet.end();
839
}
840
/*
841
 * Returns the size of the largest set that is parallel with event.
842
 *
843
 * Works by calculating the first parallel set which does not contain event by
844
 * successively going backwards through all events starting from event.
845
 */
846
unsigned int SequenceChartFacade::getLargestParallelSetSize(IEvent* event)
847
{
848
    IEvent* prev = event;
849
    std::set<ptr_t> parallelSet;
850
    parallelSet.clear();
851
    unsigned int previousSize = 0;
852
    while (prev)
853
    {
854
        previousSize = parallelSet.size();
855

  
856
        getParallelSet(prev, &parallelSet);
857

  
858
        if (parallelSet.find((ptr_t) event) == parallelSet.end())
859
        {
860
            //The current set does not contain event.
861
            //Therefore the previous set was the largest Parallel Set.
862
            break;
863
        }
864
        prev = prev->getPreviousEvent();
865
    }
866
    return previousSize;
867
}
868
/*
869
 * Returns the largest set that is parallel with event.
870
 *
871
 * Works by calculating the first parallel set which does not contain event by
872
 * successively going backwards through all events starting from event.
873
 */
874
std::set<ptr_t>* SequenceChartFacade::getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet) {
875
    IEvent* prev = event;
876
    parallelSet->clear();
877
    while (prev)
878
    {
879
        getParallelSet(prev, parallelSet);
880
        if (parallelSet->find((ptr_t) event) == parallelSet->end())
881
        {
882
            //The current set does not contain event.
883
            //Therefore the previous set was the largest Parallel Set.
884
            break;
885
        }
886
        prev = prev->getPreviousEvent();
887
    }
888
    if (prev != event) {
889
        getParallelSet(prev->getNextEvent(), parallelSet);
890
    }
891
    return parallelSet;
892
}
893

  
894
/*
895
 * Calculates a set of those events that start after event but are still in parallel to event.
896
 * This means that no other event must end before the latest start time in this set.
897
 */
898
void SequenceChartFacade::getParallelSet(IEvent* event,
899
        std::set<ptr_t>* parallelSet)
900
{
901
    IEvent* next = event->getNextEvent();
902
    simtime_t smallestParallelEndtime = getSmallestParallelEndtime(event);
903
    parallelSet->clear();
904
    parallelSet->insert((ptr_t) event);
905
    while (next)
906
    {
907
        if ((next->getSimulationTime() >= event->getSimulationTime())
908
                && (smallestParallelEndtime >= next->getSimulationTime()))
909
        {
910
            if(parallelSet->find((ptr_t)(next->getCauseEvent())) == parallelSet->end()) {
911
                parallelSet->insert((ptr_t) next);
912
            }
913
        }
914
        else
915
        {
916
            break;
917
        }
918
        next = next->getNextEvent();
919
    }
920
}
921
/*
922
 *
923
 */
924
simtime_t SequenceChartFacade::getSmallestParallelEndtime(IEvent* event)
925
{
926
    simtime_t minimum = event->getSimulationTime()
927
            + event->getEventEntry()->duration;
928
    for (IEvent *current = eventLog->getFirstEvent(); current; current
929
            = current->getNextEvent())
930
    {
931
        if (current->getSimulationTime() >= event->getSimulationTime())
932
        {
933
            if ((current->getSimulationTime()
934
                    + current->getEventEntry()->duration)
935
                    > event->getSimulationTime())
936
            {
937
                if (minimum > (current->getSimulationTime()
938
                        + current->getEventEntry()->duration))
939
                {
940
                    minimum = current->getSimulationTime()
941
                            + current->getEventEntry()->duration;
942
                }
943
            }
944
            if (current->getSimulationTime() > minimum)
945
            { // After this, no overlapping can follow
946
                break;
947
            }
948
        }
949
    }
950
    return minimum;
951
}
952

  
953
/*
954
 * Determines whether the event lies on the critical path
955
 */
956
bool SequenceChartFacade::isOnCriticalPath(IEvent* event) {
957
    if (cachedCriticalPath.empty()) {
958
        calculateCriticalPath();
959
    }
960
    return (cachedCriticalPath.find((ptr_t)event) != cachedCriticalPath.end());
961
}
962

  
963
/*
964
 * Calculates the critical path of the run and stores it in the set cachedCriticalPath
965
 * Caches the earliestStartTimes of all events
966
 */
967
void SequenceChartFacade::calculateCriticalPath() {
968
    long maxEarliestProcessingTime = 0;
969
    IEvent* maxEarliestProcessingTimeEvent;
970
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
971
        simtime_t startTime = current->getSimulationTime();
972
        int moduleId = current->getModuleId();
973
        if(current->getEventEndEntry()) {
974
            current->_earliestProcessingTime = current->getComplexity();
975
        }
976
        current->setCriticalPredecessor(eventLog->getFirstEvent());
977
        for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
978
            if(antecessor==current) {
979
                break; //We have to consider earlier events only
980
            }
981
            if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
982
                continue; // Check if this is an antecessor
983
            }
984
            if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
985
                current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
986
                current->setCriticalPredecessor(antecessor);
987
            }
988
        }
989
        // Memorize max event
990
        if (maxEarliestProcessingTime < current->_earliestProcessingTime) {
991
            maxEarliestProcessingTime = current->_earliestProcessingTime;
992
            maxEarliestProcessingTimeEvent = current;
993
        }
994
    }
995
    //Cache an additional event ordering sorted by their earliestStartingTimes
996
    cacheRealTimeEventOrder();
997

  
998
    //Now produce the convex hull of critical antecessors/predecessors:
999
    cachedCriticalPath.clear();
1000
    //Cache largest processing time:
1001
    biggestEarliestProcessingTime = maxEarliestProcessingTime / 1000000.0;
1002
    biggestEarliestProcessingTimeEvent = maxEarliestProcessingTimeEvent;
1003
    for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCriticalPredecessor()) {
1004
        cachedCriticalPath.insert((ptr_t)predecessor);
1005
        if(predecessor->getEventNumber() == 0) {
1006
            break;
1007
        }
1008
    }
1009
}
1010
/*
1011
 * Returns the event with the largest calculated earliest Processing time in REAL_TIME mode
1012
 * or the largest endtime in other modes within the given event range.
1013
 */
1014
ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr,
1015
        ptr_t endEventPtr, bool duration)
1016
{
1017
    IEvent *startEvent = (IEvent *) startEventPtr;
1018
    IEvent *endEvent = (IEvent *) endEventPtr;
1019
    switch (timelineMode)
1020
    {
1021
    case REAL_TIME:
1022
    {
1023
        //Use cached result when range contains all events
1024
        if (startEvent == eventLog->getFirstEventRealTime() && endEvent
1025
                == eventLog->getLastEventRealTime())
1026
        {
1027
            return (ptr_t) biggestEarliestProcessingTimeEvent;
1028
        }
1029

  
1030
        long largest = 0;
1031
        IEvent* largestEvent = startEvent;
1032

  
1033
        for (IEvent* current = startEvent; current; current
1034
                = current->getNextEventRealTime())
1035
        {
1036
            long temp = current->getEarliestProcessingTime();
1037
            if (temp > largest)
1038
            {
1039
                largest = temp;
1040
                largestEvent = current;
1041
            }
1042
            if (current == endEvent)
1043
            {
1044
                break;
1045
            }
1046
        }
1047
        return (ptr_t) largestEvent;
1048
    }
1049
    case SIMULATION_TIME:
1050
    case EVENT_NUMBER:
1051
    case STEP:
1052
    case NONLINEAR:
1053
    default:
1054
    {
1055
        if (!duration) {
1056
            return endEventPtr;
1057
        }
1058
        //Use cached result when range contains all events
1059
        if (startEvent == eventLog->getFirstEvent() && endEvent
1060
                == eventLog->getLastEvent() && biggestEndTimeEvent != NULL)
1061
        {
1062
            return (ptr_t) biggestEndTimeEvent;
1063
        }
1064
        simtime_t largest = 0;
1065
        IEvent* largestEvent = endEvent;
1066

  
1067
        for (IEvent* current = endEvent; current; current
1068
                = current->getPreviousEvent())
1069
        {
1070
            simtime_t temp = current->getSimulationTime()
1071
                    + current->getEventEntry()->duration;
1072
            if (temp > largest)
1073
            {
1074
                largest = temp;
1075
                largestEvent = current;
1076
            }
1077
            if (current == startEvent)
1078
            {
1079
                break;
1080
            }
1081
        }
1082
        if (startEvent == eventLog->getFirstEvent() && endEvent
1083
                == eventLog->getLastEvent())
1084
        {
1085
            biggestEndTimeEvent = largestEvent;
1086
        }
1087

  
1088
        return (ptr_t) largestEvent;
1089
    }
1090
    }
1091

  
1092
}
1093

  
1094
double SequenceChartFacade::getOverlapping(ptr_t eventPtr) {
1095
    long overlapping = 0;
1096
    IEvent* event = (IEvent*) eventPtr;
1097

  
1098
    long eventProcessingTime = event->getEarliestProcessingTime();
1099
    long eventStartTime = event->getEarliestStartTime();
1100

  
1101
    for (IEvent *current = eventLog->getFirstEventRealTime(); current; current = current->getNextEventRealTime()) {
1102

  
1103
        if(current->getComplexity() == 0) {
1104
            continue;
1105
        }
1106

  
1107
        long currentStartTime = current->getEarliestStartTime();
1108
        long currentProcessingTime = current->getEarliestProcessingTime();
1109

  
1110
        if(eventStartTime <= currentStartTime && eventProcessingTime >= currentStartTime) {
1111
            overlapping += eventProcessingTime - currentStartTime;
1112
        } else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventStartTime) {
1113
            overlapping += currentProcessingTime - eventStartTime;
1114
        } else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventProcessingTime) {
1115
            overlapping += event->getComplexity();
1116
        }
1117

  
1118
        if (current->getEarliestStartTime() > eventProcessingTime) {
1119
            break;
1120
        }
1121
    }
1122
    return overlapping / (event->getComplexity() * 1.0);
1123
}
1124

  
1125
double SequenceChartFacade::getMaximumOverlapping() {
1126
    double maxOverlapping = 0;
1127
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
1128
        if(!isOnCriticalPath(current) || current->getComplexity() == 0) {
1129
            continue;
1130
        }
1131
        double overlapping = getOverlapping((ptr_t) current);
1132
        if (overlapping > maxOverlapping){
1133
            maxOverlapping = overlapping;
1134
        }
1135
    }
1136
    return maxOverlapping;
1137
}
1138

  
1139
/*
1140
 * returns the quotient of
1141
 * relative overlapping cputime with the event / maximum relative overlapping
1142
 * cputime with any event of the critical path
1143
 */
1144
double SequenceChartFacade::getOverlappingQuotient(ptr_t eventPtr) {
1145

  
1146
    if (((IEvent*)eventPtr)->getComplexity() == 0) {
1147
        return 0;
1148
    }
1149
    double overlapping = getOverlapping(eventPtr);
1150

  
1151
    if (maximumOverlapping == -1) {
1152
        maximumOverlapping = getMaximumOverlapping();
1153
    }
1154

  
1155
    return overlapping / maximumOverlapping;
1156
}
1157

  
1158
bool SequenceChartFacade::isOverlappingInRealTimeDomain(ptr_t eventPtr1, ptr_t eventPtr2) {
1159
    long eventProcessingTime1 = ((IEvent*)eventPtr1)->getEarliestProcessingTime();
1160
    long eventStartTime1 = ((IEvent*)eventPtr1)->getEarliestStartTime();
1161
    long eventProcessingTime2 = ((IEvent*)eventPtr2)->getEarliestProcessingTime();
1162
    long eventStartTime2 = ((IEvent*)eventPtr2)->getEarliestStartTime();
1163

  
1164
    return !(eventProcessingTime1 < eventStartTime2 || eventProcessingTime2 < eventStartTime1);
1165
}
1166

  
1167

  
1168
bool compare_events_realtime (IEvent* a, IEvent* b)
1169
{
1170
  return (a->getEarliestStartTime() < b->getEarliestStartTime() || (a->getEarliestStartTime() == b->getEarliestStartTime() && a->getEventNumber() < b->getEventNumber()));
1171
}
1172

  
1173

  
1174
void SequenceChartFacade::cacheRealTimeEventOrder() {
1175
    //First Event is the same in both domains
1176
    eventLog->setFirstEventRealTime((Event*)eventLog->getFirstEvent());
1177
    int i = 0;
1178
    std::list<IEvent*> eventMap;
1179
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
1180
        i++;
1181
        eventMap.push_back(current);
1182
    }
1183
    eventMap.sort(compare_events_realtime);
1184

  
1185
    IEvent* current = NULL;
1186
    IEvent* prev = NULL;
1187
    for (std::list<IEvent*>::iterator it = eventMap.begin(); it != eventMap.end(); it++) {
1188
        current = *it;
1189
        if (prev != NULL) {
1190
            prev->setNextEventRealTime(current);
1191
            current->setPreviousEventRealTime(prev);
1192
        }
1193
        prev = current;
1194
    }
1195
    //Set last event in eventlog
1196
    eventLog->setLastEventRealTime((Event*)prev);
1197
    //Test:
1198
    /*
1199
    for (IEvent *current = eventLog->getFirstEventRealTime(); current; current = current->getNextEventRealTime()) {
1200
        printf("event %i, simtime %f, time %i \n",current->getEventNumber(), current->getSimulationTime().dbl(), current->getEarliestStartTime());
1201
    }*/
1202

  
1203

  
1204
}
src/eventlog/sequencechartfacade.h
39 39
        long timelineCoordinateSystemVersion; // a counter incremented each time the timeline coordinate system is relocated
40 40
        eventnumber_t timelineCoordinateOriginEventNumber; // -1 means undefined, otherwise the event number of the timeline coordinate system origin
41 41
        simtime_t timelineCoordinateOriginSimulationTime; // simtime_nil means undefined
42
        double timelineCoordinateOriginRealTime;
43 42
        eventnumber_t timelineCoordinateRangeStartEventNumber; // -1 means undefined, the beginning of the continuous event range which has timeline coordinates assigned
44 43
        eventnumber_t timelineCoordinateRangeEndEventNumber; // -1 means undefined, the end of the continuous event range which has timeline coordinates assigned
45 44
        TimelineMode timelineMode;
46 45
        double nonLinearFocus; // a useful constant for the nonlinear transformation between simulation time and timeline coordinate
47 46
        double nonLinearMinimumTimelineCoordinateDelta; // minimum timeline coordinate difference between two events
48 47

  
49
        long smallestComplexity;
50
        long largestComplexity;
51

  
52
        double maximumOverlapping;
53

  
54
        simtime_t smallestDuration;
55
        simtime_t largestDuration;
56

  
57
        simtime_t biggestEarliestProcessingTime;
58
        IEvent* biggestEarliestProcessingTimeEvent;
59

  
60
        IEvent* biggestEndTimeEvent;
61

  
62
        std::set<ptr_t> cachedParallelSet;
63
        IEvent* lastSelected;
64

  
65
        std::set<ptr_t> cachedCriticalPath;
66 48
    public:
67 49
        SequenceChartFacade(IEventLog *eventLog);
68 50
        virtual ~SequenceChartFacade() {}
......
87 69
         */
88 70
        double getTimelineCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
89 71
        double getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
90
        double getTimelineEventEndCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
91
        double getTimelineEventEndCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
92 72
        double getCachedTimelineCoordinate(IEvent *event);
93 73
        double IEvent_getTimelineCoordinate(ptr_t ptr);
94
        double IEvent_getTimelineEventEndCoordinate(ptr_t ptr);
95 74
        void undefineTimelineCoordinateSystem();
96 75
        void relocateTimelineCoordinateSystem(IEvent *event);
97 76

  
......
99 78
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
100 79
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
101 80

  
102
        /*
103
         * returns smallest event complexity in the event log
104
         */
105
        long getSmallestEventComplexity();
106
        /*
107
         * returns largest event complexity in the event log
108
         */
109
        long getLargestEventComplexity();
110

  
111
        /*
112
         * returns smallest event duration in the event log
113
         */
114
        simtime_t getSmallestEventDuration();
115
        /*
116
         * returns largest event duration in the event log
117
         */
118
        simtime_t getLargestEventDuration();
119

  
120
        double getOverlappingQuotient(ptr_t eventPtr);
121

  
122
        /*
123
         * returns true when the events overlap in the REAL_TIME domain (i.e. are executed on two cpus in parallel)
124
         */
125
        bool isOverlappingInRealTimeDomain(ptr_t eventPtr1, ptr_t eventPtr2);
126

  
127

  
128
        /*
129
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
130
        */
131
        bool isBottleneck(IEvent* event, double threshold);
132

  
133
        bool isParallelWithEvent(IEvent* event, IEvent* selected);
134

  
135
        IEvent* getPreviousBottleneck(IEvent* e, double threshold);
136
        IEvent* getNextBottleneck(IEvent* e, double threshold);
137

  
138
        bool isOnCriticalPath(IEvent* event);
139

  
140
        ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr, bool duration=false);
141

  
142 81
        /**
143 82
         * Timeline coordinate can be given in the range (-infinity, +infinity).
144 83
         * Simulation time will be in the range [0, lastEventSimulationTime].
......
163 102
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
164 103
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
165 104
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
166

  
167
        std::set<ptr_t>* getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
168

  
169
        unsigned int getLargestParallelSetSize(IEvent* event);
170

  
171
        void getParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
172

  
173
        simtime_t getSmallestParallelEndtime(IEvent* event);
174

  
175
        void calculateCriticalPath();
176

  
177
        void cacheRealTimeEventOrder();
178

  
179
        double getOverlapping(ptr_t eventPtr);
180

  
181
        double getMaximumOverlapping();
182

  
183

  
184 105
};
185 106

  
186 107
NAMESPACE_END

Also available in: Unified diff