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


C++ TimeStamp::getSecondsPastEpoch方法代码示例

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


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

示例1: set

bool PVTimeStamp::set(TimeStamp const & timeStamp)
{
    if(pvSecs.get()==NULL) {
        throw std::logic_error(notAttached);
    }
    if(pvSecs->isImmutable() || pvNano->isImmutable()) return false;
    pvSecs->put(timeStamp.getSecondsPastEpoch());
    pvUserTag->put(timeStamp.getUserTag());
    pvNano->put(timeStamp.getNanoseconds());
    return true;
}
开发者ID:ncanestrari,项目名称:EPICS-EPICS_V4,代码行数:11,代码来源:pvTimeStamp.cpp

示例2: toTimeStamp

void NTNDArrayConverter::toTimeStamp (NDArray *dest)
{
    PVStructurePtr src(m_array->getTimeStamp());

    if(!src.get())
        return;

    PVTimeStamp pvSrc;
    pvSrc.attach(src);

    TimeStamp ts;
    pvSrc.get(ts);

    dest->epicsTS.secPastEpoch = ts.getSecondsPastEpoch();
    dest->epicsTS.nsec = ts.getNanoseconds();
}
开发者ID:ajgdls,项目名称:ADCore,代码行数:16,代码来源:ntndArrayConverter.cpp

示例3: testTimeStamp

void testTimeStamp(FILE *fd,FILE *auxfd)
{
    assert(nanoSecPerSec==1000000000);
    TimeStamp current;
    current.getCurrent();
    fprintf(auxfd,"current %lli %i milliSec %lli\n",
        (long long)current.getSecondsPastEpoch(),
        current.getNanoSeconds(),
        (long long)current.getMilliseconds());
    time_t tt;
    current.toTime_t(tt);
    struct tm ctm;
    memcpy(&ctm,localtime(&tt),sizeof(struct tm));
    fprintf(auxfd,
        "%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
        ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
        ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
        current.getNanoSeconds(),
        (ctm.tm_isdst==0) ? "false" : "true");
    tt = time(&tt);
    current.fromTime_t(tt);
    fprintf(auxfd,"fromTime_t\ncurrent %lli %i milliSec %lli\n",
        (long long)current.getSecondsPastEpoch(),
        current.getNanoSeconds(),
        (long long)current.getMilliseconds());
    current.toTime_t(tt);
    memcpy(&ctm,localtime(&tt),sizeof(struct tm));
    fprintf(auxfd,
        "%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
        ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
        ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
        current.getNanoSeconds(),
        (ctm.tm_isdst==0) ? "false" : "true");
    TimeStamp right;
    TimeStamp left;
    right.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
    left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
    double diff;
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    assert(diff==0.0);
    assert((left==right));
    assert(!(left!=right));
    assert((left<=right));
    assert(!(left<right));
    assert((left>=right));
    assert(!(left>right));
    left.put(current.getSecondsPastEpoch()+1,current.getNanoSeconds());
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    assert(diff==1.0);
    assert(!(left==right));
    assert((left!=right));
    assert(!(left<=right));
    assert(!(left<right));
    assert((left>=right));
    assert((left>right));
    left.put(current.getSecondsPastEpoch()-1,current.getNanoSeconds());
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    assert(diff==-1.0);
    assert(!(left==right));
    assert((left!=right));
    assert((left<=right));
    assert((left<right));
    assert(!(left>=right));
    assert(!(left>right));
    left.put(current.getSecondsPastEpoch(),current.getNanoSeconds()-nanoSecPerSec);
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    assert(diff==-1.0);
    assert(!(left==right));
    assert((left!=right));
    assert((left<=right));
    assert((left<right));
    assert(!(left>=right));
    assert(!(left>right));
    left.put(current.getSecondsPastEpoch(),current.getNanoSeconds()-1);
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    assert(diff<0.0);
    assert(!(left==right));
    assert((left!=right));
    assert((left<=right));
    assert((left<right));
    assert(!(left>=right));
    assert(!(left>right));
    left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
    left += .1;
    diff = TimeStamp::diff(left,right);
    if(debug) fprintf(fd,"diff %e\n",diff);
    left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
    int64 inc = -1;
    left += inc;
    diff = TimeStamp::diff(left,right);
    assert(diff==-1.0);
    fprintf(fd,"PASSED\n");
}
开发者ID:,项目名称:,代码行数:98,代码来源:


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