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 usleep(1000000 / TIME_SPEED);
71 isTimerRunning = false;
75 //-----------------------------------------------------------------------------
79 isTimerRunning = false;
82 if (pthread_create(&thrStgTimer, NULL, StgTimer, NULL))
84 isTimerRunning = false;
91 //-----------------------------------------------------------------------------
95 pthread_join(thrStgTimer, NULL); // Cleanup thread resources
96 printfd(__FILE__, "STG_TIMER stopped\n");
98 //-----------------------------------------------------------------------------
99 bool IsStgTimerRunning()
101 return isTimerRunning;
103 //-----------------------------------------------------------------------------
104 int stgUsleep(unsigned long t)
106 #ifdef STG_TIMER_DEBUG
107 return usleep(t / TIME_SPEED);
112 //-----------------------------------------------------------------------------
115 for (int i = 0; i < 5 && !isTimerRunning; i++)
118 //-----------------------------------------------------------------------------