当前位置: 首页>>代码示例>>C++>>正文


C++ TimeInterval类代码示例

本文整理汇总了C++中TimeInterval的典型用法代码示例。如果您正苦于以下问题:C++ TimeInterval类的具体用法?C++ TimeInterval怎么用?C++ TimeInterval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TimeInterval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PrintStats

void UniverseTracker::PrintStats() {
  UniverseStatsMap::iterator iter = m_stats.begin();
  TimeStamp now;
  m_clock.CurrentTime(&now);

  TimeInterval interval = now - m_start_time;
  OLA_INFO << "Time delta was " << interval;

  for (; iter != m_stats.end(); ++iter) {
    const UniverseStats stats = iter->second;

    float fps = 0.0;
    if (interval.Seconds() > 0)
      fps = static_cast<float>(stats.frame_count) / interval.Seconds();

    cout << "Universe " << iter->first << endl;
    cout << "  Frames Received: " << stats.frame_count <<
      ", Frames/sec: " << fps << endl;
    cout << "  Frame changes: " << stats.frame_changes << endl;
    cout << "  Smallest Frame: ";
    if (stats.shortest_frame == DMX_UNIVERSE_SIZE + 1)
      cout << "N/A";
    else
      cout << stats.shortest_frame;
    cout << ", Largest Frame: ";
    if (stats.longest_frame == 0)
      cout << "N/A";
    else
      cout << stats.longest_frame;
    cout << endl;
    cout << "------------------------------" << endl;
  }
}
开发者ID:queenvictoria,项目名称:ola,代码行数:33,代码来源:ola-uni-stats.cpp

示例2: begin

/**  Returns an intersection of this interval with \a ti
     @param ti :: Time interval
     @return A valid time interval if this interval intersects with \a ti or
             an empty interval otherwise.
 */
TimeInterval TimeInterval::intersection(const TimeInterval& ti)const
{
    if (!isValid() || !ti.isValid()) return TimeInterval();

    DateAndTime t1 = begin();
    if (ti.begin() > t1) t1 = ti.begin();

    DateAndTime t2 = end();
    if (ti.end() < t2) t2 = ti.end();

    return t1 < t2? TimeInterval(t1,t2) : TimeInterval();

}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例3: timeout_manager

/*
 * Check RegisterSingleTimeout works.
 */
void TimeoutManagerTest::testSingleTimeouts() {
  MockClock clock;
  TimeoutManager timeout_manager(&m_map, &clock);

  OLA_ASSERT_FALSE(timeout_manager.EventsPending());

  TimeInterval timeout_interval(1, 0);
  timeout_id id1 = timeout_manager.RegisterSingleTimeout(
      timeout_interval,
      NewSingleCallback(this, &TimeoutManagerTest::HandleEvent, 1u));
  OLA_ASSERT_NE(id1, ola::thread::INVALID_TIMEOUT);

  TimeStamp last_checked_time;

  clock.AdvanceTime(0, 1);  // Small offset to work around timer precision
  clock.CurrentTime(&last_checked_time);
  TimeInterval next = timeout_manager.ExecuteTimeouts(&last_checked_time);
  OLA_ASSERT_EQ(0u, GetEventCounter(1));
  OLA_ASSERT_LT(next, timeout_interval);

  clock.AdvanceTime(0, 500000);
  clock.CurrentTime(&last_checked_time);
  next = timeout_manager.ExecuteTimeouts(&last_checked_time);
  OLA_ASSERT_EQ(0u, GetEventCounter(1));
  OLA_ASSERT_LT(next, TimeInterval(0, 500000));

  clock.AdvanceTime(0, 500000);
  clock.CurrentTime(&last_checked_time);
  next = timeout_manager.ExecuteTimeouts(&last_checked_time);
  OLA_ASSERT_TRUE(next.IsZero());
  OLA_ASSERT_EQ(1u, GetEventCounter(1));

  OLA_ASSERT_FALSE(timeout_manager.EventsPending());

  // now add another timeout and then remove it
  timeout_id id2 = timeout_manager.RegisterSingleTimeout(
      timeout_interval,
      NewSingleCallback(this, &TimeoutManagerTest::HandleEvent, 2u));
  OLA_ASSERT_NE(id2, ola::thread::INVALID_TIMEOUT);
  OLA_ASSERT_TRUE(timeout_manager.EventsPending());
  OLA_ASSERT_EQ(0u, GetEventCounter(2));

  timeout_manager.CancelTimeout(id2);

  clock.AdvanceTime(1, 0);
  clock.CurrentTime(&last_checked_time);
  next = timeout_manager.ExecuteTimeouts(&last_checked_time);
  OLA_ASSERT_FALSE(timeout_manager.EventsPending());
  OLA_ASSERT_EQ(0u, GetEventCounter(2));
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:53,代码来源:TimeoutManagerTest.cpp

示例4: LogTime

void Tracker::LogTime() {
  TimeStamp now;
  m_clock.CurrentTime(&now);
  TimeInterval delta = now - m_send_time;
  if (delta > m_max) {
    m_max = delta;
  }
  m_sum += delta.MicroSeconds();

  OLA_INFO << "RPC took " << delta;
  if (FLAGS_count == ++m_count) {
    m_wrapper.GetSelectServer()->Terminate();
  } else {
    SendRequest();
  }
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:16,代码来源:ola-latency.cpp

示例5: similar

void GroupableTimeSeriesSet::similar(GroupableTimeSeriesSet *other, int otherSeq, TimeInterval otherInt,
                                     SearchStrategy strat, int warps)
{
    if (!valid() || !other->valid()) {
        session->geterr() << "Warning: Attempted to find similarities using an invalid database." << endl;
        return;
    }

    if (grouping == NULL) {
        session->geterr() << "Warning: Attempted to find similarities on ungrouped dataset." << endl;
        return;
    }

    kBest best = grouping->getBestInterval(otherInt.length(),
                                           other->dataset->getRawData(otherSeq, otherInt.start),
                                           strat, warps);

    session->getout() << "Found most similar interval." << endl;
    session->getout() << "Sequence number and interval: " << best.seq << "@"
                      << "[" << best.interval.start << ", " << best.interval.end << "]." << endl;
    session->getout() << "Distance: " << best.dist << endl;
    if (verbosity > 0) {
        session->getout() << "Sequence: " << endl;
        dataset->printInterval(session->getout(), best.seq, best.interval);
    }
}
开发者ID:Samee-Swartz,项目名称:researchProjectWebapp,代码行数:26,代码来源:OnlineSession.cpp

示例6: usleep

/**
 * Check the granularity of usleep.
 */
void UartDmxThread::CheckTimeGranularity() {
  TimeStamp ts1, ts2;
  Clock clock;
  /** If sleeping for 1ms takes longer than this, don't trust
   * usleep for this session
   */
  const int threshold = 3;

  clock.CurrentTime(&ts1);
  usleep(1000);
  clock.CurrentTime(&ts2);

  TimeInterval interval = ts2 - ts1;
  m_granularity = interval.InMilliSeconds() > threshold ? BAD : GOOD;
  OLA_INFO << "Granularity for UART thread is "
           << (m_granularity == GOOD ? "GOOD" : "BAD");
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:20,代码来源:UartDmxThread.cpp

示例7: onAnimationIntervalChanged

/******************************************************************************
* This is called when the active animation interval has changed.
******************************************************************************/
void ActionManager::onAnimationIntervalChanged(TimeInterval newAnimationInterval)
{
	bool isAnimationInterval = newAnimationInterval.duration() != 0;
	getAction(ACTION_GOTO_START_OF_ANIMATION)->setEnabled(isAnimationInterval);
	getAction(ACTION_GOTO_PREVIOUS_FRAME)->setEnabled(isAnimationInterval);
	getAction(ACTION_TOGGLE_ANIMATION_PLAYBACK)->setEnabled(isAnimationInterval);
	getAction(ACTION_GOTO_NEXT_FRAME)->setEnabled(isAnimationInterval);
	getAction(ACTION_GOTO_END_OF_ANIMATION)->setEnabled(isAnimationInterval);
}
开发者ID:taohonker,项目名称:Ovito,代码行数:12,代码来源:ActionManager.cpp

示例8: interval

TimeInterval
MediaSourceDecoder::ClampIntervalToEnd(const TimeInterval& aInterval)
{
  if (!mEnded) {
    return aInterval;
  }
  TimeInterval interval(TimeUnit(), TimeUnit::FromSeconds(GetDuration()));
  return aInterval.Intersection(interval);
}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:9,代码来源:MediaSourceDecoder.cpp

示例9: SetUpReconnectTimeout

void AvahiDiscoveryAgent::SetUpReconnectTimeout() {
  // We don't strictly need an ExponentialBackoffPolicy here because the client
  // goes into the AVAHI_CLIENT_CONNECTING state if the server isn't running.
  // Still, it's a useful defense against spinning rapidly if something goes
  // wrong.
  TimeInterval delay = m_backoff.Next();
  OLA_INFO << "Re-creating avahi client in " << delay << "s";
  struct timeval tv;
  delay.AsTimeval(&tv);

  const AvahiPoll *poll = avahi_threaded_poll_get(m_threaded_poll);
  if (m_reconnect_timeout) {
    poll->timeout_update(m_reconnect_timeout, &tv);
  } else {
    m_reconnect_timeout = poll->timeout_new(
        avahi_threaded_poll_get(m_threaded_poll),
        &tv,
        reconnect_callback,
        this);
  }
}
开发者ID:FloEdelmann,项目名称:ola,代码行数:21,代码来源:AvahiDiscoveryAgent.cpp

示例10: DisplayDebug

/*
 * Display the debug page
 * @param request the HttpRequest
 * @param response the HttpResponse
 * @returns MHD_NO or MHD_YES
 */
int OlaHttpServer::DisplayDebug(const HttpRequest *request,
                                HttpResponse *response) {
    TimeStamp now;
    m_clock.CurrentTime(&now);
    TimeInterval diff = now - m_start_time;
    stringstream str;
    str << (diff.AsInt() / 1000);
    m_export_map->GetStringVar(K_UPTIME_VAR)->Set(str.str());

    vector<BaseVariable*> variables = m_export_map->AllVariables();
    response->SetContentType(HttpServer::CONTENT_TYPE_PLAIN);

    vector<BaseVariable*>::iterator iter;
    for (iter = variables.begin(); iter != variables.end(); ++iter) {
        stringstream out;
        out << (*iter)->Name() << ": " << (*iter)->Value() << "\n";
        response->Append(out.str());
    }
    int r = response->Send();
    delete response;
    return r;
    (void) request;
}
开发者ID:huyanming,项目名称:open-lighting,代码行数:29,代码来源:OlaHttpServer.cpp

示例11: returnSimilar

kBest GroupableTimeSeriesSet::returnSimilar(GroupableTimeSeriesSet *other, int otherSeq, TimeInterval otherInt,
                                     SearchStrategy strat, int warps)
{
    if (!valid() || !other->valid()) {
        session->geterr() << "Warning: Attempted to find similarities using an invalid database." << endl;
        return;
    }

    if (grouping == NULL) {
        session->geterr() << "Warning: Attempted to find similarities on ungrouped dataset." << endl;
        return;
    }

    return grouping->getBestInterval(otherInt.length(),
                                           other->dataset->getRawData(otherSeq, otherInt.start),
                                           strat, warps);

}
开发者ID:Samee-Swartz,项目名称:researchProjectWebapp,代码行数:18,代码来源:OnlineSession.cpp

示例12:

	//Returns true if a and b overlap, false otherwise
	bool operator&&(const TimeInterval& a, const TimeInterval& b){
		return a.getStart() <= b.getEnd() && a.getStart() >= b.getEnd();
	}
开发者ID:t0pth4t,项目名称:Scheduler,代码行数:4,代码来源:timeInterval.cpp

示例13: main

int main(int argc, char *argv[])
{
    const int                 test = argc > 1 ? atoi(argv[1]) : 0;
    const bool             verbose = argc > 2;
    const bool         veryVerbose = argc > 3;
    const bool     veryVeryVerbose = argc > 4;
    const bool veryVeryVeryVerbose = argc > 5;

    (void)     veryVeryVerbose;
    (void) veryVeryVeryVerbose;

    printf("TEST " __FILE__ " CASE %d\n", test);

    switch (test) {
    case 0:
    case 4: {
        // --------------------------------------------------------------------
        // USAGE EXAMPLE
        //
        // Concerns:
        //: 1 The usage example provided in the component header file must
        //:   compile, link, and run as shown.
        //
        // Plan:
        //: 1 Incorporate usage example from header into test driver, replace
        //:   leading comment characters with spaces, replace 'assert' with
        //:   'ASSERT', and insert 'if (veryVerbose)' before all output
        //:   operations.  (C-1)
        //
        // Testing:
        //   USAGE EXAMPLE
        // --------------------------------------------------------------------

        if (verbose) printf("\nUSAGE EXAMPLE"
                                "\n=============\n");

///Example 1: Getting Current Wall Clock Time
/// - - - - - - - - - - - - - - - - - - - - -
// The following snippets of code illustrate how to use this utility component
// to obtain the system time by calling 'now' and 'nowRealtimeClock'.
//
// First, we call 'nowRealtimeClock', and set 't1', to the current time
// according to the real-time clock:
//..
        bsls::TimeInterval t1 = bsls::SystemTime::nowRealtimeClock();
//
        ASSERT(bsls::TimeInterval() != t1);
//..
// Next, we sleep for 1 second:
//..
        sleep(1);
//..
// Now, we call 'now', and supply 'e_REALTIME' to indicate a real-time clock
// value should be returned, and then set 't2' to the current time according
// to the real-time clock:
//..
        bsls::TimeInterval t2 = bsls::SystemTime::now(
                                    bsls::SystemClockType::e_REALTIME);
//
        ASSERT(bsls::TimeInterval() != t2);
//..
// Finally, we verify the interval between 't1' and 't2' is close to 1 second:
//..
        bsls::TimeInterval interval = t2 - t1;
//
        ASSERT(bsls::TimeInterval(.9) <= interval &&
               interval <= bsls::TimeInterval(1.1));
//..
    }
    break;
    case 3: {
        // --------------------------------------------------------------------
        // CLASS METHODS: 'now(SystemClockType::Enum)'
        //  Ensure the returned 'TimeInterval' value represents the current
        //  system time as per the specified 'SystemClockType::Enum'.
        //
        // Concerns:
        //: 1 'now(e_REALTIME)' provides the current "wall" time.
        //:
        //: 2 'now(e_MONOTONIC)' provides the current monotonic clock time.
        //
        // Plan:
        //: 1 Verify 'now(e_REALTIME)' closely approximates the value returned
        //:   by 'nowRealtimeClock'.  (C-1)
        //:
        //: 2 Verify 'now(e_MONOTONIC)' closely approximates the value returned
        //:   by 'nowMonotonicClock'.  (C-2)
        //
        // Testing:
        //  TimeInterval now(SystemClockType::Enum);
        // --------------------------------------------------------------------

        if (verbose) printf("\nCLASS METHODS: 'now(SystemClockType::Enum)'"
                                "\n===========================================\n");

        if (veryVerbose) printf("\tCompare results w/ monotonic clock\n");
        {
            TimeInterval first  = Obj::nowMonotonicClock();
            TimeInterval second = Obj::now(SystemClockType::e_MONOTONIC);
            ASSERT(second - first  < TimeInterval(1, 0));
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: genGrouping

void OnlineSession::kSimilar(int dbindex, vector<double> qdata, TimeInterval interval, int k, int strict)
{
    if (groupings[dbindex] == NULL)
        genGrouping(dbindex, defaultST);

    TimeSeriesGrouping *t = groupings[dbindex];

    int slen = dataSets[dbindex]->seqLength;
    int ilen = interval.length();

    TimeSeriesIntervalEnvelope eqdata(TimeSeriesInterval(qdata.data(), TimeInterval(0, qdata.size() - 1)));

    double gb;
    int bsfStart = 0, bsfEnd = 0, bsfIndex = -1;
    double bsf = INF;

    if (strict == 0) {
        for (int i = 0; i < slen; i++) {
            if (debug) {
                cout << "Searching groups from start=" << i << ", bsf=" << bsf << endl;
            }
            for (int j = i; j < slen; j++) {
                int k = t->groups[i * slen + j].getBestGroup(eqdata, &gb, bsf);
                if (k < 0)
                    continue;
                if (gb < bsf) {
                    bsf = gb;
                    bsfStart = i;
                    bsfEnd = j;
                    bsfIndex = k;
                }
            }
        }
    } else if (strict == 1) {
        for (int i = 0; i + ilen - 1 < slen; i++) {
            if (debug)
                cout << "Searching groups from start=" << i << endl;
            int j = i + (ilen - 1);
            int k = t->groups[i * slen + j].getBestGroup(eqdata, &gb, bsf);
            if (k < 0)
                continue;
            if (gb < bsf) {
                bsf = gb;
                bsfStart = i;
                bsfEnd = j;
                bsfIndex = k;
            }
        }
    } else {
        bsfStart = interval.start;
        bsfEnd = interval.end;
        bsfIndex = t->groups[bsfStart * slen + bsfEnd].getBestGroup(eqdata, &gb, bsf);
        if (bsfIndex >= 0)
            bsf = gb;
    }

    if (bsf == INF || bsfIndex < 0) {
        cerr << "kSimilar: Failed to find similar objects. No suitable candidate group centroids." << endl;
        return;
    }

    cout << "Found most similar interval and group: " << bsfIndex << "@"
         << "[" << bsfStart << "," << bsfEnd << "]" << endl;

    vector<kSim> sim = t->groups[bsfStart * slen + bsfEnd].groups[bsfIndex]->getSortedSimilar(eqdata, k);

    cout << "Discovered k similar points:" << endl;
    for (unsigned int i = 0; i < sim.size(); i++) {

        cout << "Series " << sim[i].index << ", interval [" << bsfStart << "," << bsfEnd
             << "] is at distance " << sim[i].distance << "." << endl;

        TimeSeriesInterval interval = (*t->groups[bsfStart * slen + bsfEnd].groups[bsfIndex]->slice)[sim[i].index];

        for (int j = 0; j < interval.length(); j++) {
            cout << interval[j] << " ";
        }
        cout << endl;
    }
}
开发者ID:rahsan,项目名称:ONEX-Code,代码行数:80,代码来源:OnlineSession.cpp

示例15:

bool OrgMode::operator==(const TimeInterval &left, const OrgMode::TimeInterval &right)
{
    return left.start() == right.start() && left.end() == right.end();
}
开发者ID:mirkoboehm,项目名称:OrgModeParser,代码行数:4,代码来源:TimeInterval.cpp


注:本文中的TimeInterval类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。