Statistics
| Branch: | Revision:

root / src / eventlog / sequencechartfacade.h @ 1c72663d

History | View | Annotate | Download (6.86 KB)

1 01873262 Georg Kunz
//=========================================================================
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
        eventnumber_t timelineCoordinateRangeStartEventNumber;
43
        eventnumber_t timelineCoordinateRangeEndEventNumber;
44
        TimelineMode timelineMode;
45
        double nonLinearMinimumTimelineCoordinateDelta;
46
        double nonLinearFocus;
47
48 daf081df Simon Tenbusch
        long smallestComplexity;
49
        long largestComplexity;
50
51 ced95c57 Simon Tenbusch
        simtime_t smallestDuration;
52
        simtime_t largestDuration;
53
54 1c72663d Simon Tenbusch
        std::set<ptr_t> cachedParallelSet;
55
        IEvent* lastSelected;
56
57 01873262 Georg Kunz
    public:
58
        SequenceChartFacade(IEventLog *eventLog);
59
        virtual ~SequenceChartFacade() {}
60
61
        double calculateNonLinearFocus();
62
        virtual void synchronize(FileReader::FileChangedState change);
63
64
        TimelineMode getTimelineMode() { return timelineMode; }
65
        void setTimelineMode(TimelineMode timelineMode);
66
67
        double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; }
68
        void setNonLinearMinimumTimelineCoordinateDelta(double value);
69
        double getNonLinearFocus() { return nonLinearFocus; }
70
        void setNonLinearFocus(double nonLinearFocus);
71
72
        IEvent *getTimelineCoordinateSystemOriginEvent() { return eventLog->getEventForEventNumber(timelineCoordinateOriginEventNumber); }
73
        eventnumber_t getTimelineCoordinateSystemOriginEventNumber() { return timelineCoordinateOriginEventNumber; }
74
        double getTimelineCoordinateDelta(double simulationTimeDelta);
75
        /**
76
         * Calculates the timeline coordinate for the given event. Returns value from the cache if already there or calculates it
77
         * while taking care about the calculation limits.
78
         */
79
        double getTimelineCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
80
        double getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
81 382d8398 Simon Tenbusch
        double getTimelineEventEndCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
82
        double getTimelineEventEndCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
83 01873262 Georg Kunz
        double getCachedTimelineCoordinate(IEvent *event);
84
        double IEvent_getTimelineCoordinate(ptr_t ptr);
85 382d8398 Simon Tenbusch
        double IEvent_getTimelineEventEndCoordinate(ptr_t ptr);
86 01873262 Georg Kunz
        void undefineTimelineCoordinateSystem();
87
        void relocateTimelineCoordinateSystem(IEvent *event);
88
89
        IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward);
90
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
91
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
92
93 daf081df Simon Tenbusch
        /*
94
         * returns smallest event complexity in the event log
95
         */
96
        long getSmallestEventComplexity();
97
        /*
98
         * returns largest event complexity in the event log
99
         */
100
        long getLargestEventComplexity();
101
102 391dcea0 Simon Tenbusch
        /*
103 ced95c57 Simon Tenbusch
         * returns smallest event duration in the event log
104
         */
105
        simtime_t getSmallestEventDuration();
106
        /*
107
         * returns largest event duration in the event log
108
         */
109
        simtime_t getLargestEventDuration();
110
111
112
        /*
113 391dcea0 Simon Tenbusch
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
114
        */
115
        bool isBottleneck(IEvent* event, unsigned int threshold);
116
117 1c72663d Simon Tenbusch
        bool isParallelWithEvent(IEvent* event, IEvent* selected);
118
119 391dcea0 Simon Tenbusch
        IEvent* getPreviousBottleneck(IEvent* e, unsigned int threshold);
120
        IEvent* getNextBottleneck(IEvent* e, unsigned int threshold);
121
122 01873262 Georg Kunz
        /**
123
         * Timeline coordinate can be given in the range (-infinity, +infinity).
124
         * Simulation time will be in the range [0, lastEventSimulationTime].
125
         */
126
        simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false);
127
        /**
128
         * Simulation time must be in the range [0, lastEventSimulationTime].
129
         * Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the
130
         * timeline origin is at the first event.
131
         */
132
        double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false);
133
        double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId);
134
135
        std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr);
136
137
        std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr);
138
        std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 0);
139
    protected:
140
        void extractSimulationTimesAndTimelineCoordinates(
141
            IEvent *event, IEvent *&nextEvent,
142
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
143
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
144
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
145 391dcea0 Simon Tenbusch
146 1c72663d Simon Tenbusch
        std::set<ptr_t>* getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
147 391dcea0 Simon Tenbusch
148
        unsigned int getLargestParallelSetSize(IEvent* event);
149
150
        void getParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);
151
152
        simtime_t getSmallestParallelEndtime(IEvent* event);
153 01873262 Georg Kunz
};
154
155
NAMESPACE_END
156
157
158
#endif