Statistics
| Branch: | Revision:

root / src / eventlog / sequencechartfacade.h @ 2595f1a9

History | View | Annotate | Download (7.22 KB)

1
//=========================================================================
2
//  SEQUENCECHARTFACADE.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Levente Meszaros
7
//
8
//=========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17
#ifndef __SEQUENCECHARTFACADE_H_
18
#define __SEQUENCECHARTFACADE_H_
19

    
20
#include <float.h>
21
#include <vector>
22
#include <map>
23
#include "ievent.h"
24
#include "ieventlog.h"
25
#include "eventlogfacade.h"
26

    
27
NAMESPACE_BEGIN
28

    
29
/**
30
 * A class that makes it possible to extract info about events, without
31
 * returning objects. (Wherever a C++ method returns an object pointer,
32
 * SWIG-generated wrapper creates a corresponding Java object with the
33
 * pointer value inside. This has disastrous effect on performance
34
 * when dealing with huge amounts of data).
35
 */
36
class EVENTLOG_API SequenceChartFacade : public EventLogFacade
37
{
38
    protected:
39
        long timelineCoordinateSystemVersion;
40
        eventnumber_t timelineCoordinateOriginEventNumber;
41
        simtime_t timelineCoordinateOriginSimulationTime;
42
        double timelineCoordinateOriginRealTime;
43
        eventnumber_t timelineCoordinateRangeStartEventNumber;
44
        eventnumber_t timelineCoordinateRangeEndEventNumber;
45
        TimelineMode timelineMode;
46
        double nonLinearMinimumTimelineCoordinateDelta;
47
        double nonLinearFocus;
48

    
49
        long smallestComplexity;
50
        long largestComplexity;
51

    
52
        simtime_t smallestDuration;
53
        simtime_t largestDuration;
54

    
55
        simtime_t biggestEarliestProcessingTime;
56
        IEvent* biggestEarliestProcessingTimeEvent;
57

    
58
        std::set<ptr_t> cachedParallelSet;
59
        IEvent* lastSelected;
60

    
61
        std::set<ptr_t> cachedCriticalPath;
62
    public:
63
        SequenceChartFacade(IEventLog *eventLog);
64
        virtual ~SequenceChartFacade() {}
65

    
66
        double calculateNonLinearFocus();
67
        virtual void synchronize(FileReader::FileChangedState change);
68

    
69
        TimelineMode getTimelineMode() { return timelineMode; }
70
        void setTimelineMode(TimelineMode timelineMode);
71

    
72
        double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; }
73
        void setNonLinearMinimumTimelineCoordinateDelta(double value);
74
        double getNonLinearFocus() { return nonLinearFocus; }
75
        void setNonLinearFocus(double nonLinearFocus);
76

    
77
        IEvent *getTimelineCoordinateSystemOriginEvent() { return eventLog->getEventForEventNumber(timelineCoordinateOriginEventNumber); }
78
        eventnumber_t getTimelineCoordinateSystemOriginEventNumber() { return timelineCoordinateOriginEventNumber; }
79
        double getTimelineCoordinateDelta(double simulationTimeDelta);
80
        /**
81
         * Calculates the timeline coordinate for the given event. Returns value from the cache if already there or calculates it
82
         * while taking care about the calculation limits.
83
         */
84
        double getTimelineCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
85
        double getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
86
        double getTimelineEventEndCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
87
        double getTimelineEventEndCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
88
        double getCachedTimelineCoordinate(IEvent *event);
89
        double IEvent_getTimelineCoordinate(ptr_t ptr);
90
        double IEvent_getTimelineEventEndCoordinate(ptr_t ptr);
91
        void undefineTimelineCoordinateSystem();
92
        void relocateTimelineCoordinateSystem(IEvent *event);
93

    
94
        IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward);
95
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
96
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
97

    
98
        /*
99
         * returns smallest event complexity in the event log
100
         */
101
        long getSmallestEventComplexity();
102
        /*
103
         * returns largest event complexity in the event log
104
         */
105
        long getLargestEventComplexity();
106

    
107
        /*
108
         * returns smallest event duration in the event log
109
         */
110
        simtime_t getSmallestEventDuration();
111
        /*
112
         * returns largest event duration in the event log
113
         */
114
        simtime_t getLargestEventDuration();
115

    
116

    
117
        /*
118
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
119
        */
120
        bool isBottleneck(IEvent* event, unsigned int threshold);
121

    
122
        bool isParallelWithEvent(IEvent* event, IEvent* selected);
123

    
124
        IEvent* getPreviousBottleneck(IEvent* e, unsigned int threshold);
125
        IEvent* getNextBottleneck(IEvent* e, unsigned int threshold);
126

    
127
        bool isOnCriticalPath(IEvent* event);
128

    
129
        ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr);
130

    
131
        /**
132
         * Timeline coordinate can be given in the range (-infinity, +infinity).
133
         * Simulation time will be in the range [0, lastEventSimulationTime].
134
         */
135
        simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false);
136
        /**
137
         * Simulation time must be in the range [0, lastEventSimulationTime].
138
         * Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the
139
         * timeline origin is at the first event.
140
         */
141
        double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false);
142
        double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId);
143

    
144
        std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr);
145

    
146
        std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr);
147
        std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 0);
148
    protected:
149
        void extractSimulationTimesAndTimelineCoordinates(
150
            IEvent *event, IEvent *&nextEvent,
151
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
152
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
153
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
154

    
155
        std::set<ptr_t>* getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
156

    
157
        unsigned int getLargestParallelSetSize(IEvent* event);
158

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

    
161
        simtime_t getSmallestParallelEndtime(IEvent* event);
162

    
163
        void calculateCriticalPath();
164

    
165

    
166
};
167

    
168
NAMESPACE_END
169

    
170

    
171
#endif