TOBI SignalServer  0.1
/home/breidi/Dropbox/signalserver/include/hardware/kinect.h
Go to the documentation of this file.
00001 /*
00002     This file is part of the TOBI SignalServer.
00003 
00004     Commercial Usage
00005     Licensees holding valid Graz University of Technology Commercial
00006     licenses may use this file in accordance with the Graz University
00007     of Technology Commercial License Agreement provided with the
00008     Software or, alternatively, in accordance with the terms contained in
00009     a written agreement between you and Graz University of Technology.
00010 
00011     --------------------------------------------------
00012 
00013     GNU General Public License Usage
00014     Alternatively, this file may be used under the terms of the GNU
00015     General Public License version 3.0 as published by the Free Software
00016     Foundation and appearing in the file gpl.txt included in the
00017     packaging of this file.  Please review the following information to
00018     ensure the GNU General Public License version 3.0 requirements will be
00019     met: http://www.gnu.org/copyleft/gpl.html.
00020 
00021     In case of GNU General Public License Usage ,the TOBI SignalServer
00022     is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025     GNU General Public License for more details.
00026 
00027     You should have received a copy of the GNU General Public License
00028     along with the TOBI SignalServer. If not, see <http://www.gnu.org/licenses/>.
00029 
00030     Copyright 2010 Graz University of Technology
00031     Contact: SignalServer@tobi-project.org
00032 */
00033 
00039 #ifndef HANDPOINT_H
00040 #define HANDPOINT_H
00041 
00042 #include <boost/cstdint.hpp>
00043 #include <boost/interprocess/mapped_region.hpp>
00044 #include <boost/interprocess/shared_memory_object.hpp>
00045 #include <boost/interprocess/sync/interprocess_mutex.hpp>
00046 #include <boost/interprocess/sync/interprocess_semaphore.hpp>
00047 
00048 #include <boost/date_time/posix_time/posix_time.hpp>
00049 
00050 #include "hw_thread.h"
00051 #include "hw_thread_builder.h"
00052 
00053 
00054 namespace tobiss
00055 {
00056 //-----------------------------------------------------------------------------
00057 
00063 class KinectShmReader : public HWThread
00064 {
00065   public:
00069     KinectShmReader (ticpp::Iterator<ticpp::Element> hw);
00070 
00074     virtual ~KinectShmReader();
00075 
00084     virtual SampleBlock<double> getAsyncData();
00085 
00089     virtual void run();
00090 
00094     virtual void stop();
00095 
00096     //-----------------------------------------------
00097   private:
00102     virtual void setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father);
00103 
00108     virtual void setChannelSettings(ticpp::Iterator<ticpp::Element>const &father);
00109 
00114     virtual SampleBlock<double> getSyncData()   {return data_; }
00115 
00116     //-----------------------------------------------
00117 
00118     boost::uint32_t old_frame_id_;
00119     boost::posix_time::ptime last_change_;
00120 
00121     bool connected_, event_reset_needed_;
00122 
00123     std::vector<double> KinectShmReader_data_;
00124 
00125     SampleBlock<double> data_;
00126     SampleBlock<double> empty_block_;
00127 
00128     boost::interprocess::shared_memory_object *shared_memory_obj_;
00129     boost::interprocess::mapped_region *region_;
00130 
00131     struct shared_memory_struct
00132     {
00133       double x, y, z, confidence;
00134       boost::uint32_t event, state, frame_id, clients;
00135 
00136       boost::interprocess::interprocess_mutex mutex;
00137     } *shared_memory_;
00138 
00139     // timeout for IPC in ms
00140     static const long TIMEOUT = 100;
00141 
00142     // name of shared memory
00143     static const char *SHARED_MEMORY_NAME;
00144 
00145     static const HWThreadBuilderTemplateRegistratorWithoutIOService<KinectShmReader> FACTORY_REGISTRATOR_;
00146 };
00147 
00148 } // Namespace tobiss
00149 
00150 #endif // HANDPOINT_H
00151 
00152 //-----------------------------------------------------------------------------
All Data Structures Files Functions Variables