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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = pwrmtr.cpp
  3. //
  4. #include <stdlib.h>
  5. #include <fstream>
  6. #include <math.h>
  7. #include "parmfile.h"
  8. #include "pwrmtr.h"
  9. #include "model_graph.h"
  10. #include "sigstuff.h"
  11. #include "syst_graph.h"
  12. #include "misdefs.h"
  13. #include "gensig.h"
  14. extern ParmFile *ParmInput;
  15. ///extern ActiveSystemGraph ActSystGraph;
  16. #ifdef _DEBUG
  17.   extern ofstream *DebugFile;
  18. #endif
  19. //======================================================
  20. // normal constructor
  21. PowerMeter::PowerMeter( char* instance_name,
  22.                         PracSimModel* outer_model,
  23.                         Signal<float>* in_sig,
  24.                         Signal<float>* est_avg_sig_pwr)
  25.               :PracSimModel(instance_name,
  26.                             outer_model)
  27. {
  28.   In_Sig = in_sig;
  29.   Est_Avg_Sig_Pwr = est_avg_sig_pwr;
  30.   OPEN_PARM_BLOCK;
  31.   float init_pwr_output;
  32.   GET_FLOAT_PARM(init_pwr_output);
  33.   float integ_const;
  34.   GET_FLOAT_PARM(integ_const);
  35.   
  36.   char sub_name[50];
  37.   strcpy(sub_name,GetModelName());
  38.   strcat(sub_name, ":Kernel");
  39.   Kernel = new k_PowerMeter<float>( sub_name,
  40.                                  init_pwr_output,
  41.                                  integ_const);
  42.   Setup();
  43. }
  44. //============================================
  45. //  constructor for subordinate instance
  46. PowerMeter::PowerMeter( char *instance_name,
  47.                         PracSimModel *outer_model,
  48.                         Signal<float> *in_sig,
  49.                         Signal<float> *est_avg_sig_pwr,
  50.                         float init_pwr_output,
  51.                         float integ_const )
  52.         :PracSimModel( instance_name, outer_model)
  53. {
  54.   In_Sig = in_sig;
  55.   Est_Avg_Sig_Pwr = est_avg_sig_pwr;
  56.   char sub_name[50];
  57.   strcpy(sub_name,GetModelName());
  58.   strcat(sub_name, ":Kernel");
  59.   Kernel = new k_PowerMeter<float>( sub_name,
  60.                              init_pwr_output,
  61.                              integ_const);
  62.   Setup();
  63. }
  64. //=============================================
  65. PowerMeter::~PowerMeter( void ){ };
  66. //=============================================
  67. void PowerMeter::Setup( void )
  68. {
  69.   MAKE_OUTPUT(Est_Avg_Sig_Pwr);
  70.   MAKE_INPUT(In_Sig);
  71.   SAME_RATE(In_Sig, Est_Avg_Sig_Pwr);
  72. };
  73. //===========================================
  74. void PowerMeter::Initialize(void)
  75. {
  76.   *DebugFile << "Now in CmpxPowerMeter::Initialize()" << endl;
  77.   Proc_Block_Size = In_Sig->GetBlockSize();
  78.   Kernel->Initialize( Proc_Block_Size,
  79.                       In_Sig->GetSampIntvl());
  80. }
  81. //=============================================
  82. int PowerMeter::Execute(void)
  83. {
  84.   int pm_status;
  85.   float *out_sig_ptr;
  86.   float *in_sig_ptr;
  87.   int block_size;
  88.   *DebugFile << "In PowerMeter::Execute" << endl;
  89.   block_size = In_Sig->GetValidBlockSize();
  90.   Est_Avg_Sig_Pwr->SetValidBlockSize( block_size );
  91.   in_sig_ptr = GET_INPUT_PTR(In_Sig);
  92.   out_sig_ptr = GET_OUTPUT_PTR(Est_Avg_Sig_Pwr);
  93.   //----------------------------------------------
  94.   pm_status = Kernel->Execute(  in_sig_ptr,
  95.                                 out_sig_ptr,
  96.                                 block_size);
  97.   return(_MES_AOK);
  98. }