Project

General

Profile

Revision bcffd494

IDbcffd49434291c7f2c503d1832bad45a6585e824

Added by Simon Tenbusch almost 9 years ago

[sequencechart] first steps towards REAL_TIME visualization.

View differences:

src/eventlog/sequencechartfacade.cc
100 100
    timelineCoordinateSystemVersion++;
101 101
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = -1;
102 102
    timelineCoordinateOriginSimulationTime = simtime_nil;
103
    timelineCoordinateOriginRealTime = 0;
103 104
}
104 105

  
105 106
void SequenceChartFacade::relocateTimelineCoordinateSystem(IEvent *event)
......
109 110
    timelineCoordinateSystemVersion++;
110 111
    timelineCoordinateOriginEventNumber = timelineCoordinateRangeStartEventNumber = timelineCoordinateRangeEndEventNumber = event->getEventNumber();
111 112
    timelineCoordinateOriginSimulationTime = event->getSimulationTime();
113
    timelineCoordinateOriginRealTime = event->getEarliestStartTime();
112 114
    event->cachedTimelineCoordinate = 0;
113 115
    event->cachedTimelineCoordinateSystemVersion = timelineCoordinateSystemVersion;
114 116
}
......
166 168
        double timelineCoordinate;
167 169

  
168 170
        switch (timelineMode) {
171
            case REAL_TIME:
172
                timelineCoordinate = ((event->getEarliestStartTime() - timelineCoordinateOriginRealTime));
173
                break;
169 174
            case SIMULATION_TIME:
170 175
                timelineCoordinate = (event->getSimulationTime() - timelineCoordinateOriginSimulationTime).dbl();
171 176
                break;
......
241 246
    }
242 247
        double timelineEventEndCoordinate;
243 248
        switch (timelineMode) {
249
            case REAL_TIME:
250
                timelineEventEndCoordinate = (event->getEarliestProcessingTime() - timelineCoordinateOriginRealTime);
251
                break;
244 252
            case SIMULATION_TIME:
245 253
                timelineEventEndCoordinate = (event->getSimulationTime()+event->getEventEntry()->duration - timelineCoordinateOriginSimulationTime).dbl();
246 254
                break;
......
302 310
        return NULL;
303 311

  
304 312
    switch (timelineMode) {
313
        case REAL_TIME:
314
        {
315
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
316
            IEvent* res = eventLog->getFirstEvent();
317
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
318
                if ((double) current->getEarliestStartTime() < timelineCoordinate) {
319
                    if (current->getEarliestStartTime() > res->getEarliestStartTime()) {
320
                        res = current;
321
                    }
322
                }
323
            }
324
            return res;
325
        }
305 326
        case SIMULATION_TIME:
306 327
            return eventLog->getLastEventNotAfterSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
307 328
        case EVENT_NUMBER:
......
334 355
        return NULL;
335 356

  
336 357
    switch (timelineMode) {
358
        case REAL_TIME:
359
        {
360
            //TODO MAKE THIS MORE EFFICIENT (i.e. sorted data structure)!
361
            IEvent* res = eventLog->getLastEvent();
362
            for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
363
                if ((double) current->getEarliestStartTime() > timelineCoordinate) {
364
                    if (current->getEarliestStartTime() < res->getEarliestStartTime()) {
365
                        res = current;
366
                    }
367
                }
368
            }
369
            return res;
370
        }
337 371
        case SIMULATION_TIME:
338 372
            return eventLog->getFirstEventNotBeforeSimulationTime(getSimulationTimeForTimelineCoordinate(timelineCoordinate));
339 373
        case EVENT_NUMBER:
......
366 400
    simtime_t &nextEventSimulationTime, double &nextEventTimelineCoordinate,
367 401
    simtime_t &simulationTimeDelta, double &timelineCoordinateDelta)
368 402
{
403
    //TODO: REAL_TIME
404

  
369 405
    // if before the first event
370 406
    if (event) {
371 407
        eventSimulationTime = event->getSimulationTime();
......
405 441

  
406 442
    switch (timelineMode)
407 443
    {
444
        case REAL_TIME:
445
        {
446
            simtime_t lastEventSimulationTime = (eventLog->getLastEvent()->getEarliestStartTime()/1000000.0); //TODO: Change this to getEarliestStartTime();
447
            //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));
449
        }
450
            //Fall back to SIMULATION_TIME (TODO)
408 451
        case SIMULATION_TIME:
409 452
            {
410 453
                simtime_t lastEventSimulationTime = eventLog->getLastEvent()->getSimulationTime();
......
468 511

  
469 512
    switch (timelineMode)
470 513
    {
514
        case REAL_TIME:
515
        //Fall back to SIMULATION_TIME (TODO)
471 516
        case SIMULATION_TIME:
472 517
            timelineCoordinate = (simulationTime - timelineCoordinateOriginSimulationTime).dbl();
473 518
            break;
......
892 937
        simtime_t startTime = current->getSimulationTime();
893 938
        int moduleId = current->getModuleId();
894 939
        if(current->getEventEndEntry()) {
895
            current->earliestProcessingTime = current->getComplexity();
940
            current->_earliestProcessingTime = current->getComplexity();
896 941
        }
897 942
        for (IEvent *antecessor = eventLog->getFirstEvent(); antecessor; antecessor = antecessor->getNextEvent()) {
898 943
            if(antecessor==current) {
......
901 946
            if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
902 947
                continue; // Check if this is an antecesor
903 948
            }
904
            if(antecessor->earliestProcessingTime+current->getComplexity() > current->earliestProcessingTime) {
905
                current->earliestProcessingTime = antecessor->earliestProcessingTime+current->getComplexity();
949
            if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
950
                current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
906 951
            }
907 952
        }
908 953
        // Memorize max event
909
        if (maxEarliestProcessingTime < current->earliestProcessingTime) {
910
            maxEarliestProcessingTime = current->earliestProcessingTime;
954
        if (maxEarliestProcessingTime < current->_earliestProcessingTime) {
955
            maxEarliestProcessingTime = current->_earliestProcessingTime;
911 956
            maxEarliestProcessingTimeEvent = current;
912 957
        }
913 958
    }

Also available in: Unified diff