ConOpSys V2970  P004.07
ANVILEX control operating system
Function_Block_RMS_Moving_Average_Filter.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Function_Block_RMS_Moving_Average_Filter.h
3 //! @brief Root mean squere moving average filter class header file.
4 //! @copyright ANVILEX GmbH
5 //! @attention No special attention requered.
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Blocks/Function_Block_RMS_Moving_Average_Filter.h $
7 //! $Revision: 2912 $
8 //! $Date: 2021-12-17 10:36:24 +0500 (Fr, 17 Dez 2021) $
9 //! $Author: minch $
10 //
11 //! COPYRIGHT(C) 2018-2019 ANVILEX GmbH
12 //!
13 //! Redistribution and use in source and binary forms, with or without
14 //! modification, are permitted provided that the following conditions are met:
15 //!
16 //! 1. Redistributions of source code must retain the above copyright notice,
17 //! this list of conditions and the following disclaimer.
18 //!
19 //! 2. Redistributions in binary form must reproduce the above copyright notice,
20 //! this list of conditions and the following disclaimer in the documentation
21 //! and/or other materials provided with the distribution.
22 //!
23 //! 3. Neither the name of ANVILEX nor the names of its contributors may be
24 //! used to endorse or promote products derived from this software without
25 //! specific prior written permission.
26 //!
27 //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31 //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 //! POSSIBILITY OF SUCH DAMAGE.
38 //------------------------------------------------------------------------------
39 
40 //------------------------------------------------------------------------------
41 // Protecting header files from mutual, recursive inclusion.
42 //------------------------------------------------------------------------------
43 
44 #pragma once
45 
46 //------------------------------------------------------------------------------
47 // Include standard libraries header files
48 //------------------------------------------------------------------------------
49 
50 //------------------------------------------------------------------------------
51 // Include thrid party header files
52 //------------------------------------------------------------------------------
53 
54 //------------------------------------------------------------------------------
55 // Include ConOpSys header files
56 //------------------------------------------------------------------------------
57 
58 #include "Function_Block_Base.h"
59 
60 //------------------------------------------------------------------------------
61 // Include ConOpSys application header files
62 //------------------------------------------------------------------------------
63 
64 //------------------------------------------------------------------------------
65 // Macros
66 //------------------------------------------------------------------------------
67 
68 //------------------------------------------------------------------------------
69 // Class declaration description
70 //------------------------------------------------------------------------------
71 /*
72 class TFunction_Block_RMS_Moving_Average_Filter_128 : public TFunction_Block_Base
73 {
74 
75  //----------------------------------------------------------------------------
76 
77  public:
78 
79  //!-------------------------------------------------------------------------
80  //! @brief Class constructor method.
81  //! @note None
82  //! \par Override
83  //! Not allowed
84  //! @attention Don't call this method directly.
85  //--------------------------------------------------------------------------
86 
87  TFunction_Block_RMS_Moving_Average_Filter_128();
88 
89  ~TFunction_Block_RMS_Moving_Average_Filter_128(); //!< Destructor method
90 
91  //!-------------------------------------------------------------------------
92  //! @brief Function block initialisation method.
93  //! @note None
94  //! \par Override
95  //! Not allowed
96  //! @attention Don't call this method directly.
97  //--------------------------------------------------------------------------
98 
99  virtual VOID Init();
100 
101  //!-------------------------------------------------------------------------
102  //! @brief Function block execution method.
103  //! @note None
104  //! \par Override
105  //! Not allowed
106  //! @attention None
107  //--------------------------------------------------------------------------
108 
109  virtual VOID Execute();
110 
111  //--------------------------------------------------------------------------
112  // Function block parameter connectors
113  //--------------------------------------------------------------------------
114 
115  TBlock_Input_Connector object_f32_Averaging_Time; //!< Averaging time
116  TBlock_Input_Connector object_f32_Sample_Time; //!< Sample time parameter
117 
118  //--------------------------------------------------------------------------
119  // Function block input connectors
120  //--------------------------------------------------------------------------
121 
122  TBlock_Input_Connector object_f32_Input; //!< Input signal
123 
124  //--------------------------------------------------------------------------
125  // Function block output connectors
126  //--------------------------------------------------------------------------
127 
128  TBlock_Output_Connector object_f32_Output; //!< Moving average block output
129 
130  //----------------------------------------------------------------------------
131 
132  protected:
133 
134  //----------------------------------------------------------------------------
135 
136  private:
137 
138  U32 u32_Averaging_Buffer_Size;
139  F32 f32_1_Div_Averaging_Buffer_Size;
140  U32 u32_Buffer_Index;
141  F32 f32_Buffer[ 128 ];
142 
143 };
144 */
145 //------------------------------------------------------------------------------
146 /*
147 class TFunction_Block_RMS_Moving_Average_Filter_256 : public TFunction_Block_Base
148 {
149 
150  //----------------------------------------------------------------------------
151 
152  public:
153 
154  //!-------------------------------------------------------------------------
155  //! @brief Class constructor method.
156  //! @note None
157  //! \par Override
158  //! Not allowed
159  //! @attention Don't call this method directly.
160  //--------------------------------------------------------------------------
161 
162  TFunction_Block_RMS_Moving_Average_Filter_256();
163 
164  ~TFunction_Block_RMS_Moving_Average_Filter_256(); //!< Destructor method
165 
166  //!-------------------------------------------------------------------------
167  //! @brief Function block initialisation method.
168  //! @note None
169  //! \par Override
170  //! Not allowed
171  //! @attention Don't call this method directly.
172  //--------------------------------------------------------------------------
173 
174  virtual VOID Init();
175 
176  //!-------------------------------------------------------------------------
177  //! @brief Function block execution method.
178  //! @note None
179  //! \par Override
180  //! Not allowed
181  //! @attention None
182  //--------------------------------------------------------------------------
183 
184  virtual VOID Execute();
185 
186  //--------------------------------------------------------------------------
187  // Function block parameter connectors
188  //--------------------------------------------------------------------------
189 
190  TBlock_Input_Connector object_f32_Averaging_Time; //!< Averaging time
191  TBlock_Input_Connector object_f32_Sample_Time; //!< Sample time parameter
192 
193  //--------------------------------------------------------------------------
194  // Function block input connectors
195  //--------------------------------------------------------------------------
196 
197  TBlock_Input_Connector object_f32_Input; //!< Input signal
198 
199  //--------------------------------------------------------------------------
200  // Function block output connectors
201  //--------------------------------------------------------------------------
202 
203  TBlock_Output_Connector object_f32_Output; //!< Moving average block output
204 
205  //----------------------------------------------------------------------------
206 
207  protected:
208 
209  //----------------------------------------------------------------------------
210 
211  private:
212 
213  U32 u32_Averaging_Buffer_Size;
214  F32 f32_1_Div_Averaging_Buffer_Size;
215  U32 u32_Buffer_Index;
216  F32 f32_Buffer[ 256 ];
217 
218 };
219 */
220 //------------------------------------------------------------------------------
221 //! @brief Class declaration description
222 //------------------------------------------------------------------------------
223 /*
224 class TFunction_Block_RMS_Moving_Average_Filter_128_FAST : public TFunction_Block_Base
225 {
226 
227  //----------------------------------------------------------------------------
228 
229  public:
230 
231  //!-------------------------------------------------------------------------
232  //! @brief Class constructor method.
233  //! @note None
234  //! \par Override
235  //! Not allowed
236  //! @attention Don't call this method directly.
237  //--------------------------------------------------------------------------
238 
239  TFunction_Block_RMS_Moving_Average_Filter_128_FAST();
240 
241  ~TFunction_Block_RMS_Moving_Average_Filter_128_FAST(); //!< Destructor method
242 
243  //!-------------------------------------------------------------------------
244  //! @brief Function block initialisation method.
245  //! @note None
246  //! \par Override
247  //! Not allowed
248  //! @attention Don't call this method directly.
249  //--------------------------------------------------------------------------
250 
251  virtual VOID Init();
252 
253  //!-------------------------------------------------------------------------
254  //! @brief Function block execution method.
255  //! @note None
256  //! \par Override
257  //! Not allowed
258  //! @attention None
259  //--------------------------------------------------------------------------
260 
261  virtual VOID Execute();
262 
263  //--------------------------------------------------------------------------
264  // Function block parameter connectors
265  //--------------------------------------------------------------------------
266 
267  TBlock_Input_Connector object_f32_Averaging_Time; //!< Averaging time
268  TBlock_Input_Connector object_f32_Sample_Time; //!< Sample time parameter
269 
270  //--------------------------------------------------------------------------
271  // Function block input connectors
272  //--------------------------------------------------------------------------
273 
274  TBlock_Input_Connector object_f32_Input; //!< Input signal
275 
276  //--------------------------------------------------------------------------
277  // Function block output connectors
278  //--------------------------------------------------------------------------
279 
280  TBlock_Output_Connector object_f32_Output; //!< Moving average block output
281 
282  //----------------------------------------------------------------------------
283 
284  protected:
285 
286  //----------------------------------------------------------------------------
287 
288  private:
289 
290  U32 u32_Averaging_Buffer_Size;
291  F32 f32_1_Div_Averaging_Buffer_Size;
292  U32 u32_Buffer_Index;
293  F32 f32_Buffer[ 128 ];
294  F32 f32_Sector[ 8 ];
295 
296 };
297 */
298 //------------------------------------------------------------------------------
299 // Class declaration description
300 //------------------------------------------------------------------------------
301 /*
302 class TFunction_Block_RMS_Moving_Average_Filter_128_2 : public TFunction_Block_Base
303 {
304 
305  //----------------------------------------------------------------------------
306  // Public defines, methods and variables
307  //----------------------------------------------------------------------------
308 
309  public:
310 
311  //!-------------------------------------------------------------------------
312  //! @brief Class constructor method.
313  //! @note None
314  //! \par Override
315  //! Not allowed
316  //! @attention Don't call this method directly.
317  //--------------------------------------------------------------------------
318 
319  TFunction_Block_RMS_Moving_Average_Filter_128_2();
320 
321  ~TFunction_Block_RMS_Moving_Average_Filter_128_2(); //!< Destructor methods
322 
323  //!-------------------------------------------------------------------------
324  //! @brief Function block initialisation method.
325  //! @note None
326  //! \par Override
327  //! Not allowed
328  //! @attention Don't call this method directly.
329  //--------------------------------------------------------------------------
330 
331  virtual VOID Init();
332 
333  //!-------------------------------------------------------------------------
334  //! @brief Function block execution method.
335  //! @note None
336  //! \par Override
337  //! Not allowed
338  //! @attention None
339  //--------------------------------------------------------------------------
340 
341  virtual VOID Execute();
342 
343  //!-------------------------------------------------------------------------
344  //! @brief Send information about Function block over communication link protocol
345  //! @note This method sends information about Function block over specified communication link protocol.
346  //! @param [in] TProtocol_Base *object_Protocol - Pointer to the communication link protocol
347  //! @return None
348  //! \par Override
349  //! Not allowed
350  //! @attention None
351  //--------------------------------------------------------------------------
352 
353  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
354 
355  //--------------------------------------------------------------------------
356  // Function block parameter connectors
357  //--------------------------------------------------------------------------
358 
359  TBlock_Input_Connector object_f32_Averaging_Time; //!< Averaging time
360  TBlock_Input_Connector object_f32_Sample_Time; //!< Sample time parameter
361 
362  //--------------------------------------------------------------------------
363  // Function block input connectors
364  //--------------------------------------------------------------------------
365 
366  TBlock_Input_Connector object_f32_Input_1; //!< Input signal
367  TBlock_Input_Connector object_f32_Input_2; //!< Input signal
368 
369  //--------------------------------------------------------------------------
370  // Function block output connectors
371  //--------------------------------------------------------------------------
372 
373  TBlock_Output_Connector object_f32_Output_1; //!< Moving average block output
374  TBlock_Output_Connector object_f32_Output_2; //!< Moving average block output
375 
376  //----------------------------------------------------------------------------
377  // Protected methods and variables
378  //----------------------------------------------------------------------------
379 
380  protected:
381 
382  //----------------------------------------------------------------------------
383  // Private methods and variables
384  //----------------------------------------------------------------------------
385 
386  private:
387 
388  U32 u32_Averaging_Buffer_Size;
389  F32 f32_1_Div_Averaging_Buffer_Size;
390  U32 u32_Buffer_Index;
391  F32 f32_Buffer_1[ 128 ];
392  F32 f32_Buffer_2[ 128 ];
393 
394 };
395 */
396 //------------------------------------------------------------------------------
397 //! @brief 128 points, 3 channel, root mean squere (RMS) moving average filter class
398 //------------------------------------------------------------------------------
399 
401 {
402 
403  //----------------------------------------------------------------------------
404  // Public defines, methods and variables
405  //----------------------------------------------------------------------------
406 
407  public:
408 
409  //--------------------------------------------------------------------------
410  // Public methods
411  //--------------------------------------------------------------------------
412 
413  //!-------------------------------------------------------------------------
414  //! @brief Class constructor method.
415  //! @note None
416  //! \par Override
417  //! Not allowed
418  //! @attention Don't call this method directly.
419  //--------------------------------------------------------------------------
420 
422 
423  //!-------------------------------------------------------------------------
424  //! @brief Class destructor method.
425  //! @note None
426  //! \par Override
427  //! Not allowed
428  //! @attention Don't call this method directly.
429  //--------------------------------------------------------------------------
430 
432 
433  //!-------------------------------------------------------------------------
434  //! @brief Function block initialisation method.
435  //! @note None
436  //! \par Override
437  //! Not allowed
438  //! @attention Don't call this method directly.
439  //--------------------------------------------------------------------------
440 
441  virtual VOID Init();
442 
443  //!-------------------------------------------------------------------------
444  //! @brief Function block execution method.
445  //! @note None
446  //! \par Override
447  //! Not allowed
448  //! @attention None
449  //--------------------------------------------------------------------------
450 
451  virtual VOID Execute();
452 
453  //!-------------------------------------------------------------------------
454  //! @brief Send information about Function block over communication link protocol
455  //! @note This method sends information about Function block over specified communication link protocol.
456  //! @param [in] TProtocol_Base *object_Protocol - Pointer to the communication link protocol
457  //! @return None
458  //! \par Override
459  //! Not allowed
460  //! @attention None
461  //--------------------------------------------------------------------------
462 
463  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
464 
465  //--------------------------------------------------------------------------
466  // Public variables
467  //--------------------------------------------------------------------------
468 
469  //--------------------------------------------------------------------------
470  // Function block parameter connectors
471  //--------------------------------------------------------------------------
472 
473  //! @brief Function block sample time in seconds
475 
476  //! @brief Averaging time in seconds
478 
479  //--------------------------------------------------------------------------
480  // Function block input connectors
481  //--------------------------------------------------------------------------
482 
483  //! @brief Moving avarage filter input signal of channel 1
485 
486  //! @brief Moving avarage filter input signal of channel 2
488 
489  //! @brief Moving avarage filter input signal of channel 3
491 
492  //--------------------------------------------------------------------------
493  // Function block output connectors
494  //--------------------------------------------------------------------------
495 
496  //! @brief Moving average filter block output of channel 1
498 
499  //! @brief Moving average filter block output of channel 2
501 
502  //! @brief Moving average filter block output of channel 3
504 
505  //----------------------------------------------------------------------------
506  // Protected defines, methods and variables
507  //----------------------------------------------------------------------------
508 
509  protected:
510 
511  //----------------------------------------------------------------------------
512  // Private defines, methods and variables
513  //----------------------------------------------------------------------------
514 
515  private:
516 
517  //--------------------------------------------------------------------------
518  // Private variables
519  //--------------------------------------------------------------------------
520 
521  //! @brief Sampling ratio
523 
524  //! @brief Requered averaging buffer size in samples
526 
527  //! @brief Inversed value of requered averaging buffer size
530 
531  //! @brief Data buffer of the channel 1
532  F32 f32_Buffer_1[ 128 ] = { (F32)0.0f };
533 
534  //! @brief Data buffer of the channel 2
535  F32 f32_Buffer_2[ 128 ] = { (F32)0.0f };
536 
537  //! @brief Data buffer of the channel 3
538  F32 f32_Buffer_3[ 128 ] = { (F32)0.0f };
539 
540 };
541 
542 //------------------------------------------------------------------------------
543 // End of file
544 //------------------------------------------------------------------------------
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
float F32
IEEE-754 32-Bit single presession floating point numbers datatype defenition.
Definition: Defines.h:324
Function block base class header file.
Function block input connector class.
Definition: Block_Input_Connector.h:83
Function block output connector class.
Definition: Block_Output_Connector.h:59
Function block base class for device.
Definition: Function_Block_Base.h:96
Class declaration description.
Definition: Function_Block_RMS_Moving_Average_Filter.h:401
virtual VOID Init()
Function block initialisation method.
Definition: Function_Block_RMS_Moving_Average_Filter.cpp:764
TFunction_Block_RMS_Moving_Average_Filter_128_3C()
Class constructor method.
Definition: Function_Block_RMS_Moving_Average_Filter.cpp:706
TBlock_Output_Connector object_f32_Output_1
Moving average filter block output of channel 1.
Definition: Function_Block_RMS_Moving_Average_Filter.h:497
U32 u32_Averaging_Buffer_Size
Requered averaging buffer size in samples.
Definition: Function_Block_RMS_Moving_Average_Filter.h:525
F32 f32_Sampling_Ratio
Sampling ratio.
Definition: Function_Block_RMS_Moving_Average_Filter.h:522
TBlock_Input_Connector object_f32_Sample_Time
Function block sample time in seconds.
Definition: Function_Block_RMS_Moving_Average_Filter.h:474
TBlock_Input_Connector object_f32_Input_1
Moving avarage filter input signal of channel 1.
Definition: Function_Block_RMS_Moving_Average_Filter.h:484
TBlock_Output_Connector object_f32_Output_3
Moving average filter block output of channel 3.
Definition: Function_Block_RMS_Moving_Average_Filter.h:503
TBlock_Output_Connector object_f32_Output_2
Moving average filter block output of channel 2.
Definition: Function_Block_RMS_Moving_Average_Filter.h:500
F32 f32_Buffer_1[128]
Data buffer of the channel 1.
Definition: Function_Block_RMS_Moving_Average_Filter.h:532
virtual VOID Execute()
Function block execution method.
Definition: Function_Block_RMS_Moving_Average_Filter.cpp:818
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Send information about Function block over communication link protocol.
Definition: Function_Block_RMS_Moving_Average_Filter.cpp:887
TBlock_Input_Connector object_f32_Input_3
Moving avarage filter input signal of channel 3.
Definition: Function_Block_RMS_Moving_Average_Filter.h:490
F32 f32_Buffer_3[128]
Data buffer of the channel 3.
Definition: Function_Block_RMS_Moving_Average_Filter.h:538
TBlock_Input_Connector object_f32_Input_2
Moving avarage filter input signal of channel 2.
Definition: Function_Block_RMS_Moving_Average_Filter.h:487
TBlock_Input_Connector object_f32_Averaging_Time
Averaging time in seconds.
Definition: Function_Block_RMS_Moving_Average_Filter.h:477
virtual ~TFunction_Block_RMS_Moving_Average_Filter_128_3C()
Class destructor method.
Definition: Function_Block_RMS_Moving_Average_Filter.cpp:756
F32 f32_Buffer_2[128]
Data buffer of the channel 2.
Definition: Function_Block_RMS_Moving_Average_Filter.h:535
U32 u32_Buffer_Index
Definition: Function_Block_RMS_Moving_Average_Filter.h:529
F32 f32_1_Div_Averaging_Buffer_Size
Inversed value of requered averaging buffer size.
Definition: Function_Block_RMS_Moving_Average_Filter.h:528
Definition: Protocol_Base.h:57