Esempio n. 1
0
 void invokeDataEvent( adicontroller::SignalObserver::Observer * o, unsigned int events, unsigned int pos ) override {
     for ( auto& dataEvent : dataEventHandler_ )
         dataEvent( o, events, pos );
 }
static std::unique_ptr<TraceEventList>
CreateTestEvents(TraceEvent::TimeStamp timeStampOffset)
{
    const TraceEvent::TimeStamp ms = ArchSecondsToTicks(0.001);
    timeStampOffset += ms;
    std::unique_ptr<TraceEventList> events(new TraceEventList);

    static constexpr TraceStaticKeyData counterKey("Test Counter");
    {
        TraceEvent counterEvent(
            TraceEvent::CounterDelta,
            counterKey,
            1,
            TraceCategory::Default
        );
        counterEvent.SetTimeStamp(2*ms + timeStampOffset);
        events->EmplaceBack(std::move(counterEvent));
    }

    events->EmplaceBack(
        TraceEvent::Begin,
        events->CacheKey("Inner Scope 2"),
        3*ms + timeStampOffset,
        TestCategory
    );
    events->EmplaceBack(
        TraceEvent::End,
        events->CacheKey("Inner Scope 2"),
        4*ms + timeStampOffset,
        TestCategory
    );

    {
        bool data = true;
        TraceEvent dataEvent(
            TraceEvent::Data,
            events->CacheKey("Test Data 0"),
            data,
            TraceCategory::Default
        );
        dataEvent.SetTimeStamp(5*ms+timeStampOffset);
        events->EmplaceBack(std::move(dataEvent));
    }
    {
        int data = -2;
        TraceEvent dataEvent(
            TraceEvent::Data,
            events->CacheKey("Test Data 1"),
            data,
            TraceCategory::Default
        );
        dataEvent.SetTimeStamp(6*ms+timeStampOffset);
        events->EmplaceBack(std::move(dataEvent));
    }
    {
        uint64_t data = ~0;
        TraceEvent dataEvent(
            TraceEvent::Data,
            events->CacheKey("Test Data 2"),
            data,
            TraceCategory::Default
        );
        dataEvent.SetTimeStamp(7*ms+timeStampOffset);
        events->EmplaceBack(std::move(dataEvent));
    }
    {
        double data = 1.5;
        TraceEvent dataEvent(
            TraceEvent::Data,
            events->CacheKey("Test Data 3"),
            data,
            TraceCategory::Default
        );
        dataEvent.SetTimeStamp(8*ms+timeStampOffset);
        events->EmplaceBack(std::move(dataEvent));
    }
    {
        std::string data = "String Data";
        TraceEvent dataEvent(
            TraceEvent::Data,
            events->CacheKey("Test Data 4"),
            events->StoreData(data.c_str()),
            TraceCategory::Default
        );
        dataEvent.SetTimeStamp(9*ms+timeStampOffset);
        events->EmplaceBack(std::move(dataEvent));
    }

    static constexpr TraceStaticKeyData keyInner("InnerScope");
    events->EmplaceBack(TraceEvent::Timespan, keyInner,
        ms + timeStampOffset,
        10*ms + timeStampOffset,
        TraceCategory::Default);


    {
        TraceEvent counterEvent(
            TraceEvent::CounterDelta,
            counterKey,
            1,
            TraceCategory::Default
        );
        counterEvent.SetTimeStamp(11*ms + timeStampOffset);
        events->EmplaceBack(std::move(counterEvent));
    }
    {
        TraceEvent counterEvent(
            TraceEvent::CounterValue,
            counterKey,
            -1,
            TraceCategory::Default
        );
        counterEvent.SetTimeStamp(12*ms + timeStampOffset);
        events->EmplaceBack(std::move(counterEvent));
    }
    static constexpr TraceStaticKeyData keyOuter("OuterScope");
    events->EmplaceBack(TraceEvent::Timespan, keyOuter,
        0 + timeStampOffset,
        13*ms + timeStampOffset,
        TraceCategory::Default);

    events->EmplaceBack(
        TraceEvent::Marker,
        events->CacheKey("Test Marker 1"),
        4*ms + timeStampOffset,
        TraceCategory::Default
    );

    events->EmplaceBack(
        TraceEvent::Marker,
        events->CacheKey("Test Marker 2"),
        5*ms + timeStampOffset,
        TraceCategory::Default
    );
    return events;
}