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

3G开发

开发平台:

Visual C++

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