Changeset 217:f2dbe431c1a3 in finroc


Ignore:
Timestamp:
11.07.2012 18:42:38 (7 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Improved templates by adding information about typical handling of data changes

Location:
etc/content_templates
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • etc/content_templates/class.cpp.template

    r214 r217  
    5454// t%%NAME%% constructors 
    5555//---------------------------------------------------------------------- 
    56 t%%NAME%%::t%%NAME%%() 
    57   : some_value( Values should be initialized here ) 
     56t%%NAME%%::t%%NAME%%() : 
     57  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    5858{} 
    5959 
     
    6565 
    6666//---------------------------------------------------------------------- 
    67 // t%%NAME%% SomeMethod 
     67// t%%NAME%% SomeExampleMethod 
    6868//---------------------------------------------------------------------- 
    69 void t%%NAME%%::SomeMethod() 
     69void t%%NAME%%::SomeExampleMethod() 
    7070{ 
    71   This is an example for a method that might somhow use this->some_value. 
    72   Delete both if you do not use it. 
     71  This is an example for a method. Replace it by your own methods! 
    7372} 
    7473 
  • etc/content_templates/class.h.template

    r180 r217  
    5858  t%%NAME%%(); 
    5959 
    60   ~t%%NAME%%(); 
     60  ~t%%NAME%%();   You need this destructor if you allocated memory on the heap that must be free'd. Delete otherwise! 
    6161 
    62   void SomeMethod(); 
     62  Here is the right place for your public methods. Replace this line by your declarations! 
    6363 
    6464//---------------------------------------------------------------------- 
     
    6767private: 
    6868 
    69   double some_value; 
     69  Here is the right place for your variables. Replace this line by your declarations! 
    7070 
    7171}; 
  • etc/content_templates/class.hpp.template

    r214 r217  
    5050//---------------------------------------------------------------------- 
    5151template <> 
    52 t%%NAME%%<>::t%%NAME%%() 
    53   : some_value( Values should be initialized here ) 
     52t%%NAME%%<>::t%%NAME%%() : 
     53  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    5454{} 
    5555 
     
    6262 
    6363//---------------------------------------------------------------------- 
    64 // t%%NAME%% SomeMethod 
     64// t%%NAME%% SomeExampleMethod 
    6565//---------------------------------------------------------------------- 
    6666template <> 
    67 void t%%NAME%%<>::SomeMethod() 
     67void t%%NAME%%<>::SomeExampleMethod() 
    6868{ 
    69   This is an example for a method that might somhow use this->some_value. 
    70   Delete both if you do not use it. 
     69  This is an example for a method. Replace it by your own methods! 
    7170} 
    7271 
  • etc/content_templates/group.h.template

    r211 r217  
    6868 
    6969  g%%NAME%%(core::tFrameworkElement *parent, const util::tString &name = "%%NAME%%", 
    70     %%INDENT_ONE_NAME%%const finroc::util::tString &structure_config_file = __FILE__".xml"); 
     70    %%INDENT_ONE_NAME%%const util::tString &structure_config_file = __FILE__".xml"); 
     71 
     72  ~g%%NAME%%();   You need this destructor if you allocated memory on the heap that must be free'd. Delete otherwise! 
    7173 
    7274}; 
  • etc/content_templates/misc.cpp.template

    r214 r217  
    5454// SomeFunction 
    5555//---------------------------------------------------------------------- 
    56 void SomeFunction() 
     56void SomeExampleFunction() 
    5757{ 
    58   Implement this function which acts as an example or delete it and write your own 
     58  This is an example for a function. Replace it by your own functions! 
    5959} 
    6060 
  • etc/content_templates/misc.h.template

    r180 r217  
    4141//---------------------------------------------------------------------- 
    4242 
    43 void SomeFunction() 
     43Here is the right place for your functions. Replace this line by your declarations! 
    4444 
    4545//---------------------------------------------------------------------- 
  • etc/content_templates/misc.hpp.template

    r214 r217  
    4747 
    4848//---------------------------------------------------------------------- 
    49 // SomeFunction 
     49// SomeExampleFunction 
    5050//---------------------------------------------------------------------- 
    5151template <> 
    52 void SomeFunction() 
     52void SomeExampleFunction() 
    5353{ 
    54   Implement this function which acts as an example or delete it and write your own 
     54  This is an example for a function. Replace it by your own functions! 
    5555} 
    5656 
  • etc/content_templates/module.cpp.template

    r214 r217  
    5555// m%%NAME%% constructor 
    5656//---------------------------------------------------------------------- 
    57 m%%NAME%%::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) 
    58   : tModule(parent, name), 
    59     some_value( Values should be initialized here ) 
     57m%%NAME%%::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) : 
     58  tModule(parent, name), 
     59  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    6060{} 
    6161 
     
    6767 
    6868//---------------------------------------------------------------------- 
    69 // m%%NAME%% ParametersChanged 
     69// m%%NAME%% EvaluateStaticParameters 
    7070//---------------------------------------------------------------------- 
    71 void m%%NAME%%::ParametersChanged() 
     71void m%%NAME%%::EvaluateStaticParameters() 
    7272{ 
    73   if (this->parameter.HasChanged()) 
     73  if (this->static_parameter_1.HasChanged()) 
    7474  { 
    75     do something 
     75    As this static parameter has changed, do something with its value! 
    7676  } 
     77} 
     78 
     79//---------------------------------------------------------------------- 
     80// m%%NAME%% EvaluateParameters 
     81//---------------------------------------------------------------------- 
     82void m%%NAME%%::EvaluateParameters() 
     83{ 
     84  If this method is called, at least on of your parameters has changed. However, each can be checked using its .HasChanged() method. 
    7785} 
    7886 
     
    8290void m%%NAME%%::Update() 
    8391{ 
    84   this->some_value = 2 * this->some_value; 
    85 } 
    86  
    87 //---------------------------------------------------------------------- 
    88 // m%%NAME%% EvaluateStaticParameters 
    89 //---------------------------------------------------------------------- 
    90 void m%%NAME%%::EvaluateStaticParameters() 
    91 { 
    92   if (this->static_parameter.HasChanged()) 
     92  if (this->InputChanged()) 
    9393  { 
    94     do something 
     94    At least one of your input ports has changed. Do something useful with its data. 
     95    However, using the .HasChanged() method on each port you can check in more detail. 
    9596  } 
     97   
     98  Do something each cycle independent from changing ports. 
     99   
     100  this->output_signal_1.Publish(some meaningful value); can be used to publish data via your output ports. 
    96101} 
    97102 
  • etc/content_templates/module.h.template

    r214 r217  
    5959public: 
    6060 
    61   tStaticParameter<double> static_parameter; 
     61  tStaticParameter<double> static_parameter_1;   Example for a static parameter. Replace or delete it! 
    6262   
    63   tParameter<double> parameter; 
     63  tParameter<double> parameter_1;   Example for a runtime parameter. Replace or delete it! 
    6464 
    65   tInput<double> input_signal_1; 
     65  tInput<double> input_signal_1;   Example for input ports. Replace or delete them! 
    6666  tInput<double> input_signal_2; 
    6767 
    68   tOutput<double> output_signal_1; 
     68  tOutput<double> output_signal_1;   Examples for output ports. Replace or delete them! 
    6969  tOutput<double> output_signal_2; 
    7070 
     
    7676  m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name = "%%NAME%%"); 
    7777 
    78   ~m%%NAME%%(); 
    79  
    80 //---------------------------------------------------------------------- 
    81 // Protected methods 
    82 //---------------------------------------------------------------------- 
    83 protected: 
    84  
    85   virtual void ParametersChanged(); 
    86  
    87   virtual void Update(); 
     78  ~m%%NAME%%();   You need this destructor if you allocated memory on the heap that must be free'd. Delete otherwise! 
    8879 
    8980//---------------------------------------------------------------------- 
     
    9283private: 
    9384 
    94   double some_value; 
    95    
    96   virtual void EvaluateStaticParameters(); 
    97    
     85  Here is the right place for your variables. Replace this line by your declarations! 
     86 
     87  virtual void EvaluateStaticParameters();   Might be needed to process static parameters. Delete otherwise! 
     88 
     89  virtual void EvaluateParameters();   Might be needed to react to changes in parameters independent from Update() calls. Delete otherwise! 
     90 
     91  virtual void Update(); 
     92 
    9893}; 
    9994 
  • etc/content_templates/module.hpp.template

    r214 r217  
    5656//---------------------------------------------------------------------- 
    5757template <> 
    58 m%%NAME%%<>::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) 
    59   : tModule(parent, name), 
    60     some_value( Values should be initialized here ) 
     58m%%NAME%%<>::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) : 
     59  tModule(parent, name), 
     60  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    6161{} 
    6262 
     
    6969 
    7070//---------------------------------------------------------------------- 
    71 // m%%NAME%% ParametersChanged 
     71// m%%NAME%% EvaluateStaticParameters 
    7272//---------------------------------------------------------------------- 
    7373template <> 
    74 void m%%NAME%%<>::ParametersChanged() 
     74void m%%NAME%%<>::EvaluateStaticParameters() 
    7575{ 
    76   if (this->parameter.HasChanged()) 
     76  if (this->static_parameter_1.HasChanged()) 
    7777  { 
    78     do something 
     78    As this static parameter has changed, do something with its value! 
    7979  } 
     80} 
     81 
     82//---------------------------------------------------------------------- 
     83// m%%NAME%% EvaluateParameters 
     84//---------------------------------------------------------------------- 
     85template <> 
     86void m%%NAME%%<>::EvaluateParameters() 
     87{ 
     88  If this method is called, at least on of your parameters has changed. However, each can be checked using its .HasChanged() method. 
    8089} 
    8190 
     
    8695void m%%NAME%%<>::Update() 
    8796{ 
    88   this->some_value = 2 * this->some_value; 
    89 } 
    90  
    91 //---------------------------------------------------------------------- 
    92 // m%%NAME%% EvaluateStaticParameters 
    93 //---------------------------------------------------------------------- 
    94 template <> 
    95 void m%%NAME%%<>::EvaluateStaticParameters() 
    96 { 
    97   if (this->static_parameter.HasChanged()) 
     97  if (this->InputChanged()) 
    9898  { 
    99     do something 
     99    At least one of your input ports has changed. Do something useful with its data. 
     100    However, using the .HasChanged() method on each port you can check in more detail. 
    100101  } 
     102   
     103  Do something each cycle independent from changing ports. 
     104   
     105  this->output_signal_1.Publish(some meaningful value); can be used to publish data via your output ports. 
    101106} 
    102107 
  • etc/content_templates/sense_control_module.cpp.template

    r214 r217  
    5555// m%%NAME%% constructor 
    5656//---------------------------------------------------------------------- 
    57 m%%NAME%%::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) 
    58   : tSenseControlModule(parent, name), 
    59     some_value( Values should be initialized here ) 
     57m%%NAME%%::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) : 
     58  tSenseControlModule(parent, name), 
     59  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    6060{} 
    6161 
     
    6767 
    6868//---------------------------------------------------------------------- 
    69 // m%%NAME%% ParametersChanged 
     69// m%%NAME%% EvaluateStaticParameters 
    7070//---------------------------------------------------------------------- 
    71 void m%%NAME%%::ParametersChanged() 
     71void m%%NAME%%::EvaluateStaticParameters() 
    7272{ 
    73   if (this->parameter.HasChanged()) 
     73  if (this->static_parameter_1.HasChanged()) 
    7474  { 
    75     do something 
     75    As this static parameter has changed, do something with its value! 
    7676  } 
     77} 
     78 
     79//---------------------------------------------------------------------- 
     80// m%%NAME%% EvaluateParameters 
     81//---------------------------------------------------------------------- 
     82void m%%NAME%%::EvaluateParameters() 
     83{ 
     84  If this method is called, at least on of your parameters has changed. However, each can be checked using its .HasChanged() method. 
     85} 
     86 
     87//---------------------------------------------------------------------- 
     88// m%%NAME%% Sense 
     89//---------------------------------------------------------------------- 
     90void m%%NAME%%::Sense() 
     91{ 
     92  if (this->SensorInputChanged()) 
     93  { 
     94    At least one of your sensor input ports has changed. Do something useful with its data. 
     95    However, using the .HasChanged() method on each port you can check in more detail. 
     96  } 
     97   
     98  Do something each cycle independent from changing ports. 
     99   
     100  this->so_signal_1.Publish(some meaningful value); can be used to publish data via your sensor output ports. 
    77101} 
    78102 
     
    82106void m%%NAME%%::Control() 
    83107{ 
    84   this->some_value = 2 * this->some_value; 
    85 } 
    86  
    87 //---------------------------------------------------------------------- 
    88 // m%%NAME%% Sense 
    89 //---------------------------------------------------------------------- 
    90 void m%%NAME%%::Sense() 
    91 { 
    92   this->some_value = 2 * this->some_value; 
    93 } 
    94  
    95 //---------------------------------------------------------------------- 
    96 // m%%NAME%% EvaluateStaticParameters 
    97 //---------------------------------------------------------------------- 
    98 void m%%NAME%%::EvaluateStaticParameters() 
    99 { 
    100   if (this->static_parameter.HasChanged()) 
     108  if (this->ControllerInputChanged()) 
    101109  { 
    102     do something 
     110    At least one of your controller input ports has changed. Do something useful with its data. 
     111    However, using the .HasChanged() method on each port you can check in more detail. 
    103112  } 
     113   
     114  Do something each cycle independent from changing ports. 
     115   
     116  this->co_signal_1.Publish(some meaningful value); can be used to publish data via your sensor output ports. 
    104117} 
    105118 
  • etc/content_templates/sense_control_module.h.template

    r214 r217  
    5959public: 
    6060 
    61   tControllerInput<double> ci_signal_1; 
     61  tStaticParameter<double> static_parameter_1;   Example for a static parameter. Replace or delete it! 
     62   
     63  tParameter<double> parameter_1;   Example for a runtime parameter. Replace or delete it! 
     64 
     65  tSensorInput<double> si_signal_1;   Example for sensor input ports. Replace or delete them! 
     66  tSensorInput<double> si_signal_2; 
     67 
     68  tSensorOutput<double> so_signal_1;   Examples for sensor output ports. Replace or delete them! 
     69 
     70  tControllerInput<double> ci_signal_1;   Example for controller input ports. Replace or delete them! 
    6271  tControllerInput<double> ci_signal_2; 
    6372 
    64   tControllerOutput<double> co_signal_3; 
    65  
    66   tSensorInput<double> si_signal_1; 
    67   tSensorInput<double> si_signal_2; 
    68  
    69   tSensorOutput<double> so_signal_3; 
     73  tControllerOutput<double> co_signal_1;   Examples for controller output ports. Replace or delete them! 
    7074 
    7175//---------------------------------------------------------------------- 
     
    7680  m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name = "%%NAME%%"); 
    7781 
    78   ~m%%NAME%%(); 
    79  
    80 //---------------------------------------------------------------------- 
    81 // Protected methods 
    82 //---------------------------------------------------------------------- 
    83 protected: 
    84  
    85   virtual void ParametersChanged(); 
    86  
    87   virtual void Control(); 
    88  
    89   virtual void Sense(); 
     82  ~m%%NAME%%();   You need this destructor if you allocated memory on the heap that must be free'd. Delete otherwise! 
    9083 
    9184//---------------------------------------------------------------------- 
     
    9487private: 
    9588 
    96   double some_value; 
     89  Here is the right place for your variables. Replace this line by your declarations! 
    9790 
    98   virtual void EvaluateStaticParameters(); 
     91  virtual void EvaluateStaticParameters();   Might be needed to process static parameters. Delete otherwise! 
     92 
     93  virtual void EvaluateParameters();   Might be needed to react to changes in parameters independent from Update() calls. Delete otherwise! 
     94 
     95  virtual void Sense(); 
     96 
     97  virtual void Control(); 
    9998 
    10099}; 
  • etc/content_templates/sense_control_module.hpp.template

    r214 r217  
    5656//---------------------------------------------------------------------- 
    5757template <> 
    58 m%%NAME%%<>::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) 
    59   : tSenseControlModule(parent, name), 
    60     some_value( Values should be initialized here ) 
     58m%%NAME%%<>::m%%NAME%%(core::tFrameworkElement *parent, const util::tString &name) : 
     59  tSenseControlModule(parent, name), 
     60  If you have some member variables, please initialize them here. Especially built-in types (like pointers!). Delete this line otherwise! 
    6161{} 
    6262 
     
    6969 
    7070//---------------------------------------------------------------------- 
    71 // m%%NAME%% ParametersChanged 
     71// m%%NAME%% EvaluateStaticParameters 
    7272//---------------------------------------------------------------------- 
    7373template <> 
    74 void m%%NAME%%<>::ParametersChanged() 
     74void m%%NAME%%<>::EvaluateStaticParameters() 
    7575{ 
    76   if (this->parameter.HasChanged()) 
     76  if (this->static_parameter_1.HasChanged()) 
    7777  { 
    78     do something 
     78    As this static parameter has changed, do something with its value! 
    7979  } 
     80} 
     81 
     82//---------------------------------------------------------------------- 
     83// m%%NAME%% EvaluateParameters 
     84//---------------------------------------------------------------------- 
     85template <> 
     86void m%%NAME%%<>::EvaluateParameters() 
     87{ 
     88  If this method is called, at least on of your parameters has changed. However, each can be checked using its .HasChanged() method. 
     89} 
     90 
     91//---------------------------------------------------------------------- 
     92// m%%NAME%% Sense 
     93//---------------------------------------------------------------------- 
     94template <> 
     95void m%%NAME%%<>::Sense() 
     96{ 
     97  if (this->SensorInputChanged()) 
     98  { 
     99    At least one of your sensor input ports has changed. Do something useful with its data. 
     100    However, using the .HasChanged() method on each port you can check in more detail. 
     101  } 
     102   
     103  Do something each cycle independent from changing ports. 
     104   
     105  this->so_signal_1.Publish(some meaningful value); can be used to publish data via your sensor output ports. 
    80106} 
    81107 
     
    86112void m%%NAME%%<>::Control() 
    87113{ 
    88   this->some_value = 2 * this->some_value; 
    89 } 
    90  
    91 //---------------------------------------------------------------------- 
    92 // m%%NAME%% Sense 
    93 //---------------------------------------------------------------------- 
    94 template <> 
    95 void m%%NAME%%<>::Sense() 
    96 { 
    97   this->some_value = 2 * this->some_value; 
    98 } 
    99  
    100 //---------------------------------------------------------------------- 
    101 // m%%NAME%% EvaluateStaticParameters 
    102 //---------------------------------------------------------------------- 
    103 template <> 
    104 void m%%NAME%%<>::EvaluateStaticParameters() 
    105 { 
    106   if (this->static_parameter.HasChanged()) 
     114  if (this->ControllerInputChanged()) 
    107115  { 
    108     do something 
     116    At least one of your controller input ports has changed. Do something useful with its data. 
     117    However, using the .HasChanged() method on each port you can check in more detail. 
    109118  } 
     119   
     120  Do something each cycle independent from changing ports. 
     121   
     122  this->co_signal_1.Publish(some meaningful value); can be used to publish data via your sensor output ports. 
    110123} 
    111124 
Note: See TracChangeset for help on using the changeset viewer.