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

3G开发

开发平台:

Visual C++

  1. //
  2. //  File = disc_delay_tester.cpp
  3. //
  4. #include <stdlib.h>
  5. #include <fstream>
  6. #include <strstream>
  7. #include "parmfile.h"
  8. #include "disc_delay_tester.h"
  9. #include "model_graph.h"
  10. #include "uni_rand.h"
  11. extern ParmFile ParmInput;
  12. extern int PassNumber;
  13. //======================================================
  14. template< class T >
  15. DiscreteDelayTester< T >::DiscreteDelayTester( char* instance_name,
  16.                                 PracSimModel* outer_model,
  17.                                 Signal<T>* in_signal,
  18.                                 Signal<T>* out_signal,
  19.                                 Control<int> *delay_value,
  20.                                 Control<bool> *delay_change_enabled )
  21.               :PracSimModel(instance_name,
  22.                             outer_model)
  23. {
  24.   MODEL_NAME(DelayControlTester);
  25.   //-----------------------------------
  26.   // Read configuration parameters
  27.   //OPEN_PARM_BLOCK;
  28.   //GET_DOUBLE_PARM(Max_Delay);
  29.   //GET_DOUBLE_PARM(Initial_Delay);
  30.   //-----------------------------------
  31.   //  Signals
  32.   In_Sig = in_signal;
  33.   Out_Sig = out_signal;
  34.   MAKE_OUTPUT( Out_Sig );
  35.   MAKE_INPUT( In_Sig );
  36.   //--------------------------------
  37.   //  Controls
  38.   Delay_Value = delay_value;
  39.   Delay_Change_Enabled = delay_change_enabled;
  40.   return;
  41.   }
  42. //================================================
  43. template< class T >
  44. DiscreteDelayTester<T>::~DiscreteDelayTester( void ){ };
  45. //=======================================================
  46. template< class T >
  47. void DiscreteDelayTester<T>::Initialize()
  48. {
  49.   //---------------------------------------
  50.   //  Initialize derived parameters
  51.   Samp_Intvl = In_Sig->GetSampIntvl();
  52.   Block_Size = In_Sig->GetBlockSize();
  53. }
  54. //=======================================
  55. template< class T >
  56. int DiscreteDelayTester<T>::Execute()
  57. {
  58.   T input_samp, *input_signal_ptr;
  59.   T *output_signal_ptr;
  60.   int is;
  61.   int block_size;
  62.   //-----------------------------------------
  63.   // Get pointers for input and output signals
  64.   
  65.   output_signal_ptr = GET_OUTPUT_PTR(Out_Sig);
  66.   input_signal_ptr = GET_INPUT_PTR(In_Sig);
  67.   block_size = In_Sig->GetValidBlockSize();
  68.   Out_Sig->SetValidBlockSize(block_size);
  69.   for(is=0; is<block_size; is++)
  70.     {
  71.     input_samp = *input_signal_ptr++;
  72.     //*output_signal_ptr++ = 0.5 * input_samp;
  73.     *output_signal_ptr++ = input_samp;
  74.     }
  75.   Delay_Value->SetValue(5-PassNumber);
  76.   //Delay_Value->SetValue(4000);
  77.   if( (PassNumber%2)==0 )
  78.     {
  79.     Delay_Change_Enabled->SetValue(true);
  80.     }
  81.   else
  82.     {
  83.     Delay_Change_Enabled->SetValue(false);
  84.     }
  85.   return(_MES_AOK);
  86. }
  87. template DiscreteDelayTester< int >;
  88. template DiscreteDelayTester< float >;