Revision 8aeaaccc

View differences:

ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/editors/SequenceChartContributor.java
632 632
									sequenceChart.setTimelineMode(timelineMode);
633 633
									timelineModeStatus.update();
634 634
									if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME && timelineMode != SequenceChart.TimelineMode.REAL_TIME) {
635
									    sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
635
										sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
636
									}
637
									if (timelineMode == SequenceChart.TimelineMode.REAL_TIME) {
638
										sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.COMPLEXITY);
636 639
									}
637 640
									update();
638 641
								}
ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/widgets/SequenceChart.java
1797 1797
            if (debug)
1798 1798
                Debug.println("Collecting axis modules for module method calls using event range: " + sequenceChartFacade.IEvent_getEventNumber(startEventPtr) + " -> " + sequenceChartFacade.IEvent_getEventNumber(endEventPtr));
1799 1799

  
1800

  
1800 1801
            PtrVector moduleMethodBeginEntries = sequenceChartFacade.getModuleMethodBeginEntries(startEventPtr, endEventPtr);
1801 1802

  
1802 1803
            for (int i = 0; i < moduleMethodBeginEntries.size(); i++) {
......
2578 2579
                    fillZeroSimulationTimeRegion(graphics, r, clip, x, startX - x);
2579 2580
			}
2580 2581

  
2581
			// draw rectangles where simulation time has not elapsed between events
2582
			for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade.IEvent_getNextEvent(eventPtr)) {
2583
				if (previousEventPtr != -1) {
2584
					x = getEventXViewportCoordinate(eventPtr);
2585
					long previousX = getEventXViewportCoordinate(previousEventPtr);
2586
					org.omnetpp.common.engine.BigDecimal simulationTime = sequenceChartFacade.IEvent_getSimulationTime(eventPtr);
2587
					org.omnetpp.common.engine.BigDecimal previousSimulationTime = sequenceChartFacade.IEvent_getSimulationTime(previousEventPtr);
2588

  
2589
					if (simulationTime.equals(previousSimulationTime) && x != previousX)
2590
	                    fillZeroSimulationTimeRegion(graphics, r, clip, previousX, x - previousX);
2591
				}
2582
			// draw rectangles where simulation time has not elapsed between
2583
			// events
2584
			if (getTimelineMode() != TimelineMode.REAL_TIME) {
2585
				for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade
2586
						.IEvent_getNextEvent(eventPtr)) {
2587
					if (previousEventPtr != -1) {
2588
						x = getEventXViewportCoordinate(eventPtr);
2589
						long previousX = getEventXViewportCoordinate(previousEventPtr);
2590
						org.omnetpp.common.engine.BigDecimal simulationTime = sequenceChartFacade
2591
								.IEvent_getSimulationTime(eventPtr);
2592
						org.omnetpp.common.engine.BigDecimal previousSimulationTime = sequenceChartFacade
2593
								.IEvent_getSimulationTime(previousEventPtr);
2594

  
2595
						if (simulationTime.equals(previousSimulationTime)
2596
								&& x != previousX)
2597
							fillZeroSimulationTimeRegion(graphics, r, clip,
2598
									previousX, x - previousX);
2599
					}
2592 2600

  
2593
				previousEventPtr = eventPtr;
2601
					previousEventPtr = eventPtr;
2594 2602

  
2595
				if (eventPtr == endEventPtr)
2596
					break;
2603
					if (eventPtr == endEventPtr)
2604
						break;
2605
				}
2597 2606
			}
2598

  
2599 2607
			// draw rectangle after the very end of the simulation
2600 2608
			if (sequenceChartFacade.IEvent_getNextEvent(endEventPtr) == 0) {
2601 2609
				x = clip.right();
2602
				long endX = getEventXViewportCoordinate(endEventPtr);
2610
				long largestEvent = sequenceChartFacade.getLargestEndtimeInEventRange(startEventPtr,endEventPtr);
2611
				long endX = getEventXViewportCoordinate(largestEvent) + getEventLength(largestEvent) - 2;
2603 2612

  
2604 2613
				if (x != endX)
2605 2614
				    fillZeroSimulationTimeRegion(graphics, r, clip, endX, x - endX);
......
2997 3006
        calculateTicks(getViewportWidth());
2998 3007

  
2999 3008
        IEvent lastEvent = eventLog.getLastEvent();
3000
        org.omnetpp.common.engine.BigDecimal endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime();
3009
        org.omnetpp.common.engine.BigDecimal endSimulationTime;
3010
        
3011
		if (getTimelineMode() == TimelineMode.REAL_TIME){
3012
			//TODO Cache this
3013
			lastEvent = sequenceChartFacade.IEvent_getEvent(sequenceChartFacade.getLargestEndtimeInEventRange(eventLog.getFirstEvent().getCPtr(),eventLog.getLastEvent().getCPtr()));
3014
			endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : new org.omnetpp.common.engine.BigDecimal(lastEvent.getEarliestProcessingTime()/1000000.0);
3015
		//} else if (getEventLengthMode() == EventLengthMode.DURATION){
3016
		//	endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime().add(lastEvent.getEventEntry().getDuration());
3017
		} else {
3018
			endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime();
3019
		}
3001 3020

  
3002 3021
		for (BigDecimal tick : ticks) {
3003 3022
			// BigDecimal to double conversions loose precision both in Java and C++ but we must stick to the one in C++
......
3835 3854
		if (eventLog == null || eventLog.isEmpty() || eventLog.getApproximateNumberOfEvents() == 0)
3836 3855
			return new long[] {0, 0};
3837 3856
		else {
3857
			
3858
			//Fix for REAL_TIME Visualization:
3859
			//In this mode, events are not necessarily ordered in event number order so 
3860
			//that an interval of visible events may not be correct.
3861
			//fix it by just returning the interval of all events.
3862
			if (getTimelineMode() == TimelineMode.REAL_TIME){
3863
				return new long[] { eventLog.getFirstEvent().getCPtr(), eventLog.getLastEvent().getCPtr() };
3864
			}
3865
			
3838 3866
    		double leftTimelineCoordinate = getTimelineCoordinateForViewportCoordinate(x1);
3839 3867
    		double rightTimelineCoordinate = getTimelineCoordinateForViewportCoordinate(x2);
3840 3868

  
......
3845 3873
    		IEvent endEvent = sequenceChartFacade.getFirstEventNotBeforeTimelineCoordinate(rightTimelineCoordinate);
3846 3874
    		if (endEvent == null)
3847 3875
    			endEvent = eventLog.getLastEvent();
3848

  
3876
            
3849 3877
    		return new long[] {startEvent == null ? 0 : startEvent.getCPtr(), endEvent == null ? 0 : endEvent.getCPtr()};
3850 3878
		}
3851 3879
	}
......
3956 3984
    			IEvent lastEvent = eventLog.getLastEvent();
3957 3985

  
3958 3986
    			if (lastEvent != null) {
3959
    				BigDecimal endSimulationTime = lastEvent.getSimulationTime().toBigDecimal();
3987
    				BigDecimal endSimulationTime;
3988
    				if (getTimelineMode() == TimelineMode.REAL_TIME){
3989
    					//TODO cache this
3990
    					lastEvent = sequenceChartFacade.IEvent_getEvent(sequenceChartFacade.getLargestEndtimeInEventRange(eventLog.getFirstEvent().getCPtr(),eventLog.getLastEvent().getCPtr()));
3991
    					endSimulationTime = lastEvent == null ? BigDecimal.ZERO : new BigDecimal(lastEvent.getEarliestProcessingTime()/1000000.0);
3992
    				} else if (getEventLengthMode() == EventLengthMode.DURATION){
3993
    					endSimulationTime = lastEvent == null ? BigDecimal.ZERO : lastEvent.getSimulationTime().toBigDecimal().add(lastEvent.getEventEntry().getDuration().toBigDecimal());
3994
    				} else {
3995
    					endSimulationTime = lastEvent == null ? BigDecimal.ZERO : lastEvent.getSimulationTime().toBigDecimal();
3996
    				}
3997
    				
3960 3998

  
3961 3999
    				for (long t = tleft; t < tright; t += TICK_SPACING) {
3962 4000
    					BigDecimal tick = calculateTick(t, TICK_SPACING / 2);
src/eventlog/sequencechartfacade.cc
984 984
    }
985 985
}
986 986

  
987
ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr) {
988
    IEvent *startEvent = (IEvent *)startEventPtr;
989
    IEvent *endEvent = (IEvent *)endEventPtr;
990
    switch (timelineMode)
991
    {
992
    case REAL_TIME:
993
    {
994
        long largest = 0;
995
        IEvent* largestEvent = startEvent;
996

  
997
        for (IEvent* current = startEvent; current; current = current->getNextEvent()) {
998
            long temp = current->getEarliestProcessingTime();
999
            if (temp > largest) {
1000
                largest = temp;
1001
                largestEvent = current;
1002
            }
1003
            if (current==endEvent) {
1004
                break;
1005
            }
1006
        }
1007
        return (ptr_t) largestEvent;
1008
    }
1009
    case SIMULATION_TIME:
1010
    case EVENT_NUMBER:
1011
    case STEP:
1012
    case NONLINEAR:
1013
    default:
1014
        return endEventPtr;
1015
    }
1016

  
1017
}
src/eventlog/sequencechartfacade.h
123 123

  
124 124
        bool isOnCriticalPath(IEvent* event);
125 125

  
126
        ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr);
127

  
126 128
        /**
127 129
         * Timeline coordinate can be given in the range (-infinity, +infinity).
128 130
         * Simulation time will be in the range [0, lastEventSimulationTime].
......
156 158
        simtime_t getSmallestParallelEndtime(IEvent* event);
157 159

  
158 160
        void calculateCriticalPath();
161

  
162

  
159 163
};
160 164

  
161 165
NAMESPACE_END

Also available in: Unified diff