• Main Page
  • Packages
  • Classes
  • Files
  • File List
  • File Members

unlock/bci/acquire-c++/MockSignal.hpp

Go to the documentation of this file.
00001 
00002 // Copyright (c) James Percent and Unlock contributors.
00003 // All rights reserved.
00004 // Redistribution and use in source and binary forms, with or without modification,
00005 // are permitted provided that the following conditions are met:
00006 //
00007 //    1. Redistributions of source code must retain the above copyright notice,
00008 //       this list of conditions and the following disclaimer.
00009 //    
00010 //    2. Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //
00014 //    3. Neither the name of Unlock nor the names of its contributors may be used
00015 //       to endorse or promote products derived from this software without
00016 //       specific prior written permission.
00017 
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00019 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00022 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00024 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00025 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00027 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 
00029 #ifndef MOCK_SIGNAL_HPP
00030 #define MOCK_SIGNAL_HPP
00031 
00032 #include "ISignal.hpp"
00033 #include "Portability.hpp"
00034 
00035 class DllExport MockSignal : public ISignal
00036 {
00037  public:
00038   MockSignal()
00039   : mOpenCount(0), mOpenRet(true), mInitCount(0), mLastChannels(5), mInitRet(true), mChannelsCount(0), mStartCount(0), mStartRet(true),
00040     mAcquireCount(0), mAcquireRet(5), mGetDataCount(0), mpLastGetData(0), mLastSamples(0),
00041     mTimestampCount(0), mTimestampRet(-1), mStopCount(0), mStopRet(true), mCloseCount(0),
00042     mCloseRet(true)
00043 {
00044   mLastMac[0] = 0xd;
00045   mLastMac[1] = 0xe;
00046   mLastMac[2] = 0xa;
00047   mLastMac[3] = 0xd;
00048   mLastMac[4] = 0xe;
00049   mLastMac[5] = 0xd;
00050 }
00051 
00052   virtual ~MockSignal()  {}
00053   virtual bool open(uint8_t* mac) {
00054   BOOST_VERIFY(pMacAddress != 0);
00055   mOpenCount++;
00056   std::copy(pMacAddress, pMacAddress+MAC_ADDRESS_SIZE, mLastMac);
00057   return mOpenRet;
00058 }
00059 
00060   virtual bool init(size_t channels) {
00061   mInitCount++;
00062   mLastChannels = channels;
00063   return mInitRet;
00064 }
00065 
00066   virtual size_t channels() {
00067   mChannelsCount++;
00068   return mLastChannels;
00069 }
00070 
00071   virtual bool start() {
00072   mStartCount++;
00073   return mStartRet;
00074 }
00075 
00076   virtual size_t acquire(){
00077   mAcquireCount++;
00078   return mAcquireRet;
00079 }
00080 
00081 
00082   virtual void getdata(uint32_t* buffer, size_t samples) {
00083   BOOST_VERIFY(buffer != 0);
00084   mGetDataCount++;
00085   for(size_t i=0; i < samples; i++) {
00086     buffer[i] = (uint32_t)i;
00087   }
00088   buffer[samples - 1] = 0;
00089   mpLastGetData = buffer;
00090   mLastSamples = samples;
00091 }
00092 
00093 
00094 
00095   virtual uint64_t timestamp() {
00096   mTimestampCount++;
00097   return mTimestampRet;
00098 }
00099 
00100   virtual bool stop()  {
00101   mStopCount++;
00102   return mStopRet;
00103 }
00104 
00105   virtual bool close(){
00106   mCloseCount++;
00107   return mCloseRet;
00108 }
00109 
00110  public:
00111   size_t mOpenCount;
00112   bool mOpenRet;
00113   uint8_t mLastMac[MAC_ADDRESS_SIZE];
00114   size_t mInitCount;
00115   size_t mLastChannels;
00116   bool mInitRet;
00117   size_t mChannelsCount;
00118   size_t mStartCount;
00119   bool mStartRet;
00120   size_t mAcquireCount;
00121   size_t mAcquireRet;
00122   size_t mGetDataCount;
00123   uint32_t* mpLastGetData;
00124   size_t mLastSamples;
00125   size_t mTimestampCount;
00126   uint64_t mTimestampRet;
00127   size_t mStopCount;
00128   bool mStopRet;
00129   size_t mCloseCount;
00130   bool mCloseRet;       
00131 };
00132 
00133 #endif

Generated on Mon Nov 10 2014 11:09:07 for The Unlock Project by  doxygen 1.7.1