Revision 12288d0e src/eventlog/sequencechartfacade.cc

View differences:

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
}

Also available in: Unified diff