aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-lib/inc/ucs_mgr.h
blob: 719b622717e2d84bd2777428762df5a341bcee53 (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
/*------------------------------------------------------------------------------------------------*/
/* 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 CManager class
 *
 * \cond UCS_INTERNAL_DOC
 * \addtogroup G_MGR
 * @{
 */

#ifndef UCS_MGR_H
#define UCS_MGR_H

/*------------------------------------------------------------------------------------------------*/
/* Includes                                                                                       */
/*------------------------------------------------------------------------------------------------*/
#include "ucs_fsm.h"
#include "ucs_inic.h"
#include "ucs_net.h"
#include "ucs_base.h"
#include "ucs_jobs.h"
#include "ucs_nodedis.h"

#ifdef __cplusplus
extern "C"
{
#endif

/*------------------------------------------------------------------------------------------------*/
/* Internal constants                                                                             */
/*------------------------------------------------------------------------------------------------*/
/*! \brief The default value of the desired packet bandwidth for startup command */
#define MGR_PACKET_BW_DEFAULT  52U

/*------------------------------------------------------------------------------------------------*/
/* Types                                                                                          */
/*------------------------------------------------------------------------------------------------*/


/*------------------------------------------------------------------------------------------------*/
/* Class                                                                                          */
/*------------------------------------------------------------------------------------------------*/

/*! \brief      Manager Class
 *  \details    Implements the UNICENS Manager State Machine
 */
typedef struct CManager_
{
    bool            listening;                  /*!< \brief Listening is active */
    CFsm            fsm;                        /*!< \brief State machine object */
    CJobService     job_service;
    CSingleObserver job_q_obs;
    CJobQ          *current_q_ptr;
    
    CJobQ           job_q_startup;               
    CJobQ           job_q_force_startup;
 /* CJobQ           job_q_shutdown; */
    CJob            job_startup;
    CJob            job_leave_forced_na;
 /* CJob            job_shutdown; */

    CJob           *list_startup[2];
    CJob           *list_force_startup[3];
 /* CJob           *list_shutdown[2]; */

    CMaskedObserver event_observer;             /*!< \brief Observes init complete event */
    CMaskedObserver nwstatus_mobs;              /*!< \brief Observe network status */

    uint16_t             packet_bw;             /*!< \brief The desired packet bandwidth */
    CBase               *base_ptr;              /*!< \brief Reference to base services */
    CInic               *inic_ptr;              /*!< \brief Reference to class CInic */
    CNetworkManagement  *net_ptr;               /*!< \brief Reference to network management */
    CNodeDiscovery      *nd_ptr;                /*!< \brief Reference to node discovery */

    CSingleObserver startup_obs;                /*!< \brief Startup result callback */
 /* CSingleObserver shutdown_obs; */            /*!< \brief Shutdown result callback */
    CSingleObserver force_na_obs;               /*!< \brief ForceNA result callback */
    bool                 initial;               /*!< \brief Is \c true for the initial network status "available" */

} CManager;

/*------------------------------------------------------------------------------------------------*/
/* Methods                                                                                        */
/*------------------------------------------------------------------------------------------------*/
extern void Mgr_Ctor(CManager *self, CBase *base_ptr, CInic *inic_ptr, CNetworkManagement *net_ptr, CNodeDiscovery *nd_ptr, uint16_t packet_bw);

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

#endif          /* UCS_MGR_H */

/*!
 * @}
 * \endcond
 */

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