ConOpSys V2970  P004.07
ANVILEX control operating system
Event_Manager_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Event_Manager_Base.h
3 //! @brief Event manager base class header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2015-2020 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Engine/Event_Manager_Base.h $
7 //! $Revision: 2582 $
8 //! $Date: 2021-04-11 19:40:47 +0500 (So, 11 Apr 2021) $
9 //! $Author: minch $
10 //------------------------------------------------------------------------------
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // 1. Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright notice,
19 // this list of conditions and the following disclaimer in the documentation
20 // and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of ANVILEX nor the names of its contributors may be
23 // used to endorse or promote products derived from this software without
24 // specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 //------------------------------------------------------------------------------
39 
40 #pragma once
41 
42 //------------------------------------------------------------------------------
43 // System includes
44 //------------------------------------------------------------------------------
45 
46 #include "Application_Resource_Configuration.h"
47 #include "System_Date.h"
48 #include "Protocol_Base.h"
49 #include "SPI_Memory_Base.h"
50 #include "Event_Database.h"
51 #include "S25FL512.h"
52 
53 //------------------------------------------------------------------------------
54 // Event manager buffer size
55 //------------------------------------------------------------------------------
56 
57 #define RECORD_SIZE 64
58 #define EVENT_MANAGER_BUFFER_SIZE 32
59 #define EVENT_MANAGER_BUFFERS_COUNT 2
60 #define GLOBAL_INDEX_BYTES_NUMBER 8
61 
62 //-------------------------------------------------------------------------------
63 // Class definitions
64 //-------------------------------------------------------------------------------
65 
66 //! @brief Event manager class
68 {
69 
70  //----------------------------------------------------------------------------
71  // Public defines, methods and variables
72  //----------------------------------------------------------------------------
73 
74  public:
75 
76  //--------------------------------------------------------------------------
77  // Public defines
78  //--------------------------------------------------------------------------
79 
80  //! @brief Event header data record, 64 bytes
81  typedef union
82  {
83 
84  //! @brief Raw data representation
85  U8 u8_Raw_Data[ 64 ];
86 
87  //! @brief Structured data representation
88  struct
89  {
90 
91  //! @brief Global event index union
92  union
93  {
94 
95  //! @brief Global event index, 8 bytes
97 
98 
99  struct
100  {
101 
102  //! @brief Event index bits, 48 bits
104 
105  //! @brief Event followed data block counts, 16 bits
107 
108  } Bits;
109 
110  };
111 
112  //! @brief Event absolute timestamp information, 8 x 2 = 16 bytes
114 
115  //! @brief Event relative timestamp, 8 bytes
117 
118  //! @brief Task iteration since system power up, 8 bytes
120 
121  //! @brief Event header union
122  union
123  {
124 
125  //! @brief Event header, 4 byte
127 
128  //! @brief Event identifier
130 
131  };
132 
133  //! @brief Event data, 4 bytes
135 
136  //! @brief OS Version, 4 bytes
138 
139  //! @brief Application ID, 4 bytes
141 
142  //! @brief Application version, 4 bytes
144 
145  //! @brief CRC32, 4 bytes
147 
148  };
149 
150  } TEvent_Header_Record;
151 
152  //! @brief Event payload data record, 64 bytes
153  typedef union
154  {
155 
156  //! @brief Raw data representation
157  U8 u8_Raw_Data[ 64 ];
158 
159  //! @brief Structured data representation
160  struct
161  {
162 
163  //! @brief Global event index, 8 bytes
165 
166  //! @brief Relative event information, 8 bytes
168 
169  //! @brief Data block index, 4 bytes
171 
172  //! @brief CRC32, 4 bytes
174 
175  //! @brief Event data union
176  union
177  {
178 
179  //! @brief Event data as raw data array
180  U8 u8_Data[ 40 ];
181 
182  //! @brief Event data as variant
184 
185  };
186 
187  };
188 
189  } TEvent_Payload_Record;
190 
191  //! @brief Consolidated generic event data record
192  typedef union
193  {
194 
195  //! @brief Raw data representation
196  U8 u8_Raw_Data[ 64 ];
197 
198  //! @brief Structured data representation
199  union
200  {
201 
202  //! @brief Event header record
204 
205  //! @brief Event payload record
207 
208  };
209 
210  } TEvent_Generic_Record;
211 
212  //--------------------------------------------------------------------------
213  // Public methods
214  //--------------------------------------------------------------------------
215 /*
216  //!-------------------------------------------------------------------------
217  //! @brief Class constructor method.
218  //! @note None
219  //! \par Override
220  //! Not allowed
221  //! @attention Don't call this method directly.
222  //--------------------------------------------------------------------------
223 
224  TEvent_Manager();
225 */
226 /*
227  //!-------------------------------------------------------------------------
228  //! @brief Class destructor method.
229  //! @note None
230  //! \par Override
231  //! Not allowed
232  //! @attention Don't call this method directly.
233  //--------------------------------------------------------------------------
234 
235  ~TEvent_Manager();
236 */
237  //!-------------------------------------------------------------------------
238  //! @brief Event manager initialisation method.
239  //! @note None
240  //! @return None
241  //! \par Override
242  //! Not allowed
243  //! @attention None
244  //--------------------------------------------------------------------------
245 
246  virtual VOID Init();
247 
248  //!-------------------------------------------------------------------------
249  //! @brief Event manager finalisation method.
250  //! @note None
251  //! @return None
252  //! \par Override
253  //! Not allowed
254  //! @attention None
255  //--------------------------------------------------------------------------
256 
257  virtual VOID Done();
258 
259  //!-------------------------------------------------------------------------
260  //! @brief Event manager background execution method.
261  //! @note None
262  //! @return None
263  //! \par Override
264  //! Not allowed
265  //! @attention None
266  //--------------------------------------------------------------------------
267 
268  virtual VOID Execute();
269 
270  //!-------------------------------------------------------------------------
271  //! @brief Memory type assignment method.
272  //! @note Assign SPI memory
273  //! @param [in] *object_Memory_Pointer - Pointer to object of memory class
274  //! @return None
275  //! \par Override
276  //! Not allowed
277  //! @attention None
278  //--------------------------------------------------------------------------
279 
280 // VOID Assign_Memory( TSPI_Memory_Base *object_Memory_Pointer );
281  virtual VOID Assign_Memory( TS25FL512 *object_Memory_Pointer );
282 
283  //!-------------------------------------------------------------------------
284  //! @brief Verify database method.
285  //! @note None
286  //! @return None
287  //! \par Override
288  //! Not allowed
289  //! @attention None
290  //--------------------------------------------------------------------------
291 
292  virtual VOID Verify_Database();
293 /*
294  //!-------------------------------------------------------------------------
295  //! @brief Erasing flash memory.
296  //! @note Erase only good blocks
297  //! @return BOOL - Erasing status
298  //! @retval false - Erasing failed
299  //! @retval true - Erasing successfully done
300  //! \par Override
301  //! Not allowed
302  //! @attention None
303  //--------------------------------------------------------------------------
304 
305  BOOL Format_Event_Storage();
306 */
307  //!-------------------------------------------------------------------------
308  //! @brief Method for creating event with determine event index.
309  //! @note None
310  //! @param [in] u32_Event_ID - Event index
311  //! @return None
312  //! \par Override
313  //! Not allowed
314  //! @attention None
315  //--------------------------------------------------------------------------
316 
317  virtual VOID Create( U32 u32_Event_ID );
318 
319  //!-------------------------------------------------------------------------
320  //! @brief Method for creating event by given event descriptor
321  //! @note None
322  //! @param [in] &struct_Event_Descriptor - Event descriptor
323  //! @return None
324  //! \par Override
325  //! Not allowed
326  //! @attention None
327  //--------------------------------------------------------------------------
328 
329  virtual VOID Create( const TEvent_Descriptor &struct_Event_Descriptor );
330 /*
331  //!-------------------------------------------------------------------------
332  //! @brief Method for creating event header
333  //! @note None
334  //! @param [out] **struct_Event_Record - Pointer to getting event
335  //! @return None
336  //! \par Override
337  //! Not allowed
338  //! @attention None
339  //--------------------------------------------------------------------------
340 
341  VOID Create_Header_Event( TEvent_Header_Record **struct_Event_Record );
342 */
343 /*
344  //!-------------------------------------------------------------------------
345  //! @brief Method for creating event header
346  //! @note Data events are connected to the event header.
347  //! @param [in] u64_Relative_Event_Index - Relative event index
348  //! @param [out] **struct_Event_Record - Pointer to getting event
349  //! @return None
350  //! \par Override
351  //! Not allowed
352  //! @attention None
353  //--------------------------------------------------------------------------
354 
355  VOID Create_Data_Event( U64 u64_Relative_Event_Index, TEvent_Payload_Record **struct_Event_Record );
356 */
357  //!-------------------------------------------------------------------------
358  //! @brief Method get event database descriptor hash
359  //! @note None
360  //! @return Event database descriptor hash
361  //! \par Override
362  //! Not allowed
363  //! @attention None
364  //--------------------------------------------------------------------------
365 
366  virtual U32 Get_Database_Hash();
367 
368  //!-------------------------------------------------------------------------
369  //! @brief Method get event database descriptor hash
370  //! @note None
371  //! @return Databse record count
372  //! \par Override
373  //! Not allowed
374  //! @attention None
375  //--------------------------------------------------------------------------
376 
377  virtual U32 Get_Database_Record_Count();
378 /*
379  //!-------------------------------------------------------------------------
380  //! @brief Method get event buffer size
381  //! @note None
382  //! @return Event buffer size
383  //! \par Override
384  //! Not allowed
385  //! @attention None
386  //--------------------------------------------------------------------------
387 
388  U32 Get_Event_Buffer_Size();
389 */
390 /*
391  //!-------------------------------------------------------------------------
392  //! @brief Method get event buffer size
393  //! @note None
394  //! @return Event buffer size
395  //! \par Override
396  //! Not allowed
397  //! @attention None
398  //--------------------------------------------------------------------------
399 
400  U32 Get_Event_Record_Size();
401 */
402 /*
403  //!-------------------------------------------------------------------------
404  //! @brief Method get current buffer index
405  //! @note None
406  //! @return Current buffer index
407  //! \par Override
408  //! Not allowed
409  //! @attention None
410  //--------------------------------------------------------------------------
411 
412  U32 Get_Current_Buffer_Index();
413 */
414 /*
415  //!-------------------------------------------------------------------------
416  //! @brief Method search event record by event index
417  //! @note None
418  //! @param [in] u64_Event_Index - Event index
419  //! @param [out] **struct_Event_Record - Pointer to event
420  //! @return BOOL - Searching status
421  //! @retval false - Searching failed
422  //! @retval true - Searching successfully done
423  //! \par Override
424  //! Not allowed
425  //! @attention None
426  //--------------------------------------------------------------------------
427 
428  BOOL Get_Event_Record_By_Index( U64 u64_Event_Index, TEvent_Generic_Record **struct_Event_Record );
429 */
430  //!-------------------------------------------------------------------------
431  //! @brief Method get index of the first event record
432  //! @note None
433  //! @return U64 - Event index for first record
434  //! \par Override
435  //! Not allowed
436  //! @attention None
437  //--------------------------------------------------------------------------
438 
439  virtual U64 Get_First_Event_Index();
440 
441  //!-------------------------------------------------------------------------
442  //! @brief Method get index of the last event record
443  //! @note None
444  //! @return U64 - Event index for last record
445  //! \par Override
446  //! Not allowed
447  //! @attention None
448  //--------------------------------------------------------------------------
449 
450  virtual U64 Get_Last_Event_Index();
451 
452  //!-------------------------------------------------------------------------
453  //! @brief Method get index of the currently selected event
454  //! @note None
455  //! @return U64 - index of the currently selected event
456  //! \par Override
457  //! Not allowed
458  //! @attention None
459  //--------------------------------------------------------------------------
460 
461  virtual U64 Get_Selected_Event_Index();
462 
463  //!-------------------------------------------------------------------------
464  //! @brief Method set index of the currently selected even
465  //! @note None
466  //! @return BOOL - Operation status
467  //! @retval false - Index dont set
468  //! @retval true - Index set successfully
469  //! \par Override
470  //! Not allowed
471  //! @attention None
472  //--------------------------------------------------------------------------
473 
474  virtual BOOL Set_Selected_Event_Index( U64 u64_Selected_Event_New_Index );
475 
476  //!-------------------------------------------------------------------------
477  //! @brief Method get selected event
478  //! @note None
479  //! @param [out] **struct_Event_Record - Pointer to event
480  //! @return BOOL - Operation status
481  //! @retval false - Event not getting
482  //! @retval true - Event successfully getting
483  //! \par Override
484  //! Not allowed
485  //! @attention None
486  //--------------------------------------------------------------------------
487 
488  virtual BOOL Get_Selected_Event( TEvent_Generic_Record **struct_Event_Record );
489 
490  //!-------------------------------------------------------------------------
491  //! @brief Method show boot information message method
492  //! @note None
493  //! @param [in] *object_Protocol - Pointer to communication protocol
494  //! @return None
495  //! \par Override
496  //! Not allowed
497  //! @attention None
498  //--------------------------------------------------------------------------
499 
500  virtual VOID Show_Boot_Information( TProtocol_Base *object_Protocol );
501 
502  //!-------------------------------------------------------------------------
503  //! @brief Method send diagnostic information about event manager
504  //! @note None
505  //! @param [in] *object_Protocol - Pointer to communication protocol
506  //! @return None
507  //! \par Override
508  //! Not allowed
509  //! @attention None
510  //--------------------------------------------------------------------------
511 
512  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
513 /*
514  //!-------------------------------------------------------------------------
515  //! @brief Method send event desctiption over protocol
516  //! @note None
517  //! @param [in] *object_Protocol - Pointer to communication protocol
518  //! @param [in] enum_Event_ID - Event index
519  //! @return None
520  //! \par Override
521  //! Not allowed
522  //! @attention None
523  //--------------------------------------------------------------------------
524 
525  VOID Send_Event_Description( TProtocol_Base *object_Protocol, U32 enum_Event_ID );
526 */
527  //!-------------------------------------------------------------------------
528  //! @brief Method get pointer to event description by given event ID
529  //! @note None
530  //! @param [in] u32_Event_ID - Event index
531  //! @param [out] **c8_Event_Description - Pointer to event description
532  //! @return BOOL - Operation status
533  //! @retval false - Operation falled
534  //! @retval true - Operation successfully done
535  //! \par Override
536  //! Not allowed
537  //! @attention None
538  //--------------------------------------------------------------------------
539 
540  virtual BOOL Get_Event_Description_By_Event_ID( U32 u32_Event_ID, C8 **c8_Event_Description );
541 
542  //!-------------------------------------------------------------------------
543  //! @brief This method return OS status
544  //! @note None
545  //! @return U32 - OS status
546  //! \par Override
547  //! Required
548  //! @attention None
549  //--------------------------------------------------------------------------
550 
551  virtual U32 Get_OS_Status();
552 
553  //!-------------------------------------------------------------------------
554  //! @brief This method set module in operation mode
555  //! @note None
556  //! @return BOOL - Module status
557  //! @retval false - Module in error mode
558  //! @retval true - Module ready to operations
559  //! \par Override
560  //! Required
561  //! @attention None
562  //--------------------------------------------------------------------------
563 
564  virtual BOOL Start_Operation();
565 
566  //----------------------------------------------------------------------------
567  // Protected defines, methods and variables
568  //----------------------------------------------------------------------------
569 
570  protected:
571 
572  //----------------------------------------------------------------------------
573  // Private defines, methods and variables
574  //----------------------------------------------------------------------------
575 
576  private:
577 
578 };
579 
580 //------------------------------------------------------------------------------
581 // End of file
582 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
unsigned long long U64
Binary 64-Bit unsigned integer datatype defenition.
Definition: Defines.h:213
unsigned char U8
Binary 8-Bit unsigned integer datatype defenition.
Definition: Defines.h:183
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
char C8
ASCII 8-Bit char datatype defenition.
Definition: Defines.h:156
Event database header file.
Communication protocol base class header file.
SPI NAND FLASH memory chip S25FL512 hardware driver class header file.
SPI connected memory base class header file.
System date and time calss implementation.
Event manager class.
Definition: Event_Manager_Base.h:68
virtual VOID Assign_Memory(TS25FL512 *object_Memory_Pointer)
Memory type assignment method.
Definition: Event_Manager_Base.cpp:120
virtual BOOL Get_Selected_Event(TEvent_Generic_Record **struct_Event_Record)
Method get selected event.
Definition: Event_Manager_Base.cpp:272
virtual BOOL Get_Event_Description_By_Event_ID(U32 u32_Event_ID, C8 **c8_Event_Description)
Method get pointer to event description by given event ID.
Definition: Event_Manager_Base.cpp:316
virtual VOID Execute()
Event manager background execution method.
Definition: Event_Manager_Base.cpp:180
virtual VOID Init()
Event manager initialisation method.
Definition: Event_Manager_Base.cpp:91
virtual VOID Create(U32 u32_Event_ID)
Method for creating event with determine event index.
Definition: Event_Manager_Base.cpp:148
virtual VOID Done()
Event manager finalisation method.
Definition: Event_Manager_Base.cpp:99
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Method send diagnostic information about event manager.
Definition: Event_Manager_Base.cpp:296
virtual VOID Show_Boot_Information(TProtocol_Base *object_Protocol)
Method show boot information message method.
Definition: Event_Manager_Base.cpp:107
virtual U32 Get_OS_Status()
This method return OS status.
Definition: Event_Manager_Base.cpp:352
virtual BOOL Start_Operation()
This method set module in operation mode.
Definition: Event_Manager_Base.cpp:364
virtual U32 Get_Database_Record_Count()
Method get event database descriptor hash.
Definition: Event_Manager_Base.cpp:340
virtual U64 Get_First_Event_Index()
Method get index of the first event record.
Definition: Event_Manager_Base.cpp:224
virtual BOOL Set_Selected_Event_Index(U64 u64_Selected_Event_New_Index)
Method set index of the currently selected even.
Definition: Event_Manager_Base.cpp:260
virtual U64 Get_Last_Event_Index()
Method get index of the last event record.
Definition: Event_Manager_Base.cpp:236
virtual U32 Get_Database_Hash()
Method get event database descriptor hash.
Definition: Event_Manager_Base.cpp:188
virtual U64 Get_Selected_Event_Index()
Method get index of the currently selected event.
Definition: Event_Manager_Base.cpp:248
virtual VOID Verify_Database()
Verify database method.
Definition: Event_Manager_Base.cpp:128
Definition: Protocol_Base.h:57
NAND memory hardware driver.
Definition: S25FL512.h:62
Date and time structure.
Definition: System_Date.h:88
Event descriptor structure.
Definition: Event_Database.h:241
ConOpSys variant data storage structure.
Definition: ConOpSys_Variant.h:403
TEvent_Payload_Record Event_Data
Event payload record.
Definition: Event_Manager_Base.h:206
TEvent_Header_Record Event_Header
Event header record.
Definition: Event_Manager_Base.h:203
Event header data record, 64 bytes.
Definition: Event_Manager_Base.h:82
U32 u32_Event_Data
Event data, 4 bytes.
Definition: Event_Manager_Base.h:134
U64 u64_Task_Iteration
Task iteration since system power up, 8 bytes.
Definition: Event_Manager_Base.h:119
U32 u32_Event_ID
Event identifier.
Definition: Event_Manager_Base.h:129
U64 u64_Global_Event_Index
Global event index, 8 bytes.
Definition: Event_Manager_Base.h:96
U32 u32_OS_Version
OS Version, 4 bytes.
Definition: Event_Manager_Base.h:137
U32 u32_Event_Header
Event header, 4 byte.
Definition: Event_Manager_Base.h:126
U32 u32_App_Version
Application version, 4 bytes.
Definition: Event_Manager_Base.h:143
TDate_Time::TDate_Time_Structure struct_Absolute_Timestamp
Event absolute timestamp information, 8 x 2 = 16 bytes.
Definition: Event_Manager_Base.h:113
U64 u64_Relative_Timestamp
Event relative timestamp, 8 bytes.
Definition: Event_Manager_Base.h:116
U32 u32_CRC
CRC32, 4 bytes.
Definition: Event_Manager_Base.h:146
U64 event_Index
Event index bits, 48 bits.
Definition: Event_Manager_Base.h:103
U32 u32_App_ID
Application ID, 4 bytes.
Definition: Event_Manager_Base.h:140
U16 block_Block_Numbers
Event followed data block counts, 16 bits.
Definition: Event_Manager_Base.h:106
Event payload data record, 64 bytes.
Definition: Event_Manager_Base.h:154
U32 u32_CRC
CRC32, 4 bytes.
Definition: Event_Manager_Base.h:173
U64 u64_Relative_Event_Index
Relative event information, 8 bytes.
Definition: Event_Manager_Base.h:167
U32 u32_Data_Block_Index
Data block index, 4 bytes.
Definition: Event_Manager_Base.h:170
U64 u64_Global_Event_Index
Global event index, 8 bytes.
Definition: Event_Manager_Base.h:164