Commit 2595f1a9 authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

- various bugfixes
parent 8aeaaccc
......@@ -353,6 +353,7 @@ public class SequenceChart
setupListeners();
parallelSelectionUpdater = new ParallelSelectionUpdater(this);
}
private void setupHoverSupport() {
......@@ -2530,8 +2531,10 @@ public class SequenceChart
/*long longestEventOffset = getPixelLength(sequenceChartFacade.getLargestEventDuration());
System.out.println(longestEventOffset);
*/
long longestEventOffset = 0; //TODO: Make this work to fix error with long events getting not displayed even when they are visible.
long[] eventPtrRange = getFirstLastEventPtrForViewportRange(Rectangle.SINGLETON.x - (extraClipping+longestEventOffset), Rectangle.SINGLETON.right() + extraClipping);
//long longestEventOffset = 0; //TODO: Make this work to fix error with long events getting not displayed even when they are visible.
//long[] eventPtrRange = getFirstLastEventPtrForViewportRange(Rectangle.SINGLETON.x - (extraClipping+longestEventOffset), Rectangle.SINGLETON.right() + extraClipping);
long[] eventPtrRange = getFirstLastEventPtrForViewportRange(0, Rectangle.SINGLETON.right() + extraClipping);
long startEventPtr = eventPtrRange[0];
long endEventPtr = eventPtrRange[1];
......@@ -3986,9 +3989,8 @@ public class SequenceChart
if (lastEvent != null) {
BigDecimal endSimulationTime;
if (getTimelineMode() == TimelineMode.REAL_TIME){
//TODO cache this
lastEvent = sequenceChartFacade.IEvent_getEvent(sequenceChartFacade.getLargestEndtimeInEventRange(eventLog.getFirstEvent().getCPtr(),eventLog.getLastEvent().getCPtr()));
endSimulationTime = lastEvent == null ? BigDecimal.ZERO : new BigDecimal(lastEvent.getEarliestProcessingTime()/1000000.0);
endSimulationTime = lastEvent == null ? BigDecimal.ZERO : new BigDecimal(lastEvent.getEarliestProcessingTime()/1000000);
} else if (getEventLengthMode() == EventLengthMode.DURATION){
endSimulationTime = lastEvent == null ? BigDecimal.ZERO : lastEvent.getSimulationTime().toBigDecimal().add(lastEvent.getEventEntry().getDuration().toBigDecimal());
} else {
......
......@@ -42,6 +42,8 @@ SequenceChartFacade::SequenceChartFacade(IEventLog *eventLog) : EventLogFacade(e
smallestDuration = -1;
largestDuration = -1;
biggestEarliestProcessingTime = 0;
cachedParallelSet.clear();
cachedCriticalPath.clear();
}
......@@ -452,9 +454,7 @@ simtime_t SequenceChartFacade::getSimulationTimeForTimelineCoordinate(double tim
{
case REAL_TIME:
{
simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime())/1000000.0;
//NOTE: This sometimes crashes the Sequencechart because the returned value might be too big
simulationTime = max(BigDecimal::Zero, min(lastEventSimulationTime, (timelineCoordinate + timelineCoordinateOriginRealTime)));
simulationTime = max(BigDecimal::Zero, min(biggestEarliestProcessingTime, (timelineCoordinate + timelineCoordinateOriginRealTime)));
}
break;
case SIMULATION_TIME:
......@@ -976,6 +976,9 @@ void SequenceChartFacade::calculateCriticalPath() {
}
//Now produce the convex hull of critical antecessors/predecessors:
cachedCriticalPath.clear();
//Cache largest processing time:
biggestEarliestProcessingTime = maxEarliestProcessingTime / 1000000.0;
biggestEarliestProcessingTimeEvent = maxEarliestProcessingTimeEvent;
for (IEvent *predecessor = maxEarliestProcessingTimeEvent; predecessor ; predecessor = predecessor->getCriticalPredecessor()) {
cachedCriticalPath.insert((ptr_t)predecessor);
if(predecessor->getEventNumber() == 0) {
......@@ -983,7 +986,10 @@ void SequenceChartFacade::calculateCriticalPath() {
}
}
}
/*
* Returns the event with the largest calculated earliest Processing time in REAL_TIME mode
* or the largest endtime in other modes within the given event range.
*/
ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr) {
IEvent *startEvent = (IEvent *)startEventPtr;
IEvent *endEvent = (IEvent *)endEventPtr;
......@@ -991,6 +997,11 @@ ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr, pt
{
case REAL_TIME:
{
//Use cached result when range contains all events
if(startEvent == eventLog->getFirstEvent() && endEvent == eventLog->getLastEvent()) {
return (ptr_t)biggestEarliestProcessingTimeEvent;
}
long largest = 0;
IEvent* largestEvent = startEvent;
......
......@@ -52,6 +52,9 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
simtime_t smallestDuration;
simtime_t largestDuration;
simtime_t biggestEarliestProcessingTime;
IEvent* biggestEarliestProcessingTimeEvent;
std::set<ptr_t> cachedParallelSet;
IEvent* lastSelected;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment