719b622717e2d84bd2777428762df5a341bcee53
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_mgr.h
1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491                                                                            */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
4 /*                                                                                                */
5 /* This program is free software: you can redistribute it and/or modify                           */
6 /* it under the terms of the GNU General Public License as published by                           */
7 /* the Free Software Foundation, either version 2 of the License, or                              */
8 /* (at your option) any later version.                                                            */
9 /*                                                                                                */
10 /* This program is distributed in the hope that it will be useful,                                */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
13 /* GNU General Public License for more details.                                                   */
14 /*                                                                                                */
15 /* You should have received a copy of the GNU General Public License                              */
16 /* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
17 /*                                                                                                */
18 /* You may also obtain this software under a propriety license from Microchip.                    */
19 /* Please contact Microchip for further information.                                              */
20 /*------------------------------------------------------------------------------------------------*/
21
22 /*!
23  * \file
24  * \brief Internal header file of the CManager class
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_MGR
28  * @{
29  */
30
31 #ifndef UCS_MGR_H
32 #define UCS_MGR_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_fsm.h"
38 #include "ucs_inic.h"
39 #include "ucs_net.h"
40 #include "ucs_base.h"
41 #include "ucs_jobs.h"
42 #include "ucs_nodedis.h"
43
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif
48
49 /*------------------------------------------------------------------------------------------------*/
50 /* Internal constants                                                                             */
51 /*------------------------------------------------------------------------------------------------*/
52 /*! \brief The default value of the desired packet bandwidth for startup command */
53 #define MGR_PACKET_BW_DEFAULT  52U
54
55 /*------------------------------------------------------------------------------------------------*/
56 /* Types                                                                                          */
57 /*------------------------------------------------------------------------------------------------*/
58
59
60 /*------------------------------------------------------------------------------------------------*/
61 /* Class                                                                                          */
62 /*------------------------------------------------------------------------------------------------*/
63
64 /*! \brief      Manager Class
65  *  \details    Implements the UNICENS Manager State Machine
66  */
67 typedef struct CManager_
68 {
69     bool            listening;                  /*!< \brief Listening is active */
70     CFsm            fsm;                        /*!< \brief State machine object */
71     CJobService     job_service;
72     CSingleObserver job_q_obs;
73     CJobQ          *current_q_ptr;
74     
75     CJobQ           job_q_startup;               
76     CJobQ           job_q_force_startup;
77  /* CJobQ           job_q_shutdown; */
78     CJob            job_startup;
79     CJob            job_leave_forced_na;
80  /* CJob            job_shutdown; */
81
82     CJob           *list_startup[2];
83     CJob           *list_force_startup[3];
84  /* CJob           *list_shutdown[2]; */
85
86     CMaskedObserver event_observer;             /*!< \brief Observes init complete event */
87     CMaskedObserver nwstatus_mobs;              /*!< \brief Observe network status */
88
89     uint16_t             packet_bw;             /*!< \brief The desired packet bandwidth */
90     CBase               *base_ptr;              /*!< \brief Reference to base services */
91     CInic               *inic_ptr;              /*!< \brief Reference to class CInic */
92     CNetworkManagement  *net_ptr;               /*!< \brief Reference to network management */
93     CNodeDiscovery      *nd_ptr;                /*!< \brief Reference to node discovery */
94
95     CSingleObserver startup_obs;                /*!< \brief Startup result callback */
96  /* CSingleObserver shutdown_obs; */            /*!< \brief Shutdown result callback */
97     CSingleObserver force_na_obs;               /*!< \brief ForceNA result callback */
98     bool                 initial;               /*!< \brief Is \c true for the initial network status "available" */
99
100 } CManager;
101
102 /*------------------------------------------------------------------------------------------------*/
103 /* Methods                                                                                        */
104 /*------------------------------------------------------------------------------------------------*/
105 extern void Mgr_Ctor(CManager *self, CBase *base_ptr, CInic *inic_ptr, CNetworkManagement *net_ptr, CNodeDiscovery *nd_ptr, uint16_t packet_bw);
106
107 #ifdef __cplusplus
108 }               /* extern "C" */
109 #endif
110
111 #endif          /* UCS_MGR_H */
112
113 /*!
114  * @}
115  * \endcond
116  */
117
118 /*------------------------------------------------------------------------------------------------*/
119 /* End of file                                                                                    */
120 /*------------------------------------------------------------------------------------------------*/
121