Revision 0596ce67

View differences:

ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/widgets/SequenceChart.java
756 756
	public void setTimelineMode(TimelineMode timelineMode) {
757 757
	    org.omnetpp.common.engine.BigDecimal[] leftRightSimulationTimes = null;
758 758

  
759
	    if(timelineMode==TimelineMode.REAL_TIME) {
760
	    	//Trigger initialization of earliest starting times 
761
	    	sequenceChartFacade.isOnCriticalPath(null);
762
	    }
763
	    
759 764
	    if (!eventLog.isEmpty())
760 765
	        leftRightSimulationTimes = getViewportSimulationTimeRange();
761 766

  
......
2764 2769
	}
2765 2770
	
2766 2771
	/**
2772
	 * Returns the relative pixellength of an event depending on its complexity.
2773
	 */
2774
	private int getEventComplexityLength(IEvent event) {
2775
	    return (int) (getViewportCoordinateForTimelineCoordinate(event.getEarliestProcessingTime()/1000000.0) - getViewportCoordinateForTimelineCoordinate(event.getEarliestStartTime() / 1000000.0));
2776
	}
2777
	/**
2767 2778
	 * Returns the relative pixellength of an event depending on its duration.
2768 2779
	 */
2769 2780
	private int getPixelLength(org.omnetpp.common.engine.BigDecimal time) {
......
2860 2871
			return Math.max(5,getEventDurationLength(sequenceChartFacade.IEvent_getEvent(eventPtr)));
2861 2872
		case COMPLEXITY:
2862 2873
			//TODO: Find good relative length
2863
			return Math.max(5,(int)(getComplexityPercentage(sequenceChartFacade.IEvent_getEvent(eventPtr).getComplexity()) * 100));
2874
			if (getTimelineMode() == TimelineMode.REAL_TIME) {
2875
				return Math.max(5,getEventComplexityLength(sequenceChartFacade.IEvent_getEvent(eventPtr)));
2876
			} else {
2877
				return Math.max(5,(int)(getComplexityPercentage(sequenceChartFacade.IEvent_getEvent(eventPtr).getComplexity()) * 100));
2878
			}
2879
			
2864 2880
		case NONE:
2865 2881
		default:
2866 2882
			return 5;
src/eventlog/ievent.cc
23 23
{
24 24
    nextEvent = NULL;
25 25
    previousEvent = NULL;
26
    criticalPredecessor = NULL;
26 27
    cachedTimelineCoordinate = -1;
27 28
    cachedTimelineCoordinateSystemVersion = -1;
28 29
}
src/eventlog/ievent.h
30 30
        IEvent *previousEvent;
31 31
        IEvent *nextEvent;
32 32

  
33
        IEvent* criticalPredecessor;
34

  
33 35
    public:
34 36
        // gui state for SequenceChart
35 37
        double cachedTimelineCoordinate;
......
148 150

  
149 151
        virtual long getEarliestProcessingTime() = 0;
150 152
        virtual long getEarliestStartTime() = 0;
153

  
154
        IEvent* getCriticalPredecessor() {
155
            return criticalPredecessor;
156
        }
157

  
158
        void setCriticalPredecessor(IEvent* e) {
159
            criticalPredecessor = e;
160
        }
151 161
};
152 162

  
153 163
NAMESPACE_END
src/eventlog/sequencechartfacade.cc
110 110
    timelineCoordinateSystemVersion++;
111 111
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = event->getEventNumber();
112 112
    timelineCoordinateOriginSimulationTime = event->getSimulationTime();
113
    timelineCoordinateOriginRealTime = event->getEarliestStartTime();
113
    timelineCoordinateOriginRealTime = event->getEarliestStartTime() / 1000000.0;
114 114
    event->cachedTimelineCoordinate = 0;
115 115
    event->cachedTimelineCoordinateSystemVersion = timelineCoordinateSystemVersion;
116 116
}
......
169 169

  
170 170
        switch (timelineMode) {
171 171
            case REAL_TIME:
172
                timelineCoordinate = ((event->getEarliestStartTime() - timelineCoordinateOriginRealTime));
172
                timelineCoordinate = ((event->getEarliestStartTime()/1000000.0 - timelineCoordinateOriginRealTime));
173 173
                break;
174 174
            case SIMULATION_TIME:
175 175
                timelineCoordinate = (event->getSimulationTime() - timelineCoordinateOriginSimulationTime).dbl();
......
247 247
        double timelineEventEndCoordinate;
248 248
        switch (timelineMode) {
249 249
            case REAL_TIME:
250
                timelineEventEndCoordinate = (event->getEarliestProcessingTime() - timelineCoordinateOriginRealTime);
250
                timelineEventEndCoordinate = (event->getEarliestProcessingTime()/ 1000000.0 - timelineCoordinateOriginRealTime) ;
251 251
                break;
252 252
            case SIMULATION_TIME:
253 253
                timelineEventEndCoordinate = (event->getSimulationTime()+event->getEventEntry()->duration - timelineCoordinateOriginSimulationTime).dbl();
......
315 315
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
316 316
            IEvent* res = eventLog->getFirstEvent();
317 317
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
318
                if ((double) current->getEarliestStartTime() < timelineCoordinate) {
318
                if ((double) current->getEarliestStartTime() / 1000000.0 < timelineCoordinate) {
319 319
                    if (current->getEarliestStartTime() > res->getEarliestStartTime()) {
320 320
                        res = current;
321 321
                    }
......
360 360
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
361 361
            IEvent* res = eventLog->getLastEvent();
362 362
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
363
                if ((double) current->getEarliestStartTime() > timelineCoordinate) {
363
                if ((double) current->getEarliestStartTime() / 1000000.0 > timelineCoordinate) {
364 364
                    if (current->getEarliestStartTime() < res->getEarliestStartTime()) {
365 365
                        res = current;
366 366
                    }
......
400 400
    simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
401 401
    simtime_t &simulationTimeDelta, double &timelineCoordinateDelta)
402 402
{
403
    //TODO: REAL_TIME
404

  
405 403
    // if before the first event
406 404
    if (event) {
407
        eventSimulationTime = event->getSimulationTime();
405
        if (timelineMode==REAL_TIME) {
406
            eventSimulationTime = event->getEarliestStartTime() / 1000000.0;
407
        } else {
408
            eventSimulationTime = event->getSimulationTime();
409
        }
408 410
        eventTimelineCoordinate = getTimelineCoordinate(event);
409 411
    }
410 412
    else {
......
414 416

  
415 417
        if (timelineMode == EVENT_NUMBER)
416 418
            eventTimelineCoordinate -= 1;
419
        else if (timelineMode == REAL_TIME)
420
            eventTimelineCoordinate -= getTimelineCoordinateDelta(0);
417 421
        else
418 422
            eventTimelineCoordinate -= getTimelineCoordinateDelta(firstEvent->getSimulationTime().dbl());
419 423
    }
......
422 426
    nextEvent = event ? event->getNextEvent() : eventLog->getFirstEvent();
423 427

  
424 428
    if (nextEvent) {
425
        nextEventSimulationTime = nextEvent->getSimulationTime();
429
        if(timelineMode==REAL_TIME) {
430
            nextEventSimulationTime = nextEvent->getEarliestStartTime() / 1000000.0;
431
        } else {
432
            nextEventSimulationTime = nextEvent->getSimulationTime();
433
        }
434

  
426 435
        nextEventTimelineCoordinate = getTimelineCoordinate(nextEvent);
427 436

  
428 437
        simulationTimeDelta = nextEventSimulationTime - eventSimulationTime;
......
443 452
    {
444 453
        case REAL_TIME:
445 454
        {
446
            simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime()/1000000.0); //TODO: Change this to getEarliestStartTime();
455
            simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime())/1000000.0;
447 456
            //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));
457
            simulationTime = max(BigDecimal::Zero, min(lastEventSimulationTime, (timelineCoordinate + timelineCoordinateOriginRealTime)));
449 458
        }
450
            //Fall back to SIMULATION_TIME (TODO)
459
        break;
451 460
        case SIMULATION_TIME:
452 461
            {
453 462
                simtime_t lastEventSimulationTime = eventLog->getLastEvent()->getSimulationTime();
......
492 501

  
493 502
    Assert(!simulationTime.isNaN());
494 503
    Assert(simulationTime >= BigDecimal::Zero);
495
    Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
504
    if (timelineMode != REAL_TIME)
505
        Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
496 506

  
497 507
    return simulationTime;
498 508
}
......
505 515
        return 0;
506 516

  
507 517
    Assert(simulationTime >= BigDecimal::Zero);
508
    Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
518
    if (timelineMode != REAL_TIME)
519
        Assert(simulationTime <= eventLog->getLastEvent()->getSimulationTime());
520

  
509 521

  
510 522
    double timelineCoordinate;
511 523

  
512 524
    switch (timelineMode)
513 525
    {
514 526
        case REAL_TIME:
515
        //Fall back to SIMULATION_TIME (TODO)
527
            //treat simulationTime as real time:
528
            timelineCoordinate = simulationTime.dbl() - timelineCoordinateOriginRealTime;
529
            break;
516 530
        case SIMULATION_TIME:
517 531
            timelineCoordinate = (simulationTime - timelineCoordinateOriginSimulationTime).dbl();
518 532
            break;
......
939 953
        if(current->getEventEndEntry()) {
940 954
            current->_earliestProcessingTime = current->getComplexity();
941 955
        }
956

  
957
        current->setCriticalPredecessor(eventLog->getFirstEvent());
958

  
942 959
        for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
943 960
            if(antecessor==current) {
944 961
                break; //We have to consider earlier events only
......
948 965
            }
949 966
            if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
950 967
                current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
968
                current->setCriticalPredecessor(antecessor);
951 969
            }
952 970
        }
953 971
        // Memorize max event
......
956 974
            maxEarliestProcessingTimeEvent = current;
957 975
        }
958 976
    }
959
    //Now produce the convex hull of predecessors:
977
    //Now produce the convex hull of critical antecessors/predecessors:
960 978
    cachedCriticalPath.clear();
961
    for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCauseEvent()) {
979
    for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCriticalPredecessor()) {
962 980
        cachedCriticalPath.insert((ptr_t)predecessor);
963 981
        if(predecessor->getEventNumber() == 0) {
964 982
            break;
src/eventlog/sequencechartfacade.h
39 39
        long timelineCoordinateSystemVersion;
40 40
        eventnumber_t timelineCoordinateOriginEventNumber;
41 41
        simtime_t timelineCoordinateOriginSimulationTime;
42
        long timelineCoordinateOriginRealTime;
42
        double timelineCoordinateOriginRealTime;
43 43
        eventnumber_t timelineCoordinateRangeStartEventNumber;
44 44
        eventnumber_t timelineCoordinateRangeEndEventNumber;
45 45
        TimelineMode timelineMode;

Also available in: Unified diff