root / src / eventlog / sequencechartfacade.h @ 8aeaaccc
History  View  Annotate  Download (7.12 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) 20062008 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 
* SWIGgenerated 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 
std::set<ptr_t> cachedParallelSet; 
56 
IEvent* lastSelected; 
57  
58 
std::set<ptr_t> cachedCriticalPath; 
59 
public:

60 
SequenceChartFacade(IEventLog *eventLog); 
61 
virtual ~SequenceChartFacade() {} 
62  
63 
double calculateNonLinearFocus();

64 
virtual void synchronize(FileReader::FileChangedState change);

65  
66 
TimelineMode getTimelineMode() { return timelineMode; }

67 
void setTimelineMode(TimelineMode timelineMode);

68  
69 
double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; } 
70 
void setNonLinearMinimumTimelineCoordinateDelta(double value); 
71 
double getNonLinearFocus() { return nonLinearFocus; } 
72 
void setNonLinearFocus(double nonLinearFocus); 
73  
74 
IEvent *getTimelineCoordinateSystemOriginEvent() { return eventLog>getEventForEventNumber(timelineCoordinateOriginEventNumber); }

75 
eventnumber_t getTimelineCoordinateSystemOriginEventNumber() { return timelineCoordinateOriginEventNumber; }

76 
double getTimelineCoordinateDelta(double simulationTimeDelta); 
77 
/**

78 
* Calculates the timeline coordinate for the given event. Returns value from the cache if already there or calculates it

79 
* while taking care about the calculation limits.

80 
*/

81 
double getTimelineCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX); 
82 
double getTimelineCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX); 
83 
double getTimelineEventEndCoordinate(IEvent *event, double lowerTimelineCoordinateCalculationLimit = DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX); 
84 
double getTimelineEventEndCoordinate(ptr_t ptr, double lowerTimelineCoordinateCalculationLimit = DBL_MAX, double upperTimelineCoordinateCalculationLimit = DBL_MAX); 
85 
double getCachedTimelineCoordinate(IEvent *event);

86 
double IEvent_getTimelineCoordinate(ptr_t ptr);

87 
double IEvent_getTimelineEventEndCoordinate(ptr_t ptr);

88 
void undefineTimelineCoordinateSystem();

89 
void relocateTimelineCoordinateSystem(IEvent *event);

90  
91 
IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward); 
92 
IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);

93 
IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);

94  
95 
/*

96 
* returns smallest event complexity in the event log

97 
*/

98 
long getSmallestEventComplexity();

99 
/*

100 
* returns largest event complexity in the event log

101 
*/

102 
long getLargestEventComplexity();

103  
104 
/*

105 
* returns smallest event duration in the event log

106 
*/

107 
simtime_t getSmallestEventDuration(); 
108 
/*

109 
* returns largest event duration in the event log

110 
*/

111 
simtime_t getLargestEventDuration(); 
112  
113  
114 
/*

115 
* Returns whether an event not part of a set of parallel events with more than treshold elements.

116 
*/

117 
bool isBottleneck(IEvent* event, unsigned int threshold); 
118  
119 
bool isParallelWithEvent(IEvent* event, IEvent* selected);

120  
121 
IEvent* getPreviousBottleneck(IEvent* e, unsigned int threshold); 
122 
IEvent* getNextBottleneck(IEvent* e, unsigned int threshold); 
123  
124 
bool isOnCriticalPath(IEvent* event);

125  
126 
ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr); 
127  
128 
/**

129 
* Timeline coordinate can be given in the range (infinity, +infinity).

130 
* Simulation time will be in the range [0, lastEventSimulationTime].

131 
*/

132 
simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false); 
133 
/**

134 
* Simulation time must be in the range [0, lastEventSimulationTime].

135 
* Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the

136 
* timeline origin is at the first event.

137 
*/

138 
double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false); 
139 
double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId); 
140  
141 
std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr); 
142  
143 
std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr); 
144 
std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 0); 
145 
protected:

146 
void extractSimulationTimesAndTimelineCoordinates(

147 
IEvent *event, IEvent *&nextEvent, 
148 
simtime_t &eventSimulationTime, double &eventTimelineCoordinate,

149 
simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,

150 
simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);

151  
152 
std::set<ptr_t>* getLargestParallelSet(IEvent* event, std::set<ptr_t>* parallelSet); 
153  
154 
unsigned int getLargestParallelSetSize(IEvent* event); 
155  
156 
void getParallelSet(IEvent* event, std::set<ptr_t>* parallelSet);

157  
158 
simtime_t getSmallestParallelEndtime(IEvent* event); 
159  
160 
void calculateCriticalPath();

161  
162  
163 
}; 
164  
165 
NAMESPACE_END 
166  
167  
168 
#endif
