Statistics
| Branch: | Revision:

root / src / eventlog / sequencechartfacade.h @ 842775ab

History | View | Annotate | Download (5.59 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; // a counter incremented each time the timeline coordinate system is relocated
40
        eventnumber_t timelineCoordinateOriginEventNumber; // -1 means undefined, otherwise the event number of the timeline coordinate system origin
41
        simtime_t timelineCoordinateOriginSimulationTime; // simtime_nil means undefined
42
        eventnumber_t timelineCoordinateRangeStartEventNumber; // -1 means undefined, the beginning of the continuous event range which has timeline coordinates assigned
43
        eventnumber_t timelineCoordinateRangeEndEventNumber; // -1 means undefined, the end of the continuous event range which has timeline coordinates assigned
44
        TimelineMode timelineMode;
45
        double nonLinearFocus; // a useful constant for the nonlinear transformation between simulation time and timeline coordinate
46
        double nonLinearMinimumTimelineCoordinateDelta; // minimum timeline coordinate difference between two events
47

    
48
    public:
49
        SequenceChartFacade(IEventLog *eventLog);
50
        virtual ~SequenceChartFacade() {}
51

    
52
        double calculateNonLinearFocus();
53
        virtual void synchronize(FileReader::FileChangedState change);
54

    
55
        TimelineMode getTimelineMode() { return timelineMode; }
56
        void setTimelineMode(TimelineMode timelineMode);
57

    
58
        double getNonLinearMinimumTimelineCoordinateDelta() { return nonLinearMinimumTimelineCoordinateDelta; }
59
        void setNonLinearMinimumTimelineCoordinateDelta(double value);
60
        double getNonLinearFocus();
61
        void setNonLinearFocus(double nonLinearFocus);
62

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

    
77
        IEvent *getEventForNonLinearTimelineCoordinate(double timelineCoordinate, bool &forward);
78
        IEvent *getLastEventNotAfterTimelineCoordinate(double timelineCoordinate);
79
        IEvent *getFirstEventNotBeforeTimelineCoordinate(double timelineCoordinate);
80

    
81
        /**
82
         * Timeline coordinate can be given in the range (-infinity, +infinity).
83
         * Simulation time will be in the range [0, lastEventSimulationTime].
84
         */
85
        simtime_t getSimulationTimeForTimelineCoordinate(double timelineCoordinate, bool upperLimit = false);
86
        /**
87
         * Simulation time must be in the range [0, lastEventSimulationTime].
88
         * Timeline coordinate will be in the range [0, lastEventTimelineCoordinate] if the
89
         * timeline origin is at the first event.
90
         */
91
        double getTimelineCoordinateForSimulationTime(simtime_t simulationTime, bool upperLimit = false);
92
        double getTimelineCoordinateForSimulationTimeAndEventInModule(simtime_t simulationTime, int moduleId);
93

    
94
        std::vector<ptr_t> *getModuleMethodBeginEntries(ptr_t startEventPtr, ptr_t endEventPtr);
95

    
96
        std::vector<ptr_t> *getIntersectingMessageDependencies(ptr_t startEventPtr, ptr_t endEventPtr);
97
        std::vector<int> getApproximateMessageDependencyCountAdjacencyMatrix(std::map<int, int> *moduleIdToAxisIdMap, int numberOfSamples, int messageSendWeight = 1, int messageReuseWeight = 1);
98

    
99
    protected:
100
        void extractSimulationTimesAndTimelineCoordinates(
101
            IEvent *event, IEvent *&nextEvent,
102
            simtime_t &eventSimulationTime, double &eventTimelineCoordinate,
103
            simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
104
            simtime_t &simulationTimeDelta, double &timelineCoordinateDelta);
105
};
106

    
107
NAMESPACE_END
108

    
109

    
110
#endif