Initial Commit
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_rtm.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 Route Manager.
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_RTM
28  * @{
29  */
30
31 #ifndef UCS_RTM_H
32 #define UCS_RTM_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_base.h"
38 #include "ucs_ret_pb.h"
39 #include "ucs_obs.h"
40 #include "ucs_epm.h"
41 #include "ucs_net.h"
42
43 #ifdef __cplusplus
44 extern "C"
45 {
46 #endif
47
48 /*------------------------------------------------------------------------------------------------*/
49 /* Structures                                                                                     */
50 /*------------------------------------------------------------------------------------------------*/
51 /*! \brief  Stores data required by RTM during initialization. */
52 typedef struct Rtm_InitData_
53 {
54     CBase *base_ptr;                /*!< \brief Reference to base instance */
55     CEndpointManagement *epm_ptr;   /*!< \brief Reference to the endpoint management instance */
56     CNetworkManagement *net_ptr;    /*!< \brief Reference to Network instance */
57     Ucs_Rm_ReportCb_t report_fptr;  /*!< \brief Reference to the report callback function */
58
59 } Rtm_InitData_t;
60
61 /*! \brief  Class structure of the Route Management. */
62 typedef struct CRouteManagement_
63 {
64     /*! \brief Reference to a base instance */
65     CBase *base_ptr;
66     /*! \brief Reference to a network instance */
67     CEndpointManagement * epm_ptr;
68     /*!< \brief Reference to the timer management */ 
69     CTimerManagement * tm_ptr;
70     /*!< \brief Reference to Network instance */
71     CNetworkManagement *net_ptr;
72     /*!< \brief Timer for checking routes process */
73     CTimer route_check;
74     /*!< \brief Reference to the routes list */
75     Ucs_Rm_Route_t * routes_list_ptr;
76     /*! \brief Points to the current routes to be handled */
77     Ucs_Rm_Route_t * curr_route_ptr;
78     /*! \brief Current route index */
79     uint16_t curr_route_index;
80     /*! \brief Size of the current routes list */
81     uint16_t routes_list_size;
82     /*! \brief Service instance for the scheduler */
83     CService rtm_srv;
84     /*! \brief Report callback of the routes list */
85     Ucs_Rm_ReportCb_t report_fptr;
86     /*! \brief Observe MOST Network status in Net module */
87     CMaskedObserver nwstatus_observer;
88     /*! \brief Observer used to monitor UCS initialization result */
89     CMaskedObserver ucsinit_observer;
90     /*! \brief Observer used to monitor UCS termination event */
91     CMaskedObserver ucstermination_observer;
92     /*! \brief Specifies used to monitor UCS termination event */
93     bool ucs_is_stopping;
94     /*! \brief specifies whether the network status is available or not */
95     bool nw_available;
96     /*! \brief Flag to lock the API */
97     bool lock_api;
98
99 } CRouteManagement;
100
101 /*------------------------------------------------------------------------------------------------*/
102 /* Prototypes of class CRouteManagement                                                           */
103 /*------------------------------------------------------------------------------------------------*/
104 extern void Rtm_Ctor(CRouteManagement * self, Rtm_InitData_t * init_ptr);
105 extern Ucs_Return_t Rtm_StartProcess(CRouteManagement * self,  Ucs_Rm_Route_t routes_list[], uint16_t size);
106 extern Ucs_Return_t Rtm_DeactivateRoute(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
107 extern Ucs_Return_t Rtm_ActivateRoute(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
108 extern Ucs_Return_t Rtm_SetNodeAvailable(CRouteManagement * self, Ucs_Rm_Node_t *node_ptr, bool available);
109 extern bool Rtm_GetNodeAvailable(CRouteManagement * self, Ucs_Rm_Node_t *node_ptr);
110 extern Ucs_Return_t Rtm_GetAttachedRoutes(CRouteManagement * self, Ucs_Rm_EndPoint_t * ep_inst, Ucs_Rm_Route_t * ext_routes_list[], uint16_t size_list);
111 extern uint16_t Rtm_GetConnectionLabel(CRouteManagement * self, Ucs_Rm_Route_t * route_ptr);
112
113 #ifdef __cplusplus
114 }   /* extern "C" */
115 #endif
116
117 #endif /* #ifndef UCS_RTM_H */
118
119 /*!
120  * @}
121  * \endcond
122  */
123
124 /*------------------------------------------------------------------------------------------------*/
125 /* End of file                                                                                    */
126 /*------------------------------------------------------------------------------------------------*/
127