9 static pthread_t thrStgTimer;
10 static bool isTimerRunning = false;
11 volatile time_t stgTime;
13 const int TIME_SPEED = 1;
21 const int START_TIME = 0;
24 1 - start before new day (3 min before) 29.11.2005 23:57:00
25 2 - start before new month (3 min before) 30.11.2005 23:57:00
28 //-----------------------------------------------------------------------------
29 void * StgTimer(void *)
31 #ifdef STG_TIMER_DEBUG
33 memset(<, 0, sizeof(lt));
35 lt.tm_year = 2007 - 1900; // 2005
36 lt.tm_mon = 11 - 1; // Nov
37 lt.tm_hour = 23; // 23 h
38 lt.tm_min = 57; // 50 min
39 lt.tm_sec = 0; // 00 sec
49 stgTime = mktime(<);
54 stgTime = mktime(<);
60 isTimerRunning = true;
63 #ifdef STG_TIMER_DEBUG
64 struct timespec ts = {0, 1000000000 / TIME_SPEED};
66 //usleep(1000000 / TIME_SPEED);
69 struct timespec ts = {0, 500000000};
75 isTimerRunning = false;
79 //-----------------------------------------------------------------------------
83 isTimerRunning = false;
86 if (pthread_create(&thrStgTimer, NULL, StgTimer, NULL))
88 isTimerRunning = false;
95 //-----------------------------------------------------------------------------
99 pthread_join(thrStgTimer, NULL); // Cleanup thread resources
100 printfd(__FILE__, "STG_TIMER stopped\n");
102 //-----------------------------------------------------------------------------
103 bool IsStgTimerRunning()
105 return isTimerRunning;
107 //-----------------------------------------------------------------------------
108 int stgUsleep(unsigned long t)
110 #ifdef STG_TIMER_DEBUG
111 struct timespec ts = {(t / TIME_SPEED) / 1000000, ((t / TIME_SPEED) % 1000000) * 1000};
112 return nanosleep(&ts);
113 //return usleep(t / TIME_SPEED);
115 struct timespec ts = {t / 1000000, (t % 1000000) * 1000};
116 return nanosleep(&ts);
120 //-----------------------------------------------------------------------------
123 for (int i = 0; i < 5 && !isTimerRunning; i++)
126 //-----------------------------------------------------------------------------