Project

General

Profile

Revision bcffd494

IDbcffd49434291c7f2c503d1832bad45a6585e824

Added by Simon Tenbusch almost 9 years ago

[sequencechart] first steps towards REAL_TIME visualization.

View differences:

ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/editors/SequenceChartContributor.java
607 607
						addSubMenuItem(menu, "Event number", SequenceChart.TimelineMode.EVENT_NUMBER);
608 608
						addSubMenuItem(menu, "Step", SequenceChart.TimelineMode.STEP);
609 609
						addSubMenuItem(menu, "Nonlinear", SequenceChart.TimelineMode.NONLINEAR);
610
						addSubMenuItem(menu, "Real Time", SequenceChart.TimelineMode.REAL_TIME);
610 611

  
611 612
						MenuItem subMenuItem = new MenuItem(menu, SWT.RADIO);
612 613
						subMenuItem.setText("Custom nonlinear...");
......
630 631
								if (menuItem.getSelection()) {
631 632
									sequenceChart.setTimelineMode(timelineMode);
632 633
									timelineModeStatus.update();
633
									if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME) {
634
									if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME && timelineMode != SequenceChart.TimelineMode.REAL_TIME) {
634 635
									    sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
635 636
									}
636 637
									update();
......
729 730

  
730 731
								if (menuItem.getSelection()) {
731 732
								    sequenceChart.setEventLengthMode(eventLengthMode);
732
								    if (eventLengthMode != SequenceChart.EventLengthMode.NONE){
733
								    if (eventLengthMode == SequenceChart.EventLengthMode.DURATION){
733 734
								    	sequenceChart.setTimelineMode(SequenceChart.TimelineMode.SIMULATION_TIME);
734 735
										timelineModeStatus.update();
735 736
								    }
ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/widgets/SequenceChart.java
311 311
		SIMULATION_TIME,
312 312
		EVENT_NUMBER,
313 313
		STEP,
314
		NONLINEAR
314
		NONLINEAR,
315
		REAL_TIME
315 316
	}
316 317

  
317 318
	/**
src/eventlog/event.cc
76 76

  
77 77
    eventLogEntries.clear();
78 78

  
79
    earliestProcessingTime = 0;
79
    _earliestProcessingTime = 0;
80 80
}
81 81

  
82 82
void Event::synchronize()
......
438 438
    beginSendEntryNumber = -1;
439 439
    return NULL;
440 440
}
441

  
442
long Event::getEarliestProcessingTime() {
443
    return _earliestProcessingTime;
444
}
445
long Event::getEarliestStartTime() {
446
    return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
447
}
src/eventlog/event.h
108 108

  
109 109
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
110 110

  
111
        virtual long getEarliestProcessingTime();
112
        virtual long getEarliestStartTime();
113

  
114

  
111 115
    protected:
112 116
        void deleteAllocatedObjects();
113 117
        void clearInternalState();
src/eventlog/eventlogdefs.h
103 103
    SIMULATION_TIME,
104 104
    EVENT_NUMBER,
105 105
    STEP,
106
    NONLINEAR
106
    NONLINEAR,
107
    REAL_TIME
107 108
};
108 109

  
109 110
NAMESPACE_END
src/eventlog/filteredevent.cc
315 315

  
316 316
    messageDependencies->push_back(newMessageDependency);
317 317
}
318
long FilteredEvent::getEarliestProcessingTime() {
319
    return _earliestProcessingTime;
320
}
321
long FilteredEvent::getEarliestStartTime() {
322
    return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
323
}
src/eventlog/filteredevent.h
108 108
        void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool isReuse, int level);
109 109
        int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
110 110
        void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, bool isReuse, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
111
        virtual long getEarliestProcessingTime();
112
        virtual long getEarliestStartTime();
113

  
111 114
};
112 115

  
113 116
NAMESPACE_END
src/eventlog/ievent.h
35 35
        double cachedTimelineCoordinate;
36 36
        long cachedTimelineCoordinateSystemVersion;
37 37

  
38
        long earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
38
        long _earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
39 39

  
40 40

  
41 41

  
......
110 110
        virtual IMessageDependencyList *getCauses() = 0;
111 111
        virtual IMessageDependencyList *getConsequences() = 0;
112 112

  
113
        /**
113
        /**  public int getEarliestProcessingTime() {
114
    return EventLogEngineJNI.IEvent_earliestProcessingTime_get(swigCPtr, this);
115
  }
114 116
         * Print all entries of this event.
115 117
         */
116 118
        virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
......
143 145
         */
144 146
        static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
145 147
        static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
148

  
149
        virtual long getEarliestProcessingTime() = 0;
150
        virtual long getEarliestStartTime() = 0;
146 151
};
147 152

  
148 153
NAMESPACE_END
src/eventlog/sequencechartfacade.cc
100 100
    timelineCoordinateSystemVersion++;
101 101
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = -1;
102 102
    timelineCoordinateOriginSimulationTime = simtime_nil;
103
    timelineCoordinateOriginRealTime = 0;
103 104
}
104 105

  
105 106
void SequenceChartFacade::relocateTimelineCoordinateSystem(IEvent *event)
......
109 110
    timelineCoordinateSystemVersion++;
110 111
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = event->getEventNumber();
111 112
    timelineCoordinateOriginSimulationTime = event->getSimulationTime();
113
    timelineCoordinateOriginRealTime = event->getEarliestStartTime();
112 114
    event->cachedTimelineCoordinate = 0;
113 115
    event->cachedTimelineCoordinateSystemVersion = timelineCoordinateSystemVersion;
114 116
}
......
166 168
        double timelineCoordinate;
167 169

  
168 170
        switch (timelineMode) {
171
            case REAL_TIME:
172
                timelineCoordinate = ((event->getEarliestStartTime() - timelineCoordinateOriginRealTime));
173
                break;
169 174
            case SIMULATION_TIME:
170 175
                timelineCoordinate = (event->getSimulationTime() - timelineCoordinateOriginSimulationTime).dbl();
171 176
                break;
......
241 246
    }
242 247
        double timelineEventEndCoordinate;
243 248
        switch (timelineMode) {
249
            case REAL_TIME:
250
                timelineEventEndCoordinate = (event->getEarliestProcessingTime() - timelineCoordinateOriginRealTime);
251
                break;
244 252
            case SIMULATION_TIME:
245 253
                timelineEventEndCoordinate = (event->getSimulationTime()+event->getEventEntry()->duration - timelineCoordinateOriginSimulationTime).dbl();
246 254
                break;
......
302 310
        return NULL;
303 311

  
304 312
    switch (timelineMode) {
313
        case REAL_TIME:
314
        {
315
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
316
            IEvent* res = eventLog->getFirstEvent();
317
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
318
                if ((double) current->getEarliestStartTime() < timelineCoordinate) {
319
                    if (current->getEarliestStartTime() > res->getEarliestStartTime()) {
320
                        res = current;
321
                    }
322
                }
323
            }
324
            return res;
325
        }
305 326
        case SIMULATION_TIME:
306 327
            return eventLog->getLastEventNotAfterSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
307 328
        case EVENT_NUMBER:
......
334 355
        return NULL;
335 356

  
336 357
    switch (timelineMode) {
358
        case REAL_TIME:
359
        {
360
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
361
            IEvent* res = eventLog->getLastEvent();
362
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
363
                if ((double) current->getEarliestStartTime() > timelineCoordinate) {
364
                    if (current->getEarliestStartTime() < res->getEarliestStartTime()) {
365
                        res = current;
366
                    }
367
                }
368
            }
369
            return res;
370
        }
337 371
        case SIMULATION_TIME:
338 372
            return eventLog->getFirstEventNotBeforeSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
339 373
        case EVENT_NUMBER:
......
366 400
    simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
367 401
    simtime_t &simulationTimeDelta, double &timelineCoordinateDelta)
368 402
{
403
    //TODO: REAL_TIME
404

  
369 405
    // if before the first event
370 406
    if (event) {
371 407
        eventSimulationTime = event->getSimulationTime();
......
405 441

  
406 442
    switch (timelineMode)
407 443
    {
444
        case REAL_TIME:
445
        {
446
            simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime()/1000000.0); //TODO: Change this to getEarliestStartTime();
447
            //NOTE: This sometimes crashes the Sequencechart because the returned value might be too big
448
            simulationTime = max(BigDecimal::Zero, min(lastEventSimulationTime, (timelineCoordinate + timelineCoordinateOriginRealTime)/1000000.0));
449
        }
450
            //Fall back to SIMULATION_TIME (TODO)
408 451
        case SIMULATION_TIME:
409 452
            {
410 453
                simtime_t lastEventSimulationTime = eventLog->getLastEvent()->getSimulationTime();
......
468 511

  
469 512
    switch (timelineMode)
470 513
    {
514
        case REAL_TIME:
515
        //Fall back to SIMULATION_TIME (TODO)
471 516
        case SIMULATION_TIME:
472 517
            timelineCoordinate = (simulationTime - timelineCoordinateOriginSimulationTime).dbl();
473 518
            break;
......
892 937
        simtime_t startTime = current->getSimulationTime();
893 938
        int moduleId = current->getModuleId();
894 939
        if(current->getEventEndEntry()) {
895
            current->earliestProcessingTime = current->getComplexity();
940
            current->_earliestProcessingTime = current->getComplexity();
896 941
        }
897 942
        for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
898 943
            if(antecessor==current) {
......
901 946
            if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
902 947
                continue; // Check if this is an antecesor
903 948
            }
904
            if(antecessor->earliestProcessingTime+current->getComplexity() > current->earliestProcessingTime) {
905
                current->earliestProcessingTime = antecessor->earliestProcessingTime+current->getComplexity();
949
            if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
950
                current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
906 951
            }
907 952
        }
908 953
        // Memorize max event
909
        if (maxEarliestProcessingTime < current->earliestProcessingTime) {
910
            maxEarliestProcessingTime = current->earliestProcessingTime;
954
        if (maxEarliestProcessingTime < current->_earliestProcessingTime) {
955
            maxEarliestProcessingTime = current->_earliestProcessingTime;
911 956
            maxEarliestProcessingTimeEvent = current;
912 957
        }
913 958
    }
src/eventlog/sequencechartfacade.h
39 39
        long timelineCoordinateSystemVersion;
40 40
        eventnumber_t timelineCoordinateOriginEventNumber;
41 41
        simtime_t timelineCoordinateOriginSimulationTime;
42
        long timelineCoordinateOriginRealTime;
42 43
        eventnumber_t timelineCoordinateRangeStartEventNumber;
43 44
        eventnumber_t timelineCoordinateRangeEndEventNumber;
44 45
        TimelineMode timelineMode;

Also available in: Unified diff