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


C++ OsTime::usecs方法代码示例

本文整理汇总了C++中OsTime::usecs方法的典型用法代码示例。如果您正苦于以下问题:C++ OsTime::usecs方法的具体用法?C++ OsTime::usecs怎么用?C++ OsTime::usecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OsTime的用法示例。


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

示例1: getLogString

void OsTimeLog::getLogString(UtlString& log) const
{
    int index;
    OsTime time;
    OsTime deltaTime;
    OsTime tZero;
    OsTime previousTime;
    size_t maxNameLength = 0;
    char timeString[40];

    for(index = 0; index < mMaxEventCount; index++)
    {
        if(mpaEventNames[index] &&
            mpaEventNames[index]->length() > maxNameLength)
        {
            maxNameLength = mpaEventNames[index]->length();
        }
    }

    int nameColumnTabs = ((int) (maxNameLength / 8)) + 1;

    // Put a header in after we know how long the event names are
    log.append("Name");
    for(index = 0; index < nameColumnTabs; index++)
        log.append('\t');
    log.append("Time\tIncremental Time\n");

    if(mpaEventTimes[0]) tZero = *(mpaEventTimes[0]);
    for(index = 0; index < mMaxEventCount; index++)
    {
        if(mpaEventNames[index])
        {
            log.append(mpaEventNames[index]->data());
        }

        if(mpaEventTimes[index])
        {
            time = *mpaEventTimes[index] - tZero;;
            sprintf(timeString, "\t%ld.%.6ld", time.seconds(),
                time.usecs());
            log.append(timeString);

            if(index > 0)
            {
                deltaTime = time - previousTime;
                sprintf(timeString, "\t%ld.%.6ld", deltaTime.seconds(),
                deltaTime.usecs());
                log.append(timeString);
            }
            else
            {
                log.append("\tN/A");
            }
            previousTime = time;
        }
        if(mpaEventNames[index] || mpaEventTimes[index] ||
            index < mNumEvents) log.append("\n");
    }

}
开发者ID:Konnekt,项目名称:lib-sipx,代码行数:60,代码来源:OsTimeLog.cpp

示例2: checkMeanAgainstThresholds

   void checkMeanAgainstThresholds(const OsTime& start, const OsTime& stop, 
                                   unsigned nDeltas,
                                   unsigned targetDelta, // <-- was periodUSecs
                                   long lowerMeanThresh, long upperMeanThresh)
   {
      CPPUNIT_ASSERT_MESSAGE("Timer didn't fire or deltas were not collected!",
                             nDeltas > 0);

      double meanAvg = 0;

      int64_t totStartUSecs = start.seconds()*1000*1000 + start.usecs();
      int64_t totStopUSecs = stop.seconds()*1000*1000 + stop.usecs();

      meanAvg = (totStopUSecs-totStartUSecs)/(double)nDeltas;
      printf("Mean: %.2f us\n", meanAvg);

      // Assert when mean is outside error range specified above.
      char errStrBuf[256];
      SNPRINTF(errStrBuf, sizeof(errStrBuf), 
         "Mean timer value %.2f falls outside threshold of %ld to %ld us",
         meanAvg, lowerMeanThresh, upperMeanThresh);

      CPPUNIT_ASSERT_MESSAGE(errStrBuf,
                             (meanAvg-(long)targetDelta >= lowerMeanThresh && 
                              meanAvg-(long)targetDelta <= upperMeanThresh));
   }
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:26,代码来源:MpMMTimerTest.cpp

示例3: getLogString

void OsTimeLog::getLogString(UtlString& log) const
{
   if ( mNumEvents > 0 )
   {
      size_t event;
      OsTime time;
      OsTime deltaTime;
      OsTime tZero;
      OsTime previousTime;
      char   formatted[40];

      log.append("\n           Time          Increment  Name");

      tZero = mpEventTimes[0];

      size_t numRecordedEvents = (mNumEvents < mMaxEventCount ? mNumEvents : mMaxEventCount);
      for(event = 0; event < numRecordedEvents; event++)
      {
         time = mpEventTimes[event] - tZero;;
         sprintf(formatted, "\n  %8d.%.06d", time.seconds(), time.usecs());
         log.append(formatted);

         if(event > 0)
         {
            deltaTime = time - previousTime;
            sprintf(formatted, "  %8d.%.06d  ", deltaTime.seconds(), deltaTime.usecs());
            log.append(formatted);
         }
         else
         {
            log.append("                   ");
         }
         previousTime = time;

         size_t labelEnd = (  event < numRecordedEvents-1  // last event?
                            ? mpEventLabelOffsets[event+1] // no  - use start of next event
                            : mEventLabels.length()        // yes - use end of string
                            );
         log.append(mEventLabels,mpEventLabelOffsets[event],labelEnd-mpEventLabelOffsets[event]);
      }

      if ( mNumEvents > mMaxEventCount )
      {
         sprintf(formatted, "\n  !!! Overflow - %ld events lost !!!", long(mNumEvents - mMaxEventCount));
         log.append(formatted);
      }
   }
   else
   {
      log.append("\n No Events Logged.");
   }
}
开发者ID:mranga,项目名称:sipxecs,代码行数:52,代码来源:OsTimeLog.cpp

示例4: nextValue

// Compute the next chain value.
void CallId::nextValue(const char* seed)
{
   // If we haven't initialized yet, do so.
   if (!sChainValueInitialized)
   {
      initialize();
   }

   // Get the time.
   OsTime currentTime;
   OsDateTime::getCurTime(currentTime);

   // Force usecs. to be 6 digits with leading zeros so that we do
   // not have to do 64 bit integer math just to build a big unique
   // string.
   char buffer[256];
   sprintf(buffer, "%s/%d%.6d/%.*s/%s",
           sKey.data(),
           currentTime.seconds(), currentTime.usecs(),
           MAX_SEED_CHARS, seed,
           sChainValue.data());

   // Hash them.
   NetMd5Codec encoder;
   encoder.encode(buffer, sChainValue);
   // Truncate the hash to CHAIN_VALUE_LENGTH characters.
   sChainValue.remove(CHAIN_VALUE_LENGTH);
}
开发者ID:mranga,项目名称:sipxecs,代码行数:29,代码来源:CallId.cpp

示例5: FileTimeToSystemTime

/// Convert an OsTime to an OsDateTime
OsDateTimeWnt::OsDateTimeWnt(const OsTime& toTime)
{
   // first convert the OsTime to a Windows FILETIME
   int64_t winTime_64;
   winTime_64 =  toTime.seconds();
   winTime_64 += WINDOWSTIME2UNIXTIME;   // adjust for epoch difference
   winTime_64 *= FILETIME_UNITS_PER_SEC; // scale to windows ticks
   winTime_64 += toTime.usecs() * FILETIME_UNITS_PER_USEC;
   FILETIME winTime;
   winTime.dwHighDateTime = (unsigned long)(winTime_64 >> 32);
   winTime.dwLowDateTime  = (unsigned long)(winTime_64 & 0xFFFFFFFF);

   // then the FILETIME to a broken out SYSTEMTIME
   SYSTEMTIME sysTime;
   FileTimeToSystemTime(&winTime, &sysTime);

   // and last, SYSTEMTIME to OsDateTime
   mYear        = sysTime.wYear;
   mMonth       = sysTime.wMonth - 1; // windows is 1-based
   mDay         = (unsigned char)sysTime.wDay;
   mHour        = (unsigned char)sysTime.wHour;
   mMinute      = (unsigned char)sysTime.wMinute;
   mSecond      = (unsigned char)sysTime.wSecond;
   mMicrosecond = sysTime.wMilliseconds * MICROSECS_PER_MILLISEC;
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:26,代码来源:OsDateTimeWnt.cpp

示例6: srand

// Constructor
UtlRandom::UtlRandom()
{
    static int siCounter = 0 ;

    int iTaskId = 0 ;
    OsTime now ;
    unsigned int seed ;

    OsTask::getCurrentTaskId(iTaskId) ;      
    OsDateTime::getCurTime(now) ;

    seed = (now.cvtToMsecs() ^ (now.usecs() + (now.usecs() << 16)) ^ 
            iTaskId) + siCounter++ ;

    srand(seed) ;
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:17,代码来源:UtlRandom.cpp

示例7: schedulePublishing

// Declare that some content has changed and needs to be published.
void ResourceListSet::schedulePublishing()
{
   Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                 "ResourceListSet::schedulePublishing this = %p",
                 this);

   // If publishing has been suspended, do not start the timer --
   // it will be started when publishing is resumed.
   if (!publishingSuspended())
   {
      OsTime pubDelay = getResourceListServer()->getPublishingDelay();

      // Check if waiting for the gap timeout (rather than the publishing timeout)
      if (mPublishOnTimeout == FALSE)
      {
         OsTimer::OsTimerState tmrState;
         OsTimer::Time tmrExpiresAt;
         UtlBoolean tmrPeriodic;
         OsTimer::Interval tmrPeriod;
         mPublishingTimer.getFullState(tmrState, tmrExpiresAt, tmrPeriodic, tmrPeriod);

         // Check if the timer is currently running.
         if (tmrState == OsTimer::STARTED)
         {
            // Calculate the amount of time before the gap timer expires (in seconds and microseconds).
            OsTimer::Time timeDelta = tmrExpiresAt - OsTimer::now();
            OsTime pubGap(timeDelta / 1000000, timeDelta % 1000000);

            // If the remaining gap timeout is less than the pubDelay
            // then we need to wait for pubDelay before publishing.
            if (pubGap < pubDelay)
            {
               // Cancel the current gap timeout so that oneshotAfter can restart the timer.
               mPublishingTimer.stop();
               Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                             "ResourceListSet::schedulePublishing mPublishingTimer.stop()");
            }
         }
      }

      // Start the timer with the publishing timeout if the timer is not already started.
      // If it is already started, OsTimer::oneshotAfter() does nothing.
      mPublishingTimer.oneshotAfter(pubDelay);
      Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                    "ResourceListSet::schedulePublishing mPublishingTimer.oneshotAfter(%d.%06d)",
                    pubDelay.seconds(), pubDelay.usecs());

      // Publish once the publishing timer expires.
      mPublishOnTimeout = TRUE;
   }
}
开发者ID:edaniels,项目名称:sipxecs,代码行数:52,代码来源:ResourceListSet.cpp

示例8: markTransfer

// Start the transfer deadman timer, and set mTransferInProgress.
void ParkedCallObject::markTransfer(const OsTime &timeOut)
{
   // Mark that a transfer is in progress (and so the call is not
   // available for other transfer attempts).
   mTransferInProgress = TRUE;
   // Start the timer to detect failed transfer attempts.
   mTransferTimer.oneshotAfter(timeOut);
   OsSysLog::add(FAC_PARK, PRI_DEBUG,
                 "ParkedCallObject::markTransfer "
                 "transfer timer started "
                 "callId = '%s', time = %d.%06d",
                 mOriginalCallId.data(), (int) timeOut.seconds(),
                 (int) timeOut.usecs());
}
开发者ID:mranga,项目名称:sipxecs,代码行数:15,代码来源:ParkedCallObject.cpp

示例9:

/// Convert an OsTime to an OsDateTime
OsDateTimeLinux::OsDateTimeLinux(const OsTime& toTime)
{
   struct tm dateTime;
   time_t seconds = toTime.seconds();
   gmtime_r(&seconds, &dateTime);

   mYear        = 1900 + dateTime.tm_year;
   mMonth       = (unsigned char) dateTime.tm_mon;
   mDay         = (unsigned char) dateTime.tm_mday;
   mHour        = (unsigned char) dateTime.tm_hour;
   mMinute      = (unsigned char) dateTime.tm_min;
   mSecond      = (unsigned char) dateTime.tm_sec;
   mMicrosecond = toTime.usecs();
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:15,代码来源:OsDateTimeLinux.cpp

示例10: initialize

// Initialize the chain value.
void CallId::initialize()
{
   // Get the start time.
   OsTime currentTime;
   OsDateTime::getCurTime(currentTime);

   // Get the process ID.
   PID processId;
   processId = OsProcess::getCurrentPID();

   // Get the host identity.
   UtlString thisHost;
   OsSocket::getHostIp(&thisHost);
   // Ensure it does not contain @.
   thisHost.replace('@','*');

   // Force usecs. to be 6 digits with leading zeros so that we do
   // not have to do 64 bit integer math just to build a big unique
   // string.
   char buffer[256];
   sprintf(buffer, "%d/%d.%.6d/%s",
           processId,
           currentTime.seconds(), currentTime.usecs(),
           thisHost.data());
   OsSysLog::add(FAC_SIP, PRI_DEBUG,
                 "CallId::initialize sChainValue generated from '%s'",
                 buffer);
   // Hash them.
   NetMd5Codec encoder;
   encoder.encode(buffer, sChainValue);
   // Truncate the hash to CHAIN_VALUE_LENGTH characters.
   sChainValue.remove(CHAIN_VALUE_LENGTH);

   // Note initialization is done.
   sChainValueInitialized = TRUE;
}
开发者ID:mranga,项目名称:sipxecs,代码行数:37,代码来源:CallId.cpp

示例11: lock

UtlBoolean
SipRedirectorJoinTask::handleMessage(OsMsg& eventMessage)
{
   int msgType = eventMessage.getMsgType();

   switch (msgType)
   {
   case OsMsg::PHONE_APP:
   {
      // Get a pointer to the message.
      const SipMessage* message =
         ((SipMessageEvent&)eventMessage).getMessage();

      // Extract the request method.
      UtlString method;
      message->getRequestMethod(&method);

      if (method.compareTo(SIP_NOTIFY_METHOD, UtlString::ignoreCase) == 0)
      {
         // Get the Call-Id.
         UtlString callId;
         message->getCallIdField(&callId);
         Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                       "SipRedirectorJoinTask::handleMessage "
                       "Start processing NOTIFY CallID '%s'", callId.data());

         {
            // This block holds SipRedirectServer::mRedirectorMutex.
            OsLock lock(SipRedirectServer::getInstance()->mRedirectorMutex);

            // Look for a suspended request whose SUBSCRIBE had this Call-Id.
            SipRedirectServerPrivateStorageIterator itor(mRedirectorNo);
            // Fetch a pointer to each element of myContentSource into
            // pStorage.
            SipRedirectorPrivateStorageJoin* pStorage;
            while ((pStorage =
                    dynamic_cast<SipRedirectorPrivateStorageJoin*> (itor())))
            {
               // Does this request have the same Call-Id?
               if (callId.compareTo(pStorage->mSubscribeCallId) == 0)
               {
                  // This is the request to which this NOTIFY is a response.
                  // Process the NOTIFY and store its information in
                  // *pStorage.
                  const char* body;
                  ssize_t length;
                  // Be careful getting the body, as any of the pointers
                  // may be null.
                  const HttpBody* http_body;
                  if (!(http_body = message->getBody()))
                  {
                     Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                                   "SipRedirectorJoinTask::handleMessage "
                                   "getBody returns NULL, ignoring");
                  }
                  else if (http_body->getBytes(&body, &length),
                           !(body && length > 0))
                  {
                     Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                                   "SipRedirectorJoinTask::handleMessage "
                                   "getBytes returns no body, ignoring");
                  }
                  else
                  {
                     if (Os::Logger::instance().willLog(FAC_SIP, PRI_DEBUG))
                     {
                        // Calculate the response delay.
                        OsTime now;
                        OsDateTime::getCurTime(now);
                        OsTime delta;
                        delta = now - (pStorage->mSubscribeSendTime);

                        Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                                      "SipRedirectorJoinTask::handleMessage "
                                      "NOTIFY for request %d, delay %d.%06d, "
                                      "body '%s'",
                                      itor.requestSeqNo(),
                                      (int) delta.seconds(), (int) delta.usecs(),
                                      body);
                     }
                     // Parse this NOTICE and store the needed
                     // information in private storage.
                     pStorage->processNotify(body);
                  }

                  // Don't bother checking for a match with any other request.
                  break;
               }
            }
         }

         // Return a 200 response.
         Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                       "SipRedirectServer::handleMessage "
                       "Sending 200 OK response to NOTIFY");
         SipMessage response;
         response.setOkResponseData(message);
         mpSipUserAgent->send(response);
      }
   }
//.........这里部分代码省略.........
开发者ID:ClydeFroq,项目名称:sipxecs,代码行数:101,代码来源:SipRedirectorJoin.cpp

示例12: now

// Get the current time as a Time.
OsTimer::Time OsTimer::now()
{
   OsTime t;
   OsDateTime::getCurTime(t);
   return (Time)(t.seconds()) * TIMER_TIME_UNIT + t.usecs();
}
开发者ID:iplabbet,项目名称:sipxecs4.6.0-u5,代码行数:7,代码来源:OsTimer.cpp

示例13: execute

int SipSendCommand::execute(int argc, char* argv[])
{
        int commandStatus = CommandProcessor::COMMAND_FAILED;
        UtlString messageBuffer;
        char buffer[1025];
        int bufferSize = 1024;
        int charsRead;

        if(argc != 2 && argc != 3)
        {
                printf("Usage: %s %s", argv[0], UsageMsg);
        }

        else
        {
        int transactionCount = 1;
        if(argc == 3) transactionCount = atoi(argv[2]);

        FILE* sipMessageFile = fopen(argv[1], "r");
                if(sipMessageFile)
                {
                        //printf("opened file: \"%s\"\n", argv[1]);
                        do
                        {
                                charsRead = fread(buffer, 1, bufferSize, sipMessageFile);
                                if(charsRead > 0)
                                {
                                        messageBuffer.append(buffer, charsRead);
                                }
                        }
                        while(charsRead);
            fclose(sipMessageFile);

                        //printf("Read file contents:\n%s\n====END====\n", messageBuffer.data());
                        SipMessage message(messageBuffer.data());
            UtlString callId;
            message.getCallIdField(&callId);
            char callIdBuffer[500];
            OsTime start;
            OsDateTime::getCurTimeSinceBoot(start);
            int transactionIndex;
            for(transactionIndex = 0; transactionIndex < transactionCount;
            transactionIndex++)
            {
                            if(sipUserAgent->send(message))
                            {
                                    commandStatus = CommandProcessor::COMMAND_SUCCESS;
                            }
                            else
                            {
                                    printf("Failed to send SIP message");
                    break;
                            }
                sprintf(callIdBuffer, "%d-%s", transactionIndex + 1,
                    callId.data());
                message.setCallIdField(callIdBuffer);
            }
            OsTime finish;
            OsDateTime::getCurTimeSinceBoot(finish);
            OsTime lapse = finish - start;
            double seconds = lapse.seconds() +
                ((double) lapse.usecs())/1000000.0;
            double transPerSecond = ((double) transactionIndex) / seconds;
            printf("Transactions: %d Seconds: %f tps: %f spt: %f\n",
                transactionIndex, seconds, transPerSecond,
                1.0/transPerSecond);

                }
                else
                {
                        printf("send file: \"%s\" does not exist\n", argv[1]);
                        commandStatus = CommandProcessor::COMMAND_FAILED;
                }
        }

        return(commandStatus);
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:77,代码来源:SipSendCommand.cpp

示例14: cvtOsTimeToWntTime

// Convert an OsTime to the corresponding number of millisecs for WinNT
DWORD OsUtilWnt::cvtOsTimeToWntTime(const OsTime& rTimer)
{
   return (rTimer.seconds() * MILLISECS_PER_SEC) +
          (rTimer.usecs()   / MICROSECS_PER_MILLISEC);
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:6,代码来源:OsUtilWnt.cpp

示例15: IncrementCounts

/**
 *
 * Method Name:  IncrementCounts
 *
 *
 * Inputs:       unsigned long  ulOctetCount    -   RTP Octets Sent
 *
 * Outputs:      None
 *
 * Returns:      void
 *
 * Description:  The IncrementCounts method shall add the number of octets
 *               passed to the cumulative octet count stored as an attribute
 *               to this object. Each call to IncrementCounts() shall also
 *               increment the packet count by 1.
 *
 * Usage Notes:
 *
 */
void CSenderReport::IncrementCounts(uint32_t ulOctetCount, rtpts_t RTPTimestampBase, rtpts_t RTPTimestamp, ssrc_t ssrc)
{
    uint32_t ntp_secs;
    uint32_t ntp_usec;

    OsTime now;
    OsDateTime::getCurTime(now);
    // Load Most Significant word with Wall time seconds
    ntp_secs = now.seconds();
    // Load Least Significant word with Wall time microseconds
    ntp_usec = now.usecs();

    // OsSysLog::add(FAC_MP, PRI_DEBUG, "CSenderReport::IncrementCounts: this=%p, NTP = {%2d.%06d}, octets=%04d, rtpTSBase=%u=0x%08X, rtpTS=%u=0x%08X, SSRC=0x%08X,0x%08X", this, (ntp_secs&0x3F), ntp_usec, ulOctetCount, RTPTimestampBase, RTPTimestampBase, RTPTimestamp, RTPTimestamp, ssrc, GetSSRC());

    OsLock lock(SR_sMultiThreadLock);

    if ((m_ulRTPTimestampBase != RTPTimestampBase) || ((0xFFFFFFFF & GetSSRC()) != (0xFFFFFFFF & ssrc))) {
        SetSSRC(ssrc); // NOTE: Calls ResetStatistics()
        m_ulRTPTimestampBase = RTPTimestampBase;
    }

    // We will increment the packet count by 1 and the Octet count by the
    //  number specified within the octet count
    m_ulPacketCount++;
    m_ulOctetCount += ulOctetCount;

    switch (m_iTSCollectState)
    {
    case 0: // Initial state, save first values
        m_ulRTPTimestamps[0] = RTPTimestamp;
        m_ulNTPSeconds[0] = ntp_secs;
        m_ulNTPuSecs[0] = ntp_usec;
        m_iTSCollectState = 1;
        break;

    case 1: // Second state, wait for first value to change
        if (m_ulRTPTimestamps[0] != RTPTimestamp) {
            m_ulRTPTimestamps[1] = RTPTimestamp; // needed for state #2
            m_ulRTPTimestamps[0] = RTPTimestamp;
            m_ulNTPSeconds[0] = ntp_secs;
            m_ulNTPuSecs[0] = ntp_usec;
            m_iTSCollectState = 2;
        }
        break;

    case 2: // Save last values for the first time
    case 3: // Steady state, save last values, allow SR construction
        if (m_ulRTPTimestamps[1] != RTPTimestamp) {
            m_ulRTPTimestamps[1] = RTPTimestamp;
            m_ulNTPSeconds[1] = ntp_secs;
            m_ulNTPuSecs[1] = ntp_usec;
            m_iTSCollectState = 3;
        }
        break;

    default:
        assert(0);
    }

    // Set the Media Sent flag so that we know to transmit a Sender
    // Report in the next reporting period.
    m_bMediaSent = TRUE;

}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:83,代码来源:SenderReport.cpp


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