Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
IPCMotionHook.ccGo to the documentation of this file.00001 #include "IPCMotionHook.h" 00002 #include "IPC/MessageQueue.h" 00003 #include <sstream> 00004 00005 using namespace std; 00006 00007 unsigned int IPCMotionHook::count=0; 00008 00009 IPCMotionHook::~IPCMotionHook() { 00010 for(msgbuf_t::iterator it=regions.begin();it!=regions.end(); ++it) 00011 (*it)->RemoveReference(); 00012 } 00013 00014 void IPCMotionHook::motionCheck(const float outputs[][NumOutputs]) { 00015 RCRegion * r = getRegion(); 00016 memcpy(r->Base(),outputs,r->Size()); 00017 mq.sendMessage(r); 00018 regions.push_back(r); 00019 } 00020 00021 void IPCMotionHook::updatePIDs(const std::vector<PIDUpdate>& pids) { 00022 stringstream ss; 00023 ss << "MotionPIDUpdate." << count++; 00024 //cout << "Created " << ss.str() << endl; 00025 RCRegion * r = new RCRegion(ss.str(),pids.size()*sizeof(PIDUpdate)); 00026 memcpy(r->Base(),&pids[0],r->Size()); 00027 pidmq.sendMessage(r,true); 00028 } 00029 00030 RCRegion* IPCMotionHook::getRegion() { 00031 for(msgbuf_t::iterator it=regions.begin();it!=regions.end(); ++it) { 00032 if((*it)->NumberOfReference()==1) { 00033 RCRegion * ans=*it; 00034 regions.erase(it); 00035 return ans; 00036 } 00037 } 00038 // no unused regions found, make a new one 00039 stringstream ss; 00040 ss << "MotionUpdate." << count++; 00041 //cout << "Created " << ss.str() << endl; 00042 return new RCRegion(ss.str(),sizeof(float)*NumOutputs*NumFrames); 00043 } 00044 00045 /*! @file 00046 * @brief 00047 * @author Ethan Tira-Thompson (ejt) (Creator) 00048 */ |
Tekkotsu Hardware Abstraction Layer 5.1CVS |
Generated Mon May 9 05:01:38 2016 by Doxygen 1.6.3 |