00001 00002 // Copyright (c) James Percent and Unlock contributors. 00003 // All rights reserved. 00004 // Redistribution and use in source and binary forms, with or without modification, 00005 // are permitted provided that the following conditions are met: 00006 // 00007 // 1. Redistributions of source code must retain the above copyright notice, 00008 // this list of conditions and the following disclaimer. 00009 // 00010 // 2. Redistributions in binary form must reproduce the above copyright 00011 // notice, this list of conditions and the following disclaimer in the 00012 // documentation and/or other materials provided with the distribution. 00013 // 00014 // 3. Neither the name of Unlock nor the names of its contributors may be used 00015 // to endorse or promote products derived from this software without 00016 // specific prior written permission. 00017 00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00019 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00020 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00022 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00025 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 00029 #ifndef PYNOBIO_HPP 00030 #define PYNOBIO_HPP 00031 00032 #include <Windows.h> 00033 //#include <boost/mutex.hpp> 00034 #include <boost/thread.hpp> 00035 #include <fstream> 00036 00037 #include "ISignal.hpp" 00038 #include "ITimer.hpp" 00039 #include "IEnobioSignalHandler.hpp" 00040 #include "EnobioDataReceiver.hpp" 00041 #include "EnobioStatusReceiver.hpp" 00042 #include "Enobio3G.h" 00043 #include "Channeldata.h" 00044 #include "StatusData.h" 00045 #include "Portability.hpp" 00046 00047 class DllExport EnobioSignalHandler : public ISignal, public IEnobioSignalHandler { 00048 public: 00049 EnobioSignalHandler(Enobio3G* pEnobio3G, ITimer* pTimer); 00050 virtual ~EnobioSignalHandler(); 00051 void setEnobioDataReceiver(EnobioDataReceiver* pDataReceiver); 00052 void setEnobioStatusReceiver(EnobioStatusReceiver* pStatusReceiver); 00053 00054 public: // IEnobioSignalHandler 00055 virtual void handleStatusData(StatusData* pStatusData); 00056 virtual void handleChannelData(ChannelData* pChannelData); 00057 00058 public: //ISignal 00059 virtual bool open(uint8_t* mac); 00060 virtual bool init(size_t channels); 00061 virtual size_t channels(); 00062 virtual bool start(); 00063 virtual size_t acquire(); 00064 virtual void getdata(uint32_t* buffer, size_t samples); 00065 virtual uint64_t timestamp(); 00066 bool stop(); 00067 bool close(); 00068 00069 private: 00070 Enobio3G* mpEnobio3G; 00071 ITimer* mpTimer; 00072 EnobioDataReceiver* mpDataReceiver; 00073 EnobioStatusReceiver* mpStatusReceiver; 00074 uint32_t* mpRawBuffer; 00075 uint32_t* mpSamples; 00076 size_t mNumSamples; 00077 size_t mNumChannels; 00078 uint64_t mTimeStamp; 00079 HANDLE mhEvent; 00080 boost::mutex mMutex; 00081 bool mOpened; 00082 bool mStarted; 00083 std::ofstream mRawEnobioLog; 00084 }; 00085 00086 #endif