aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-lib/inc/ucs_net.h
blob: 4e53c0b07aca77391dc0166d04b751cf2a493579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*------------------------------------------------------------------------------------------------*/
/* UNICENS V2.1.0-3491                                                                            */
/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
/*                                                                                                */
/* This program is free software: you can redistribute it and/or modify                           */
/* it under the terms of the GNU General Public License as published by                           */
/* the Free Software Foundation, either version 2 of the License, or                              */
/* (at your option) any later version.                                                            */
/*                                                                                                */
/* This program is distributed in the hope that it will be useful,                                */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
/* GNU General Public License for more details.                                                   */
/*                                                                                                */
/* You should have received a copy of the GNU General Public License                              */
/* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
/*                                                                                                */
/* You may also obtain this software under a propriety license from Microchip.                    */
/* Please contact Microchip for further information.                                              */
/*------------------------------------------------------------------------------------------------*/

/*!
 * \file
 * \brief Internal header file of the Network Management.
 *
 * \cond UCS_INTERNAL_DOC
 * \addtogroup G_NET
 * @{
 */

#ifndef UCS_NET_H
#define UCS_NET_H

/*------------------------------------------------------------------------------------------------*/
/* Includes                                                                                       */
/*------------------------------------------------------------------------------------------------*/
#include "ucs_base.h"
#include "ucs_inic.h"
#include "ucs_ret_pb.h"
#include "ucs_obs.h"
#include "ucs_fsm.h"

#ifdef __cplusplus
extern "C"
{
#endif

/*------------------------------------------------------------------------------------------------*/
/* Enumerations                                                                                   */
/*------------------------------------------------------------------------------------------------*/
/*! \brief  Result codes of function Net_IsOwnAddress() */
typedef enum Net_IsOwnAddrResult_
{
    NET_IS_OWN_ADDR_NODE,   /*!< \brief Is own node position address or own logical node address */
    NET_IS_OWN_ADDR_GROUP,  /*!< \brief Is own group address */
    NET_IS_OWN_ADDR_NONE    /*!< \brief Is foreign address */

} Net_IsOwnAddrResult_t;

/*------------------------------------------------------------------------------------------------*/
/* Structures                                                                                     */
/*------------------------------------------------------------------------------------------------*/
/*! \brief  Initialization structure of the attach service. */
typedef struct Net_InitData_
{
    CBase *base_ptr;                /*!< \brief Reference to base instance */
    CInic *inic_ptr;                /*!< \brief Reference to INIC instance */

} Net_InitData_t;

/*! \brief Parameter structure for MOST Network Status */
typedef struct Net_NetworkStatusParam_
{
    /*! \brief Indicates if parameters have been changed since last update */
    uint16_t change_mask;
    /*! \brief Indicates if the MOST network is available and ready for control/packet
               data transmission */
    Ucs_Network_Availability_t availability;
    /*! \brief Indicates the sub state to parameter Availability */
    Ucs_Network_AvailInfo_t avail_info;
    /*! \brief Indicates the transition cause of the MOST network going from Available to 
               NotAvailable or vice versa */
    Ucs_Network_AvailTransCause_t avail_trans_cause;
    /*! \brief Contains events relating to the functionality for the MOST Network Interface */
    uint16_t events;
    /*! \brief Current size of packet bandwidth */
    uint16_t packet_bw;
    /*! \brief Current node address of the device */
    uint16_t node_address;
    /*! \brief Node position of the device */
    uint8_t node_position;
    /*! \brief Node position of last device in the ring */
    uint8_t max_position;

} Net_NetworkStatusParam_t;

/*! \brief Structure holds the parameters of property INIC.MOSTNetworkStatus */
typedef struct Net_NetworkStatus_
{
    /*! \brief Parameters of MOST Network Status */
    Net_NetworkStatusParam_t param;
    /*! \brief Observe MOST Network status in INIC module */
    CObserver observer;
    /*! \brief Subject to notify MOST Network Status the first time a observer has been added */
    CSubject pre_subject;
    /*! \brief Subject to notify MOST Network Status */
    CSubject subject;

} Net_NetworkStatus_t;

/*! \brief Parameter structure for MOST Network Configuration */
typedef struct Net_NetworkConfigParam_
{
    /*! \brief Indicates if parameters have been changed since last update */
    uint16_t change_mask;
    /*! \brief Current node address of the device */
    uint16_t node_address;
    /*! \brief Current group address of the device */
    uint16_t group_address;
    /*! \brief Low-level retry block count */
    uint8_t llrbc;

} Net_NetworkConfigParam_t;

/*! \brief Structure holds the parameters of property INIC.MOSTNetworkConfiguration */
typedef struct Net_NetworkConfiguration_
{
    /*! \brief Parameters of MOST Network Configuration */
    Net_NetworkConfigParam_t param;
    /*! \brief Observe MOST Network Configuration in INIC module */
    CObserver observer;
    /*! \brief Subject to notify MOST Network Configuration the first time a observer has been added */
    CSubject pre_subject;
    /*! \brief Subject to notify MOST Network Configuration */
    CSubject subject;

} Net_NetworkConfiguration_t;

/*! \brief  Class structure of the Network Management. */
typedef struct CNetworkManagement_
{
    /*! \brief Parameters of property INIC.MOSTNetworkStatus */
    Net_NetworkStatus_t network_status;
    /*! \brief Parameters of property INIC.MOSTNetworkConfig. */
    Net_NetworkConfiguration_t network_configuration;
    /*! \brief Reference to INIC instance */
    CInic *inic_ptr;
    /*! \brief Reference to base instance */
    CBase *base_ptr;
    /*! \brief Service instance for the scheduler */
    CService net_srv;

} CNetworkManagement;

/*------------------------------------------------------------------------------------------------*/
/* Prototypes of class CNetworkManagement                                                         */
/*------------------------------------------------------------------------------------------------*/
extern void Net_Ctor(CNetworkManagement *self, Net_InitData_t *init_ptr);
extern void Net_AddObserverNetworkStatus(CNetworkManagement *self, CMaskedObserver *obs_ptr);
extern void Net_DelObserverNetworkStatus(CNetworkManagement *self, CMaskedObserver *obs_ptr);
extern void Net_AddObserverNetworkConfig(CNetworkManagement *self, CMaskedObserver *obs_ptr);
extern void Net_DelObserverNetworkConfig(CNetworkManagement *self, CMaskedObserver *obs_ptr);
extern Net_IsOwnAddrResult_t Net_IsOwnAddress(CNetworkManagement *self, uint16_t address);

#ifdef __cplusplus
}   /* extern "C" */
#endif

#endif  /* #ifndef UCS_NET_H */

/*!
 * @}
 * \endcond
 */

/*------------------------------------------------------------------------------------------------*/
/* End of file                                                                                    */
/*------------------------------------------------------------------------------------------------*/