Revision 12288d0e

View differences:

src/eventlog/event.cc
306 306
    return (Event *)nextEvent;
307 307
}
308 308

  
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

  
309 327
Event *Event::getCauseEvent()
310 328
{
311 329
    int causeEventNumber = getCauseEventNumber();
src/eventlog/event.h
100 100
        virtual Event *getPreviousEvent();
101 101
        virtual Event *getNextEvent();
102 102

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

  
103 106
        virtual Event *getCauseEvent();
104 107
        virtual BeginSendEntry *getCauseBeginSendEntry();
105 108
        virtual MessageDependency *getCause();
src/eventlog/eventlog.cc
286 286
    return lastEvent;
287 287
}
288 288

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

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

  
289 301
Event *EventLog::getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind)
290 302
{
291 303
    Assert(eventNumber >= 0);
src/eventlog/eventlog.h
52 52
        Event *firstEvent;
53 53
        Event *lastEvent;
54 54

  
55
        Event *firstEventRealTime;
56
        Event *lastEventRealTime;
57

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

  
57 60
        typedef std::vector<EventLogEntry *> EventLogEntryList;
......
109 112

  
110 113
        virtual Event *getFirstEvent();
111 114
        virtual Event *getLastEvent();
115

  
116
        virtual Event *getFirstEventRealTime();
117
        virtual Event *getLastEventRealTime();
118

  
119
        virtual void setFirstEventRealTime(Event* e) {
120
            firstEventRealTime = e;;
121
        }
122
        virtual void setLastEventRealTime(Event* e){
123
            lastEventRealTime = e;
124
        }
125

  
112 126
        virtual Event *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
113 127
        virtual Event *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT);
114 128
        virtual Event *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT);
src/eventlog/filteredevent.h
95 95
        virtual FilteredEvent *getPreviousEvent();
96 96
        virtual FilteredEvent *getNextEvent();
97 97

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

  
102
        }
103

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

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

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

  
98 117
        virtual FilteredEvent *getCauseEvent();
99 118
        virtual IMessageDependency *getCause();
100 119
        virtual BeginSendEntry *getCauseBeginSendEntry();
src/eventlog/filteredeventlog.h
163 163
        virtual bool isEmpty();
164 164
        virtual FilteredEvent *getFirstEvent();
165 165
        virtual FilteredEvent *getLastEvent();
166

  
167
        virtual Event *getFirstEventRealTime() {
168
            Assert(false);
169
            return NULL;
170
        }
171
        virtual Event *getLastEventRealTime() {
172
            Assert(false);
173
            return NULL;
174
        }
175

  
176
        virtual void setFirstEventRealTime(Event* e) {
177
            Assert(false);
178
        }
179
        virtual void setLastEventRealTime(Event* e){
180
            Assert(false);
181
        }
182

  
166 183
        virtual FilteredEvent *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
167 184
        virtual FilteredEvent *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT);
168 185
        virtual FilteredEvent *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT);
src/eventlog/ievent.h
30 30
        IEvent *previousEvent;
31 31
        IEvent *nextEvent;
32 32

  
33
        IEvent *previousEventRealTime;
34
        IEvent *nextEventRealTime;
35

  
33 36
        IEvent* criticalPredecessor;
34 37

  
35 38
    public:
......
104 107
        virtual IEvent *getNextEvent() = 0;
105 108

  
106 109
        /**
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
        /**
107 127
         * Returns the closest preceding event which caused this event by sending a message.
108 128
         */
109 129
        virtual IEvent *getCauseEvent() = 0;
src/eventlog/ieventlog.h
136 136
         */
137 137
        virtual IEvent *getLastEvent() = 0;
138 138
        /**
139
         * Returns the first event in RealTime or NULL if the log is empty.
140
         */
141
        virtual IEvent *getFirstEventRealTime() = 0;
142
        /**
143
         * Returns the last event in RealTime or NULL if the log is empty.
144
         */
145
        virtual IEvent *getLastEventRealTime() = 0;
146

  
147
        virtual void setFirstEventRealTime(Event* e) = 0;
148
        virtual void setLastEventRealTime(Event* e) = 0;
149
        /**
139 150
         * Returns the requested event or NULL if there is no such event included in the log.
140 151
         * The given event number may not be included in the log.
141 152
         */
src/eventlog/sequencechartfacade.cc
17 17
#include <stdio.h>
18 18
#include <algorithm>
19 19
#include <set>
20
#include <list>
20 21
#include <math.h>
21 22
#include "lcgrandom.h"
22 23
#include "ievent.h"
......
950 951

  
951 952
/*
952 953
 * Calculates the critical path of the run and stores it in the set cachedCriticalPath
954
 * Caches the earliestStartTimes of all events
953 955
 */
954 956
void SequenceChartFacade::calculateCriticalPath() {
955 957
    long maxEarliestProcessingTime = 0;
......
969 971
                break; //We have to consider earlier events only
970 972
            }
971 973
            if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
972
                continue; // Check if this is an antecesor
974
                continue; // Check if this is an antecessor
973 975
            }
974 976
            if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
975 977
                current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
......
982 984
            maxEarliestProcessingTimeEvent = current;
983 985
        }
984 986
    }
987
    //Cache an additional event ordering sorted by their earliestStartingTimes
988
    cacheRealTimeEventOrder();
989

  
985 990
    //Now produce the convex hull of critical antecessors/predecessors:
986 991
    cachedCriticalPath.clear();
987 992
    //Cache largest processing time:
......
1146 1151

  
1147 1152
    return !(eventProcessingTime1 < eventStartTime2 || eventProcessingTime2 < eventStartTime1);
1148 1153
}
1154

  
1155

  
1156
bool compare_events_realtime (IEvent* a, IEvent* b)
1157
{
1158
  return a->getEarliestStartTime() <= b->getEarliestStartTime();
1159
}
1160

  
1161

  
1162
void SequenceChartFacade::cacheRealTimeEventOrder() {
1163
    //First Event is the same in both domains
1164
    eventLog->setFirstEventRealTime((Event*)eventLog->getFirstEvent());
1165
    int i = 0;
1166
    std::list<IEvent*> eventMap;
1167
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
1168
        i++;
1169
        eventMap.push_back(current);
1170
    }
1171
    eventMap.sort(compare_events_realtime);
1172

  
1173
    IEvent* current = NULL;
1174
    IEvent* prev = NULL;
1175
    for (std::list<IEvent*>::iterator it = eventMap.begin(); it != eventMap.end(); it++) {
1176
        current = *it;
1177
        if (prev != NULL) {
1178
            prev->setNextEventRealTime(current);
1179
            current->setPreviousEventRealTime(prev);
1180
        }
1181
        prev = current;
1182
    }
1183
    //Set last event in eventlog
1184
    eventLog->setLastEventRealTime((Event*)prev);
1185
    //Test:
1186
    for (IEvent *current = eventLog->getFirstEventRealTime(); current; current = current->getNextEventRealTime()) {
1187
        printf("event %i, simtime %f, time %i \n",current->getEventNumber(), current->getSimulationTime().dbl(), current->getEarliestStartTime());
1188
    }
1189

  
1190

  
1191
}
src/eventlog/sequencechartfacade.h
173 173

  
174 174
        void calculateCriticalPath();
175 175

  
176
        void cacheRealTimeEventOrder();
177

  
176 178
        double getOverlapping(ptr_t eventPtr);
177 179

  
178 180
        double getMaximumOverlapping();

Also available in: Unified diff