Initial Commit
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_factory.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 MNS Factory.
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_FAC
28  * @{
29  */
30
31
32 #ifndef UCS_FAC_H
33 #define UCS_FAC_H
34
35 /*------------------------------------------------------------------------------------------------*/
36 /* Includes                                                                                       */
37 /*------------------------------------------------------------------------------------------------*/
38 #include "ucs_net.h"
39 #include "ucs_base.h"
40 #include "ucs_inic.h"
41 #include "ucs_ret_pb.h"
42 #include "ucs_rsm.h"
43 #include "ucs_xrm.h"
44 #include "ucs_i2c.h"
45 #include "ucs_gpio.h"
46 #include "ucs_nsm.h"
47 #include "ucs_xrmpool.h"
48
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53
54 /*------------------------------------------------------------------------------------------------*/
55 /* Definitions                                                                                    */
56 /*------------------------------------------------------------------------------------------------*/
57 /*! \def FAC_NUM_DEVICES
58  *  \brief      Defines the number of remote devices.
59  *  \details    The number of remote devices required by the application for remote jobs. The 
60  *              default value is 0 in MNS configuration file ucs_cfg.h. The user can adjust this 
61  *              value by defining the macro \ref UCS_NUM_REMOTE_DEVICES. Valid values are in 
62  *              the range from 0 to 63.
63  *  \ingroup    G_FAC
64  */
65 #define FAC_NUM_DEVICES              ((uint8_t)UCS_NUM_REMOTE_DEVICES + 1U)
66
67
68 /*------------------------------------------------------------------------------------------------*/
69 /* Enumerations                                                                                   */
70 /*------------------------------------------------------------------------------------------------*/
71 /*! \brief Factory Instances type. */
72 typedef enum Fac_Inst_
73 {
74     FAC_INST_INIC, /*!< \brief   Corresponds to the INIC Instance type */
75     FAC_INST_RSM,  /*!< \brief   Corresponds to the RSM Instance type */
76     FAC_INST_XRM,  /*!< \brief   Corresponds to the XRM Instance type */
77     FAC_INST_GPIO, /*!< \brief   Corresponds to the GPIO Instance type */
78     FAC_INST_I2C,  /*!< \brief   Corresponds to the I2C Instance type */
79     FAC_INST_NSM   /*!< \brief   Corresponds to the NSM Instance type */
80 } Fac_Inst_t;
81
82 /*------------------------------------------------------------------------------------------------*/
83 /* Type definitions                                                                               */
84 /*------------------------------------------------------------------------------------------------*/
85 /*! \brief Callback signature used by the foreach-function of the factory class.
86  *  \param inst_type  The instance type to be looked for.
87  *  \param inst_ptr   Reference to the current instance.
88  *  \param ud_ptr     Reference to the user data
89  *  \return true: Stop the for-each-loop
90  *  \return false: Continue the for-each-loop
91  */
92 typedef bool (*Fac_ForeachFunc_t)(Fac_Inst_t inst_type, void *inst_ptr, void *ud_ptr);
93
94 /*------------------------------------------------------------------------------------------------*/
95 /* Structures                                                                                     */
96 /*------------------------------------------------------------------------------------------------*/
97 /*! \brief  Stores data required by the Factory during initialization. */
98 typedef struct Fac_InitData_
99 {
100     CBase *base_ptr;                /*!< \brief Reference to base instance */
101     CNetworkManagement *net_ptr;    /*!< \brief Reference to Network instance */
102     CXrmPool * xrmp_ptr;            /*!< \brief Reference to the XRM Pool instance */
103     CTransceiver * icm_transceiver; /*!< \brief Reference to ICM transceiver */
104     CTransceiver * rcm_transceiver; /*!< \brief Reference to MCM transceiver */
105
106 } Fac_InitData_t;
107
108 /*! \brief  Class structure of the MNS Factory. */
109 typedef struct CFactory_
110 {
111     /*! \brief FBlock INIC list */
112     CInic fbi_list[FAC_NUM_DEVICES];
113     /*! \brief XRM list */
114     CExtendedResourceManager xrm_list[FAC_NUM_DEVICES];
115     /*! \brief RSM list */
116     CRemoteSyncManagement rsm_list[FAC_NUM_DEVICES];
117     /*! \brief GPIO list */
118     CGpio gpio_list[FAC_NUM_DEVICES];
119     /*! \brief I2C list */
120     CI2c i2c_list[FAC_NUM_DEVICES];
121     /*! \brief Node Scripting list */
122     CNodeScriptManagement nsm_list[FAC_NUM_DEVICES];
123     /*! \brief Reference to a base instance */
124     CBase *base_ptr;
125     /*! \brief Reference to a network instance */
126     CNetworkManagement *net_ptr;
127     /*!< \brief Reference to the XRM Pool instance */
128     CXrmPool * xrmp_ptr;
129     /*! \brief The ICM transceiver */
130     CTransceiver * icm_transceiver;
131     /*! \brief The RCM transceiver */
132     CTransceiver * rcm_transceiver;
133
134 } CFactory;
135
136 /*------------------------------------------------------------------------------------------------*/
137 /* Prototypes of class CFactory                                                                   */
138 /*------------------------------------------------------------------------------------------------*/
139 extern void Fac_Ctor(CFactory * self, Fac_InitData_t * init_ptr);
140 extern CExtendedResourceManager * Fac_GetXrm(CFactory * self, uint16_t address, Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr);
141 extern CExtendedResourceManager * Fac_GetXrmByJobList(CFactory * self, UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
142 extern CExtendedResourceManager * Fac_GetXrmLegacy(CFactory * self, uint16_t address, Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr);
143 extern CInic * Fac_GetInic(CFactory * self, uint16_t address);
144 extern CInic * Fac_FindInic(CFactory * self, uint16_t address);
145 extern CNodeScriptManagement * Fac_GetNsm(CFactory * self, uint16_t address);
146 extern CNodeScriptManagement * Fac_FindNsm(CFactory * self, uint16_t address);
147 extern CRemoteSyncManagement * Fac_GetRsm(CFactory * self, uint16_t address);
148 extern CRemoteSyncManagement * Fac_FindRsm(CFactory * self, uint16_t address);
149 extern CGpio * Fac_GetGpio(CFactory * self, uint16_t address, Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr);
150 extern CI2c * Fac_GetI2c(CFactory * self, uint16_t address, Ucs_I2c_IntEventReportCb_t i2c_interrupt_report_fptr);
151 extern void Fac_Foreach(CFactory * self, Fac_Inst_t inst_type, Fac_ForeachFunc_t func_ptr, void *user_data_ptr);
152
153 #ifdef __cplusplus
154 }   /* extern "C" */
155 #endif
156
157 #endif /* #ifndef UCS_RSM_H */
158
159 /*!
160  * @}
161  * \endcond
162  */
163
164 /*------------------------------------------------------------------------------------------------*/
165 /* End of file                                                                                    */
166 /*------------------------------------------------------------------------------------------------*/
167