- Timestamp:
- Mar 8, 2019, 10:30:25 AM (6 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore
-
Property svn:ignore
set to
build_x86_64
build_core2_64
build_armv7a_neon
build_armv5te
build_arm
build
.codelite
.clang
-
Property svn:ignore
set to
-
trunk/lib/FlairCore/src/Thread.cpp
r252 r307 98 98 #else 99 99 Time current = GetTime(); 100 100 101 if (current < time) { 101 102 //usleep((time - current) / 1000); 103 Time tmp=time - current; 102 104 struct timespec req; 103 req.tv_nsec = time - current; 104 req.tv_sec = req.tv_nsec / 1000000000; 105 req.tv_nsec %= 1000000000; 105 req.tv_sec = tmp / (Time)1000000000; 106 req.tv_nsec = tmp%(Time)1000000000; 106 107 struct timespec rem; 107 108 if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR … … 113 114 114 115 void Thread::SleepMS(uint32_t time) const { 115 #ifdef __XENO__ 116 int status = rt_task_sleep(time * 1000 * 1000); 117 if (status != 0) { 118 char errorMsg[256]; 119 Err("erreur rt_task_sleep (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg))); 120 } 121 #else 122 //usleep(time * 1000); 123 struct timespec req; 124 req.tv_nsec = time * 1000000; 125 req.tv_sec = req.tv_nsec / 1000000000; 126 req.tv_nsec %= 1000000000; 127 struct timespec rem; 128 if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR 129 #endif 116 SleepUS(time*1000); 130 117 } 131 118 … … 140 127 //usleep(time); 141 128 struct timespec req; 142 req.tv_nsec = time * 1000; 143 req.tv_sec = req.tv_nsec / 1000000000; 144 req.tv_nsec %= 1000000000; 129 req.tv_sec = (Time)time / (Time)1000; 130 req.tv_nsec = (Time)time%(Time)1000; 145 131 struct timespec rem; 146 132 if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR -
trunk/lib/FlairCore/src/Thread_impl.cpp
r250 r307 174 174 175 175 #ifdef __XENO__ 176 int status = rt_task_set_periodic(&task_rt, TM_NOW, period *1000);176 int status = rt_task_set_periodic(&task_rt, TM_NOW, (Time)period * (Time)1000); 177 177 if (status != 0) { 178 178 char errorMsg[256]; … … 181 181 #else 182 182 if (period_set) { 183 next_time -= period;184 next_time += period *1000;185 } else next_time=GetTime()+ period*1000;186 #endif 187 this->period = period *1000;183 next_time -= (Time)period; 184 next_time += (Time)period * (Time)1000; 185 } else next_time=GetTime()+(Time)period*(Time)1000; 186 #endif 187 this->period = (Time)period * (Time)1000; 188 188 period_set = true; 189 189 } … … 192 192 193 193 void Thread_impl::SetPeriodMS(uint32_t period) { 194 if (period == 0) { 195 self->Err("Period must be>0\n"); 196 return; 197 } 198 199 #ifdef __XENO__ 200 int status = rt_task_set_periodic(&task_rt, TM_NOW, period * 1000 * 1000); 201 if (status != 0) { 202 char errorMsg[256]; 203 self->Err("Error rt_task_set_periodic %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg))); 204 } 205 #else 206 if (period_set) { 207 next_time -= period; 208 next_time += period * 1000 * 1000; 209 } else next_time=GetTime()+period*1000*1000; 210 #endif 211 this->period = period * 1000 * 1000; 212 period_set = true; 194 SetPeriodUS(period*1000); 213 195 } 214 196 -
trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
r169 r307 104 104 // fps counter 105 105 fpsCounter++; 106 if (fpsCounter == 100) { 106 if (GetTime() > (fpsPrev + 5 * (Time)1000000000)) { 107 // toute les 5 secondes 107 108 fpsNow = GetTime(); 108 109 fps->SetText("fps: %.1f", 109 110 fpsCounter / ((float)(fpsNow - fpsPrev) / 1000000000.)); 110 111 fpsCounter = 0; 111 112 fpsPrev = fpsNow; 112 } 113 113 } 114 114 115 // cam properties 115 116 if (gain->ValueChanged() == true && autogain->Value() == false)
Note:
See TracChangeset
for help on using the changeset viewer.