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 BRAINAMPSERIES_H 00035 #define BRAINAMPSERIES_H 00036 00042 #include <string> 00043 00044 #include <boost/cstdint.hpp> 00045 #include <windows.h> 00046 #include <stdio.h> 00047 #include <io.h> 00048 #include <conio.h> 00049 #include <WinIoCtl.h> 00050 00051 #include "hardware/hw_thread.h" 00052 #include "hardware/hw_thread_builder.h" 00053 00054 #include "extern/include/brainproducts/BrainAmpIoCtl.h" 00055 #include "extern/include/FilterTools/iirbutterlpf.h" 00056 00057 namespace tobiss 00058 { 00059 00060 //----------------------------------------------------------------------------- 00061 00062 class BrainAmpSeries : public HWThread 00063 { 00064 public: 00065 BrainAmpSeries(ticpp::Iterator<ticpp::Element> hw); 00066 ~BrainAmpSeries(); 00067 00068 virtual SampleBlock<double> getSyncData(); 00069 virtual SampleBlock<double> getAsyncData(); 00070 00074 virtual void run(); 00078 virtual void stop(); 00079 00080 private: 00081 00082 enum AmpType 00083 { 00084 None = 0, Standard = 1, MR = 2, DCMRplus = 3, ExGMR = 4 00085 }; 00086 enum Resolution 00087 { 00088 r_100nV = 0, r_500nV = 1, r_10muV = 2, r_152_6muV = 3 00089 }; 00090 enum AcquisitionType 00091 { 00092 Impedance = 0, DataAcqu = 1, TestSignal = 2 00093 }; 00094 00098 virtual void setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father); 00102 virtual void setChannelSettings(ticpp::Iterator<ticpp::Element>const &father); 00106 void setHardware(ticpp::Iterator<ticpp::Element>const &hw); 00107 00108 void setBrainAmpSamplingRate(ticpp::Iterator<ticpp::Element>const &elem); 00109 void setDeviceLowImp(ticpp::Iterator<ticpp::Element>const &elem); 00110 void setDeviceTriggerValue(ticpp::Iterator<ticpp::Element>const &elem); 00111 void setDeviceLowpass250(ticpp::Iterator<ticpp::Element>const &elem); 00112 void setDeviceDCCoupling(ticpp::Iterator<ticpp::Element>const &elem); 00113 void setDeviceResolution(ticpp::Iterator<ticpp::Element>const &elem); 00114 void setDeviceCalibrationMode(ticpp::Iterator<ticpp::Element>const &elem); 00115 00116 void setChannelLowpass250(ticpp::Iterator<ticpp::Element>const &father); 00117 void setChannelDCDecoupling(ticpp::Iterator<ticpp::Element>const &father); 00118 void setChannelResolution(ticpp::Iterator<ticpp::Element>const &father); 00119 00120 void setTriggerLine(ticpp::Iterator<ticpp::Element>const &elem); 00121 void checkTriggerLineChannel(); 00122 00123 std::string getErrorMsg(int error_code); 00124 void setBrainAmpChannelList(); 00125 bool OpenUSBDevice(); 00126 std::vector<AmpType> GetConnectedAmps(); 00127 void printConnectedAmplifiers( std::vector<AmpType> amps); 00128 void checkHighestChannelNr( std::vector<AmpType> amps); 00129 void initDownsamplingFilters(); 00130 00131 bool readData(); 00132 void fillSampleVector(); 00133 void doDownSamplingAndFillSampleVector(); 00134 unsigned int findChannelPostionInChannelList(boost::uint32_t ch); 00135 00136 private: 00137 00138 std::vector<short> raw_buffer_; 00139 std::vector<double> downsampling_buffer_; 00140 std::vector<unsigned short> trigger_buffer_; 00141 std::vector<double> samples_; 00142 00143 BA_SETUP brainamp_settings_; 00144 BA_CALIBRATION_SETTINGS brainamp_calibration_settings_; 00145 00146 long acqu_type_; 00147 HANDLE dev_handle_; 00148 int driver_version_; 00149 00150 vector< IIRButterLpf<double> > lp_filters_; 00151 unsigned int ds_factor_; 00152 00153 bool trigger_line_enabled_; 00154 boost::uint32_t trigger_line_sig_type_; 00155 00156 00157 //----------------------------------------------- 00158 // Constants 00159 00160 static const HWThreadBuilderTemplateRegistratorWithoutIOService<BrainAmpSeries> factory_registrator_; 00161 static const std::string hw_low_imp_; 00162 static const std::string hw_trigger_value_; 00163 static const std::string hw_trigger_line_; 00164 static const std::string hw_250lp_; 00165 static const std::string hw_dc_coupl_; 00166 static const std::string hw_resolution_; 00167 static const std::string hw_calibration_; 00168 static const std::string hw_calib_on_; 00169 static const std::string hw_calib_sig_; 00170 static const std::string hw_calib_freq_; 00171 00172 static const std::string hw_value_; 00173 00174 static const float scaling_values_[]; 00175 std::map<std::string, unsigned int> resolution_names_; 00176 00180 std::map<std::string, unsigned int> calibration_signals_; 00181 00185 std::map<AmpType, std::pair<std::string, unsigned int> > channels_per_amp_; // 00186 00187 }; 00188 00189 } //tobiss 00190 00191 #endif // BRAINAMPSERIES_H