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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = integ_dump_slice.cpp
  3. //
  4. #include <stdlib.h>
  5. //#include <fstream>
  6. #include "parmfile.h"
  7. #include "integ_dump_slice.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. IntegrateDumpAndSlice::IntegrateDumpAndSlice( char* instance_name,
  18.                       PracSimModel* outer_model,
  19.                       Signal<float>* in_sig,
  20.                       //Signal<float>* corr_sig,
  21.                       Signal< bit_t >* symb_clock_in,
  22.                       Signal<float>* samp_wave_out,
  23.                       Signal<bit_t>* out_sig )
  24.                 :PracSimModel( instance_name,
  25.                                outer_model )
  26. {
  27.   MODEL_NAME(IntegrateDumpAndSlice);
  28.   In_Sig = in_sig;
  29.   //Corr_Sig = corr_sig;
  30.   Out_Sig = out_sig;
  31.   Samp_Wave_Out = samp_wave_out;
  32.   Symb_Clock_In = symb_clock_in;
  33.   OPEN_PARM_BLOCK;
  34.   GET_DOUBLE_PARM( Symb_Width );
  35.   ENABLE_MULTIRATE;
  36.   MAKE_OUTPUT( Out_Sig );
  37.   MAKE_OUTPUT(Samp_Wave_Out);
  38.   MAKE_INPUT( Symb_Clock_In );
  39.   MAKE_INPUT( In_Sig );
  40.   //MAKE_INPUT( Corr_Sig );
  41.   // one sample per symbol at output
  42.   SET_SAMP_INTVL( Out_Sig, Symb_Width );
  43.   SAME_RATE(In_Sig, Samp_Wave_Out);
  44.   //SAME_RATE(Corr_Sig, Samp_Wave_Out);
  45. }
  46. IntegrateDumpAndSlice::~IntegrateDumpAndSlice( void ){ };
  47. void IntegrateDumpAndSlice::Initialize(void)
  48. {
  49.   Out_Block_Size = Out_Sig->GetBlockSize();
  50.   In_Block_Size = In_Sig->GetBlockSize();
  51.   In_Samp_Intvl = In_Sig->GetSampIntvl();
  52.   Out_Samp_Intvl = Out_Sig->GetSampIntvl();
  53.   Integ_Val = 0.0;
  54. };
  55. //============================================
  56. int IntegrateDumpAndSlice::Execute()
  57. {
  58.   float *in_sig_ptr, in_val;
  59.   //float *corr_sig_ptr, corr_val;
  60.   float *samp_wave_out_ptr;
  61.   bit_t *out_sig_ptr, symb_decis;
  62.   bit_t *symb_clock_in_ptr;
  63.   int is;
  64.   double integ_val = Integ_Val;
  65.    Out_Sig->SetValidBlockSize(Out_Block_Size);
  66.    Samp_Wave_Out->SetValidBlockSize(In_Block_Size);
  67.   out_sig_ptr = GET_OUTPUT_PTR( Out_Sig );
  68.   samp_wave_out_ptr = GET_OUTPUT_PTR( Samp_Wave_Out );
  69.   symb_clock_in_ptr = GET_INPUT_PTR( Symb_Clock_In );
  70.   in_sig_ptr = GET_INPUT_PTR( In_Sig );
  71.   //corr_sig_ptr = GET_INPUT_PTR( Corr_Sig );
  72.   for (is=0; is<In_Block_Size; is++)
  73.     {
  74.     in_val = *in_sig_ptr++;
  75.     //corr_val = *corr_sig_ptr++;
  76.     //integ_val += in_val*corr_val;
  77.     integ_val += in_val;
  78.     if(*symb_clock_in_ptr != 0)
  79.       {
  80.       // time to make a decision
  81.       if(integ_val < 0.0) symb_decis = 0;
  82.       else symb_decis = 1;
  83.       *out_sig_ptr++ = symb_decis;
  84.       *samp_wave_out_ptr++ = integ_val;
  85.       integ_val = 0.0;
  86.       }
  87.     else
  88.       {
  89.       //*samp_wave_out_ptr++ = 0.0;
  90.       *samp_wave_out_ptr++ = integ_val;
  91.       }
  92.     symb_clock_in_ptr++;
  93.     }
  94.   Integ_Val = integ_val;
  95.   return(_MES_AOK);
  96. }