- Timestamp:
- Nov 2, 2017, 3:04:47 PM (7 years ago)
- Location:
- trunk/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Thread.cpp
r139 r202 91 91 if (status != 0) { 92 92 char errorMsg[256]; 93 Err("% s,error rt_task_sleep_until (%s), resume time: %lld, actual time: "94 "%lld\n", ObjectName().c_str(),strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());93 Err("%error rt_task_sleep_until (%s), resume time: %lld, actual time: " 94 "%lld\n",strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime()); 95 95 } 96 96 // Printf("rt_task_sleep_until, resume time: %lld, actual time: … … 99 99 Time current = GetTime(); 100 100 if (current < time) { 101 usleep((time - current) / 1000); 101 //usleep((time - current) / 1000); 102 struct timespec req; 103 req.tv_nsec = time - current; 104 req.tv_sec = req.tv_nsec / 1000000000; 105 req.tv_nsec %= 1000000000; 106 struct timespec rem; 107 if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR 108 } else { 109 Err("error resume time is passed by %lldns\n", ( current-time)); 102 110 } 103 111 #endif … … 112 120 } 113 121 #else 114 usleep(time * 1000); 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 115 129 #endif 116 130 } … … 124 138 } 125 139 #else 126 usleep(time); 140 //usleep(time); 141 struct timespec req; 142 req.tv_nsec = time * 1000; 143 req.tv_sec = req.tv_nsec / 1000000000; 144 req.tv_nsec %= 1000000000; 145 struct timespec rem; 146 if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR 127 147 #endif 128 148 } -
trunk/lib/FlairCore/src/Thread_impl.cpp
r186 r202 232 232 #else 233 233 self->SleepUntil(next_time); 234 next_time += period; 234 Time current = GetTime(); 235 if(current>next_time+period) self->Err("overrun of %lld\n", current-next_time); 236 while (next_time < current) { 237 next_time += period; 238 } 235 239 #endif 236 240 ComputeLatency(GetTime()); … … 326 330 if(last!=0) 327 331 #endif 328 { Printf("Thread::%s :\n", self->ObjectName().c_str()); } 332 { Printf("Thread::%s :\n", self->ObjectName().c_str()); 333 if(period_set) {Printf(" period (ns): %lld\n", period);}} 329 334 #ifdef __XENO__ 330 335 Printf(" number of context switches: %i\n", info.ctxswitches); … … 349 354 Printf(" max latency (ns): %lld\n", max_latency); 350 355 Printf(" latency moy (ns): %lld\n", mean_latency / cpt); 351 Printf(" iter tions: %lld\n", cpt);356 Printf(" iterations: %lld\n", cpt); 352 357 } 353 358 } -
trunk/lib/FlairSensorActuator/src/EmulatedController.cpp
r178 r202 19 19 #include <cvmatrix.h> 20 20 #include <stdexcept> 21 22 #include <unistd.h> // for sleep (debug)23 21 24 22 using namespace flair::core; -
trunk/lib/FlairSensorActuator/src/SimuImu.cpp
r198 r202 34 34 namespace sensor { 35 35 36 //Construct a SimuImu. Control part. 36 37 SimuImu::SimuImu(string name, uint32_t modelId,uint32_t deviceId, 37 38 uint8_t priority) … … 46 47 } 47 48 49 //Construct a SimuImu. Simulation part. 48 50 SimuImu::SimuImu(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId) 49 51 : Imu(parent,name), Thread(parent, name, 0) { … … 109 111 SetPeriodUS((uint32_t)(1000000. / dataRate->Value())); 110 112 } 111 112 113 shmem->Read((char *)&state, sizeof(imu_states_t)); 113 114 Quaternion quaternion(state.q0, state.q1, state.q2, state.q3); 114 Quaternion quaternion(state.q0, state.q1, state.q2, state.q3); 115 115 Vector3Df angRate(state.wx, state.wy, state.wz); 116 116 Vector3Df rawAcc(state.ax, state.ay, state.az); … … 128 128 imuData->SetDataTime(GetTime()); 129 129 ahrsData->SetDataTime(GetTime()); 130 131 130 ProcessUpdate(ahrsData); 132 131 } -
trunk/lib/FlairSensorActuator/src/TargetController.cpp
r186 r202 24 24 #include <cstring> 25 25 #include <string> 26 27 #include <unistd.h> //for usleep28 26 29 27 using namespace flair::core; -
trunk/lib/FlairSensorActuator/src/TargetEthController.cpp
r178 r202 27 27 #include <stdexcept> 28 28 29 #include <unistd.h> // for sleep (debug)30 31 29 using namespace flair::core; 32 30 using namespace flair::gui; -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r186 r202 54 54 Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId) 55 55 : ISceneNode(getGui()->getSceneManager()->getRootSceneNode(), getGui()->getSceneManager(), -1), 56 Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)56 Thread(self, name, 99), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_) 57 57 58 58 #else 59 59 Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId) 60 : Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)60 : Thread(self, name, 99), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_) 61 61 #endif 62 62 {
Note:
See TracChangeset
for help on using the changeset viewer.