urg_ticks.cpp
Go to the documentation of this file.
00001 
00010 #include "urg_ticks.h"
00011 #ifdef Q_WS_WIN
00012 #include <time.h>
00013 #else
00014 #include <sys/time.h>
00015 #include <stdio.h>
00016 #endif
00017 
00018 
00019 long urg_ticks(void)
00020 {
00021   long current_ticks = 0;
00022 #ifndef Q_WS_WIN
00023   // Linux で SDL がない場合の実装。最初の呼び出しは 0 を返す
00024   static long first_ticks = 0;
00025   struct timeval tvp;
00026   gettimeofday(&tvp, NULL);
00027   long global_ticks = tvp.tv_sec * 1000 + tvp.tv_usec / 1000;
00028   if (first_ticks == 0) {
00029     first_ticks = global_ticks;
00030   }
00031   current_ticks = global_ticks - first_ticks;
00032 
00033 #else
00034   current_ticks = (long)(clock() / (CLOCKS_PER_SEC / 1000.0));
00035 #endif
00036   return current_ticks;
00037 }


corobot_teleop
Author(s): Morgan Cormier/Gang Li/mcormier@coroware.com
autogenerated on Tue Jan 7 2014 11:39:41