コード例 #1
0
ファイル: Message.cpp プロジェクト: jaaaaf/LK8000
void Message::AddMessage(unsigned tshow, int type, const TCHAR* Text) {

    Lock();

    unsigned fpsTime = startTime.Elapsed();
    messages.emplace_back((Message_t){Text, type, fpsTime, fpsTime, tshow});

    Unlock();
}
コード例 #2
0
ファイル: Message.cpp プロジェクト: jaaaaf/LK8000
void Message::Repeat(int type) {
    Lock();
    if (!messagesHistory.empty()) {

        // copy most recent message from history to active message.
        messages_t::iterator It = messagesHistory.begin();
        (*It).texpiry = (*It).tstart = startTime.Elapsed();

        messages.splice(messages.end(), messagesHistory, It);
    }
    Unlock();
}
コード例 #3
0
ファイル: Message.cpp プロジェクト: jaaaaf/LK8000
bool Message::Render() {
    if (!GlobalRunning) return false;
    if (block_ref) return false;

    Lock();
    unsigned fpsTime = startTime.Elapsed();

    // this has to be done quickly, since it happens in GUI thread
    // at subsecond interval
    msgText.clear();
    nvisible = 0;
    bool changed = false;
    messages_t::iterator msgIt = messages.begin();
    while (msgIt != messages.end()) {
        if (msgIt->type == 0) {
            // ignore unknown messages, remove it.
            messages.erase(msgIt++);
            changed = true;
            continue;
        }

        if (msgIt->texpiry < fpsTime && msgIt->texpiry > msgIt->tstart) {
            // this message has expired, move to history list
            messagesHistory.splice(messagesHistory.begin(), messages, msgIt++);
            changed = true;
            continue;
        }

        if (msgIt->texpiry == msgIt->tstart) {
            // new message has been added, set new expiry time.
            msgIt->texpiry = fpsTime + msgIt->tshow;
            changed = true;
        }

        if (nvisible > 0) {
            msgText += TEXT("\r\n"); // add a line separator
        }
        msgText += msgIt->text; // Append Text

        ++nvisible;
        ++msgIt; // advance to next
    }
    if(messagesHistory.size() > 20) {
        // don't save more than 20 message into history.
        messagesHistory.erase(--messagesHistory.end());
    }

    if (changed || (!hidden && messages.empty())) {
        Resize();
    }
    Unlock();
    return changed;
}
コード例 #4
0
void
ProcessTimer()
{
  CommonProcessTimer();

  if (!is_simulator()) {
    // now check GPS status
    devTick(CommonInterface::Calculated());

    // also service replay logger
    if (replay && replay->Update()) {
      if (CommonInterface::MovementDetected())
        replay->Stop();
    }

    ConnectionProcessTimer();
  } else {
    static PeriodClock m_clock;
    if (m_clock.Elapsed() < 0)
      m_clock.Update();

    if (replay && replay->Update()) {
      m_clock.Update();
    } else if (m_clock.Elapsed() >= 1000) {
      m_clock.Update();
      device_blackboard->ProcessSimulation();
    }
  }

#ifdef HAVE_TRACKING
  if (tracking != NULL && CommonInterface::Basic().gps.real) {
    tracking->SetSettings(CommonInterface::GetComputerSettings().tracking);
    tracking->OnTimer(CommonInterface::Basic(), CommonInterface::Calculated());
  }
#endif
}
コード例 #5
0
ファイル: WorkerThread.cpp プロジェクト: CnZoom/XcSoarPull
void
WorkerThread::Run()
{
  PeriodClock clock;

  while (true) {
    /* wait for work */
    event_trigger.Wait();

    /* got the "stop" trigger? */
    if (delay > 0
        ? WaitForStopped(delay)
        : CheckStoppedOrSuspended())
      break;

    /* reset the trigger here, because our client might have called
       Trigger() a few more times while we were suspended in
       CheckStoppedOrSuspended() */
    event_trigger.Reset();

    if (IsCommandPending()) {
      /* just in case we got another suspend/stop command after
         CheckStoppedOrSuspended() returned and before the trigger got
         reset: restore the trigger and skip this iteration, to fix
         the race condition */
      event_trigger.Signal();
      continue;
    }

    /* do the actual work */
    if (period_min > 0)
      clock.Update();

    Tick();

    unsigned idle = idle_min;
    if (period_min > 0) {
      unsigned elapsed = clock.Elapsed();
      if (elapsed + idle < period_min)
        idle = period_min - elapsed;
    }

    if (idle > 0 && WaitForStopped(idle))
      break;
  }
}