TOBI SignalServer  0.1
/home/breidi/Dropbox/signalserver/include/hardware/artificial_signal_source.h
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 
00039 #ifndef ARTIFICIAL_SIGNAL_SOURCE
00040 #define ARTIFICIAL_SIGNAL_SOURCE
00041 
00042 #include <vector>
00043 #include <map>
00044 
00045 #include <boost/asio.hpp>
00046 #include <boost/thread/condition.hpp>               // for mutex and cond. variables
00047 #include <boost/thread/shared_mutex.hpp>
00048 #include <boost/date_time/posix_time/posix_time.hpp>
00049 #include <boost/cstdint.hpp>
00050 
00051 #include "hw_thread.h"
00052 #include "hardware/hw_thread_builder.h"
00053 
00054 namespace tobiss
00055 {
00056 //-----------------------------------------------------------------------------
00062 class ArtificialSignalSource : public HWThread
00063 {
00064   public:
00068     virtual ~ArtificialSignalSource();
00069 
00077     virtual SampleBlock<double> getSyncData();
00090     virtual SampleBlock<double> getAsyncData();
00091 
00092 
00093 //-----------------------------------------------
00094   protected:
00101     ArtificialSignalSource(boost::asio::io_service& io, ticpp::Iterator<ticpp::Element> hw);
00102 
00106     virtual void run();
00110     virtual void stop();
00111 
00118     void init();
00119 
00125     virtual void setHardware(ticpp::Iterator<ticpp::Element>const &hw) = 0;
00129     virtual void generateSignal() = 0;
00135     virtual void setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father) = 0;
00141     virtual void setChannelSettings(ticpp::Iterator<ticpp::Element>const &father) = 0;
00142 
00143 //-----------------------------------------------
00144 
00145   protected:
00146     bool acquiring_;   
00147     boost::asio::io_service&     io_;
00148     boost::asio::deadline_timer* t_;   
00149     double step_;        
00150     double cycle_dur_;   
00151     boost::uint16_t current_block_;     
00152     boost::posix_time::microseconds td_;   
00153 
00154     boost::mutex sync_mut_;  
00155     boost::condition_variable_any cond_;   
00156 
00157     std::vector<double> samples_; 
00158 
00166     SampleBlock<double> buffer_;
00167 };
00168 
00169 } // Namespace tobiss
00170 
00171 #endif // ARTIFICIAL_SIGNAL_SOURCE
00172 
00173 //-----------------------------------------------------------------------------
 All Data Structures Files Functions Variables