Fawkes API  Fawkes Development Version
context_thread.h
1 
2 /***************************************************************************
3  * context_thread.h - OpenNI context providing thread
4  *
5  * Created: Sat Feb 26 15:23:16 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_OPENNI_CONTEXT_THREAD_H_
24 #define __PLUGINS_OPENNI_CONTEXT_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <core/utils/lockptr.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/blocked_timing.h>
32 #include <aspect/aspect_provider.h>
33 #include <plugins/openni/aspect/openni_inifin.h>
34 #include <utils/time/time.h>
35 
36 #include <sys/types.h>
37 #include <map>
38 #include <string>
39 
40 namespace xn {
41  class Context;
42  class Device;
43 }
44 
46 : public fawkes::Thread,
48  public fawkes::LoggingAspect,
50  public fawkes::ClockAspect,
52 {
53  public:
55  virtual ~OpenNiContextThread();
56 
57  virtual void init();
58  virtual void loop();
59  virtual void finalize();
60 
61  private:
62  void print_nodes();
63  void verify_active();
64  void start_sensor_server();
65  void stop_sensor_server();
66 
67  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
68  protected: virtual void run() { Thread::run(); }
69 
70  private:
72  fawkes::OpenNiAspectIniFin __openni_aspect_inifin;
73 
74  bool __cfg_run_sensor_server;
75  std::string __cfg_sensor_bin;
76  pid_t __sensor_server_pid;
77  xn::Device *__device;
78 
79  int __last_refcount;
80 
81  fawkes::Time __check_last;
82  fawkes::Time __check_now;
83 
84  unsigned int __device_no_data_loops;
85 
86  std::map<std::string, unsigned int> __dead_loops;
87 };
88 
89 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
A class for handling time.
Definition: time.h:91
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to use blocked timing.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect provide a new aspect.
Thread aspect to access configuration data.
Definition: configurable.h:35
OpenNI Context Thread.
Definition: openni.h:30
OpenNiAspect initializer/finalizer.
Definition: openni_inifin.h:35