Statistics
| Branch: | Revision:

root / src / eventlog / sequencechartfacade.h @ 12288d0e

History | View | Annotate | Download (7.69 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
        double maximumOverlapping;
53

    
54
        simtime_t smallestDuration;
55
        simtime_t largestDuration;
56

    
57
        simtime_t biggestEarliestProcessingTime;
58
        IEvent* biggestEarliestProcessingTimeEvent;
59

    
60
        IEvent* biggestEndTimeEvent;
61

    
62
        std::set<ptr_t> cachedParallelSet;
63
        IEvent* lastSelected;
64

    
65
        std::set<ptr_t> cachedCriticalPath;
66
    public:
67
        SequenceChartFacade(IEventLog *eventLog);
68
        virtual ~SequenceChartFacade() {}
69

    
70
        double calculateNonLinearFocus();
71
        virtual void synchronize(FileReader::FileChangedState change);
72

    
73
        TimelineMode getTimelineMode() { return timelineMode; }
74
        void setTimelineMode(TimelineMode timelineMode);
75

    
76
        double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; }
77
        void setNonLinearMinimumTimelineCoordinateDelta(double value);
78
        double getNonLinearFocus() { return nonLinearFocus; }
79
        void setNonLinearFocus(double nonLinearFocus);
80

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

    
98
        IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward);
99
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
100
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
101

    
102
        /*
103
         * returns smallest event complexity in the event log
104
         */
105
        long getSmallestEventComplexity();
106
        /*
107
         * returns largest event complexity in the event log
108
         */
109
        long getLargestEventComplexity();
110

    
111
        /*
112
         * returns smallest event duration in the event log
113
         */
114
        simtime_t getSmallestEventDuration();
115
        /*
116
         * returns largest event duration in the event log
117
         */
118
        simtime_t getLargestEventDuration();
119

    
120
        double getOverlappingQuotient(ptr_t eventPtr);
121

    
122
        /*
123
         * returns true when the events overlap in the REAL_TIME domain (i.e. are executed on two cpus in parallel)
124
         */
125
        bool isOverlappingInRealTimeDomain(ptr_t eventPtr1, ptr_t eventPtr2);
126

    
127

    
128
        /*
129
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
130
        */
131
        bool isBottleneck(IEvent* event, double threshold);
132

    
133
        bool isParallelWithEvent(IEvent* event, IEvent* selected);
134

    
135
        IEvent* getPreviousBottleneck(IEvent* e, double threshold);
136
        IEvent* getNextBottleneck(IEvent* e, double threshold);
137

    
138
        bool isOnCriticalPath(IEvent* event);
139

    
140
        ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr, bool duration=false);
141

    
142
        /**
143
         * Timeline coordinate can be given in the range (-infinity, +infinity).
144
         * Simulation time will be in the range [0, lastEventSimulationTime].
145
         */
146
        simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false);
147
        /**
148
         * Simulation time must be in the range [0, lastEventSimulationTime].
149
         * Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the
150
         * timeline origin is at the first event.
151
         */
152
        double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false);
153
        double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId);
154

    
155
        std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr);
156

    
157
        std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr);
158
        std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 0);
159
    protected:
160
        void extractSimulationTimesAndTimelineCoordinates(
161
            IEvent *event, IEvent *&nextEvent,
162
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
163
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
164
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
165

    
166
        std::set<ptr_t>* getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
167

    
168
        unsigned int getLargestParallelSetSize(IEvent* event);
169

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

    
172
        simtime_t getSmallestParallelEndtime(IEvent* event);
173

    
174
        void calculateCriticalPath();
175

    
176
        void cacheRealTimeEventOrder();
177

    
178
        double getOverlapping(ptr_t eventPtr);
179

    
180
        double getMaximumOverlapping();
181

    
182

    
183
};
184

    
185
NAMESPACE_END
186

    
187

    
188
#endif