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


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

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


在下文中一共展示了OsTime::seconds方法的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: 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

示例5: printStatus

void SipProtocolServerBase::printStatus()
{
    int numClients = mClientList.getCount();
    int iteratorHandle = mClientList.getIteratorHandle();

    OsTime time;
    OsDateTime::getCurTimeSinceBoot(time);
    long currentTime = time.seconds();

    //long currentTime = OsDateTime::getSecsSinceEpoch();
    SipClient* client;
    UtlString clientNames;
    long clientTouchedTime;
    UtlBoolean clientOk;

    osPrintf("%s %d clients in list at: %ld\n",
        mProtocolString.data(), numClients, currentTime);

    while ((client = (SipClient*)mClientList.next(iteratorHandle)))
    {
        // Remove this or any other bad client
        clientTouchedTime = client->getLastTouchedTime();
        clientOk = client->isOk();
        client->getClientNames(clientNames);

        osPrintf("%s client %p last used: %ld ok: %d names:\n%s\n",
            mProtocolString.data(), this, clientTouchedTime,
            clientOk, clientNames.data());
    }
    mClientList.releaseIteratorHandle(iteratorHandle);
}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:31,代码来源:SipProtocolServerBase.cpp

示例6: 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

示例7: touch

void SipClient::touch()
{
   OsTime time;
   OsDateTime::getCurTimeSinceBoot(time);
   touchedTime = time.seconds();
   //Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "SipClient[%s]::touch client: %p time: %d\n",
   //             mName.data(), this, touchedTime);
}
开发者ID:ossapp,项目名称:sipxecs,代码行数:8,代码来源:SipClient.cpp

示例8: 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

示例9: markForDeletion

// Is this connection marked for deletion?
void Connection::markForDeletion()
{
   OsTime timeNow ;
   OsTime deleteAfterSecs(CONN_DELETE_DELAY_SECS, 0) ;

   OsDateTime::getCurTimeSinceBoot(deleteAfterSecs) ;

   mDeleteAfter = timeNow + deleteAfterSecs ;

   Os::Logger::instance().log(FAC_CP, PRI_DEBUG,
       "Connection::markForDeletion connection %p in %d secs (now:%ld then: %ld)",
           this, deleteAfterSecs.seconds(), timeNow.seconds(),
           mDeleteAfter.seconds());
}
开发者ID:ciuc,项目名称:sipxecs,代码行数:15,代码来源:Connection.cpp

示例10:

/// 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

示例11: 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

示例12: isOsTimeValid

// Verify that the OsTime is >= 0 and representable in msecs
UtlBoolean OsUtilWnt::isOsTimeValid(const OsTime& rTimer)
{
   int secs = rTimer.seconds();

   // Assume that the size of an int is 4 bytes
   assert(sizeof(int) == 4);

   // Timeout values should be in the future
   if (secs < 0)
      return FALSE;

   // The following test is "<" rather than "<=" since the contribution of
   //  the microseconds portion of rTimer could add another second.
   return (secs < (0x7FFFFFFF / MILLISECS_PER_SEC));
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:16,代码来源:OsUtilWnt.cpp

示例13: encode

/// Encodes identity info
void SipXauthIdentity::encode(UtlString        & identityValue,
                              const UtlString  & callId,
                              const UtlString  & fromTag,
                              const OsDateTime & timestamp,
                              DialogRule       bindRule
                              )
{

   // calculate timestamp
   OsTime osTime;
   timestamp.cvtToTimeSinceEpoch(osTime);
   long seconds = osTime.seconds();
   char stamp[65];
   sprintf(stamp, "%lX", seconds);
   UtlString strSignature(stamp);

   strSignature.append(SignatureFieldSeparator);

   // signature-hash=MD5(<timestamp><secret><from-tag><call-id><identity>)
   NetMd5Codec signatureHash;
   signatureHash.hash(stamp);
   signatureHash.hash(sSignatureSecret);
   if (requireDialogBinding == bindRule)
   {
      signatureHash.hash(fromTag);
      signatureHash.hash(callId);
   }
   else
   {
      strSignature.append(SignatureFieldSeparator);
   }
   signatureHash.hash(mIdentity);

   UtlString strSignatureHash;
   signatureHash.appendHashValue(strSignature);

   Url encodedUrl(mIdentity);
   encodedUrl.setScheme(Url::SipUrlScheme);
   encodedUrl.setUrlParameter(SignatureUrlParamName, strSignature.data());

   encodedUrl.toString(identityValue);

   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                 "SipXauthIdentity::encode "
                 "identity '%s'",
                 identityValue.data()
                 );
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:49,代码来源:SipXauthIdentity.cpp

示例14: 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

示例15: 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


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