ConOpSys V2970  P004.07
ANVILEX control operating system
Command_Manager.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Command_Manager.h
3 //! @brief ConOpSys command manager 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/Command_Manager.h $
7 //! $Revision: 2954 $
8 //! $Date: 2022-03-01 12:44:44 +0500 (Di, 01 Mrz 2022) $
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 //------------------------------------------------------------------------------
41 //! @page Doxygen_Page_Command_Manager Command manager
42 //!
43 //! Command manager description first line text.
44 //!
45 //! Command manager description second line text.
46 //
47 //------------------------------------------------------------------------------
48 
49 Doxygen_Page_Parameter_Database
50 
51 //------------------------------------------------------------------------------
52 // Protecting header files from mutual, recursive inclusion.
53 //------------------------------------------------------------------------------
54 
55 #pragma once
56 
57 //------------------------------------------------------------------------------
58 // Include standard libraries header files
59 //------------------------------------------------------------------------------
60 
61 //------------------------------------------------------------------------------
62 // Include thrid party header files
63 //------------------------------------------------------------------------------
64 
65 //------------------------------------------------------------------------------
66 // Include ConOpSys header files
67 //------------------------------------------------------------------------------
68 
69 //#include "Command_Base.h"
70 #include "Command_Manager_Base.h"
71 
72 //------------------------------------------------------------------------------
73 // Include ConOpSys related commands headers
74 //------------------------------------------------------------------------------
75 
76 //------------------------------------------------------------------------------
77 // Include ConOpSys application header files
78 //------------------------------------------------------------------------------
79 
80 //------------------------------------------------------------------------------
81 // Class definitions
82 //------------------------------------------------------------------------------
83 
84 //! @brief ConOpSys terminal command manager class
86 {
87 
88  //----------------------------------------------------------------------------
89  // Public defines, methods and variables
90  //----------------------------------------------------------------------------
91 
92  public:
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Class constructor method
96  //! @note None
97  //! \par Override
98  //! Not allowed
99  //! @attention Don't call this method directly.
100  //--------------------------------------------------------------------------
101 
103 
104  //!-------------------------------------------------------------------------
105  //! @brief Class destructor method
106  //! @note None
107  //! \par Override
108  //! Not allowed
109  //! @attention Don't call this method directly.
110  //--------------------------------------------------------------------------
111 
112  virtual ~TCommand_Manager();
113 
114  //!-------------------------------------------------------------------------
115  //! @brief Command manager initialisation method
116  //! @note None
117  //! \par Override
118  //! Not allowed
119  //! @attention Don't call this method directly.
120  //--------------------------------------------------------------------------
121 
122  virtual VOID Init();
123 
124  //!-------------------------------------------------------------------------
125  //! @brief Command manager finalisation method
126  //! @note None
127  //! \par Override
128  //! Not allowed
129  //! @attention Don't call this method directly.
130  //--------------------------------------------------------------------------
131 
132  virtual VOID Done();
133 
134  //!-------------------------------------------------------------------------
135  //! @brief Get command object index referenced by command object pointer
136  //! @note This method allows resovle command manager storage index of the command
137  //! @param [out] *u32_Storage_Index - Command manager storage index
138  //! @param [in] *object_Command - Pointer to the command object
139  //! @return BOOL - Execution status
140  //! @retval false - Command object not found in command manager storage
141  //! @retval true - Command object found in command manager storage
142  //! \par Override
143  //! Not allowed
144  //! @attention None
145  //--------------------------------------------------------------------------
146 
147  virtual BOOL Get_Index( U32 *u32_Storage_Index, TCommand_Base *object_Command );
148 
149  //!-------------------------------------------------------------------------
150  //! @brief Get pointer to the command object referenced by command manager storage index
151  //! @note None
152  //! @param [in] u32_Storage_Index - Command manager storage index
153  //! @param [out] **object_Command - Pointer to the command object
154  //! @return BOOL - Execution status
155  //! @retval false - Command object not found in command manager storage
156  //! @retval true - Command object found in command manager storage
157  //! \par Override
158  //! Not allowed
159  //! @attention None
160  //--------------------------------------------------------------------------
161 
162  virtual BOOL Get_Command_By_Storage_Index( U32 u32_Storage_Index, TCommand_Base **object_Command );
163 
164  //!-------------------------------------------------------------------------
165  //! @brief Test for command registered in command manager
166  //! @note None
167  //! @param [in] *object_Command - Pointer to the command object
168  //! @return BOOL - Execution status
169  //! @retval false - Command object not registered in command manager storage
170  //! @retval true - Command object registered in command manager storage
171  //! \par Override
172  //! Not allowed
173  //! @attention None
174  //--------------------------------------------------------------------------
175 
176  virtual BOOL Is_Registered( TCommand_Base *object_Command );
177 
178  //!-------------------------------------------------------------------------
179  //! @brief Performs registration of the command in command manager
180  //! @note None
181  //! @param [in] *object_Command - Pointer to the command object
182  //! @return BOOL - Execution status
183  //! @retval false - Command object registration successed
184  //! @retval true - Command object registration failed
185  //! \par Override
186  //! Not allowed
187  //! @attention None
188  //--------------------------------------------------------------------------
189 
190  virtual BOOL Register( TCommand_Base *object_Command );
191 
192  //!-------------------------------------------------------------------------
193  //! @brief Performs unregistration of the command in command manager
194  //! @note None
195  //! @param [in] *object_Command - Pointer to the command object
196  //! @return BOOL - Execution status
197  //! @retval false - Command object unregistration successed
198  //! @retval true - Command object unregistration failed
199  //! \par Override
200  //! Not allowed
201  //! @attention None
202  //--------------------------------------------------------------------------
203 
204  virtual BOOL Unregister( TCommand_Base *object_Command );
205 
206  //!-------------------------------------------------------------------------
207  //! @brief Execute command method
208  //! @note None
209  //! @param [in] *c8_Command_String - Pointer to the command name string
210  //! @param [in] *object_Protocol - Pointer to the communication protocol object
211  //! @return BOOL - Execution status
212  //! @retval false - Command name is not equal and command not executed
213  //! @retval true - Command name is equal and command executed
214  //! \par Override
215  //! Not allowed
216  //! @attention None
217  //--------------------------------------------------------------------------
218 
219  virtual BOOL Execute( C8 *c8_Command_String, TProtocol_Base *object_Protocol );
220 
221  //!-------------------------------------------------------------------------
222  //! @brief Get command count registered in command manager
223  //! @note None
224  //! @return U32 - Command count
225  //! \par Override
226  //! Not allowed
227  //! @attention None
228  //--------------------------------------------------------------------------
229 
230  virtual U32 Get_Command_Count();
231 
232  //!-------------------------------------------------------------------------
233  //! @brief Get command manager storage utilisation
234  //! @note None
235  //! @param [out] *u32_Command_Capacity - Pointer to the command manager capacity variable
236  //! @param [out] *u32_Command_Count - Pointer to the command count variable
237  //! @return None
238  //! \par Override
239  //! Not allowed
240  //! @attention None
241  //--------------------------------------------------------------------------
242 
243  virtual VOID Get_Usage( U32 *u32_Command_Capacity, U32 *u32_Command_Count );
244 
245  //!-------------------------------------------------------------------------
246  //! @brief Send boot information message over given protocol
247  //! @note None
248  //! @param [in] *object_Protocol - Pointer to the communication protocol object
249  //! @return None
250  //! \par Override
251  //! Not allowed
252  //! @attention None
253  //--------------------------------------------------------------------------
254 
255  virtual VOID Show_Boot_Information( TProtocol_Base *object_Protocol );
256 
257  //!-------------------------------------------------------------------------
258  //! @brief This method return OS status
259  //! @note None
260  //! @return U32 - Command manager OS status
261  //! \par Override
262  //! Required
263  //! @attention None
264  //--------------------------------------------------------------------------
265 
266  virtual U32 Get_OS_Status();
267 
268  //!-------------------------------------------------------------------------
269  //! @brief This method set module in operation mode
270  //! @note None
271  //! @return BOOL - Module status
272  //! @retval false - Module in error mode
273  //! @retval true - Module ready to operations
274  //! \par Override
275  //! Required
276  //! @attention None
277  //--------------------------------------------------------------------------
278 
279  virtual BOOL Start_Operation();
280 
281  //----------------------------------------------------------------------------
282  // Protected defines, methods and variables
283  //----------------------------------------------------------------------------
284 
285  protected:
286 
287  //----------------------------------------------------------------------------
288  // Private defines, methods and variables
289  //----------------------------------------------------------------------------
290 
291  private:
292 
293  //!-------------------------------------------------------------------------
294  //! @brief Get command manager database size in bytes
295  //! @note None
296  //! @return U32 - Command manager database size in bytes
297  //! \par Override
298  //! Not allowed
299  //! @attention None
300  //--------------------------------------------------------------------------
301 
303 
304  //!-------------------------------------------------------------------------
305  //! @brief Get command manager database record count
306  //! @note None
307  //! @return U32 - Command manager database record count
308  //! \par Override
309  //! Not allowed
310  //! @attention None
311  //--------------------------------------------------------------------------
312 
314 
315  //! @brief Static storage for command object pointers
316  TCommand_Base* object_Command_Storage[ COMMAND_STORAGE_SIZE ];
317 
318  //! @brief Pointer to the command database storage mapped directly to the section
320 
321  //! @brief Command registration requests counter
323 
324  //! @brief Successful command registration counter
326 
327  //! @brief Failed command registration counter
329 
330  //! @brief Count of double registered commands
332 
333  //! @brief Command storage overflow status
335 
336  //! @brief Container for OS status
337 // TOS_Status_Structure struct_OS_Status;
338 
339 };
340 
341 //------------------------------------------------------------------------------
342 // End of file
343 //------------------------------------------------------------------------------
ConOpSys command manager base class header file.
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
char C8
ASCII 8-Bit char datatype defenition.
Definition: Defines.h:156
ConOpSys terminal command base class.
Definition: Command_Base.h:86
ConOpSys terminal command manager base class.
Definition: Command_Manager_Base.h:74
ConOpSys terminal command manager class.
Definition: Command_Manager.h:86
virtual VOID Get_Usage(U32 *u32_Command_Capacity, U32 *u32_Command_Count)
Get command manager storage utilisation.
Definition: Command_Manager.cpp:752
virtual BOOL Get_Command_By_Storage_Index(U32 u32_Storage_Index, TCommand_Base **object_Command)
Get pointer to the command object referenced by command manager storage index.
Definition: Command_Manager.cpp:365
virtual BOOL Register(TCommand_Base *object_Command)
Performs registration of the command in command manager.
Definition: Command_Manager.cpp:491
virtual U32 Get_OS_Status()
This method return OS status.
Definition: Command_Manager.cpp:795
virtual VOID Done()
Command manager finalisation method.
Definition: Command_Manager.cpp:265
virtual ~TCommand_Manager()
Class destructor method.
Definition: Command_Manager.cpp:175
virtual BOOL Start_Operation()
This method set module in operation mode.
Definition: Command_Manager.cpp:807
virtual BOOL Is_Registered(TCommand_Base *object_Command)
Test for command registered in command manager.
Definition: Command_Manager.cpp:428
virtual BOOL Get_Index(U32 *u32_Storage_Index, TCommand_Base *object_Command)
Get command object index referenced by command object pointer.
Definition: Command_Manager.cpp:321
U32 u32_Command_Double_Registration_Counter
Count of double registered commands.
Definition: Command_Manager.h:331
U32 Get_Database_Record_Count()
Get command manager database record count.
Definition: Command_Manager.cpp:780
BOOL bool_Command_Storage_Overflow
Command storage overflow status.
Definition: Command_Manager.h:334
TCommand_Manager()
Class constructor method.
Definition: Command_Manager.cpp:136
TCommand_Base::TCommand_Descriptor * struct_Command_Database
Pointer to the command database storage mapped directly to the section.
Definition: Command_Manager.h:319
U32 u32_Command_Successful_Registration_Counter
Successful command registration counter.
Definition: Command_Manager.h:325
U32 u32_Command_Registration_Requests_Counter
Command registration requests counter.
Definition: Command_Manager.h:322
U32 Get_Database_Size_In_Bytes()
Get command manager database size in bytes.
Definition: Command_Manager.cpp:765
virtual U32 Get_Command_Count()
Get command count registered in command manager.
Definition: Command_Manager.cpp:740
TCommand_Base * object_Command_Storage[COMMAND_STORAGE_SIZE]
Static storage for command object pointers.
Definition: Command_Manager.h:316
virtual BOOL Execute(C8 *c8_Command_String, TProtocol_Base *object_Protocol)
Execute command method.
Definition: Command_Manager.cpp:640
virtual VOID Show_Boot_Information(TProtocol_Base *object_Protocol)
Send boot information message over given protocol.
Definition: Command_Manager.cpp:273
virtual VOID Init()
Command manager initialisation method.
Definition: Command_Manager.cpp:183
U32 u32_Command_Failed_Registration_Counter
Failed command registration counter.
Definition: Command_Manager.h:328
virtual BOOL Unregister(TCommand_Base *object_Command)
Performs unregistration of the command in command manager.
Definition: Command_Manager.cpp:576
Definition: Protocol_Base.h:57
Command descriptor structure.
Definition: Command_Base.h:100