Statistics
| Branch: | Revision:

root / src / eventlog / sequencechartfacade.h @ ced95c57

History | View | Annotate | Download (6.23 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
        eventnumber_t timelineCoordinateRangeStartEventNumber;
43
        eventnumber_t timelineCoordinateRangeEndEventNumber;
44
        TimelineMode timelineMode;
45
        double nonLinearMinimumTimelineCoordinateDelta;
46
        double nonLinearFocus;
47

    
48
        long smallestComplexity;
49
        long largestComplexity;
50

    
51
        simtime_t smallestDuration;
52
        simtime_t largestDuration;
53

    
54
    public:
55
        SequenceChartFacade(IEventLog *eventLog);
56
        virtual ~SequenceChartFacade() {}
57

    
58
        double calculateNonLinearFocus();
59
        virtual void synchronize(FileReader::FileChangedState change);
60

    
61
        TimelineMode getTimelineMode() { return timelineMode; }
62
        void setTimelineMode(TimelineMode timelineMode);
63

    
64
        double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; }
65
        void setNonLinearMinimumTimelineCoordinateDelta(double value);
66
        double getNonLinearFocus() { return nonLinearFocus; }
67
        void setNonLinearFocus(double nonLinearFocus);
68

    
69
        IEvent *getTimelineCoordinateSystemOriginEvent() { return eventLog->getEventForEventNumber(timelineCoordinateOriginEventNumber); }
70
        eventnumber_t getTimelineCoordinateSystemOriginEventNumber() { return timelineCoordinateOriginEventNumber; }
71
        double getTimelineCoordinateDelta(double simulationTimeDelta);
72
        /**
73
         * Calculates the timeline coordinate for the given event. Returns value from the cache if already there or calculates it
74
         * while taking care about the calculation limits.
75
         */
76
        double getTimelineCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
77
        double getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = -DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX);
78
        double getCachedTimelineCoordinate(IEvent *event);
79
        double IEvent_getTimelineCoordinate(ptr_t ptr);
80
        void undefineTimelineCoordinateSystem();
81
        void relocateTimelineCoordinateSystem(IEvent *event);
82

    
83
        IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward);
84
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
85
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
86

    
87
        /*
88
         * returns smallest event complexity in the event log
89
         */
90
        long getSmallestEventComplexity();
91
        /*
92
         * returns largest event complexity in the event log
93
         */
94
        long getLargestEventComplexity();
95

    
96
        /*
97
         * returns smallest event duration in the event log
98
         */
99
        simtime_t getSmallestEventDuration();
100
        /*
101
         * returns largest event duration in the event log
102
         */
103
        simtime_t getLargestEventDuration();
104

    
105

    
106
        /*
107
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
108
        */
109
        bool isBottleneck(IEvent* event, unsigned int threshold);
110

    
111
        IEvent* getPreviousBottleneck(IEvent* e, unsigned int threshold);
112
        IEvent* getNextBottleneck(IEvent* e, unsigned int threshold);
113

    
114
        /**
115
         * Timeline coordinate can be given in the range (-infinity, +infinity).
116
         * Simulation time will be in the range [0, lastEventSimulationTime].
117
         */
118
        simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false);
119
        /**
120
         * Simulation time must be in the range [0, lastEventSimulationTime].
121
         * Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the
122
         * timeline origin is at the first event.
123
         */
124
        double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false);
125
        double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId);
126

    
127
        std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr);
128

    
129
        std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr);
130
        std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 0);
131
    protected:
132
        void extractSimulationTimesAndTimelineCoordinates(
133
            IEvent *event, IEvent *&nextEvent,
134
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
135
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
136
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
137

    
138

    
139
        unsigned int getLargestParallelSetSize(IEvent* event);
140

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

    
143
        simtime_t getSmallestParallelEndtime(IEvent* event);
144
};
145

    
146
NAMESPACE_END
147

    
148

    
149
#endif