TOBI SignalServer  0.1
/home/breidi/Dropbox/signalserver/src/hardware/usbamp.cpp
Go to the documentation of this file.
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 
00038 #include "winsock2.h"
00039 #include "hardware/usbamp.h"
00040 #include "tia/constants.h"
00041 
00042 #include <boost/bind.hpp>
00043 #include <boost/numeric/conversion/cast.hpp>
00044 #include <boost/format.hpp>
00045 #include <boost/lexical_cast.hpp>
00046 #include <boost/algorithm/string.hpp>
00047 
00048 namespace tobiss
00049 {
00050 using boost::uint8_t;
00051 using boost::uint16_t;
00052 using boost::uint32_t;
00053 
00054 using std::cout;
00055 using std::cerr;
00056 using std::endl;
00057 using std::left;
00058 using std::right;
00059 using std::string;
00060 using std::vector;
00061 using std::map;
00062 using std::pair;
00063 
00064 using boost::lexical_cast;
00065 using boost::bad_lexical_cast;
00066 using boost::algorithm::to_lower_copy;
00067 
00068 
00069 std::set<std::string> USBamp::serials_;
00070 bool USBamp::is_usbamp_master_(0);
00071 
00072 USBamp* USBamp::master_device_(0);
00073 std::vector<USBamp*>  USBamp::slave_devices_;
00074 
00075 static const unsigned int USBAMP_MAX_NR_OF_AMPS   = 8;
00076 static const unsigned int USBAMP_MAX_NR_OF_CHANNELS   = 17;
00077 static const unsigned int USBAMP_NR_OF_CHANNEL_GROUPS = 4;
00078 static const unsigned int USBAMP_NOTCH_HALF_WIDTH = 2;   // to one side  ...  e.g.  f_center = 50 Hz -->  48/52 Hz
00079 static const unsigned int USBAMP_ERROR_MSG_SIZE = 256;
00080 static const unsigned int USBAMP_NR_OF_OVERLAPPED = 8;
00081 
00082 
00083 const HWThreadBuilderTemplateRegistratorWithoutIOService<USBamp> USBamp::FACTORY_REGISTRATOR_ ("usbamp", "g.usbamp");
00084 
00085 const string USBamp::hw_filter_("filter");
00086 const string USBamp::hw_filter_type_("type");
00087 const string USBamp::hw_filter_order_("order");
00088 const string USBamp::hw_filter_low_("f_low");
00089 const string USBamp::hw_filter_high_("f_high");
00090 
00091 const string USBamp::hw_notch_("notch");
00092 const string USBamp::hw_notch_center_("f_center");
00093 
00094 const string USBamp::hw_opmode_("operation_mode");
00095 const string USBamp::hw_sc_("shortcut");
00096 const string USBamp::hw_trigger_line_("trigger_line");
00097 const string USBamp::hw_usbampmaster_("usbamp_master");
00098 const string USBamp::hw_comgnd_("common_ground");
00099 const string USBamp::hw_gnd_("gnd");
00100 const string USBamp::hw_gnd_block_("block");
00101 const string USBamp::hw_gnd_value_("value");
00102 
00103 const string USBamp::hw_comref_("common_reference");
00104 const string USBamp::hw_cr_("cr");
00105 const string USBamp::hw_cr_block_("block");
00106 const string USBamp::hw_cr_value_("value");
00107 
00108 const string USBamp::hw_bipolar_("bipolar");
00109 const string USBamp::hw_bipolar_with_("with");
00110 const string USBamp::hw_drl_("driven_right_leg");
00111 const string USBamp::hw_drl_value_("value");
00112 
00113 //-----------------------------------------------------------------------------
00114 
00115 template<typename T> inline bool isnan(T value)
00116 {
00117   return value != value;
00118 }
00119 
00120 //-----------------------------------------------------------------------------
00121 
00122 USBamp::USBamp(ticpp::Iterator<ticpp::Element> hw)
00123   : HWThread(), enable_sc_(0),
00124     external_sync_(0), trigger_line_(0), trigger_line_sig_type_(SIG_USER_1),
00125     sample_count_(0), error_count_(0) ,error_code_(0), error_msg_(0),
00126     driver_buffer_size_(0), timeout_(0), expected_values_(0),
00127     first_run_(1), current_overlapped_(0),
00128     h_(0), nr_of_bp_filters_(0), bp_filters_(0), nr_of_notch_filters_(0),
00129     notch_filters_(0)
00130 
00131 {
00132   #ifdef DEBUG
00133     cout << "USBamp: Constructor" << endl;
00134   #endif
00135 
00136   usbamp_filter_types_.insert(pair <string,int>("chebyshev", 1));
00137   usbamp_filter_types_.insert(pair <string,int>("cheby", 1));
00138   usbamp_filter_types_.insert(pair <string,int>("butterworth", 2));
00139   usbamp_filter_types_.insert(pair <string,int>("butter", 2));
00140 
00141   usbamp_opModes_.insert(pair <string,string>("normal", "M_NORMAL"));
00142   usbamp_opModes_.insert(pair <string,string>("calibrate", "M_CALIBRATE"));
00143   usbamp_opModes_.insert(pair <string,string>("impedance", "M_IMPEDANCE"));
00144 
00145   usbamp_block_names_.insert(pair <string,int>("a", 0));
00146   usbamp_block_names_.insert(pair <string,int>("b", 1));
00147   usbamp_block_names_.insert(pair <string,int>("c", 2));
00148   usbamp_block_names_.insert(pair <string,int>("d", 3));
00149 
00150   setType("g.USBamp");
00151 
00152   ticpp::Iterator<ticpp::Element> elem(hw);
00153   ticpp::Iterator< ticpp::Attribute > attribute;
00154 
00155   for(attribute = attribute.begin(elem.Get()); attribute != attribute.end();
00156       attribute++)
00157     m_.insert(pair<string, string>(attribute->Name(), attribute->Value()));
00158 
00159   checkMandatoryHardwareTags(hw);
00160 
00161   ov_.resize(USBAMP_NR_OF_OVERLAPPED);
00162   data_Ev_.resize(USBAMP_NR_OF_OVERLAPPED);
00163   bytes_received_.resize(USBAMP_NR_OF_OVERLAPPED);
00164 
00165   getHandles();
00166   initFilterPtrs();
00167   setHardware(hw);
00168 
00169   expected_values_ = nr_ch_ * blocks_;
00170 
00171   driver_buffer_size_ = expected_values_ * sizeof(float) + HEADER_SIZE;
00172 
00173   for(unsigned int n = 0; n < ov_.size(); n++)
00174     driver_buffer_.push_back( new BYTE[driver_buffer_size_] );
00175 
00176   // raw_buffer_.reserve(USBAMP_SAMPLE_BUFFER_MULTIPLIER *
00177                         // (expected_values_ * sizeof(float)) );
00178 
00179   error_msg_ = new CHAR[USBAMP_ERROR_MSG_SIZE];
00180 
00181   data_.init(blocks_, nr_ch_, channel_types_);
00182   samples_.resize(expected_values_, 0);
00183 
00184   initUSBamp();
00185 
00186   if(external_sync_)
00187     slave_devices_.push_back(this);
00188   else
00189     master_device_ = this;
00190 
00191   cout << endl;
00192   cout << " --> g.USBamp " << serial_;
00193   cout << "  (driver version: " << usb_amp_.getDriverVersion ();
00194   cout << ", hardware version: " << usb_amp_.getHWVersion (h_) << ")" <<  endl;
00195 
00196   if(!homogenous_signal_type_)
00197   {
00198     cout << "   ... NOTICE: Device is acquiring different signal types" << endl;
00199     cout << "     --  ensure that reference and ground settings are correctly set!" << endl;
00200   }
00201 }
00202 
00203 //-----------------------------------------------------------------------------
00204 
00205 USBamp::~USBamp()
00206 {
00207   #ifdef DEBUG
00208     cout << "USBamp: Destructor" << endl;
00209   #endif
00210 
00211   delete[] bp_filters_;
00212   delete[] notch_filters_;
00213   for(unsigned int n = 0; n < driver_buffer_.size(); n++)
00214     delete[] driver_buffer_[n];
00215   delete[] error_msg_;
00216 }
00217 
00218 //-----------------------------------------------------------------------------
00219 
00220 void USBamp::setHardware(ticpp::Iterator<ticpp::Element>const& hw)
00221 {
00222   #ifdef DEBUG
00223     cout << "USBamp: setHardware" << endl;
00224   #endif
00225 
00226   ticpp::Iterator<ticpp::Element> ds(hw->FirstChildElement(hw_devset_, true));
00227 
00228   setDeviceSettings(ds);
00229 
00230   ticpp::Iterator<ticpp::Element> cs(hw->FirstChildElement(hw_chset_, false));
00231   if (cs != cs.end())
00232   {
00233     for(ticpp::Iterator<ticpp::Element> it(cs); ++it != it.end(); )
00234       if(it->Value() == hw_chset_)
00235       {
00236         string ex_str(type_ + " -- Multiple channel_settings found!");
00237         throw(std::invalid_argument(ex_str));
00238       }
00239       setChannelSettings(cs);
00240   }
00241 
00242   checkTriggerLineChannel();
00243 }
00244 
00245 //-----------------------------------------------------------------------------
00246 
00247 SampleBlock<double> USBamp::getSyncData()
00248 {
00249   #ifdef DEBUG
00250     cout << "USBamp: getSyncData" << endl;
00251   #endif
00252 
00253   if(!running_)
00254   {
00255     cout << "Not running!" << endl;
00256     return(data_);
00257   }
00258 
00259   boost::unique_lock<boost::shared_mutex> lock(rw_);
00260   bytes_received_[current_overlapped_] = 0;
00261 
00262   if(!first_run_)
00263   {
00264     for(uint32_t n = 0; n < slave_devices_.size(); n++)
00265       slave_devices_[n]->callGT_GetData();
00266     callGT_GetData();
00267   }
00268   else
00269     first_run_ = false;
00270 
00271   for(uint32_t n = 0; n < slave_devices_.size(); n++)
00272     slave_devices_[n]->fillSyncBuffer();
00273   fillSyncBuffer();
00274 
00275   fillSampleBlock();
00276   for(uint32_t n = 0; n < slave_devices_.size(); n++)
00277     slave_devices_[n]->fillSampleBlock();
00278 
00279   lock.unlock();
00280   return(data_);
00281 }
00282 
00283 //-----------------------------------------------------------------------------
00284 
00285 SampleBlock<double> USBamp::getAsyncData()
00286 {
00287   #ifdef DEBUG
00288     cout << "USBamp: getAsyncData" << endl;
00289   #endif
00290 
00291   if(!running_)
00292   {
00293     // cout << "Not running!" << endl;
00294     return(data_);
00295   }
00296 
00297 //   cout << " --> getting Slave data ..." << endl;
00298   if(external_sync_)
00299     return(data_);
00300 
00301   throw(std::runtime_error("USBamp::getAsyncData -- Async data acquisition not available for g.USBamp yet!"));
00302 
00303 //   boost::shared_lock<boost::shared_mutex> lock(rw_);
00304 //   vector<float> tmp(buffer);
00305 //   samples_available_ = false;
00306 //   lock.unlock();
00307 //   return(tmp);
00308   return(data_);
00309 }
00310 
00311 //-----------------------------------------------------------------------------
00312 
00313 inline void USBamp::callGT_GetData()
00314 {
00315   // if(first_run_)
00316   // {
00317     // for(unsigned int n = 0; n < ov_.size(); n++)
00318       // if( !GT_GetData(h_, driver_buffer_[n], driver_buffer_size_, &ov_[n]))
00319         // throw(std::runtime_error("USBamp::getSyncData -- Error getting data!"));
00320 
00321     // first_run_ = false;
00322     // return;
00323   // }
00324 
00325   if( !usb_amp_.getData(h_, driver_buffer_[current_overlapped_], driver_buffer_size_, &ov_[current_overlapped_]))
00326     throw(std::runtime_error("USBamp::getSyncData -- Error getting data!"));
00327 
00328   // GT_GetData(h_, driver_buffer_[current_overlapped_], driver_buffer_size_, &ov_[current_overlapped_]);
00329 
00330 }
00331 
00332 //-----------------------------------------------------------------------------
00333 
00334 void USBamp::callGT_ResetTransfer()
00335 {
00336   if( !usb_amp_.resetTransfer (h_))
00337     throw(std::runtime_error("USBamp::run -- Error resetting transfer!"));
00338 
00339   for(unsigned int n = 0; n < ov_.size(); n++)
00340     ResetEvent(data_Ev_[n]);
00341 }
00342 
00343 //-----------------------------------------------------------------------------
00344 
00345 inline void USBamp::callGT_Start()
00346 {
00347   if( !usb_amp_.start (h_))
00348     throw(std::runtime_error("USBamp::run -- Error starting g.USBamp!"));
00349 
00350 }
00351 
00352 //-----------------------------------------------------------------------------
00353 
00354 void USBamp::fillSyncBuffer()
00355 {
00356   if(!running_)
00357     return;
00358 
00359   samples_available_ = true;
00360   check4USBampError();
00361 
00362   timeout_ = WaitForSingleObject(data_Ev_[current_overlapped_],1000);
00363   if(timeout_ == WAIT_TIMEOUT)
00364   {
00365     cerr << "Timeout!" << endl;
00366   if( !usb_amp_.resetTransfer(h_))
00367       throw(std::runtime_error("USBamp::getSyncData -- Error resetting transfer!"));
00368     return;
00369   }
00370 
00371   GetOverlappedResult(h_, &ov_[current_overlapped_], &bytes_received_[current_overlapped_], false);
00372   sample_count_++;
00373 
00374   bytes_received_[current_overlapped_] -= HEADER_SIZE;
00375 
00376   if(bytes_received_[current_overlapped_] != expected_values_ * sizeof(float) )
00377   {
00378     cerr << "Received not enough data  at sample " << sample_count_ << "... " << bytes_received_[current_overlapped_] << ";  expected: " << expected_values_ * sizeof(float) << endl;
00379 
00380     for(unsigned int n = 0; n < ( (expected_values_ * sizeof(float) ) - bytes_received_[current_overlapped_] ) ; n++)
00381       driver_buffer_[current_overlapped_][ bytes_received_[current_overlapped_] + n ]  = 0;
00382   }
00383 
00384 }
00385 
00386 //-----------------------------------------------------------------------------
00387 
00388 void USBamp::fillSampleBlock()
00389 {
00390   unsigned int pos = 0;
00391   for(unsigned int k = 0; k < expected_values_/blocks_ ; k++)
00392     for(unsigned int j = 0; j < blocks_; j++)
00393     {
00394       pos = (k*blocks_) + j;
00395       samples_[ pos ] = *(reinterpret_cast<float*>(driver_buffer_[current_overlapped_] + HEADER_SIZE + (k +(j* expected_values_/blocks_) )*sizeof(float) ));
00396 
00397       if( isnan( samples_[pos] ) )
00398          cerr << "Received NaNs at block " << sample_count_ << "!" << endl;
00399     }
00400 
00401   data_.setSamples(samples_);
00402 
00403   (current_overlapped_ == ov_.size() -1)?(current_overlapped_ = 0):(current_overlapped_++);
00404 }
00405 
00406 //-----------------------------------------------------------------------------
00407 
00408 void USBamp::check4USBampError()
00409 {
00410   #ifdef DEBUG
00411     cout << "USBamp: check4USBampError" << endl;
00412   #endif
00413 
00414   error_code_ = 0;
00415   CHAR* error_ptr = error_msg_;
00416 
00417   if( !usb_amp_.getLastError(&error_code_, error_ptr))
00418     throw(std::runtime_error("USBamp::getSyncData -- Error getting last error message!"));
00419 
00420   if(error_code_)
00421     cerr << "Error code: " << error_code_ << ";  Error message: " << error_msg_ << endl;
00422 }
00423 
00424 //-----------------------------------------------------------------------------
00425 
00426 void USBamp::getHandles()
00427 {
00428   #ifdef DEBUG
00429     cout << "USBamp: getHandles" << endl;
00430   #endif
00431 
00432   if(serials_.find(m_.find(hardware_serial_)->second) != serials_.end())
00433     throw(std::invalid_argument("USBamp::getHandles -- g.USBamp with serial "\
00434           +m_.find(hardware_serial_)->second+" already in use!"));
00435 
00436   if(m_.find(hardware_serial_)->second == "")
00437     throw(std::invalid_argument("USBamp::getHandles -- No serial number for g.USBamp given!"));
00438 
00439   serials_.insert(m_.find(hardware_serial_)->second);
00440   serial_ = m_.find(hardware_serial_)->second;
00441 
00442   HANDLE h_tmp;
00443   h_tmp = usb_amp_.openDeviceEx( const_cast<LPSTR>(  m_.find(hardware_serial_)->second.c_str() ));
00444   if(h_tmp != 0)
00445   {
00446     h_ = (h_tmp);
00447     for(unsigned int n = 0; n < ov_.size(); n++)
00448     {
00449       memset(&ov_[n], 0, sizeof(OVERLAPPED) );
00450       data_Ev_[n] = CreateEvent(0, false, false, 0);
00451 
00452       ov_[n].hEvent = data_Ev_[n];
00453       ov_[n].Offset = 0;
00454       ov_[n].OffsetHigh = 0;
00455       // ResetEvent(data_Ev_[n]);   ... done in callGT_RestetTransfer
00456     }
00457   }
00458   else
00459   {
00460   printAvailableAmps();
00461     throw(std::invalid_argument("USBamp::getHandles -- g.USBamp with serial "\
00462           +m_.find(hardware_serial_)->second+" not connected!"));
00463   }
00464 }
00465 
00466 //-----------------------------------------------------------------------------
00467 
00468 void USBamp::initFilterPtrs()
00469 {
00470   #ifdef DEBUG
00471     cout << "USBamp: initFilterPtrs" << endl;
00472   #endif
00473 
00474   if( !usb_amp_.getNumberOfFilter(&nr_of_bp_filters_))
00475     throw(std::runtime_error("USBamp::initFilterPtrs -- Error getting number of filter!"));
00476   bp_filters_ = new FILT[nr_of_bp_filters_];
00477   if( !usb_amp_.getFilterSpec(bp_filters_))
00478     throw(std::runtime_error("USBamp::initFilterPtrs -- Error getting filter specifications!"));
00479 
00480   if( !usb_amp_.getNumberOfNotch(&nr_of_notch_filters_))
00481     throw(std::runtime_error("USBamp::initFilterPtrs -- Error getting number of notch!"));
00482   notch_filters_ = new FILT[nr_of_notch_filters_];
00483   if( !usb_amp_.getNotchSpec(notch_filters_))
00484     throw(std::runtime_error("USBamp::initFilterPtrs -- Error getting notch specifications!"));
00485 }
00486 
00487 //-----------------------------------------------------------------------------
00488 
00489 void USBamp::run()
00490 {
00491   #ifdef DEBUG
00492     cout << "USBamp: run" << endl;
00493   #endif
00494 
00495   if(!external_sync_)
00496   {
00497     for(uint32_t n = 0; n < slave_devices_.size(); n++)
00498       slave_devices_[n]->callGT_ResetTransfer();
00499 
00500     callGT_ResetTransfer();
00501 
00502     for(uint32_t n = 0; n < slave_devices_.size(); n++)
00503       slave_devices_[n]->callGT_Start();
00504 
00505     callGT_Start();
00506 
00507     for(unsigned int m = 0; m < ov_.size(); m++)
00508     {
00509       current_overlapped_ = m;
00510 
00511       for(uint32_t n = 0; n < slave_devices_.size(); n++)
00512         slave_devices_[n]->callGT_GetData();
00513       callGT_GetData();
00514     }
00515     current_overlapped_ = 0;
00516     first_run_ = true;
00517 
00518 
00519     for(uint32_t n = 0; n < slave_devices_.size(); n++)
00520     {
00521       slave_devices_[n]->running_ = 1;
00522       cout << " * g.USBamp " << slave_devices_[n]->serial_ << " sucessfully started by the master" << endl;
00523     }
00524 
00525     running_ = 1;
00526     cout << " * g.USBamp " << serial_ << " sucessfully started" << endl;
00527 
00528   }
00529   else
00530     cout << " * g.USBamp " << serial_ << " will be started by the master ..." << endl;
00531 }
00532 
00533 //-----------------------------------------------------------------------------
00534 
00535 void USBamp::stop()
00536 {
00537   #ifdef DEBUG
00538     cout << "USBamp: stop" << endl;
00539   #endif
00540 
00541   if(!running_)
00542     return;
00543   cout << " * stopping USBamp "  << m_.find(hardware_serial_)->second << " ... ";
00544   boost::unique_lock<boost::shared_mutex> lock(rw_);
00545   running_ = 0;
00546 
00547   if(!external_sync_)
00548     for(uint32_t n = 0; n < slave_devices_.size(); n++)
00549       slave_devices_[n]->stop();
00550 
00551   if( !usb_amp_.stop (h_))
00552     throw(std::runtime_error("USBamp::stop -- Error stopping the device!"));
00553 
00554   if( !usb_amp_.closeDevice (&h_))
00555     throw(std::runtime_error("USBamp::stop -- Error closing the device!"));
00556 
00557   h_ = 0;
00558   serials_.erase(m_.find(hardware_serial_)->second);
00559 
00560   for(unsigned int n = 0; n < ov_.size(); n++)
00561     CloseHandle(data_Ev_[n]);
00562   lock.unlock();
00563 
00564 
00565   serials_.erase(m_.find(hardware_serial_)->second);
00566 }
00567 
00568 //-----------------------------------------------------------------------------
00569 
00570 void USBamp::setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father)
00571 {
00572   #ifdef DEBUG
00573     cout << "USBamp: setDeviceSettings" << endl;
00574   #endif
00575 
00576   ticpp::Iterator<ticpp::Element> elem(father->FirstChildElement(hw_fs_,true));
00577     setSamplingRate(elem);
00578 
00579   elem = father->FirstChildElement(hw_channels_,false);
00580   if(elem != elem.end())
00581     setDeviceChannels(elem);
00582   checkNrOfChannels();
00583 
00584   elem = father->FirstChildElement(hw_blocksize_,true);
00585   if(elem != elem.end())
00586     setBlocks(elem);
00587 
00588   setDefaultSettings();
00589 
00590   //---- optional ---
00591 
00592   elem = father->FirstChildElement(hw_filter_,false);
00593   if(elem != elem.end())
00594     setDeviceFilterSettings(elem);
00595 
00596   elem = father->FirstChildElement(hw_notch_,false);
00597   if(elem != elem.end())
00598     setDeviceNotchSettings(elem);
00599 
00600   elem = father->FirstChildElement(hw_opmode_,false);
00601   if(elem != elem.end())
00602     setOperationMode(elem);
00603 
00604   elem = father->FirstChildElement(hw_sc_,false);
00605   if(elem != elem.end())
00606     setShortCut(elem);
00607 
00608   elem = father->FirstChildElement(hw_trigger_line_,false);
00609   if(elem != elem.end())
00610     setTriggerLine(elem);
00611 
00612   elem = father->FirstChildElement(hw_usbampmaster_,false);
00613   if(elem != elem.end())
00614     setUSBampMasterOrSlave(elem);
00615 
00616   elem = father->FirstChildElement(hw_comgnd_,false);
00617   if(elem != elem.end())
00618     setCommonGround(elem);
00619 
00620   elem = father->FirstChildElement(hw_comref_,false);
00621   if(elem != elem.end())
00622     setCommonReference(elem);
00623 
00624   elem = father->FirstChildElement(hw_drl_,false);
00625   if(elem != elem.end())
00626     setDrivenRightLeg(elem);
00627 }
00628 
00629 //---------------------------------------------------------------------------------------
00630 
00631 void USBamp::setChannelSettings(ticpp::Iterator<ticpp::Element>const &father)
00632 {
00633   #ifdef DEBUG
00634     cout << "USBamp: setChannelSettings" << endl;
00635   #endif
00636 
00637   ticpp::Iterator<ticpp::Element> elem(father->FirstChildElement(hw_chset_sel_,false));
00638   if (elem != elem.end())
00639     setChannelSelection(elem);
00640   checkNrOfChannels();
00641 
00642   adjustSettingsToChannelSelection();
00643 
00644   elem = father->FirstChildElement(hw_filter_,false);
00645   if(elem != elem.end())
00646     setChannelFilterSettings(elem);
00647 
00648   elem = father->FirstChildElement(hw_notch_,false);
00649   if(elem != elem.end())
00650     setChannelNotchSettings(elem);
00651 
00652   elem = father->FirstChildElement(hw_bipolar_,false);
00653   if(elem != elem.end())
00654     setBipolar(elem);
00655 
00656   elem = father->FirstChildElement(hw_drl_,false);
00657   if(elem != elem.end())
00658     setDrivenRightLeg(elem);
00659 }
00660 
00661 //---------------------------------------------------------------------------------------
00662 
00663 void USBamp::setDefaultSettings()
00664 {
00665   #ifdef DEBUG
00666     cout << "USBamp: setDefaultSettings" << endl;
00667   #endif
00668 
00669   int id = -1;
00670   for(unsigned int n = 0; n < channel_info_.size(); n++)
00671     filter_id_.push_back(id);
00672 
00673   for(unsigned int n = 0; n < channel_info_.size(); n++)
00674     notch_id_.push_back(id);
00675 
00676   //FIXME   --  if needed, implementation of other operation modes
00677 
00678   is_usbamp_master_ = 0;
00679   enable_sc_ = 1;
00680 
00681   ground_.GND1 = 1;
00682   ground_.GND2 = 1;
00683   ground_.GND3 = 1;
00684   ground_.GND4 = 1;
00685 
00686   reference_.ref1 = 1;
00687   reference_.ref2 = 1;
00688   reference_.ref3 = 1;
00689   reference_.ref4 = 1;
00690 
00691   bipolar_channels_.Channel1 = 0;
00692   bipolar_channels_.Channel2 = 0;
00693   bipolar_channels_.Channel3 = 0;
00694   bipolar_channels_.Channel4 = 0;
00695   bipolar_channels_.Channel5 = 0;
00696   bipolar_channels_.Channel6 = 0;
00697   bipolar_channels_.Channel7 = 0;
00698   bipolar_channels_.Channel8 = 0;
00699   bipolar_channels_.Channel9 = 0;
00700   bipolar_channels_.Channel10 = 0;
00701   bipolar_channels_.Channel11 = 0;
00702   bipolar_channels_.Channel12 = 0;
00703   bipolar_channels_.Channel13 = 0;
00704   bipolar_channels_.Channel14 = 0;
00705   bipolar_channels_.Channel15 = 0;
00706   bipolar_channels_.Channel16 = 0;
00707 
00708   drl_channels_.Channel1 = 0;
00709   drl_channels_.Channel2 = 0;
00710   drl_channels_.Channel3 = 0;
00711   drl_channels_.Channel4 = 0;
00712   drl_channels_.Channel5 = 0;
00713   drl_channels_.Channel6 = 0;
00714   drl_channels_.Channel7 = 0;
00715   drl_channels_.Channel8 = 0;
00716   drl_channels_.Channel9 = 0;
00717   drl_channels_.Channel10 = 0;
00718   drl_channels_.Channel11 = 0;
00719   drl_channels_.Channel12 = 0;
00720   drl_channels_.Channel13 = 0;
00721   drl_channels_.Channel14 = 0;
00722   drl_channels_.Channel15 = 0;
00723   drl_channels_.Channel16 = 0;
00724 }
00725 
00726 //---------------------------------------------------------------------------------------
00727 
00728 void USBamp::setDeviceFilterSettings(ticpp::Iterator<ticpp::Element>const &elem)
00729 {
00730   #ifdef DEBUG
00731     cout << "USBamp: setDeviceFilterSettings" << endl;
00732   #endif
00733 
00734   checkFilterAttributes(elem);
00735 
00736   unsigned int type = 0;
00737   unsigned int order = 0;
00738   double f_low = 0;
00739   double f_high = 0;
00740 
00741   getFilterParams(elem, type, order, f_low, f_high);
00742 
00743   int id = search4FilterID(type, order, f_low, f_high);
00744   for(unsigned int n = 0; n < channel_info_.size(); n++)
00745     filter_id_[n] = id;
00746 
00747   cout << " * g.USBamp -- filter set to:" << endl;
00748   cout << "    ...  order: " << order << ", f_low: " << f_low << ", f_high: " << f_high << endl;
00749   cout << endl;
00750 
00751 }
00752 
00753 //---------------------------------------------------------------------------------------
00754 
00755 void USBamp::setChannelFilterSettings(ticpp::Iterator<ticpp::Element>const &father)
00756 {
00757   #ifdef DEBUG
00758     cout << "USBamp: setChannelFilterSettings" << endl;
00759   #endif
00760 
00761   ticpp::Iterator<ticpp::Element> elem;
00762   elem = father->FirstChildElement(hw_chset_ch_,false);
00763 
00764   cout << " * g.USBamp -- channels specific filters set to:" << endl;
00765 
00766   for(  ; elem != elem.end(); elem++)
00767     if(elem->Value() == hw_chset_ch_)
00768     {
00769       if(!elem.Get()->HasAttribute(hw_ch_nr_))
00770       {
00771         string ex_str(type_ + " -- ");
00772         ex_str += "Tag <"+hw_filter_+"> given, but channel number ("+hw_ch_nr_+") not given!";
00773         throw(std::invalid_argument(ex_str));
00774 
00775 
00776       }
00777       checkFilterAttributes(elem);
00778 
00779       uint16_t ch = 0;
00780       try{
00781         ch = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_ch_nr_) );
00782       }
00783       catch(bad_lexical_cast &)
00784       {
00785         string ex_str(type_ + " -- ");
00786         ex_str += "Tag <"+ hw_filter_ + "> : Channel is not a number!";
00787         throw(std::invalid_argument(ex_str));
00788       }
00789       if( channel_info_.find(ch) ==  channel_info_.end() )
00790       {
00791         string ex_str(type_ + " -- ");
00792         ex_str += "Tag <"+ hw_filter_ + "> - Channel "+ lexical_cast<string>(ch) +" not set for recording!";
00793         throw(std::invalid_argument(ex_str));
00794       }
00795 
00796       unsigned int type = 0;
00797       unsigned int order = 0;
00798       double f_low = 0;
00799       double f_high = 0;
00800 
00801       getFilterParams(elem, type, order, f_low, f_high);
00802 
00803       uint16_t ch_pos = 0;
00804       map<uint16_t, pair<string, uint32_t> >::iterator it;
00805       for(it = channel_info_.begin(); it !=channel_info_.find(ch); it++)
00806         ch_pos++;
00807       filter_id_.at(ch_pos) = search4FilterID(type, order, f_low, f_high);
00808 
00809       cout << "  ... channel: " << ch << ", order: " << order << ", f_low: " << f_low << ", f_high: " << f_high << endl;
00810     }
00811     else
00812       throw(std::invalid_argument("USBamp::setChannelFilterSettings -- Tag not equal to \""+hw_chset_ch_+"\"!"));
00813 }
00814 
00815 //---------------------------------------------------------------------------------------
00816 
00817 void USBamp::getFilterParams(ticpp::Iterator<ticpp::Element>const &elem,\
00818   unsigned int &type, unsigned int &order, double &f_low, double &f_high)
00819 {
00820   #ifdef DEBUG
00821     cout << "USBamp: getFilterParams" << endl;
00822   #endif
00823 
00824   type = getUSBampFilterType( elem.Get()->GetAttribute(hw_filter_type_) );
00825   try
00826   {
00827     order = lexical_cast<unsigned int>( elem.Get()->GetAttribute(hw_filter_order_) );
00828 
00829     f_low  = lexical_cast<double>( elem.Get()->GetAttribute(hw_filter_low_) );
00830     f_high = lexical_cast<double>( elem.Get()->GetAttribute(hw_filter_high_ ));
00831   }
00832   catch(bad_lexical_cast &)
00833   {
00834     string ex_str(type_ + " -- ");
00835     ex_str += "Tag <"+hw_filter_+"> given, but order, lower or upper cutoff frequency is not a number!";
00836     throw(std::invalid_argument(ex_str));
00837   }
00838 }
00839 
00840 //---------------------------------------------------------------------------------------
00841 
00842 void USBamp::checkFilterAttributes(ticpp::Iterator<ticpp::Element>const &elem)
00843 {
00844   #ifdef DEBUG
00845     cout << "USBamp: checkFilterAttributes" << endl;
00846   #endif
00847 
00848   if(!elem.Get()->HasAttribute(hw_filter_type_))
00849   {
00850     string ex_str(type_ + " -- ");
00851     ex_str += "Tag <"+hw_filter_+"> given, filter type ("+hw_filter_type_+") not given!";
00852     throw(std::invalid_argument(ex_str));
00853   }
00854   if(!elem.Get()->HasAttribute(hw_filter_order_))
00855   {
00856     string ex_str(type_ + " -- ");
00857     ex_str += "Tag <"+hw_filter_+"> given, filter order ("+hw_filter_order_+") not given!";
00858     throw(std::invalid_argument(ex_str));
00859   }
00860   if(!elem.Get()->HasAttribute(hw_filter_low_))
00861   {
00862     string ex_str(type_ + " -- ");
00863     ex_str += "Tag <"+hw_filter_+"> given, lower cutoff frequency ("+hw_filter_low_+") not given!";
00864     throw(std::invalid_argument(ex_str));
00865   }
00866   if(!elem.Get()->HasAttribute(hw_filter_high_))
00867   {
00868     string ex_str(type_ + " -- ");
00869     ex_str += "Tag <"+hw_filter_+"> given, upper cutoff frequency ("+hw_filter_high_+") not given!";
00870     throw(std::invalid_argument(ex_str));
00871   }
00872 }
00873 
00874 //---------------------------------------------------------------------------------------
00875 
00876 int USBamp::search4FilterID(unsigned int type, unsigned int order, double f_low, double f_high)
00877 {
00878   #ifdef DEBUG
00879     cout << "USBamp: search4FilterID" << endl;
00880   #endif
00881 
00882   int id = -1;
00883 
00884   for(int n = 0; n < nr_of_bp_filters_; n++)
00885   {
00886     if(( roundD(bp_filters_[n].fs)  == fs_)      &&  ( roundD(bp_filters_[n].type) == type) && \
00887        ( roundD(bp_filters_[n].order) == order) &&  ( roundD(bp_filters_[n].fu)  == f_low) && \
00888        ( roundD(bp_filters_[n].fo)    == f_high) )
00889       id = n;
00890   }
00891 
00892   if(id < 0)
00893   {
00894     printPossibleBandPassFilters();
00895     string ex_str = "USBamp::search4FilterID -- Filter settings not possible -- ";
00896     ex_str = ex_str + "Fs: "   + lexical_cast<string>(boost::format("%d") % fs_)  +  ", ";
00897     ex_str = ex_str + "Type: "   + getUSBampFilterName(type)  +  ", ";
00898     ex_str = ex_str + "Order: "  + lexical_cast<string>(order) +  ", ";
00899     ex_str = ex_str + "f_low: "  + lexical_cast<string>(boost::format("%d") % f_low) +  ", ";
00900     ex_str = ex_str + "f_high: " + lexical_cast<string>(boost::format("%d") % f_high);
00901     throw(std::invalid_argument(ex_str));
00902   }
00903 
00904   return(id);
00905 }
00906 
00907 //---------------------------------------------------------------------------------------
00908 
00909 void USBamp::printPossibleBandPassFilters()
00910 {
00911   if(!bp_filters_)
00912     return;
00913 
00914   cout << left;
00915   cout << endl;
00916   cout.width(9);
00917   cout << "     Fs: "<< " | ";
00918 
00919   cout.width(10);
00920   cout << "Type: "<< "|  ";
00921   cout << "Order: "<< "|  ";
00922 
00923   cout.width(6);
00924   cout << " f_low: "<< "| ";
00925 
00926 
00927   cout << "f_high: ";
00928 
00929   cout << endl;
00930   cout << endl;
00931 
00932 
00933   for(int n = 0; n < nr_of_bp_filters_; n++)
00934     if(fs_ == bp_filters_[n].fs)
00935     {
00936     cout << right;
00937     cout.width(9);
00938     cout << bp_filters_[n].fs << " | ";
00939 
00940     cout.width(9);
00941     cout <<  getUSBampFilterName(bp_filters_[n].type)  << " | ";
00942     cout.width(7);
00943     cout <<  bp_filters_[n].order << " | ";
00944 
00945     cout.width(8);
00946     cout << roundD(bp_filters_[n].fu) << " | ";
00947 
00948     cout << left;
00949     cout.width(8);
00950     cout << roundD(bp_filters_[n].fo);
00951     cout << endl;
00952   }
00953 
00954   cout << endl;
00955   cout << endl;
00956 }
00957 
00958 //---------------------------------------------------------------------------------------
00959 
00960 void USBamp::printPossibleNotchFilters()
00961 {
00962   if(!notch_filters_)
00963     return;
00964 
00965   cout << left;
00966   cout << endl;
00967   cout.width(9);
00968   cout << "     Fs: "<< " | ";
00969 
00970   cout.width(10);
00971   cout << "Type: "<< "|  ";
00972   cout << "Order: "<< "|  ";
00973 
00974   cout.width(6);
00975   cout << " f_low: "<< "| ";
00976 
00977 
00978   cout << "f_high: ";
00979 
00980   cout << endl;
00981   cout << endl;
00982 
00983   for(int n = 0; n < nr_of_notch_filters_; n++)
00984     if(fs_ == notch_filters_[n].fs)
00985     {
00986       cout << right;
00987       cout.width(9);
00988       cout << notch_filters_[n].fs << " | ";
00989 
00990       cout.width(8);
00991       cout <<  getUSBampFilterName(notch_filters_[n].type)  << " | ";
00992       cout.width(7);
00993       cout <<  notch_filters_[n].order << " | ";
00994 
00995       cout.width(8);
00996       cout << roundD(notch_filters_[n].fu) << " | ";
00997 
00998       cout << left;
00999       cout.width(8);
01000       cout << roundD(notch_filters_[n].fo);
01001       cout << endl;
01002     }
01003 
01004 }
01005 
01006 //---------------------------------------------------------------------------------------
01007 
01008 void USBamp::printAvailableAmps()
01009 {
01010   HANDLE dev = 0;
01011   string serial_str("\0", 16);    // at least 16 ... 256 g.tec ref. implem. !!
01012   cout << "   Available serials: " << endl;
01013 
01014   for(unsigned int n = 0; n < USBAMP_MAX_NR_OF_AMPS; n++)
01015   {
01016     dev = usb_amp_.openDevice(n);
01017     if(dev != 0)
01018     {
01019       usb_amp_.getSerial(dev, const_cast<LPSTR>(serial_str.c_str()) , serial_str.size() );
01020       cout << "    * " << serial_str.c_str() << endl;
01021       usb_amp_.closeDevice(&dev);
01022     }
01023   }
01024   cout << std::flush;
01025 }
01026 
01027 //---------------------------------------------------------------------------------------
01028 
01029 void USBamp::setDeviceNotchSettings(ticpp::Iterator<ticpp::Element>const &elem)
01030 {
01031   #ifdef DEBUG
01032     cout << "USBamp: setDeviceNotchSettings" << endl;
01033   #endif
01034 
01035   float f_center = 0;
01036 
01037   checkNotchAttributes(elem);
01038   getNotchParams(elem, f_center);
01039 
01040   int id = search4NotchID(f_center);
01041   for(unsigned int n = 0; n < channel_info_.size(); n++)
01042     notch_id_[n] = id;
01043 }
01044 
01045 //---------------------------------------------------------------------------------------
01046 
01047 void USBamp::setChannelNotchSettings(ticpp::Iterator<ticpp::Element>const &father)
01048 {
01049   #ifdef DEBUG
01050     cout << "USBamp: setChannelNotchSettings" << endl;
01051   #endif
01052 
01053   ticpp::Iterator<ticpp::Element> elem;
01054   elem = father->FirstChildElement(hw_chset_ch_,false);
01055   for(  ; elem != elem.end(); elem++)
01056     if(elem->Value() == hw_chset_ch_)
01057     {
01058       if(!elem.Get()->HasAttribute(hw_ch_nr_))
01059       {
01060         string ex_str(type_ + " -- ");
01061         ex_str += "Tag <"+hw_notch_+"> given, but channel number ("+hw_ch_nr_+") not given!";
01062         throw(std::invalid_argument(ex_str));
01063       }
01064       checkNotchAttributes(elem);
01065 
01066       uint16_t ch = 0;
01067       try{
01068         ch = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_ch_nr_) );
01069       }
01070       catch(bad_lexical_cast &)
01071       {
01072         string ex_str(type_ + " -- ");
01073         ex_str += "Tag <"+ hw_notch_ + "> : Channel is not a number!";
01074         throw(std::invalid_argument(ex_str));
01075       }
01076       if( channel_info_.find(ch) ==  channel_info_.end() )
01077       {
01078         string ex_str(type_ + " -- ");
01079         ex_str += "Tag <"+ hw_notch_ + "> - Channel "+ lexical_cast<string>(ch) +" not set for recording!";
01080         throw(std::invalid_argument(ex_str));
01081       }
01082 
01083       float f_center = 0;
01084 
01085       getNotchParams(elem, f_center);
01086 
01087       uint16_t ch_pos = 0;
01088       map<uint16_t, pair<string, uint32_t> >::iterator it;
01089       for(it = channel_info_.begin(); it !=channel_info_.find(ch); it++)
01090         ch_pos++;
01091       notch_id_.at(ch_pos) = search4NotchID(f_center);
01092     }
01093     else
01094       throw(std::invalid_argument("USBamp::setChannelNotchSettings -- Tag not equal to \""+hw_chset_ch_+"\"!"));
01095 }
01096 
01097 //---------------------------------------------------------------------------------------
01098 
01099 void USBamp::checkNotchAttributes(ticpp::Iterator<ticpp::Element>const &elem)
01100 {
01101   #ifdef DEBUG
01102     cout << "USBamp: checkNotchAttributes" << endl;
01103   #endif
01104 
01105   if(!elem.Get()->HasAttribute(hw_notch_center_))
01106   {
01107     string ex_str(type_ + " -- ");
01108     ex_str += "Tag <"+hw_notch_+"> given, notch center frequency ("+hw_notch_center_+") not given!";
01109     throw(std::invalid_argument(ex_str));
01110   }
01111 }
01112 
01113 //---------------------------------------------------------------------------------------
01114 
01115 void USBamp::getNotchParams(ticpp::Iterator<ticpp::Element>const &elem, float &f_center)
01116 {
01117   #ifdef DEBUG
01118     cout << "USBamp: getNotchParams" << endl;
01119   #endif
01120 
01121   try
01122   {
01123     f_center = lexical_cast<float>( elem.Get()->GetAttribute(hw_notch_center_));
01124   }
01125   catch(bad_lexical_cast &)
01126   {
01127     string ex_str(type_ + " -- ");
01128     ex_str += "Tag <"+hw_notch_+"> given, but center frequency is not a number!";
01129     throw(std::invalid_argument(ex_str));
01130   }
01131 }
01132 
01133 //---------------------------------------------------------------------------------------
01134 
01135 int USBamp::search4NotchID(float f_center)
01136 {
01137   #ifdef DEBUG
01138     cout << "USBamp: search4NotchID" << endl;
01139   #endif
01140 
01141   int id = -1;
01142 
01143   for(int n = 0; n < nr_of_notch_filters_; n++)
01144   {
01145     if( ( roundD(notch_filters_[n].fs)  == fs_) && \
01146       ( roundD(notch_filters_[n].fu) == f_center - USBAMP_NOTCH_HALF_WIDTH ) && \
01147       ( roundD(notch_filters_[n].fo) == f_center + USBAMP_NOTCH_HALF_WIDTH ) )
01148       id = n;
01149   }
01150 
01151   if(id < 0)
01152   {
01153     printPossibleNotchFilters();
01154     string ex_str = "USBamp::search4NotchID -- Notch settings not possible -- ";
01155     ex_str = ex_str + "f_center: " + lexical_cast<string>(boost::format("%d") % f_center);
01156     throw(std::invalid_argument(ex_str));
01157   }
01158 
01159   return(id);
01160 }
01161 
01162 //---------------------------------------------------------------------------------------
01163 
01164 void USBamp::setOperationMode(ticpp::Iterator<ticpp::Element>const &elem)
01165 {
01166   #ifdef DEBUG
01167     cout << "USBamp: setOperationMode" << endl;
01168   #endif
01169 
01170   //FIXME   --  if needed, implementation of other operation modes
01171   if(elem->GetText(true) != "normal")
01172     throw(std::invalid_argument("USBamp::setOperationMode -- So far only normal operation mode supported!"));
01173 
01174 }
01175 
01176 //---------------------------------------------------------------------------------------
01177 
01178 void USBamp::setShortCut(ticpp::Iterator<ticpp::Element>const &elem)
01179 {
01180   #ifdef DEBUG
01181     cout << "USBamp: setShortCut" << endl;
01182   #endif
01183 
01184   enable_sc_ = equalsOnOrOff(elem->GetText(true));
01185 }
01186 
01187 //---------------------------------------------------------------------------------------
01188 
01189 void USBamp::setTriggerLine(ticpp::Iterator<ticpp::Element>const &elem)
01190 {
01191   #ifdef DEBUG
01192     cout << "USBamp: setTriggerLine" << endl;
01193   #endif
01194 
01195   trigger_line_ = equalsOnOrOff(elem->GetText(true));
01196 
01197   tia::Constants cst;
01198 
01199   if(elem->HasAttribute(hw_ch_type_))
01200     trigger_line_sig_type_ = cst.getSignalFlag( elem->GetAttribute(hw_ch_type_) );
01201 }
01202 
01203 //---------------------------------------------------------------------------------------
01204 
01205 void USBamp::setUSBampMasterOrSlave(ticpp::Iterator<ticpp::Element>const &elem)
01206 {
01207   #ifdef DEBUG
01208     cout << "USBamp: setUSBampMasterOrSlave" << endl;
01209   #endif
01210 
01211   external_sync_ = !(equalsYesOrNo(elem->GetText(true)));
01212 
01213   if(is_usbamp_master_ && !external_sync_)
01214     throw(std::runtime_error("USBamp::setUSBampMasterOrSlave -- Only one USBamp master allowed!"));
01215 
01216   is_usbamp_master_ = true;
01217 }
01218 
01219 //---------------------------------------------------------------------------------------
01220 
01221 void USBamp::setCommonGround(ticpp::Iterator<ticpp::Element>const &father)
01222 {
01223   #ifdef DEBUG
01224     cout << "USBamp: setCommonGround" << endl;
01225   #endif
01226 
01227   ticpp::Iterator<ticpp::Element> elem;
01228   vector<uint8_t> v(USBAMP_NR_OF_CHANNEL_GROUPS,1);
01229   elem = father->FirstChildElement(false);
01230 
01231   for(  ; elem != elem.end(); elem++)
01232     if(elem->Value() == hw_gnd_)
01233     {
01234       if(!elem.Get()->HasAttribute(hw_gnd_block_))
01235       {
01236         string ex_str(type_ + " -- ");
01237         ex_str += "Tag <"+hw_comgnd_+"> given, but block identifier ("+hw_gnd_block_+") not given!";
01238         throw(std::invalid_argument(ex_str));
01239       }
01240       if(!elem.Get()->HasAttribute(hw_gnd_value_))
01241       {
01242         string ex_str(type_ + " -- ");
01243         ex_str += "Tag <"+hw_comgnd_+"> given, but block value ("+hw_gnd_value_+") not given!";
01244         throw(std::invalid_argument(ex_str));
01245       }
01246 
01247       int gnd = getUSBampBlockNr( elem.Get()->GetAttribute(hw_gnd_block_) );
01248       bool b = equalsYesOrNo( elem.Get()->GetAttribute(hw_gnd_value_) );
01249 
01250       v.at(gnd) = b;
01251     }
01252     else
01253       throw(std::invalid_argument("USBamp::setCommonGround -- Tag not equal to \""+hw_gnd_+"\"!"));
01254 
01255   //FIXME   --  hardcoded values
01256   ground_.GND1 = v.at(0);
01257   ground_.GND2 = v.at(1);
01258   ground_.GND3 = v.at(2);
01259   ground_.GND4 = v.at(3);
01260 }
01261 
01262 //---------------------------------------------------------------------------------------
01263 
01264 void USBamp::setCommonReference(ticpp::Iterator<ticpp::Element>const &father)
01265 {
01266   #ifdef DEBUG
01267     cout << "USBamp: setCommonReference" << endl;
01268   #endif
01269 
01270   ticpp::Iterator<ticpp::Element> elem;
01271   vector<uint8_t> v(USBAMP_NR_OF_CHANNEL_GROUPS,1);
01272   elem = father->FirstChildElement(false);
01273 
01274   for(  ; elem != elem.end(); elem++)
01275     if(elem->Value() == hw_cr_)
01276     {
01277       if(!elem.Get()->HasAttribute(hw_cr_block_))
01278       {
01279         string ex_str(type_ + " -- ");
01280         ex_str += "Tag <"+hw_comref_+"> given, but block identifier ("+hw_cr_block_+") not given!";
01281         throw(std::invalid_argument(ex_str));
01282       }
01283       if(!elem.Get()->HasAttribute(hw_cr_value_))
01284       {
01285         string ex_str(type_ + " -- ");
01286         ex_str += "Tag <"+hw_comref_+"> given, but block value ("+hw_cr_value_+") not given!";
01287         throw(std::invalid_argument(ex_str));
01288       }
01289 
01290       int ref = getUSBampBlockNr( elem.Get()->GetAttribute(hw_cr_block_) );
01291       bool b = equalsYesOrNo( elem.Get()->GetAttribute(hw_cr_value_) );
01292 
01293       v.at(ref) = b;
01294     }
01295     else
01296       throw(std::invalid_argument("USBamp::setCommonReference -- Tag not equal to \""+hw_cr_+"\"!"));
01297 
01298   //FIXME   --  hardcoded values
01299   reference_.ref1 = v.at(0);
01300   reference_.ref2 = v.at(1);
01301   reference_.ref3 = v.at(2);
01302   reference_.ref4 = v.at(3);
01303 
01304 }
01305 
01306 //---------------------------------------------------------------------------------------
01307 
01308 void USBamp::setBipolar(ticpp::Iterator<ticpp::Element>const &father)
01309 {
01310   #ifdef DEBUG
01311     cout << "USBamp: setBipolar" << endl;
01312   #endif
01313 
01314   ticpp::Iterator<ticpp::Element> elem;
01315   vector<uint8_t> v(USBAMP_MAX_NR_OF_CHANNELS,0);
01316   elem = father->FirstChildElement(hw_chset_ch_,false);
01317 
01318   for(  ; elem != elem.end(); elem++)
01319     if(elem->Value() == hw_chset_ch_)
01320     {
01321       if(!elem.Get()->HasAttribute(hw_ch_nr_))
01322       {
01323         string ex_str(type_ + " -- ");
01324         ex_str += "Tag <"+hw_bipolar_+"> given, but channel number ("+hw_ch_nr_+") not given!";
01325         throw(std::invalid_argument(ex_str));
01326       }
01327       if(!elem.Get()->HasAttribute(hw_bipolar_with_))
01328       {
01329         string ex_str(type_ + " -- ");
01330         ex_str += "Tag <"+hw_bipolar_+"> given, but bipolar combination ("+hw_bipolar_with_+") not given!";
01331         throw(std::invalid_argument(ex_str));
01332       }
01333 
01334       uint16_t with = 0;
01335       uint16_t ch   = 0;
01336 
01337       try{
01338         with = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_bipolar_with_) );
01339         ch   = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_ch_nr_) );
01340       }
01341       catch(bad_lexical_cast &)
01342       {
01343         string ex_str(type_ + " -- ");
01344         ex_str += "Tag <"+ hw_bipolar_ + "> : Channel is not a number!";
01345         throw(std::invalid_argument(ex_str));
01346       }
01347       if( (channel_info_.find(ch) ==  channel_info_.end()) || (channel_info_.find(with) ==  channel_info_.end()) )
01348       {
01349         string ex_str(type_ + " -- ");
01350         ex_str += "Tag <"+ hw_bipolar_ + "> - Channel "+ lexical_cast<string>(ch) +" not set for recording!";
01351         throw(std::invalid_argument(ex_str));
01352       }
01353 
01354       // FIXME  --  check channels, if in range ( USBAMP_MAX_NR... )
01355 
01356       v.at(ch) = boost::numeric_cast<uint8_t>(with);
01357     }
01358     else
01359       throw(std::invalid_argument("USBamp::setBipolar -- Tag not equal to \""+hw_chset_ch_+"\"!"));
01360 
01361   //FIXME   --  hardcoded values
01362   bipolar_channels_.Channel1 = v.at(0);
01363   bipolar_channels_.Channel2 = v.at(1);
01364   bipolar_channels_.Channel3 = v.at(2);
01365   bipolar_channels_.Channel4 = v.at(3);
01366   bipolar_channels_.Channel5 = v.at(4);
01367   bipolar_channels_.Channel6 = v.at(5);
01368   bipolar_channels_.Channel7 = v.at(6);
01369   bipolar_channels_.Channel8 = v.at(7);
01370   bipolar_channels_.Channel9 = v.at(8);
01371   bipolar_channels_.Channel10 = v.at(9);
01372   bipolar_channels_.Channel11 = v.at(10);
01373   bipolar_channels_.Channel12 = v.at(11);
01374   bipolar_channels_.Channel13 = v.at(12);
01375   bipolar_channels_.Channel14 = v.at(13);
01376   bipolar_channels_.Channel15 = v.at(14);
01377   bipolar_channels_.Channel16 = v.at(15);
01378 }
01379 
01380 //---------------------------------------------------------------------------------------
01381 
01382 void USBamp::setDrivenRightLeg(ticpp::Iterator<ticpp::Element>const &father)
01383 {
01384   #ifdef DEBUG
01385     cout << "USBamp: setDrivenRightLeg" << endl;
01386   #endif
01387 
01388   ticpp::Iterator<ticpp::Element> elem;
01389   elem = father->FirstChildElement(hw_chset_ch_,false);
01390   if(elem != elem.end())
01391   {
01392     setIndividualDrivenRightLeg(elem);
01393     return;
01394   }
01395 
01396   if(equalsYesOrNo(father->GetText(true)))
01397   {
01398     drl_channels_.Channel1 = 1;
01399     drl_channels_.Channel2 = 1;
01400     drl_channels_.Channel3 = 1;
01401     drl_channels_.Channel4 = 1;
01402     drl_channels_.Channel5 = 1;
01403     drl_channels_.Channel6 = 1;
01404     drl_channels_.Channel7 = 1;
01405     drl_channels_.Channel8 = 1;
01406     drl_channels_.Channel9 = 1;
01407     drl_channels_.Channel10 = 1;
01408     drl_channels_.Channel11 = 1;
01409     drl_channels_.Channel12 = 1;
01410     drl_channels_.Channel13 = 1;
01411     drl_channels_.Channel14 = 1;
01412     drl_channels_.Channel15 = 1;
01413     drl_channels_.Channel16 = 1;
01414   }
01415 }
01416 
01417 //---------------------------------------------------------------------------------------
01418 
01419 void USBamp::setIndividualDrivenRightLeg(ticpp::Iterator<ticpp::Element> &elem)
01420 {
01421   #ifdef DEBUG
01422     cout << "USBamp: setIndividualDrivenRightLeg" << endl;
01423   #endif
01424 
01425   vector<uint8_t> v(USBAMP_MAX_NR_OF_CHANNELS,0);
01426 
01427   for(  ; elem != elem.end(); elem++)
01428     if(elem->Value() == hw_chset_ch_)
01429     {
01430       if(!elem.Get()->HasAttribute(hw_ch_nr_))
01431       {
01432         string ex_str(type_ + " -- ");
01433         ex_str += "Tag <"+hw_drl_+"> given, but channel number ("+hw_ch_nr_+") not given!";
01434         throw(std::invalid_argument(ex_str));
01435       }
01436       if(!elem.Get()->HasAttribute(hw_drl_value_))
01437       {
01438         string ex_str(type_ + " -- ");
01439         ex_str += "Tag <"+hw_drl_+"> given, but DRL value ("+hw_drl_value_+") not given!";
01440         throw(std::invalid_argument(ex_str));
01441       }
01442 
01443       bool b = equalsOnOrOff( elem.Get()->GetAttribute(hw_drl_value_) );
01444       uint16_t ch   = 0;
01445 
01446       try{
01447         ch = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_ch_nr_) );
01448       }
01449       catch(bad_lexical_cast &)
01450       {
01451         string ex_str(type_ + " -- ");
01452         ex_str += "Tag <"+ hw_drl_ + "> : Channel is not a number!";
01453         throw(std::invalid_argument(ex_str));
01454       }
01455       if( channel_info_.find(ch) ==  channel_info_.end() )
01456       {
01457         string ex_str(type_ + " -- ");
01458         ex_str += "Tag <"+ hw_drl_ + "> - Channel "+ lexical_cast<string>(ch) +" not set for recording!";
01459         throw(std::invalid_argument(ex_str));
01460       }
01461 
01462       v.at(ch-1) = b;
01463     }
01464     else
01465       throw(std::invalid_argument("USBamp::setIndividualDrivenRightLeg -- Tag not equal to \""+hw_chset_ch_+"\"!"));
01466 
01467     //FIXME   --  hardcoded values
01468     drl_channels_.Channel1 = v.at(0);
01469     drl_channels_.Channel2 = v.at(1);
01470     drl_channels_.Channel3 = v.at(2);
01471     drl_channels_.Channel4 = v.at(3);
01472     drl_channels_.Channel5 = v.at(4);
01473     drl_channels_.Channel6 = v.at(5);
01474     drl_channels_.Channel7 = v.at(6);
01475     drl_channels_.Channel8 = v.at(7);
01476     drl_channels_.Channel9 = v.at(8);
01477     drl_channels_.Channel10 = v.at(9);
01478     drl_channels_.Channel11 = v.at(10);
01479     drl_channels_.Channel12 = v.at(11);
01480     drl_channels_.Channel13 = v.at(12);
01481     drl_channels_.Channel14 = v.at(13);
01482     drl_channels_.Channel15 = v.at(14);
01483     drl_channels_.Channel16 = v.at(15);
01484 }
01485 
01486 //---------------------------------------------------------------------------------------
01487 
01488 void USBamp::checkNrOfChannels()
01489 {
01490   #ifdef DEBUG
01491     cout << "USBamp: checkNrOfChannels" << endl;
01492   #endif
01493 
01494   if(nr_ch_ > USBAMP_MAX_NR_OF_CHANNELS )
01495     throw(std::invalid_argument("Too many channels defined -- maximum nr of channels: "\
01496                                 +lexical_cast<string>(USBAMP_MAX_NR_OF_CHANNELS)) );
01497 
01498   map<uint16_t, pair<string, uint32_t> >::iterator it(channel_info_.begin());
01499 
01500   for(  ; it != channel_info_.end(); it++ )
01501     if(it->first > USBAMP_MAX_NR_OF_CHANNELS )
01502       throw(std::invalid_argument("Channel number too high -- maximum nr of channels: "\
01503       +lexical_cast<string>(USBAMP_MAX_NR_OF_CHANNELS)) );
01504 }
01505 
01506 //---------------------------------------------------------------------------------------
01507 
01508 void USBamp::adjustSettingsToChannelSelection()
01509 {
01510   unsigned int new_size = channel_info_.size();
01511 
01512   boost::uint16_t notch  = notch_id_.at(0);
01513   boost::uint16_t filter = filter_id_.at(0);
01514   notch_id_.resize(new_size);
01515   filter_id_.resize(new_size);
01516 
01517   for(unsigned int n = 0; n < new_size; n++)
01518   {
01519     filter_id_[n] = filter;
01520     notch_id_[n]  = notch;
01521   }
01522 }
01523 
01524 //---------------------------------------------------------------------------------------
01525 
01526 void USBamp::setUSBampChannels()
01527 {
01528   #ifdef DEBUG
01529     cout << "USBamp: setUSBampChannels" << endl;
01530   #endif
01531 
01532   vector<uint16_t> channels;
01533   map<uint16_t, pair<string, uint32_t> >::iterator it(channel_info_.begin());
01534   map<uint16_t, pair<string, uint32_t> >::iterator stop(channel_info_.end());
01535 
01536   if(trigger_line_)
01537     stop--;
01538 
01539   for(  ; it != stop; it++)
01540       channels.push_back(it->first);
01541 
01542   UCHAR* uc_channels = new UCHAR[channels.size()];
01543   for(unsigned int n = 0; n < channels.size(); n++)
01544     uc_channels[n] = boost::numeric_cast<UCHAR>( channels[n] );
01545 
01546   if( !usb_amp_.setChannels (h_, uc_channels, channels.size()))
01547     throw(std::runtime_error("USBamp::setUSBampChannels -- Error setting channels!"));
01548 
01549   delete[] uc_channels;
01550 }
01551 
01552 //---------------------------------------------------------------------------------------
01553 
01554 void USBamp::setUSBampFilter()
01555 {
01556   #ifdef DEBUG
01557     cout << "USBamp: setUSBampFilter" << endl;
01558   #endif
01559 
01560   bool check = 1;
01561   unsigned int count = 0;
01562   map<uint16_t, pair<string, uint32_t> >::iterator it;
01563   map<uint16_t, pair<string, uint32_t> >::iterator stop(channel_info_.end());
01564 
01565   if(trigger_line_)
01566     stop--;
01567 
01568   for( it=channel_info_.begin() ; it != stop; it++)
01569   {
01570     if(check)
01571     {
01572       if(filter_id_[count] > 0)
01573       check = usb_amp_.setBandPass (h_, boost::numeric_cast<UCHAR>((*it).first)   , filter_id_[count]);
01574       else
01575         cout << "Filter for channel " << (*it).first << " NOT set!" << endl;
01576 
01577       count++;
01578     }
01579   }
01580 
01581   if(!check)
01582     throw(std::runtime_error("USBamp::setUSBampFilter -- Error setting filter!"));
01583 
01584 }
01585 
01586 //---------------------------------------------------------------------------------------
01587 
01588 void USBamp::setUSBampNotch()
01589 {
01590   #ifdef DEBUG
01591     cout << "USBamp: setUSBampNotch" << endl;
01592   #endif
01593 
01594   bool check = 1;
01595   unsigned int count = 0;
01596   map<uint16_t, pair<string, uint32_t> >::iterator it;
01597   map<uint16_t, pair<string, uint32_t> >::iterator stop(channel_info_.end());
01598 
01599   if(trigger_line_)
01600     stop--;
01601 
01602   for( it=channel_info_.begin() ; it != stop; it++)
01603   {
01604     if(check)
01605     {
01606       if(notch_id_[count] > 0)
01607       check = usb_amp_.setNotch (h_, boost::numeric_cast<UCHAR>((*it).first), notch_id_[count]);
01608       else
01609         cout << "Notch for channel " << (*it).first << " NOT set!" << endl;
01610       count++;
01611     }
01612   }
01613 
01614   if(!check)
01615     throw(std::runtime_error("USBamp::setUSBampNotch -- Error setting notch!"));
01616 
01617 }
01618 
01619 //---------------------------------------------------------------------------------------
01620 
01621 void USBamp::checkTriggerLineChannel()
01622 {
01623   #ifdef DEBUG
01624     cout << "USBamp: checkTriggerLineChannel" << endl;
01625   #endif
01626 
01627   if(trigger_line_)
01628   {
01629     boost::uint32_t last_ch = (--channel_info_.end())->first;
01630 
01631     channel_info_[last_ch + 1] = make_pair(hw_trigger_line_, trigger_line_sig_type_);
01632     nr_ch_ += 1;
01633     homogenous_signal_type_ = 0;
01634     setChannelTypes();
01635   }
01636 }
01637 
01638 //---------------------------------------------------------------------------------------
01639 
01640 void USBamp::initUSBamp()
01641 {
01642   #ifdef DEBUG
01643     cout << "USBamp: initUSBamp" << endl;
01644   #endif
01645 
01646   if( !usb_amp_.setMode (h_, M_NORMAL) )
01647     throw(std::runtime_error("USBamp::initUSBamp -- Error setting mode!"));
01648 
01649   if( !usb_amp_.setSampleRate(h_, boost::numeric_cast<WORD>(fs_) ))
01650     throw(std::runtime_error("USBamp::initUSBamp -- Error setting sampling rate!"));
01651 
01652   if( !usb_amp_.setBufferSize(h_, blocks_))
01653     throw(std::runtime_error("USBamp::initUSBamp -- Error setting buffer size!"));
01654 
01655   setUSBampChannels();
01656 
01657   if( !usb_amp_.setSlave (h_, external_sync_) )
01658     throw(std::runtime_error("USBamp::initUSBamp -- Error setting synchronization mode (master or slave)!"));
01659 
01660   if( !usb_amp_.enableTriggerLine(h_, trigger_line_))
01661     throw(std::runtime_error("USBamp::initUSBamp -- Error setting trigger line!"));
01662 
01663   if( !usb_amp_.enableSC (h_, enable_sc_) )
01664     throw(std::runtime_error("USBamp::initUSBamp -- Error setting shortcut!"));
01665 
01666   if( !usb_amp_.setBipolar (h_, bipolar_channels_) )
01667     throw(std::runtime_error("USBamp::initUSBamp -- Error setting bipolar channels!"));
01668 
01669   if( !usb_amp_.setReference (h_, reference_) )
01670     throw(std::runtime_error("USBamp::initUSBamp -- Error setting reference!"));
01671 
01672   if( !usb_amp_.setGround (h_, ground_) )
01673     throw(std::runtime_error("USBamp::initUSBamp -- Error setting ground!"));
01674 
01675   if( !usb_amp_.setDRLChannel(h_, drl_channels_) )
01676     throw(std::runtime_error("USBamp::initUSBamp -- Error setting driven right leg channels!"));
01677 
01678   setUSBampFilter();
01679   setUSBampNotch();
01680 }
01681 
01682 //-----------------------------------------------------------------------------
01683 
01684 int USBamp::getUSBampFilterType(const string& s)
01685 {
01686   map<string, unsigned int>::iterator it;
01687   it = usbamp_filter_types_.find(to_lower_copy(s));
01688   if(it == usbamp_filter_types_.end())
01689   {
01690     string e = "USBamp filter type \"" + s + "\" not found -- please also check spelling!";
01691     throw(std::invalid_argument(e));
01692   }
01693   return(it->second);
01694 }
01695 
01696 //-----------------------------------------------------------------------------
01697 
01698 string USBamp::getUSBampFilterName(double n)
01699 {
01700   map<string, unsigned int>::iterator it;
01701   int nr = boost::numeric_cast<int>(n);
01702   it = usbamp_filter_types_.begin();
01703 
01704   while(it != usbamp_filter_types_.end())
01705   {
01706     if(it->second == nr)
01707       return(it->first);
01708     it++;
01709   }
01710   string e = "USBamp filter number not found!";
01711   throw(std::invalid_argument(e));
01712 }
01713 
01714 //-----------------------------------------------------------------------------
01715 
01716 string USBamp::getUSBampOpMode(const string& s)
01717 {
01718   map<string, string>::iterator it;
01719   it = usbamp_opModes_.find(to_lower_copy(s));
01720   if(it == usbamp_opModes_.end())
01721   {
01722     string e = "USBamp operation mode \"" + s + "\" not found -- please also check spelling!";
01723     throw(std::invalid_argument(e));
01724   }
01725   return(it->second);
01726 }
01727 
01728 //-----------------------------------------------------------------------------
01729 
01730 int USBamp::getUSBampBlockNr(const string& s)
01731 {
01732   map<string, unsigned int>::iterator it;
01733   it = usbamp_block_names_.find(to_lower_copy(s));
01734   if(it == usbamp_block_names_.end())
01735   {
01736     string e = "USBamp channel block \"" + s + "\" wrong -- must be \"a, b, c or d\"!";
01737     throw(std::invalid_argument(e));
01738   }
01739   return(it->second);
01740 }
01741 
01742 //-----------------------------------------------------------------------------
01743 
01744 } // Namespace tobiss
01745 
01746 
01747 
01748 // DEBUG code from constructor
01749 
01750 //#ifdef DEBUG
01751 //  map<uint16_t, pair<string, uint32_t> >::iterator it(channel_info_.begin());
01752 //
01753 //  cout << "Filter/Notch Settings:  (filter id size)" << filter_id_.size() <<endl;
01754 //  for(unsigned int n = 0; n < filter_id_.size(); n++)
01755 //  {
01756 //    cout << "ch: " << it->first << " -- type: "<<  bp_filters_[ filter_id_[n] ].type;
01757 //    cout << ", order: "  <<  bp_filters_[ filter_id_[n] ].order;
01758 //    cout << ", f_low: "  <<  bp_filters_[ filter_id_[n] ].fu;
01759 //    cout << ", f_high: " <<  bp_filters_[ filter_id_[n] ].fo;
01760 //    cout << "; -- notch: type: " <<  notch_filters_[ notch_id_[n] ].type;
01761 //    cout << ", order: "  <<  notch_filters_[ notch_id_[n] ].order;
01762 //    cout << ", f_low: "  <<  notch_filters_[ notch_id_[n] ].fu;
01763 //    cout << ", f_high: " <<  notch_filters_[ notch_id_[n] ].fo << endl;
01764 //    it++;
01765 //  }
01766 //
01767 //  GND ground;
01768 //  usb_amp_.getGround(h_, &ground);
01769 //  //    GT_GetGround(h_, &ground);
01770 //
01771 //  cout << "Ground settings: " << endl;
01772 //  cout << ground.GND1 << ", " << ground.GND2 << ", ";
01773 //  cout << ground.GND3 << ", " << ground.GND4 << endl;
01774 //
01775 //  REF reference;
01776 //  usb_amp_.getReference(h_, &reference);
01777 //  //    GT_GetReference(h_, &reference);
01778 //
01779 //  cout << "Reference settings: " << endl;
01780 //  cout << reference.ref1 << ", " << reference.ref2 << ", ";
01781 //  cout << reference.ref3 << ", " << reference.ref4 << endl;
01782 //
01783 //  cout << "Bipolar channel settings: " << endl;
01784 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel1) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel2) << ", ";
01785 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel3) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel4) << ", ";
01786 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel5) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel6) << ", ";
01787 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel7) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel8) << endl;
01788 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel9) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel10) << ", ";
01789 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel11) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel12) << ", ";
01790 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel13) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel14) << ", ";
01791 //  cout << static_cast<uint32_t>(bipolar_channels_.Channel15) << ", " << static_cast<uint32_t>(bipolar_channels_.Channel16) << endl;
01792 //
01793 //  cout << "DRL channel settings: " << endl;
01794 //  cout << static_cast<uint32_t>(drl_channels_.Channel1) << ", " << static_cast<uint32_t>(drl_channels_.Channel2) << ", ";
01795 //  cout << static_cast<uint32_t>(drl_channels_.Channel3) << ", " << static_cast<uint32_t>(drl_channels_.Channel4) << ", ";
01796 //  cout << static_cast<uint32_t>(drl_channels_.Channel5) << ", " << static_cast<uint32_t>(drl_channels_.Channel6) << ", ";
01797 //  cout << static_cast<uint32_t>(drl_channels_.Channel7) << ", " << static_cast<uint32_t>(drl_channels_.Channel8) << endl;
01798 //  cout << static_cast<uint32_t>(drl_channels_.Channel9) << ", " << static_cast<uint32_t>(drl_channels_.Channel10) << ", ";
01799 //  cout << static_cast<uint32_t>(drl_channels_.Channel11) << ", " << static_cast<uint32_t>(drl_channels_.Channel12) << ", ";
01800 //  cout << static_cast<uint32_t>(drl_channels_.Channel13) << ", " << static_cast<uint32_t>(drl_channels_.Channel14) << ", ";
01801 //  cout << static_cast<uint32_t>(drl_channels_.Channel15) << ", " << static_cast<uint32_t>(drl_channels_.Channel16) << endl;
01802 //#endif
01803 
01804 
 All Data Structures Files Functions Variables