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


C++ Monitor::GetTimestamp方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
  }
  

  if ( mon_id > 0 )
  {
    Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY );
    if ( monitor )
    {
      if ( verbose )
      {
        printf( "Monitor %d(%s)\n", monitor->Id(), monitor->Name() );
      }
      if ( ! monitor->connect() ) {
        Error( "Can't connect to capture daemon: %d %s", monitor->Id(), monitor->Name() );
        exit( -1 );
      } 

      char separator = ' ';
      bool have_output = false;
      if ( function & ZMU_STATE )
      {
        Monitor::State state = monitor->GetState();
        if ( verbose )
          printf( "Current state: %s\n", state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle") );
        else
        {
          if ( have_output ) printf( "%c", separator );
          printf( "%d", state );
          have_output = true;
        }
      }
      if ( function & ZMU_TIME )
      {
        struct timeval timestamp = monitor->GetTimestamp( image_idx );
        if ( verbose )
        {
          char timestamp_str[64] = "None";
          if ( timestamp.tv_sec )
            strftime( timestamp_str, sizeof(timestamp_str), "%Y-%m-%d %H:%M:%S", localtime( &timestamp.tv_sec ) );
          if ( image_idx == -1 )
            printf( "Time of last image capture: %s.%02ld\n", timestamp_str, timestamp.tv_usec/10000 );
          else
            printf( "Time of image %d capture: %s.%02ld\n", image_idx, timestamp_str, timestamp.tv_usec/10000 );
        }
        else
        {
          if ( have_output ) printf( "%c", separator );
          printf( "%ld.%02ld", timestamp.tv_sec, timestamp.tv_usec/10000 );
          have_output = true;
        }
      }
      if ( function & ZMU_READ_IDX )
      {
        if ( verbose )
          printf( "Last read index: %d\n", monitor->GetLastReadIndex() );
        else
        {
          if ( have_output ) printf( "%c", separator );
          printf( "%d", monitor->GetLastReadIndex() );
          have_output = true;
        }
      }
      if ( function & ZMU_WRITE_IDX )
      {
        if ( verbose )
          printf( "Last write index: %d\n", monitor->GetLastWriteIndex() );
开发者ID:josh4trunks,项目名称:ZoneMinder,代码行数:67,代码来源:zmu.cpp


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