integ_n_dump.cpp
上传用户:jtjnyq9001
上传日期:2014-11-21
资源大小:3974k
文件大小:2k
源码类别:

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = integ_n_dump.cpp
  3. //
  4. #include <stdlib.h>
  5. #include <fstream>
  6. #include "parmfile.h"
  7. #include "integ_n_dump.h"
  8. #include "uni_rand.h"
  9. #include "model_graph.h"
  10. #include "misdefs.h"
  11. extern ParmFile *ParmInput;
  12. extern int PassNumber;
  13. #ifdef _DEBUG
  14.   extern ofstream *DebugFile;
  15. #endif
  16. //======================================================
  17. IntegrateAndDump::IntegrateAndDump( char* instance_name,
  18.                       PracSimModel* outer_model,
  19.                       Signal<float>* in_sig,
  20.                       Signal< bit_t >* symb_clock_in,
  21.                       Signal<float>* samp_wave_out )
  22.                 :PracSimModel( instance_name,
  23.                                outer_model )
  24. {
  25.   MODEL_NAME(IntegrateAndDump);
  26.   In_Sig = in_sig;
  27.   Samp_Wave_Out = samp_wave_out;
  28.   Symb_Clock_In = symb_clock_in;
  29.   OPEN_PARM_BLOCK;
  30.   GET_DOUBLE_PARM( Symb_Width );
  31.   ENABLE_MULTIRATE;
  32.   MAKE_OUTPUT(Samp_Wave_Out);
  33.   MAKE_INPUT( Symb_Clock_In );
  34.   MAKE_INPUT( In_Sig );
  35.   // one sample per symbol at output
  36. //  CHANGE_RATE(In_Sig, Samp_Wave_Out);
  37. }
  38. IntegrateAndDump::~IntegrateAndDump( void ){ };
  39. void IntegrateAndDump::Initialize(void)
  40. {
  41.   In_Block_Size = In_Sig->GetBlockSize();
  42.   In_Samp_Intvl = In_Sig->GetSampIntvl();
  43.   Integ_Val = 0.0;
  44.   Integ_Gain = 0.0;
  45. };
  46. //============================================
  47. int IntegrateAndDump::Execute()
  48. {
  49.   float *in_sig_ptr, in_val;
  50.   float *samp_wave_out_ptr;
  51.   bit_t *symb_clock_in_ptr;
  52.   int is, block_size;
  53.   int out_block_size;
  54.   double integ_val = Integ_Val;
  55.   double integ_gain = Integ_Gain;
  56.   samp_wave_out_ptr = GET_OUTPUT_PTR( Samp_Wave_Out );
  57.   symb_clock_in_ptr = GET_INPUT_PTR( Symb_Clock_In );
  58.   in_sig_ptr = GET_INPUT_PTR( In_Sig );
  59.   block_size = In_Sig->GetValidBlockSize();
  60.   out_block_size = 0;
  61.   for (is=0; is<block_size; is++)
  62.     {
  63.     in_val = *in_sig_ptr++;
  64.     integ_val += in_val;
  65.     integ_gain++;
  66.     if(*symb_clock_in_ptr != 0)
  67.       {
  68.       // time to make a decision
  69.       *samp_wave_out_ptr++ = integ_val/integ_gain;
  70.       out_block_size++;
  71.       integ_val = 0.0;
  72.       integ_gain = 0.0;
  73.       }
  74. //    else
  75. //      {
  76.       //*samp_wave_out_ptr++ = 0.0;
  77. //      *samp_wave_out_ptr++ = integ_val;
  78. //      }
  79.     symb_clock_in_ptr++;
  80.     }
  81.  Samp_Wave_Out->SetValidBlockSize(out_block_size);
  82.   Integ_Val = integ_val;
  83.   return(_MES_AOK);
  84. }