TOBI SignalServer
0.1
|
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 00034 #ifndef G_MOBILAB_H 00035 #define G_MOBILAB_H 00036 00042 #include <vector> 00043 #include <string> 00044 00045 #include <boost/thread.hpp> 00046 00047 #include "serial_port_base.h" 00048 #include "hardware/hw_thread.h" 00049 #include "hardware/hw_thread_builder.h" 00050 00051 namespace tobiss 00052 { 00053 //----------------------------------------------------------------------------- 00054 00066 class GMobilab : private SerialPortBase, public HWThread 00067 { 00068 public: 00072 GMobilab(boost::asio::io_service& io, 00073 ticpp::Iterator<ticpp::Element> hw); 00077 virtual ~GMobilab(); 00078 00079 virtual SampleBlock<double> getSyncData(); 00080 virtual SampleBlock<double> getAsyncData(); 00081 00085 virtual void run(); 00089 virtual void stop(); 00090 00091 private: 00095 virtual void setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father); 00099 virtual void setChannelSettings(ticpp::Iterator<ticpp::Element>const &father); 00103 void setHardware(ticpp::Iterator<ticpp::Element>const &hw); 00104 00108 void setScalingValues(); 00112 unsigned char getChannelCode(); 00113 00117 void checkNrOfChannels(); 00118 00122 void acquireData(); 00123 00124 enum device_types_ { MOBILAB_EEG, MOBILAB_MULTI }; 00125 00126 private: 00127 device_types_ mobilab_type_; 00128 std::map<unsigned int, unsigned char> channel_coding_; 00129 std::vector<double> scaling_factors_; 00130 std::vector<boost::int16_t> raw_data_; 00131 std::vector<double> samples_; 00132 00133 boost::thread* async_acqu_thread_; 00134 00135 static const HWThreadBuilderTemplateRegistrator<GMobilab> factory_registrator_; 00136 00137 //-------------------------------------- 00138 // Constants: 00139 00140 static const std::string hw_mobilab_serial_port_; 00141 static const std::string hw_mobilab_type_; 00142 static const std::string hw_mobilab_eeg_; 00143 static const std::string hw_mobilab_multi_; 00144 00145 }; 00146 00147 //----------------------------------------------------------------------------- 00148 00149 } // Namespace tobiss 00150 00151 00152 #endif // G_MOBILAB_H