Project

General

Profile

Revision e2b044ac

IDe2b044ac2934cde5e2a7c84adc1adbeecfbd7d3b

Added by Simon Tenbusch over 8 years ago

[sequencechartfacade]
- antecessor now considers module ID.
- Fixed bug with critical path calculation resulting in endless loop

View differences:

src/eventlog/sequencechartfacade.cc
758 758
    }
759 759
    return cachedParallelSet.find((ptr_t)event) != cachedParallelSet.end();
760 760
}
761

  
761
/*
762
 * Returns the size of the largest set that is parallel with event.
763
 *
764
 * Works by calculating the first parallel set which does not contain event by
765
 * successively going backwards through all events starting from event.
766
 */
762 767
unsigned int SequenceChartFacade::getLargestParallelSetSize(IEvent* event)
763 768
{
764 769
    IEvent* prev = event;
......
773 778

  
774 779
        if (parallelSet.find((ptr_t) event) == parallelSet.end())
775 780
        {
781
            //The current set does not contain event.
782
            //Therefore the previous set was the largest Parallel Set.
776 783
            break;
777 784
        }
778 785
        prev = prev->getPreviousEvent();
779 786
    }
780 787
    return previousSize;
781 788
}
782

  
789
/*
790
 * Returns the largest set that is parallel with event.
791
 *
792
 * Works by calculating the first parallel set which does not contain event by
793
 * successively going backwards through all events starting from event.
794
 */
783 795
std::set<ptr_t>* SequenceChartFacade::getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet) {
784 796
    IEvent* prev = event;
785 797
    parallelSet->clear();
......
788 800
        getParallelSet(prev, parallelSet);
789 801
        if (parallelSet->find((ptr_t) event) == parallelSet->end())
790 802
        {
803
            //The current set does not contain event.
804
            //Therefore the previous set was the largest Parallel Set.
791 805
            break;
792 806
        }
793 807
        prev = prev->getPreviousEvent();
794 808
    }
795

  
796 809
    if (prev != event) {
797 810
        getParallelSet(prev->getNextEvent(), parallelSet);
798 811
    }
799 812
    return parallelSet;
800 813
}
801 814

  
815
/*
816
 * Calculates a set of those events that start after event but are still in parallel to event.
817
 * This means that no other event must end before the latest start time in this set.
818
 */
802 819
void SequenceChartFacade::getParallelSet(IEvent* event,
803 820
        std::set<ptr_t>* parallelSet)
804 821
{
......
822 839
        next = next->getNextEvent();
823 840
    }
824 841
}
825

  
842
/*
843
 *
844
 */
826 845
simtime_t SequenceChartFacade::getSmallestParallelEndtime(IEvent* event)
827 846
{
828 847
    simtime_t minimum = event->getSimulationTime()
......
871 890

  
872 891
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
873 892
        simtime_t startTime = current->getSimulationTime();
893
        int moduleId = current->getModuleId();
874 894
        if(current->getEventEndEntry()) {
875 895
            current->earliestProcessingTime = current->getComplexity();
876 896
        }
......
878 898
            if(antecessor==current) {
879 899
                break; //We have to consider earlier events only
880 900
            }
881
            if(antecessor->getSimulationTime() + antecessor->getEventEntry()->duration > startTime) {
901
            if(antecessor->getModuleId() != moduleId) {
882 902
                continue; // Check if this is an antecesor
883 903
            }
884 904
            if(antecessor->earliestProcessingTime+current->getComplexity() > current->earliestProcessingTime) {
......
893 913
    }
894 914
    //Now produce the convex hull of predecessors:
895 915
    cachedCriticalPath.clear();
896
    for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor; predecessor = predecessor->getCauseEvent()) {
916
    for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCauseEvent()) {
897 917
        cachedCriticalPath.insert((ptr_t)predecessor);
918
        if(predecessor->getEventNumber() == 0) {
919
            break;
920
        }
898 921
    }
899 922
}
900 923

  

Also available in: Unified diff