TOBI SignalServer  0.1
/home/breidi/Dropbox/signalserver/src/hardware/gBSamp_base.cpp
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 #include "hardware/gBSamp_base.h"
00035 
00036 #include <iostream>
00037 #include <utility>
00038 
00039 #include <boost/lexical_cast.hpp>
00040 #include <boost/format.hpp>
00041 #include <boost/algorithm/string.hpp>
00042 
00043 #include "tia/constants.h"
00044 
00045 namespace tobiss
00046 {
00047 
00048 using std::string;
00049 using std::cout;
00050 using std::cerr;
00051 using std::endl;
00052 
00053 using boost::lexical_cast;
00054 using boost::bad_lexical_cast;
00055 
00056 const string gBSampBase::hw_jumper_("jumper");
00057 
00058 const string gBSampBase::hw_jumper_hp_("highpass");
00059 const string gBSampBase::hw_jumper_lp_("lowpass");
00060 const string gBSampBase::hw_jumper_sense_("sense");
00061 const string gBSampBase::hw_jumper_notch_("notch");
00062 
00063 const string gBSampBase::hw_daq_mode_("daq_mode");
00064 const string gBSampBase::hw_device_id_("device_label");
00065 
00066 static const float GBSAMP_EEG_HP_FILTER[2] = { 0.5,    2.0};
00067 static const float GBSAMP_EEG_LP_FILTER[2] = {30.0,  100.0};
00068 static const float GBSAMP_EEG_SENS[2]      = { 0.05,   0.1};  // scaling *10  * 20
00069 
00070 static const float GBSAMP_EOG_HP_FILTER[2] = { 0.5,    2.0};
00071 static const float GBSAMP_EOG_LP_FILTER[2] = {30.0,  100.0};
00072 static const float GBSAMP_EOG_SENS[2]      = { 0.1,    1.0};  // scaling *20  * 200
00073 
00074 static const float GBSAMP_EMG_HP_FILTER[2] = { 0.01,   2.0};
00075 static const float GBSAMP_EMG_LP_FILTER[2] = {60.0,  100.0};
00076 static const float GBSAMP_EMG_SENS[2]      = { 1.0,    5.0};  // scaling *200  * 1000
00077 
00078 static const float GBSAMP_ECG_HP_FILTER[2] = { 0.01,   2.0};
00079 static const float GBSAMP_ECG_LP_FILTER[2] = {60.0,  100.0};
00080 static const float GBSAMP_ECG_SENS[2]      = { 2.0,    5.0};  // scaling *400  * 1000
00081 
00082 static const float GBSAMP_MU_VOLT_SCALING_FACTOR = 200.0;
00083 
00084 //-----------------------------------------------------------------------------
00085 
00086 gBSampBase::gBSampBase()
00087   : daq_mode_(RSE)
00088 {
00089   daq_modes_map_.insert( std::make_pair("rse", RSE) );
00090   daq_modes_map_.insert( std::make_pair("nrse", NRSE) );
00091   daq_modes_map_.insert( std::make_pair("diff", diff) );
00092 
00093   setType("g.USBamp");
00094 }
00095 
00096 //-----------------------------------------------------------------------------
00097 
00098 void gBSampBase::setHardware(ticpp::Iterator<ticpp::Element>const &hw)
00099 {
00100   #ifdef DEBUG
00101     cout << "gBSamp: setHardware" << endl;
00102   #endif
00103 
00104   checkMandatoryHardwareTags(hw);
00105   ticpp::Iterator<ticpp::Element> ds(hw->FirstChildElement(hw_devset_, true));
00106 
00107   setDeviceSettings(ds);
00108 
00109   ticpp::Iterator<ticpp::Element> cs(hw->FirstChildElement(hw_chset_, false));
00110   if (cs != cs.end())
00111   {
00112     for(ticpp::Iterator<ticpp::Element> it(cs); ++it != it.end(); )
00113       if(it->Value() == hw_chset_)
00114       {
00115         string ex_str;
00116         ex_str = "gBSamp: Error -- ";
00117         ex_str += "Multiple channel_settings found!";
00118         throw(std::invalid_argument(ex_str));
00119       }
00120       setChannelSettings(cs);
00121   }
00122 
00123   cout << endl;
00124   for(unsigned int n = 0; n < channel_info_.size(); n++ )
00125   {
00126     cout << scaling_factors_[n] << ", ";
00127   }
00128   cout << endl;
00129 }
00130 
00131 //---------------------------------------------------------------------------------------
00132 
00133 void gBSampBase::setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father)
00134 {
00135   #ifdef DEBUG
00136     cout << "gBSamp: setDeviceSettings" << endl;
00137   #endif
00138 
00139   ticpp::Iterator<ticpp::Element> elem(father->FirstChildElement(hw_fs_,true));
00140   setSamplingRate(elem);
00141 
00142   elem = father->FirstChildElement(hw_device_id_,true);
00143   setDeviceName(elem);
00144 
00145   elem = father->FirstChildElement(hw_channels_,false);
00146   if(elem != elem.end())
00147     setDeviceChannels(elem);
00148 
00149   elem = father->FirstChildElement(hw_blocksize_,true);
00150   setBlocks(elem);
00151 
00152   elem = father->FirstChildElement(hw_daq_mode_,false);
00153   if(elem != elem.end())
00154     setAcquisitionMode(elem);
00155 
00156   cout << " * g.BSamp -- device filters per type set to:" << endl;
00157   elem = (father->FirstChildElement(hw_jumper_,true));
00158   setDeviceJumperSettings(elem);
00159   elem++;
00160   while(elem != elem.end() )
00161   {
00162     if(elem->Value() == hw_jumper_)
00163       setDeviceJumperSettings(elem);
00164     elem++;
00165   }
00166   cout << endl;
00167 
00168   setGlobalScalingValues();
00169 }
00170 
00171 //---------------------------------------------------------------------------------------
00172 
00173 void gBSampBase::setChannelSettings(ticpp::Iterator<ticpp::Element>const &father)
00174 {
00175   #ifdef DEBUG
00176     cout << "gBSamp: setChannelSettings" << endl;
00177   #endif
00178 
00179   ticpp::Iterator<ticpp::Element> elem(father->FirstChildElement(hw_chset_sel_,false));
00180   if (elem != elem.end())
00181     setChannelSelection(elem);
00182 
00183 
00184 
00185   elem = father->FirstChildElement(hw_jumper_,false);
00186   if (elem != elem.end())
00187     setChannelJumperSettings(elem);
00188   else
00189     setGlobalScalingValues();
00190 }
00191 
00192 //---------------------------------------------------------------------------------------
00193 
00194 void gBSampBase::setAcquisitionMode(ticpp::Iterator<ticpp::Element>const &elem)
00195 {
00196   #ifdef DEBUG
00197     cout << "gBSamp: setAcquisitionMode" << endl;
00198   #endif
00199 
00200   std::string mode = elem->GetText(true);
00201 
00202   std::map<string, daq_mode_type>::iterator it;
00203 
00204   it = daq_modes_map_.find(boost::algorithm::to_lower_copy(mode));
00205 
00206   if(it == daq_modes_map_.end())
00207   {
00208     string e = "g.BSamp acquisition mode \"" + mode + "\" not found -- please also check spelling!";
00209     throw(std::invalid_argument(e));
00210   }
00211 
00212   daq_mode_ = it->second;
00213 }
00214 
00215 //---------------------------------------------------------------------------------------
00216 
00217 void gBSampBase::setDeviceName(ticpp::Iterator<ticpp::Element>const &elem)
00218 {
00219   #ifdef DEBUG
00220     cout << "gBSamp: setAcquisitionMode" << endl;
00221   #endif
00222 
00223   device_id_ = elem->GetText(true);
00224 }
00225 
00226 
00227 //---------------------------------------------------------------------------------------
00228 
00229 void gBSampBase::setDeviceJumperSettings(ticpp::Iterator<ticpp::Element>const &elem)
00230 {
00231   #ifdef DEBUG
00232     cout << "gBSamp: setDeviceJumperSettings" << endl;
00233   #endif
00234 
00235   unsigned int type = 0;
00236   bool notch = 0;
00237   float highpass = 0;
00238   float lowpass = 0;
00239   float sense = 0;
00240 
00241   checkJumperAttributes(elem);
00242   getJumperParams(elem, type, notch, highpass, lowpass, sense);
00243 
00244   global_scaling_factors_[type] = sense * GBSAMP_MU_VOLT_SCALING_FACTOR;
00245 
00246   tia::Constants cst;
00247   cout << "    ...  type: " << cst.getSignalName(type) << ", HP: " << highpass << ", LP: " << lowpass << ", sense: " << sense << ", notch: " << notch << endl;
00248 }
00249 
00250 //---------------------------------------------------------------------------------------
00251 
00252 void gBSampBase::setChannelJumperSettings(ticpp::Iterator<ticpp::Element>const &father)
00253 {
00254   #ifdef DEBUG
00255     cout << "gBSamp: setChannelJumperSettings" << endl;
00256   #endif
00257 
00258     ticpp::Iterator<ticpp::Element> elem;
00259     elem = father->FirstChildElement(hw_chset_ch_,false);
00260 
00261     scaling_factors_.resize( channel_info_.size() );
00262 
00263     cout << " * g.BSamp -- channels specific jumpers set to:" << endl;
00264 
00265     for(  ; elem != elem.end(); elem++)
00266       if(elem->Value() == hw_chset_ch_)
00267       {
00268         if(!elem.Get()->HasAttribute(hw_ch_nr_))
00269         {
00270           string ex_str(type_ + " -- ");
00271           ex_str += "Tag <"+hw_jumper_+"> given, but channel number ("+hw_ch_nr_+") not given!";
00272           throw(std::invalid_argument(ex_str));
00273 
00274 
00275         }
00276         checkJumperAttributes(elem);
00277 
00278         uint16_t ch = 0;
00279         try{
00280           ch = lexical_cast<uint16_t>( elem.Get()->GetAttribute(hw_ch_nr_) );
00281         }
00282         catch(bad_lexical_cast &)
00283         {
00284           string ex_str(type_ + " -- ");
00285           ex_str += "Tag <"+ hw_jumper_ + "> : Channel is not a number!";
00286           throw(std::invalid_argument(ex_str));
00287         }
00288         if( channel_info_.find(ch) ==  channel_info_.end() )
00289         {
00290           string ex_str(type_ + " -- ");
00291           ex_str += "Tag <"+ hw_jumper_ + "> - Channel "+ lexical_cast<std::string>(ch) +" not set for recording!";
00292           throw(std::invalid_argument(ex_str));
00293         }
00294 
00295         unsigned int type = 0;
00296         bool notch = 0;
00297         float highpass = 0;
00298         float lowpass = 0;
00299         float sense = 0;
00300 
00301         getJumperParams(elem, type, notch, highpass, lowpass, sense);
00302         uint16_t ch_pos = 0;
00303         std::map<boost::uint16_t, std::pair<std::string, boost::uint32_t> >::iterator it;
00304         for(it = channel_info_.begin(); it !=channel_info_.find(ch); it++)
00305           ch_pos++;
00306 
00307         if(type != channel_types_[ch_pos])
00308           throw(std::invalid_argument(
00309               "gBSamp: Error -- Acquired signal type must match the type provided within the jumper settings" ));
00310 
00311         scaling_factors_.at(ch_pos) = sense * GBSAMP_MU_VOLT_SCALING_FACTOR;
00312 
00313         tia::Constants cst;
00314         cout << "  ... channel: " << "    ...  type: " << cst.getSignalName(type) << ", HP: " << highpass;
00315         cout << ", LP: " << lowpass << ", sense: " << sense << ", notch: " << notch << endl;
00316       }
00317       else
00318         throw(std::invalid_argument("gBSamp::setChannelJumperSettings -- Tag not equal to \""+hw_chset_ch_+"\"!"));
00319 
00320 }
00321 
00322 //---------------------------------------------------------------------------------------
00323 
00324 void gBSampBase::setGlobalScalingValues()
00325 {
00326   scaling_factors_.resize(channel_types_.size() );
00327   for(unsigned int n = 0; n < channel_types_.size(); n++ )
00328   {
00329     if( global_scaling_factors_.find( channel_types_.at(n) ) == global_scaling_factors_.end() )
00330       throw(std::invalid_argument(
00331           "gBSamp: Error -- Acquired signal type must match the type provided within the jumper settings" ));
00332     scaling_factors_[n] = global_scaling_factors_[ channel_types_[n] ];
00333   }
00334 }
00335 
00336 //---------------------------------------------------------------------------------------
00337 
00338 void gBSampBase::checkJumperAttributes(ticpp::Iterator<ticpp::Element>const &elem)
00339 {
00340   #ifdef DEBUG
00341     cout << "USBamp: checkJumperAttributes" << endl;
00342   #endif
00343 
00344   if(!elem.Get()->HasAttribute(hw_ch_type_))
00345   {
00346     string ex_str;
00347     ex_str = "gBSamp: Error -- ";
00348     ex_str += "Tag <"+hw_jumper_+"> given, ("+hw_ch_type_+") not given!";
00349     throw(std::invalid_argument(ex_str));
00350   }
00351   if(!elem.Get()->HasAttribute(hw_jumper_notch_))
00352   {
00353     string ex_str;
00354     ex_str = "gBSamp: Error -- ";
00355     ex_str += "Tag <"+hw_jumper_+"> given, "+hw_jumper_notch_+" not given!";
00356     throw(std::invalid_argument(ex_str));
00357   }
00358   if(!elem.Get()->HasAttribute(hw_jumper_hp_))
00359   {
00360     string ex_str;
00361     ex_str = "gBSamp: Error -- ";
00362     ex_str += "Tag <"+hw_jumper_+"> given, "+hw_jumper_hp_+" frequency ("+hw_jumper_hp_+") not given!";
00363     throw(std::invalid_argument(ex_str));
00364   }
00365   if(!elem.Get()->HasAttribute(hw_jumper_lp_))
00366   {
00367     string ex_str;
00368     ex_str = "gBSamp: Error -- ";
00369     ex_str += "Tag <"+hw_jumper_+"> given, "+hw_jumper_lp_+" frequency ("+hw_jumper_lp_+") not given!";
00370     throw(std::invalid_argument(ex_str));
00371   }
00372   if(!elem.Get()->HasAttribute(hw_jumper_sense_))
00373   {
00374     string ex_str;
00375     ex_str = "gBSamp: Error -- ";
00376     ex_str += "Tag <"+hw_jumper_+"> given, parameter ("+hw_jumper_sense_+") not given!";
00377     throw(std::invalid_argument(ex_str));
00378   }
00379 }
00380 
00381 //---------------------------------------------------------------------------------------
00382 
00383 void gBSampBase::getJumperParams(ticpp::Iterator<ticpp::Element>const &elem,
00384   unsigned int &type, bool &notch, float &highpass, float &lowpass, float &sense)
00385 {
00386   #ifdef DEBUG
00387     cout << "gBSamp: getJumperParams" << endl;
00388   #endif
00389 
00390   // EEG 0.1 mV.   -->.  * 20  (Saettigung: 200 muV Ampl --> 400muV SS)
00391   //     0.05 mV...-->   * 10  (Saettigung: 100 muV Ampl)
00392   // EMG 1           ;  5
00393   // EOG 0.1         ;  2
00394   // ECG 2           ;  5
00395 
00396   checkJumperAttributes(elem);
00397 
00398   tia::Constants cst;
00399   type = cst.getSignalFlag(elem.Get()->GetAttribute(hw_ch_type_));
00400 
00401   try
00402   {
00403     notch = equalsOnOrOff(elem.Get()->GetAttribute(hw_jumper_notch_));
00404   }
00405   catch(std::invalid_argument& e)
00406   {
00407     throw(std::invalid_argument( "gBSamp: Error -- Tag <"+hw_jumper_+"> - " +hw_jumper_notch_+" -- " + e.what() ));
00408   }
00409 
00410   try
00411   {
00412     highpass  = lexical_cast<float>(boost::format("%d") % elem.Get()->GetAttribute(hw_jumper_hp_));
00413     lowpass   = lexical_cast<float>(boost::format("%d") % elem.Get()->GetAttribute(hw_jumper_lp_));
00414     sense     = lexical_cast<float>(boost::format("%d") % elem.Get()->GetAttribute(hw_jumper_sense_));
00415   }
00416   catch(bad_lexical_cast &)
00417   {
00418     string ex_str = "gBSamp: Error -- Tag <"+ hw_jumper_ + "> : Unable to convert "
00419         +hw_jumper_hp_+", "+hw_jumper_lp_+", or "+hw_jumper_sense_+" into a number!";
00420     throw(std::invalid_argument(ex_str));
00421   }
00422 
00423   if(type == SIG_EEG)
00424     checkEEGJumperValues(highpass, lowpass, sense);
00425   else if(type == SIG_EOG)
00426     checkEOGJumperValues(highpass, lowpass, sense);
00427   else if(type == SIG_EMG)
00428     checkEMGJumperValues(highpass, lowpass, sense);
00429   else if(type == SIG_ECG)
00430     checkECGJumperValues(highpass, lowpass, sense);
00431   else
00432     throw(std::invalid_argument( "gBSamp: Error -- Tag <"+ hw_jumper_ + ">" +hw_ch_type_+ "not recognized!"));
00433 
00434 }
00435 
00436 //-----------------------------------------------------------------------------
00437 
00438 void gBSampBase::checkEEGJumperValues(float highpass, float lowpass, float sense)
00439 {
00440   if( (highpass != GBSAMP_EEG_HP_FILTER[0]) && (highpass != GBSAMP_EEG_HP_FILTER[1]) )
00441     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_hp_, "eeg", highpass, GBSAMP_EEG_HP_FILTER[0], GBSAMP_EEG_HP_FILTER[1]);
00442 
00443   if(lowpass != GBSAMP_EEG_LP_FILTER[0] && lowpass != GBSAMP_EEG_LP_FILTER[1])
00444     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_lp_, "eeg",lowpass, GBSAMP_EEG_LP_FILTER[0], GBSAMP_EEG_LP_FILTER[1]);
00445 
00446   if(sense != GBSAMP_EEG_SENS[0] && sense != GBSAMP_EEG_SENS[1])
00447     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_sense_, "eeg",sense, GBSAMP_EEG_SENS[0], GBSAMP_EEG_SENS[1]);
00448 }
00449 
00450 //-----------------------------------------------------------------------------
00451 
00452 void gBSampBase::checkEOGJumperValues(float highpass, float lowpass, float sense)
00453 {
00454   if(highpass != GBSAMP_EOG_HP_FILTER[0] && highpass != GBSAMP_EOG_HP_FILTER[1])
00455     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_hp_, "eog",highpass, GBSAMP_EOG_HP_FILTER[0], GBSAMP_EOG_HP_FILTER[1]);
00456 
00457   if(lowpass != GBSAMP_EOG_LP_FILTER[0] && lowpass != GBSAMP_EOG_LP_FILTER[1])
00458     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_lp_, "eog",lowpass, GBSAMP_EOG_LP_FILTER[0], GBSAMP_EOG_LP_FILTER[1]);
00459 
00460   if(sense != GBSAMP_EOG_SENS[0] && sense != GBSAMP_EOG_SENS[1])
00461     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_sense_, "eog",sense, GBSAMP_EOG_SENS[0], GBSAMP_EOG_SENS[1]);
00462 }
00463 
00464 //-----------------------------------------------------------------------------
00465 
00466 void gBSampBase::checkEMGJumperValues(float highpass, float lowpass, float sense)
00467 {
00468   if(highpass != GBSAMP_EMG_HP_FILTER[0] && highpass != GBSAMP_EMG_HP_FILTER[1])
00469     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_hp_, "emg",highpass, GBSAMP_EMG_HP_FILTER[0], GBSAMP_EMG_HP_FILTER[1]);
00470 
00471   if(lowpass != GBSAMP_EMG_LP_FILTER[0] && lowpass != GBSAMP_EMG_LP_FILTER[1])
00472     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_lp_, "emg",lowpass, GBSAMP_EMG_LP_FILTER[0], GBSAMP_EMG_LP_FILTER[1]);
00473 
00474   if(sense != GBSAMP_EMG_SENS[0] && sense != GBSAMP_EMG_SENS[1])
00475     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_sense_, "emg",sense, GBSAMP_EMG_SENS[0], GBSAMP_EMG_SENS[1]);
00476 }
00477 
00478 //-----------------------------------------------------------------------------
00479 
00480 void gBSampBase::checkECGJumperValues(float highpass, float lowpass, float sense)
00481 {
00482   if(highpass != GBSAMP_ECG_HP_FILTER[0] && highpass != GBSAMP_ECG_HP_FILTER[1])
00483     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_hp_, "ecg",highpass, GBSAMP_ECG_HP_FILTER[0], GBSAMP_ECG_HP_FILTER[1]);
00484 
00485   if(lowpass != GBSAMP_ECG_LP_FILTER[0] && lowpass != GBSAMP_ECG_LP_FILTER[1])
00486     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_lp_, "ecg",lowpass, GBSAMP_ECG_LP_FILTER[0], GBSAMP_ECG_LP_FILTER[1]);
00487 
00488   if(sense != GBSAMP_ECG_SENS[0] && sense != GBSAMP_ECG_SENS[1])
00489     throwXMLErrorWrongValue(hw_jumper_, hw_jumper_sense_, "ecg",sense, GBSAMP_ECG_SENS[0], GBSAMP_ECG_SENS[1]);
00490 }
00491 
00492 //-----------------------------------------------------------------------------
00493 
00494 
00495 void gBSampBase::throwXMLErrorWrongValue(const std::string& tag_name, const std::string& attr_name,
00496                                          std::string type, float given, float cor1, float cor2)
00497 {
00498   string ex_str;
00499   ex_str = "gBSamp: Error -- ";
00500   ex_str += "Tag <"+tag_name+"> - "+type+" - attribute: "+attr_name + " ";
00501   ex_str += "given value: " + boost::lexical_cast<std::string>(boost::format("%d") % given) +"; ";
00502   ex_str += "possible values are: "+ boost::lexical_cast<std::string>(boost::format("%d") % cor1);
00503   ex_str += " and " + boost::lexical_cast<std::string>(boost::format("%d") % cor2);
00504 
00505   throw(std::invalid_argument(ex_str));
00506 }
00507 
00508 //-----------------------------------------------------------------------------
00509 
00510 
00511 
00512 // Very bad hack!
00513 
00514 //if(type == SIG_EEG)
00515 //{
00516 //  try
00517 //  {
00518 //    f_low  = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_hp_));
00519 //    if((f_low != .5) || (f_low != 2))
00520 //    {
00521 //      string ex_str;
00522 //      ex_str = "gBSamp: Error -- ";
00523 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.5' or '2'";
00524 //      throw(ticpp::Exception(ex_str));
00525 //    }
00526 //  }
00527 //  catch(bad_lexical_cast &)
00528 //  {
00529 //    string ex_str;
00530 //    ex_str = "gBSamp: Error -- ";
00531 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00532 //    throw(ticpp::Exception(ex_str));
00533 //  }
00534 //  try
00535 //  {
00536 //    f_high = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_lp_));
00537 //    if((f_high != 30) || (f_high != 100))
00538 //    {
00539 //      string ex_str;
00540 //      ex_str = "gBSamp: Error -- ";
00541 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '30' or '100'";
00542 //      throw(ticpp::Exception(ex_str));
00543 //    }
00544 //  }
00545 //  catch(bad_lexical_cast &)
00546 //  {
00547 //    string ex_str;
00548 //    ex_str = "gBSamp: Error -- ";
00549 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00550 //    throw(ticpp::Exception(ex_str));
00551 //  }
00552 //  try
00553 //  {
00554 //    sense = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_sense_));
00555 //    if((f_low != .05) || (f_low != .1))
00556 //    {
00557 //      string ex_str;
00558 //      ex_str = "gBSamp: Error -- ";
00559 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.05' or '.1'";
00560 //      throw(ticpp::Exception(ex_str));
00561 //    }
00562 //  }
00563 //  catch(bad_lexical_cast &)
00564 //  {
00565 //    string ex_str;
00566 //    ex_str = "gBSamp: Error -- ";
00567 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00568 //    throw(ticpp::Exception(ex_str));
00569 //  }
00570 //}
00571 
00572 //if(type == SIG_EOG)
00573 //{
00574 //  try
00575 //  {
00576 //    f_low  = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_hp_));
00577 //    if((f_low != .5) || (f_low != 2))
00578 //    {
00579 //      string ex_str;
00580 //      ex_str = "gBSamp: Error -- ";
00581 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.5' or '2'";
00582 //      throw(ticpp::Exception(ex_str));
00583 //    }
00584 //  }
00585 //  catch(bad_lexical_cast &)
00586 //  {
00587 //    string ex_str;
00588 //    ex_str = "gBSamp: Error -- ";
00589 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00590 //    throw(ticpp::Exception(ex_str));
00591 //  }
00592 //  try
00593 //  {
00594 //    f_high = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_lp_));
00595 //    if((f_high != 30) || (f_high != 100))
00596 //    {
00597 //      string ex_str;
00598 //      ex_str = "gBSamp: Error -- ";
00599 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '30' or '100'";
00600 //      throw(ticpp::Exception(ex_str));
00601 //    }
00602 //  }
00603 //  catch(bad_lexical_cast &)
00604 //  {
00605 //    string ex_str;
00606 //    ex_str = "gBSamp: Error -- ";
00607 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00608 //    throw(ticpp::Exception(ex_str));
00609 //  }
00610 //  try
00611 //  {
00612 //    sense = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_sense_));
00613 //    if((f_low != .1) || (f_low != 1))
00614 //    {
00615 //      string ex_str;
00616 //      ex_str = "gBSamp: Error -- ";
00617 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.1' or '1'";
00618 //      throw(ticpp::Exception(ex_str));
00619 //    }
00620 //  }
00621 //  catch(bad_lexical_cast &)
00622 //  {
00623 //    string ex_str;
00624 //    ex_str = "gBSamp: Error -- ";
00625 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00626 //    throw(ticpp::Exception(ex_str));
00627 //  }
00628 //}
00629 
00630 //if(type == SIG_EMG)
00631 //{
00632 //  try
00633 //  {
00634 //    f_low  = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_hp_));
00635 //    if((f_low != .01) || (f_low != 2))
00636 //    {
00637 //      string ex_str;
00638 //      ex_str = "gBSamp: Error -- ";
00639 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.01' or '2'";
00640 //      throw(ticpp::Exception(ex_str));
00641 //    }
00642 //  }
00643 //  catch(bad_lexical_cast &)
00644 //  {
00645 //    string ex_str;
00646 //    ex_str = "gBSamp: Error -- ";
00647 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00648 //    throw(ticpp::Exception(ex_str));
00649 //  }
00650 //  try
00651 //  {
00652 //    f_high = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_lp_));
00653 //    if((f_high != 60) || (f_high != 100))
00654 //    {
00655 //      string ex_str;
00656 //      ex_str = "gBSamp: Error -- ";
00657 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '60' or '100'";
00658 //      throw(ticpp::Exception(ex_str));
00659 //    }
00660 //  }
00661 //  catch(bad_lexical_cast &)
00662 //  {
00663 //    string ex_str;
00664 //    ex_str = "gBSamp: Error -- ";
00665 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00666 //    throw(ticpp::Exception(ex_str));
00667 //  }
00668 //  try
00669 //  {
00670 //    sense = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_sense_));
00671 //    if((f_low != 1) || (f_low != 5))
00672 //    {
00673 //      string ex_str;
00674 //      ex_str = "gBSamp: Error -- ";
00675 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '1' or '5'";
00676 //      throw(ticpp::Exception(ex_str));
00677 //    }
00678 //  }
00679 //  catch(bad_lexical_cast &)
00680 //  {
00681 //    string ex_str;
00682 //    ex_str = "gBSamp: Error -- ";
00683 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00684 //    throw(ticpp::Exception(ex_str));
00685 //  }
00686 //}
00687 
00688 //if(type == SIG_ECG)
00689 //{
00690 //  try
00691 //  {
00692 //    f_low  = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_hp_));
00693 //    if((f_low != .01) || (f_low != 2))
00694 //    {
00695 //      string ex_str;
00696 //      ex_str = "gBSamp: Error -- ";
00697 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '0.01' or '2'";
00698 //      throw(ticpp::Exception(ex_str));
00699 //    }
00700 //  }
00701 //  catch(bad_lexical_cast &)
00702 //  {
00703 //    string ex_str;
00704 //    ex_str = "gBSamp: Error -- ";
00705 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00706 //    throw(ticpp::Exception(ex_str));
00707 //  }
00708 //  try
00709 //  {
00710 //    f_high = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_lp_));
00711 //    if((f_high != 60) || (f_high != 100))
00712 //    {
00713 //      string ex_str;
00714 //      ex_str = "gBSamp: Error -- ";
00715 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '60' or '100'";
00716 //      throw(ticpp::Exception(ex_str));
00717 //    }
00718 //  }
00719 //  catch(bad_lexical_cast &)
00720 //  {
00721 //    string ex_str;
00722 //    ex_str = "gBSamp: Error -- ";
00723 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00724 //    throw(ticpp::Exception(ex_str));
00725 //  }
00726 //  try
00727 //  {
00728 //    sense = lexical_cast<float>(elem.Get()->GetAttribute(hw_jumper_sense_));
00729 //    if((f_low != 2) || (f_low != 5))
00730 //    {
00731 //      string ex_str;
00732 //      ex_str = "gBSamp: Error -- ";
00733 //      ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not '2' or '5'";
00734 //      throw(ticpp::Exception(ex_str));
00735 //    }
00736 //  }
00737 //  catch(bad_lexical_cast &)
00738 //  {
00739 //    string ex_str;
00740 //    ex_str = "gBSamp: Error -- ";
00741 //    ex_str += "Tag <"+hw_jumper_+"> given, but lower filter is not given";
00742 //    throw(ticpp::Exception(ex_str));
00743 //  }
00744 //}
00745 
00746 }
 All Data Structures Files Functions Variables