|
TOBI Interface A
0.1
|
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 00046 #ifndef DATAPACKET3_H 00047 #define DATAPACKET3_H 00048 00049 #include <map> 00050 #include <boost/cstdint.hpp> 00051 00052 #include "tia/data_packet_interface.h" 00053 00054 namespace tia 00055 { 00056 00057 class RawMem3; 00058 00075 class DataPacket3Impl : public DataPacket 00076 { 00082 public: 00086 DataPacket3Impl(); 00087 00095 virtual ~DataPacket3Impl(); 00096 00101 DataPacket3Impl(const DataPacket3Impl &src); 00102 00103 DataPacket3Impl& operator=(const DataPacket3Impl &src); 00104 00108 void reset(); 00109 00121 void reset(void* mem); 00122 00126 void incPacketID(); 00127 00131 void setPacketID(boost::uint64_t nr); 00132 00149 void insertDataBlock(std::vector<double> v, boost::uint32_t signal_flag, boost::uint16_t blocks, bool prepend = false); 00150 00154 void setConnectionPacketNr(boost::uint64_t); 00155 00159 boost::uint64_t getConnectionPacketNr(); 00160 00164 void setTimestamp(); 00165 00170 boost::uint64_t getTimestamp() { return(timestamp_); } 00171 00176 bool hasFlag(boost::uint32_t f); 00182 boost::uint16_t getNrOfSignalTypes(); 00188 boost::uint32_t getFlags(); 00193 boost::uint64_t getPacketID(); 00194 00195 00199 virtual std::vector<boost::uint16_t> getNrOfSamples(); 00204 std::vector<boost::uint16_t> getNrSamplesPerChannel(); 00209 std::vector<boost::uint16_t> getNrOfChannels(); 00210 00211 00212 00216 boost::uint16_t getNrOfSamples(boost::uint32_t flag); 00222 boost::uint16_t getNrSamplesPerChannel(boost::uint32_t flag); 00228 boost::uint16_t getNrOfChannels(boost::uint32_t flag); 00229 00230 00236 const std::vector<double>& getData(); 00244 std::vector<double> getSingleDataBlock(boost::uint32_t flag); 00245 00254 void* getRaw(); 00255 00261 boost::uint32_t getRawMemorySize(); 00262 00267 boost::uint32_t getRequiredRawMemorySize(); 00268 00281 boost::uint32_t getRequiredRawMemorySize(void* mem, boost::uint32_t bytes_available); 00282 00283 private: 00288 boost::uint16_t calcNrOfSignalTypes(boost::uint32_t f); 00293 bool flagsOK(); 00298 void setFlag(boost::uint32_t flag); 00304 boost::uint32_t getDataPos(boost::uint32_t flag); 00310 boost::uint32_t getOffset(boost::uint32_t pos); 00311 00321 void appendDataBlock(std::vector<double> &v, boost::uint32_t signal_flag, boost::uint16_t blocks); 00322 00332 void prependDataBlock(std::vector<double> &v, boost::uint32_t signal_flag, boost::uint16_t blocks); 00333 00334 private: 00335 00336 boost::uint8_t version_; 00337 boost::uint32_t size_; 00338 00343 boost::uint64_t packet_id_; 00344 00349 boost::uint32_t flags_; 00350 boost::uint64_t connection_packet_nr_; 00351 boost::uint64_t timestamp_; 00352 00353 boost::uint16_t nr_of_signal_types_; 00354 00355 std::vector<boost::uint16_t> samples_per_channel_; 00356 std::vector<boost::uint16_t> nr_channels_; 00357 std::vector<double> data_; 00358 00359 00360 00361 std::map<boost::uint32_t, RawMem3*> raw_map_; 00362 }; 00363 00364 } // Namespace tobiss 00365 00366 #endif // DATAPACKET3_H