Commit 14650391 authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

- fixed bug in critical path calculation
parent 76c7d000
......@@ -23,6 +23,7 @@ IEvent::IEvent()
{
nextEvent = NULL;
previousEvent = NULL;
criticalPredecessor = NULL;
cachedTimelineCoordinate = -1;
cachedTimelineCoordinateSystemVersion = -1;
}
......
......@@ -30,6 +30,8 @@ class EVENTLOG_API IEvent
IEvent *previousEvent;
IEvent *nextEvent;
IEvent* criticalPredecessor;
public:
// gui state for SequenceChart
double cachedTimelineCoordinate;
......@@ -143,6 +145,15 @@ class EVENTLOG_API IEvent
*/
static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
IEvent* getCriticalPredecessor() {
return criticalPredecessor;
}
void setCriticalPredecessor(IEvent* e) {
criticalPredecessor = e;
}
};
NAMESPACE_END
......
......@@ -894,6 +894,9 @@ void SequenceChartFacade::calculateCriticalPath() {
if(current->getEventEndEntry()) {
current->earliestProcessingTime = current->getComplexity();
}
current->setCriticalPredecessor(eventLog->getFirstEvent());
for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
if(antecessor==current) {
break; //We have to consider earlier events only
......@@ -903,6 +906,7 @@ void SequenceChartFacade::calculateCriticalPath() {
}
if(antecessor->earliestProcessingTime+current->getComplexity() > current->earliestProcessingTime) {
current->earliestProcessingTime = antecessor->earliestProcessingTime+current->getComplexity();
current->setCriticalPredecessor(antecessor);
}
}
// Memorize max event
......@@ -911,9 +915,9 @@ void SequenceChartFacade::calculateCriticalPath() {
maxEarliestProcessingTimeEvent = current;
}
}
//Now produce the convex hull of predecessors:
//Now produce the convex hull of critical antecessors/predecessors:
cachedCriticalPath.clear();
for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCauseEvent()) {
for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCriticalPredecessor()) {
cachedCriticalPath.insert((ptr_t)predecessor);
if(predecessor->getEventNumber() == 0) {
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment