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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = cmpx_iq_plot.cpp
  3. //
  4. #include <stdlib.h>
  5. #include <fstream>
  6. #include "parmfile.h"
  7. #include "cmpx_iq_plot.h"
  8. #include "complex_io.h"
  9. #include "misdefs.h"
  10. #include "model_graph.h"
  11. extern ParmFile *ParmInput;
  12. extern int PassNumber;
  13. extern char *DateString;
  14. extern bool DateInFileNames;
  15. #ifdef _DEBUG
  16.   extern ofstream *DebugFile;
  17. #endif
  18. //======================================================
  19. CmpxIqPlot::CmpxIqPlot( 
  20.                char* instance_name,
  21.                PracSimModel* outer_model,
  22.                Signal< std::complex< float > >* in_sig,
  23.                Signal< bit_t >* symb_clock_in )
  24.                   :PracSimModel( instance_name,
  25.                                  outer_model)
  26. {
  27.    MODEL_NAME(CmpxIqPlot);
  28.    //-----------------------------------------
  29.    //  Read model config parms
  30.    OPEN_PARM_BLOCK;
  31.    GET_INT_PARM(Hold_Off);
  32.    GET_INT_PARM(Sampling_Offset);
  33.    GET_STRING_PARM(Plot_File_Name);
  34.    if(DateInFileNames){
  35.       strcat(Plot_File_Name,"_");
  36.       strcat(Plot_File_Name, DateString);
  37.    }
  38.    strcat(Plot_File_Name,".txt");
  39.    //--------------------------------------
  40.    //  Connect input and output signals
  41.    Symb_Clock_In = symb_clock_in;
  42.    In_Sig = in_sig;
  43.    MAKE_INPUT( Symb_Clock_In );
  44.    MAKE_INPUT( In_Sig );
  45.    Plot_File = new ofstream(Plot_File_Name, ios::out);
  46.    Processing_Completed = false;
  47. }
  48. //======================================================
  49. CmpxIqPlot::~CmpxIqPlot( void ){ };
  50. //==============================================
  51. void CmpxIqPlot::Initialize(void)
  52. {
  53.    Block_Size = In_Sig->GetBlockSize();
  54.    Sample_Strobe = -1;
  55. }
  56. //======================================================
  57. int CmpxIqPlot::Execute()
  58. {
  59.    std::complex<float> *in_sig_ptr;
  60.    bit_t *symb_clock_in_ptr;
  61.    std::complex<float> in_val;
  62.    int is;
  63.    int block_size;
  64. #ifdef _DEBUG
  65.    *DebugFile << "In CmpxIqPlot::Execute" << endl;
  66. #endif
  67.    if(Processing_Completed) return(_MES_AOK);
  68.    if(PassNumber < Hold_Off) return(_MES_AOK);
  69.    in_sig_ptr = GET_INPUT_PTR( In_Sig );
  70.    symb_clock_in_ptr = GET_INPUT_PTR( Symb_Clock_In );
  71.    block_size = In_Sig->GetValidBlockSize();
  72.    for (is=0; is<block_size; is++){
  73.       in_val = *in_sig_ptr++;
  74.       if(*symb_clock_in_ptr != 0) {
  75.          Sample_Strobe = Sampling_Offset;
  76.       }
  77.       if(Sample_Strobe == 0) {
  78.          // time to grab a sample
  79.          *Plot_File << in_val << endl;
  80.       }
  81.       Sample_Strobe--;
  82.       symb_clock_in_ptr++;
  83.    }
  84.    return(_MES_AOK);
  85. }