TOBI Interface A  0.1
/home/breidi/Dropbox/libtia/src/tia/datapacket/data_packet_selector.cpp
Go to the documentation of this file.
00001 /*
00002     This file is part of the TOBI Interface A (TiA) library.
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 Lesser General Public License Usage
00014     Alternatively, this file may be used under the terms of the GNU Lesser
00015     General Public License version 3.0 as published by the Free Software
00016     Foundation and appearing in the file lgpl.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/lgpl.html.
00020 
00021     In case of GNU Lesser General Public License Usage ,the TiA library
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 Lesser General Public License
00028     along with the TiA library. If not, see <http://www.gnu.org/licenses/>.
00029 
00030     Copyright 2010 Graz University of Technology
00031     Contact: TiA@tobi-project.org
00032 */
00033 
00038 #include "tia-private/datapacket/data_packet_selector.h"
00039 
00040 namespace tia
00041 {
00042 
00043 using std::vector;
00044 using std::map;
00045 using std::set;
00046 
00047 using boost::uint32_t;
00048 using boost::uint16_t;
00049 
00050 static const unsigned int RESERVED_NR_SAMPLES_4_WORK_VEC = 2048;
00051 
00052 DataPacketSelector::DataPacketSelector()
00053 {
00054   work_vec_.reserve(RESERVED_NR_SAMPLES_4_WORK_VEC);
00055 }
00056 
00057 //-----------------------------------------------------------------------------
00058 
00059 void DataPacketSelector::setDesiredChannels( boost::uint32_t signal_type, boost::uint16_t blocksize,
00060                                          std::set<boost::uint16_t> channels)
00061 {
00062   ch_selection_.insert( make_pair( signal_type, channels ) );
00063 
00064   vector<double> vec;
00065   vec.reserve( blocksize * channels.size() );
00066   sample_map_.insert( make_pair( signal_type, vec ) );
00067 }
00068 
00069 //-----------------------------------------------------------------------------
00070 
00071 //DataPacketImpl DataPacketSelector::getModifiedDataPacket(DataPacketImpl& packet)
00072 //{
00073 //  DataPacketImpl new_packet;
00074 
00075 //  map<uint32_t, set<uint16_t> >::iterator it;
00076 //  uint32_t flag = 0;
00077 //  uint16_t nr_ch = 0;
00078 //  uint16_t nr_values = 0;
00079 //  uint16_t blocksize = 0;
00080 //  uint32_t offset = 0;
00081 
00082 
00083 //  for( it = ch_selection_.begin(); it != ch_selection_.end(); it++  )
00084 //  {
00085 //    flag = it->first;
00086 
00087 //    work_vec_ = packet.getSingleDataBlock(flag);
00088 //    blocksize = packet.getNrOfBlocks(flag);
00089 //    nr_values = packet.getNrOfSamples(flag);
00090 //    nr_ch  = nr_values/blocksize;
00091 
00092 //    vector<double>&  sample_vec = sample_map_[flag];
00093 //    set< uint16_t >& channel_list = it->second;
00094 
00095 //    for(unsigned int n = 0; n < nr_ch; n++)
00096 //    {
00097 //      if( channel_list.find(n) != channel_list.end() )
00098 //      {
00099 //        offset = n * blocksize;
00100 //        for(unsigned int k = 0; k < blocksize; k++)
00101 //          sample_vec.push_back(offset + k);
00102 //      }
00103 //    }
00104 
00105 //    new_packet.insertDataBlock( sample_vec, flag, blocksize);
00106 //    sample_vec.clear();
00107 //  }
00108 
00109 //  return(new_packet);
00110 
00111 //}
00112 
00113 //-----------------------------------------------------------------------------
00114 
00115 }   //tobiss
 All Data Structures Files Functions Variables Typedefs Enumerations