Commit 8aeaaccc authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

- further work on REAL TIME Visualization
parent 0596ce67
......@@ -632,7 +632,10 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
sequenceChart.setTimelineMode(timelineMode);
timelineModeStatus.update();
if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME && timelineMode != SequenceChart.TimelineMode.REAL_TIME) {
sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
}
if (timelineMode == SequenceChart.TimelineMode.REAL_TIME) {
sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.COMPLEXITY);
}
update();
}
......
......@@ -1797,6 +1797,7 @@ public class SequenceChart
if (debug)
Debug.println("Collecting axis modules for module method calls using event range: " + sequenceChartFacade.IEvent_getEventNumber(startEventPtr) + " -> " + sequenceChartFacade.IEvent_getEventNumber(endEventPtr));
PtrVector moduleMethodBeginEntries = sequenceChartFacade.getModuleMethodBeginEntries(startEventPtr, endEventPtr);
for (int i = 0; i < moduleMethodBeginEntries.size(); i++) {
......@@ -2578,28 +2579,36 @@ public class SequenceChart
fillZeroSimulationTimeRegion(graphics, r, clip, x, startX - x);
}
// draw rectangles where simulation time has not elapsed between events
for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade.IEvent_getNextEvent(eventPtr)) {
if (previousEventPtr != -1) {
x = getEventXViewportCoordinate(eventPtr);
long previousX = getEventXViewportCoordinate(previousEventPtr);
org.omnetpp.common.engine.BigDecimal simulationTime = sequenceChartFacade.IEvent_getSimulationTime(eventPtr);
org.omnetpp.common.engine.BigDecimal previousSimulationTime = sequenceChartFacade.IEvent_getSimulationTime(previousEventPtr);
if (simulationTime.equals(previousSimulationTime) && x != previousX)
fillZeroSimulationTimeRegion(graphics, r, clip, previousX, x - previousX);
}
// draw rectangles where simulation time has not elapsed between
// events
if (getTimelineMode() != TimelineMode.REAL_TIME) {
for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade
.IEvent_getNextEvent(eventPtr)) {
if (previousEventPtr != -1) {
x = getEventXViewportCoordinate(eventPtr);
long previousX = getEventXViewportCoordinate(previousEventPtr);
org.omnetpp.common.engine.BigDecimal simulationTime = sequenceChartFacade
.IEvent_getSimulationTime(eventPtr);
org.omnetpp.common.engine.BigDecimal previousSimulationTime = sequenceChartFacade
.IEvent_getSimulationTime(previousEventPtr);
if (simulationTime.equals(previousSimulationTime)
&& x != previousX)
fillZeroSimulationTimeRegion(graphics, r, clip,
previousX, x - previousX);
}
previousEventPtr = eventPtr;
previousEventPtr = eventPtr;
if (eventPtr == endEventPtr)
break;
if (eventPtr == endEventPtr)
break;
}
}
// draw rectangle after the very end of the simulation
if (sequenceChartFacade.IEvent_getNextEvent(endEventPtr) == 0) {
x = clip.right();
long endX = getEventXViewportCoordinate(endEventPtr);
long largestEvent = sequenceChartFacade.getLargestEndtimeInEventRange(startEventPtr,endEventPtr);
long endX = getEventXViewportCoordinate(largestEvent) + getEventLength(largestEvent) - 2;
if (x != endX)
fillZeroSimulationTimeRegion(graphics, r, clip, endX, x - endX);
......@@ -2997,7 +3006,17 @@ public class SequenceChart
calculateTicks(getViewportWidth());
IEvent lastEvent = eventLog.getLastEvent();
org.omnetpp.common.engine.BigDecimal endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime();
org.omnetpp.common.engine.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 ? org.omnetpp.common.engine.BigDecimal.getZero() : new org.omnetpp.common.engine.BigDecimal(lastEvent.getEarliestProcessingTime()/1000000.0);
//} else if (getEventLengthMode() == EventLengthMode.DURATION){
// endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime().add(lastEvent.getEventEntry().getDuration());
} else {
endSimulationTime = lastEvent == null ? org.omnetpp.common.engine.BigDecimal.getZero() : lastEvent.getSimulationTime();
}
for (BigDecimal tick : ticks) {
// BigDecimal to double conversions loose precision both in Java and C++ but we must stick to the one in C++
......@@ -3835,6 +3854,15 @@ public class SequenceChart
if (eventLog == null || eventLog.isEmpty() || eventLog.getApproximateNumberOfEvents() == 0)
return new long[] {0, 0};
else {
//Fix for REAL_TIME Visualization:
//In this mode, events are not necessarily ordered in event number order so
//that an interval of visible events may not be correct.
//fix it by just returning the interval of all events.
if (getTimelineMode() == TimelineMode.REAL_TIME){
return new long[] { eventLog.getFirstEvent().getCPtr(), eventLog.getLastEvent().getCPtr() };
}
double leftTimelineCoordinate = getTimelineCoordinateForViewportCoordinate(x1);
double rightTimelineCoordinate = getTimelineCoordinateForViewportCoordinate(x2);
......@@ -3845,7 +3873,7 @@ public class SequenceChart
IEvent endEvent = sequenceChartFacade.getFirstEventNotBeforeTimelineCoordinate(rightTimelineCoordinate);
if (endEvent == null)
endEvent = eventLog.getLastEvent();
return new long[] {startEvent == null ? 0 : startEvent.getCPtr(), endEvent == null ? 0 : endEvent.getCPtr()};
}
}
......@@ -3956,7 +3984,17 @@ public class SequenceChart
IEvent lastEvent = eventLog.getLastEvent();
if (lastEvent != null) {
BigDecimal endSimulationTime = lastEvent.getSimulationTime().toBigDecimal();
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);
} else if (getEventLengthMode() == EventLengthMode.DURATION){
endSimulationTime = lastEvent == null ? BigDecimal.ZERO : lastEvent.getSimulationTime().toBigDecimal().add(lastEvent.getEventEntry().getDuration().toBigDecimal());
} else {
endSimulationTime = lastEvent == null ? BigDecimal.ZERO : lastEvent.getSimulationTime().toBigDecimal();
}
for (long t = tleft; t < tright; t += TICK_SPACING) {
BigDecimal tick = calculateTick(t, TICK_SPACING / 2);
......
......@@ -984,3 +984,34 @@ void SequenceChartFacade::calculateCriticalPath() {
}
}
ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr) {
IEvent *startEvent = (IEvent *)startEventPtr;
IEvent *endEvent = (IEvent *)endEventPtr;
switch (timelineMode)
{
case REAL_TIME:
{
long largest = 0;
IEvent* largestEvent = startEvent;
for (IEvent* current = startEvent; current; current = current->getNextEvent()) {
long temp = current->getEarliestProcessingTime();
if (temp > largest) {
largest = temp;
largestEvent = current;
}
if (current==endEvent) {
break;
}
}
return (ptr_t) largestEvent;
}
case SIMULATION_TIME:
case EVENT_NUMBER:
case STEP:
case NONLINEAR:
default:
return endEventPtr;
}
}
......@@ -123,6 +123,8 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
bool isOnCriticalPath(IEvent* event);
ptr_t getLargestEndtimeInEventRange(ptr_t startEventPtr, ptr_t endEventPtr);
/**
* Timeline coordinate can be given in the range (-infinity, +infinity).
* Simulation time will be in the range [0, lastEventSimulationTime].
......@@ -156,6 +158,8 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
simtime_t getSmallestParallelEndtime(IEvent* event);
void calculateCriticalPath();
};
NAMESPACE_END
......
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