Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef UNLOCK_SIGNAL_HPP
00028 #define UNLOCK_SIGNAL_HPP
00029
00030 #include "ISignal.hpp"
00031 #include "NonblockingSignal.hpp"
00032 #include "Portability.hpp"
00033 #include "PythonSignal.hpp"
00034 #include "ITimer.hpp"
00035 #include "WinTimer.hpp"
00036
00037 #include <boost/python.hpp>
00038 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
00039 #include <vector>
00040 #include <stdint.h>
00041
00042 using namespace boost::python;
00043
00044 class DllExport SignalPythonWrap : public ISignal, public wrapper<ISignal>
00045 {
00046 public:
00047 SignalPythonWrap(ISignal* pSignal) : mpSignal(pSignal) {
00048
00049 }
00050
00051 virtual ~SignalPythonWrap() {
00052 delete mpSignal;
00053 }
00054
00055 bool open(uint8_t mac[]) {
00056 return this->get_override("open")(mac);
00057 }
00058
00059 bool init(size_t channels) {
00060 return this->get_override("init")(channels);
00061 }
00062
00063 size_t channels() {
00064 return this->get_override("channels")();
00065 }
00066
00067 bool start() {
00068 return this->get_override("start")();
00069 }
00070
00071 size_t acquire() {
00072 return this->get_override("acquire")();
00073 return 0;
00074 }
00075
00076 void getdata(uint32_t* data, size_t n) {
00077 this->get_override("getdata")(data, n);
00078 }
00079
00080 uint64_t timestamp() {
00081 return this->get_override("timestamp")();
00082 return 0;
00083 }
00084
00085 bool stop() {
00086 return this->get_override("stop")();
00087 }
00088
00089 bool close() {
00090 return this->get_override("close")();
00091 }
00092 private:
00093 ISignal* mpSignal;
00094 };
00095
00096 class DllExport TimerPythonWrap : public ITimer, public wrapper<ITimer>
00097 {
00098 public:
00099 TimerPythonWrap(ITimer* pTimer) : mpTimer(pTimer) {
00100 }
00101
00102 virtual ~TimerPythonWrap() {
00103 delete mpTimer;
00104 }
00105
00106 void start() {
00107 this->get_override("start")();
00108 }
00109
00110 uint32_t elapsedCycles() {
00111 return this->get_override("elapsedCycles")();
00112 }
00113
00114 uint32_t elapsedMilliSecs() {
00115 return this->get_override("elapsedMilliSecs")();
00116 }
00117
00118 uint32_t elapsedMicroSecs() {
00119 return this->get_override("elapsedMicroSecs")();
00120 }
00121
00122 int64_t getFrequency() {
00123 return this->get_override("getFrequency")();
00124 }
00125
00126 int64_t getStartValue() {
00127 return this->get_override("getStartValue")();
00128 }
00129
00130 private:
00131 ITimer* mpTimer;
00132 };
00133
00134 BOOST_PYTHON_MODULE(neuralsignal)
00135 {
00136 class_<std::vector<int32_t> >("int32_vector")
00137 .def(vector_indexing_suite<std::vector<int32_t> >() );
00138
00139
00140
00141 class_<SignalPythonWrap, boost::noncopyable>("ISignal", no_init)
00142 .def("open", pure_virtual(&ISignal::open))
00143 .def("init", pure_virtual(&ISignal::init))
00144 .def("channels", pure_virtual(&ISignal::channels))
00145 .def("start", pure_virtual(&ISignal::start))
00146 .def("acquire", pure_virtual(&ISignal::acquire))
00147 .def("getdata", pure_virtual(&ISignal::getdata))
00148 .def("timestamp", pure_virtual(&ISignal::timestamp))
00149 .def("stop", pure_virtual(&ISignal::stop))
00150 .def("close", pure_virtual(&ISignal::close))
00151 ;
00152
00153 class_<NonblockingSignal, bases<ISignal> >("NonblockingSignal", init<ISignal*>())
00154 .def("open", &NonblockingSignal::open)
00155 .def("init", &NonblockingSignal::init)
00156 .def("channels", &NonblockingSignal::channels)
00157 .def("start", &NonblockingSignal::start)
00158 .def("acquire", &NonblockingSignal::acquire)
00159 .def("getdata", &NonblockingSignal::getdata)
00160 .def("timestamp", &NonblockingSignal::timestamp)
00161 .def("stop", &NonblockingSignal::stop)
00162 .def("close", &NonblockingSignal::close)
00163 ;
00164
00165 class_<PythonSignal>("PythonSignal", init<ISignal*, ITimer*>())
00166 .def("open", &PythonSignal::open)
00167 .def("init", &PythonSignal::init)
00168 .def("channels", &PythonSignal::channels)
00169 .def("start", &PythonSignal::start)
00170 .def("acquire", &PythonSignal::acquire)
00171 .def("getdata", &PythonSignal::getdata)
00172 .def("elapsedMicroSecs", &PythonSignal::elapsedMicroSecs)
00173 .def("timestamp", &PythonSignal::timestamp)
00174 .def("stop", &PythonSignal::stop)
00175 .def("close", &PythonSignal::close)
00176 ;
00177 }
00178
00179 #endif