Commit bcffd494 authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart] first steps towards REAL_TIME visualization.

parent 76c7d000
......@@ -607,6 +607,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
addSubMenuItem(menu, "Event number", SequenceChart.TimelineMode.EVENT_NUMBER);
addSubMenuItem(menu, "Step", SequenceChart.TimelineMode.STEP);
addSubMenuItem(menu, "Nonlinear", SequenceChart.TimelineMode.NONLINEAR);
addSubMenuItem(menu, "Real Time", SequenceChart.TimelineMode.REAL_TIME);
MenuItem subMenuItem = new MenuItem(menu, SWT.RADIO);
subMenuItem.setText("Custom nonlinear...");
......@@ -630,7 +631,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
if (menuItem.getSelection()) {
sequenceChart.setTimelineMode(timelineMode);
timelineModeStatus.update();
if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME) {
if(timelineMode != SequenceChart.TimelineMode.SIMULATION_TIME && timelineMode != SequenceChart.TimelineMode.REAL_TIME) {
sequenceChart.setEventLengthMode(SequenceChart.EventLengthMode.NONE);
}
update();
......@@ -729,7 +730,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
if (menuItem.getSelection()) {
sequenceChart.setEventLengthMode(eventLengthMode);
if (eventLengthMode != SequenceChart.EventLengthMode.NONE){
if (eventLengthMode == SequenceChart.EventLengthMode.DURATION){
sequenceChart.setTimelineMode(SequenceChart.TimelineMode.SIMULATION_TIME);
timelineModeStatus.update();
}
......
......@@ -311,7 +311,8 @@ public class SequenceChart
SIMULATION_TIME,
EVENT_NUMBER,
STEP,
NONLINEAR
NONLINEAR,
REAL_TIME
}
/**
......
......@@ -76,7 +76,7 @@ void Event::clearInternalState()
eventLogEntries.clear();
earliestProcessingTime = 0;
_earliestProcessingTime = 0;
}
void Event::synchronize()
......@@ -438,3 +438,10 @@ Event *Event::getReuserEvent(int &beginSendEntryNumber)
beginSendEntryNumber = -1;
return NULL;
}
long Event::getEarliestProcessingTime() {
return _earliestProcessingTime;
}
long Event::getEarliestStartTime() {
return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
}
......@@ -108,6 +108,10 @@ class EVENTLOG_API Event : public IEvent
virtual void print(FILE *file = stdout, bool outputEventLogMessages = true);
virtual long getEarliestProcessingTime();
virtual long getEarliestStartTime();
protected:
void deleteAllocatedObjects();
void clearInternalState();
......
......@@ -103,7 +103,8 @@ enum TimelineMode {
SIMULATION_TIME,
EVENT_NUMBER,
STEP,
NONLINEAR
NONLINEAR,
REAL_TIME
};
NAMESPACE_END
......
......@@ -315,3 +315,9 @@ void FilteredEvent::pushNewFilteredMessageDependency(IMessageDependencyList *mes
messageDependencies->push_back(newMessageDependency);
}
long FilteredEvent::getEarliestProcessingTime() {
return _earliestProcessingTime;
}
long FilteredEvent::getEarliestStartTime() {
return ((_earliestProcessingTime == 0) ? 0 : _earliestProcessingTime - getComplexity());
}
......@@ -108,6 +108,9 @@ class EVENTLOG_API FilteredEvent : public IEvent
void getConsequences(IEvent *event, IMessageDependency *beginMessageDependency, bool isReuse, int level);
int countFilteredMessageDependencies(IMessageDependencyList *messageDependencies);
void pushNewFilteredMessageDependency(IMessageDependencyList *messageDependencies, bool isReuse, IMessageDependency *beginMessageDependency, IMessageDependency *endMessageDependency);
virtual long getEarliestProcessingTime();
virtual long getEarliestStartTime();
};
NAMESPACE_END
......
......@@ -35,7 +35,7 @@ class EVENTLOG_API IEvent
double cachedTimelineCoordinate;
long cachedTimelineCoordinateSystemVersion;
long earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
long _earliestProcessingTime; //The earliest time the event can be finished, as defined in "A Critical Path Tool for Parallel Simulation Performance Optimization"
......@@ -110,7 +110,9 @@ class EVENTLOG_API IEvent
virtual IMessageDependencyList *getCauses() = 0;
virtual IMessageDependencyList *getConsequences() = 0;
/**
/** public int getEarliestProcessingTime() {
return EventLogEngineJNI.IEvent_earliestProcessingTime_get(swigCPtr, this);
}
* Print all entries of this event.
*/
virtual void print(FILE *file = stdout, bool outputEventLogMessages = true) = 0;
......@@ -143,6 +145,9 @@ class EVENTLOG_API IEvent
*/
static void linkEvents(IEvent *previousEvent, IEvent *nextEvent);
static void unlinkEvents(IEvent *previousEvent, IEvent *nextEvent);
virtual long getEarliestProcessingTime() = 0;
virtual long getEarliestStartTime() = 0;
};
NAMESPACE_END
......
......@@ -100,6 +100,7 @@ void SequenceChartFacade::undefineTimelineCoordinateSystem()
timelineCoordinateSystemVersion++;
timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = -1;
timelineCoordinateOriginSimulationTime = simtime_nil;
timelineCoordinateOriginRealTime = 0;
}
void SequenceChartFacade::relocateTimelineCoordinateSystem(IEvent *event)
......@@ -109,6 +110,7 @@ void SequenceChartFacade::relocateTimelineCoordinateSystem(IEvent *event)
timelineCoordinateSystemVersion++;
timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = event->getEventNumber();
timelineCoordinateOriginSimulationTime = event->getSimulationTime();
timelineCoordinateOriginRealTime = event->getEarliestStartTime();
event->cachedTimelineCoordinate = 0;
event->cachedTimelineCoordinateSystemVersion = timelineCoordinateSystemVersion;
}
......@@ -166,6 +168,9 @@ double SequenceChartFacade::getTimelineCoordinate(IEvent *event, double lowerTim
double timelineCoordinate;
switch (timelineMode) {
case REAL_TIME:
timelineCoordinate = ((event->getEarliestStartTime() - timelineCoordinateOriginRealTime));
break;
case SIMULATION_TIME:
timelineCoordinate = (event->getSimulationTime() - timelineCoordinateOriginSimulationTime).dbl();
break;
......@@ -241,6 +246,9 @@ double SequenceChartFacade::getTimelineEventEndCoordinate(IEvent *event, double
}
double timelineEventEndCoordinate;
switch (timelineMode) {
case REAL_TIME:
timelineEventEndCoordinate = (event->getEarliestProcessingTime() - timelineCoordinateOriginRealTime);
break;
case SIMULATION_TIME:
timelineEventEndCoordinate = (event->getSimulationTime()+event->getEventEntry()->duration - timelineCoordinateOriginSimulationTime).dbl();
break;
......@@ -302,6 +310,19 @@ IEvent *SequenceChartFacade::getLastEventNotAfterTimelineCoordinate(double timel
return NULL;
switch (timelineMode) {
case REAL_TIME:
{
//TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
IEvent* res = eventLog->getFirstEvent();
for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
if ((double) current->getEarliestStartTime() < timelineCoordinate) {
if (current->getEarliestStartTime() > res->getEarliestStartTime()) {
res = current;
}
}
}
return res;
}
case SIMULATION_TIME:
return eventLog->getLastEventNotAfterSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
case EVENT_NUMBER:
......@@ -334,6 +355,19 @@ IEvent *SequenceChartFacade::getFirstEventNotBeforeTimelineCoordinate(double tim
return NULL;
switch (timelineMode) {
case REAL_TIME:
{
//TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
IEvent* res = eventLog->getLastEvent();
for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
if ((double) current->getEarliestStartTime() > timelineCoordinate) {
if (current->getEarliestStartTime() < res->getEarliestStartTime()) {
res = current;
}
}
}
return res;
}
case SIMULATION_TIME:
return eventLog->getFirstEventNotBeforeSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
case EVENT_NUMBER:
......@@ -366,6 +400,8 @@ void SequenceChartFacade::extractSimulationTimesAndTimelineCoordinates(
simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
simtime_t &simulationTimeDelta, double &timelineCoordinateDelta)
{
//TODO: REAL_TIME
// if before the first event
if (event) {
eventSimulationTime = event->getSimulationTime();
......@@ -405,6 +441,13 @@ simtime_t SequenceChartFacade::getSimulationTimeForTimelineCoordinate(double tim
switch (timelineMode)
{
case REAL_TIME:
{
simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime()/1000000.0); //TODO: Change this to getEarliestStartTime();
//NOTE: This sometimes crashes the Sequencechart because the returned value might be too big
simulationTime = max(BigDecimal::Zero, min(lastEventSimulationTime, (timelineCoordinate + timelineCoordinateOriginRealTime)/1000000.0));
}
//Fall back to SIMULATION_TIME (TODO)
case SIMULATION_TIME:
{
simtime_t lastEventSimulationTime = eventLog->getLastEvent()->getSimulationTime();
......@@ -468,6 +511,8 @@ double SequenceChartFacade::getTimelineCoordinateForSimulationTime(simtime_t sim
switch (timelineMode)
{
case REAL_TIME:
//Fall back to SIMULATION_TIME (TODO)
case SIMULATION_TIME:
timelineCoordinate = (simulationTime - timelineCoordinateOriginSimulationTime).dbl();
break;
......@@ -892,7 +937,7 @@ void SequenceChartFacade::calculateCriticalPath() {
simtime_t startTime = current->getSimulationTime();
int moduleId = current->getModuleId();
if(current->getEventEndEntry()) {
current->earliestProcessingTime = current->getComplexity();
current->_earliestProcessingTime = current->getComplexity();
}
for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
if(antecessor==current) {
......@@ -901,13 +946,13 @@ void SequenceChartFacade::calculateCriticalPath() {
if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
continue; // Check if this is an antecesor
}
if(antecessor->earliestProcessingTime+current->getComplexity() > current->earliestProcessingTime) {
current->earliestProcessingTime = antecessor->earliestProcessingTime+current->getComplexity();
if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
}
}
// Memorize max event
if (maxEarliestProcessingTime < current->earliestProcessingTime) {
maxEarliestProcessingTime = current->earliestProcessingTime;
if (maxEarliestProcessingTime < current->_earliestProcessingTime) {
maxEarliestProcessingTime = current->_earliestProcessingTime;
maxEarliestProcessingTimeEvent = current;
}
}
......
......@@ -39,6 +39,7 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
long timelineCoordinateSystemVersion;
eventnumber_t timelineCoordinateOriginEventNumber;
simtime_t timelineCoordinateOriginSimulationTime;
long timelineCoordinateOriginRealTime;
eventnumber_t timelineCoordinateRangeStartEventNumber;
eventnumber_t timelineCoordinateRangeEndEventNumber;
TimelineMode timelineMode;
......
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