* AmMapHanlderTest - added tests for the callbacks in CAmDatabaseObserver.
[profile/ivi/genivi/genivi-audio-manager.git] / nodeStateManagerIncludes / NodeStateTypes.h
1 #ifndef NODESTATETYPES_H
2 #define NODESTATETYPES_H
3
4 /**********************************************************************************************************************
5 *
6 * Copyright (C) 2012 Continental Automotive Systems, Inc.
7 *
8 * Author: Jean-Pierre.Bogler@continental-corporation.com
9 *
10 * Type and constant definitions to communicate with the NSM.
11 *
12 * The file defines types and constants to be able to communicate with the NSM.
13 *
14 * This Source Code Form is subject to the terms of the Mozilla Public
15 * License, v. 2.0. If a copy of the MPL was not distributed with this
16 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
17 *
18 * Date       Author             Reason
19 * 2012.09.27 uidu5846  1.0.0.0  CSP_WZ#1194: Introduced 'NodeStateTypes.h' to avoid circle includes
20 *                                            and encapsulate type definitions.
21 * 2012.10.24 uidu5846  1.0.0.1  CSP_WZ#1322: Removed "ssw_types" redefinition from header.
22 *                                            Since the same native types are used, no interface change.
23 *
24 **********************************************************************************************************************/
25
26 /** \ingroup SSW_LCS */
27 /** \defgroup SSW_NSM_TEMPLATE Node State Manager
28  *  \{
29  */
30 /** \defgroup SSW_NSM_INTERFACE API document
31  *  \{
32  */
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**********************************************************************************************************************
40 *
41 *  CONSTANTS
42 *
43 **********************************************************************************************************************/
44
45 /* Definitions of D-Bus names and addresses */
46 #define NSM_BUS_TYPE              1                                               /**< Defines bus type according to GBusType */
47 #define NSM_BUS_NAME              "org.genivi.NodeStateManager"                   /**< The bus name of the NSM                */
48 #define NSM_LIFECYCLE_OBJECT      "/org/genivi/NodeStateManager/LifecycleControl" /**< Address of the lifecycle object        */
49 #define NSM_CONSUMER_OBJECT       "/org/genivi/NodeStateManager/Consumer"         /**< Address of the consumer  object        */
50
51 /* Defines for session handling */
52 #define NSM_DEFAULT_SESSION_OWNER "NodeStateManager"           /**< "Owner" of the default sessions                  */
53
54 /* Defines for internal settings like max. string lenghts */
55 #define NSM_MAX_SESSION_NAME_LENGTH  256                       /**< Max. number of chars a session name can have     */
56 #define NSM_MAX_SESSION_OWNER_LENGTH 256                       /**< Max. number of chars for name of session owner   */
57
58 /*
59  * Defines for shutdown handling as bit masks. Used to register for multiple shutdown types and as parameter to
60  * inform clients about the shutdown type via the LifecycleConsumer interface.
61  */
62 #define NSM_SHUTDOWNTYPE_NOT      0x00000000U                  /**< Client not registered for any shutdown           */
63 #define NSM_SHUTDOWNTYPE_NORMAL   0x00000001U                  /**< Client registered for normal shutdown            */
64 #define NSM_SHUTDOWNTYPE_FAST     0x00000002U                  /**< Client registered for fast shutdown              */
65 #define NSM_SHUTDOWNTYPE_RUNUP    0x80000000U                  /**< The shutdown type "run up" can not be used for
66                                                                     registration. Clients which are registered and
67                                                                     have been shut down, will automatically be
68                                                                     informed about the "run up", when the shut down
69                                                                     is canceled.                                    */
70
71 /**********************************************************************************************************************
72 *
73 *  TYPE
74 *
75 **********************************************************************************************************************/
76
77 /**
78  * The enumeration defines the different types of data that can be exchanged between the NodeStateManager (NSM)
79  * and the NodeStateMachine (NSMC). Based on this value, the setter and getter functions of the NSM and NSMC will
80  * interpret data behind the passed byte pointer.
81  */
82 typedef enum _NsmDataType_e
83 {
84   NsmDataType_AppMode,                 /**< An ApplicationMode should be set or get */
85   NsmDataType_NodeState,               /**< A NodeState should be set or get        */
86   NsmDataType_RestartReason,           /**< A RestartReason should be set or get    */
87   NsmDataType_SessionState,            /**< A SessionState should be set or get     */
88   NsmDataType_ShutdownReason,          /**< A ShutdownReason should be set or get   */
89   NsmDataType_BootMode,                /**< A BootMode should be set or get         */
90   NsmDataType_RunningReason            /**< A RunningReason should be set or get    */
91 } NsmDataType_e;
92
93
94 /**
95  * The enumeration defines the different wake up reasons.
96  */
97 typedef enum _NsmErrorStatus_e
98 {
99   NsmErrorStatus_NotSet,               /**< Initial value when error type is not set             */
100   NsmErrorStatus_Ok,                   /**< Value when no error occurred                         */
101   NsmErrorStatus_Error,                /**< A general, non-specific error occurred               */
102   NsmErrorStatus_Dbus,                 /**< Error in D-Bus communication                         */
103   NsmErrorStatus_Internal,             /**< Internal error (memory alloc. failed, etc.)          */
104   NsmErrorStatus_Parameter,            /**< A passed parameter was incorrect                     */
105   NsmErrorStatus_WrongSession,         /**< The requested session is unknown.                    */
106   NsmErrorStatus_ResponsePending,      /**< Command accepted, return value delivered asynch.     */
107   NsmErrorStatus_Last                  /**< Last error value to identify valid errors            */
108 } NsmErrorStatus_e;
109
110
111 /**
112  * Possible application modes of the node.
113  */
114 typedef enum _NsmApplicationMode_e
115 {
116   NsmApplicationMode_NotSet,           /**< Initial state                                        */
117   NsmApplicationMode_Parking,          /**< Parking          mode                                */
118   NsmApplicationMode_Factory,          /**< Factory          mode                                */
119   NsmApplicationMode_Transport,        /**< Transport        mode                                */
120   NsmApplicationMode_Normal,           /**< Normal           mode                                */
121   NsmApplicationMode_Swl,              /**< Software loading mode                                */
122   NsmApplicationMode_Last              /**< Last value to identify valid values                  */
123 }NsmApplicationMode_e;
124
125
126 /**
127  * The enumeration defines the different restart reasons.
128  */
129 typedef enum _NsmRestartReason_e
130 {
131   NsmRestartReason_NotSet,             /**< Initial value when reset reason is not set           */
132   NsmRestartReason_ApplicationFailure, /**< Reset was requested by System Health Mon.            */
133   NsmRestartReason_Diagnosis,          /**< Reset was requested by diagnosis                     */
134   NsmRestartReason_Swl,                /**< Reset was requested by the SWL application           */
135   NsmRestartReason_User,               /**< Reset was requested by an user application           */
136   NsmRestartReason_Last                /**< Last value to identify valid reset reasons           */
137 } NsmRestartReason_e;
138
139
140 /**
141  * Session can be enabled seat depended.
142  */
143 typedef enum _NsmSeat_e
144 {
145   NsmSeat_NotSet,                      /**< Initial state                                        */
146   NsmSeat_Driver,                      /**< Driver seat                                          */
147   NsmSeat_CoDriver,                    /**< CoDriver seat                                        */
148   NsmSeat_Rear1,                       /**< Rear 1                                               */
149   NsmSeat_Rear2,                       /**< Rear 2                                               */
150   NsmSeat_Rear3,                       /**< Rear 3                                               */
151   NsmSeat_Last                         /**< Last valid state                                     */
152 }NsmSeat_e;
153
154
155 /**
156  * The enumeration defines the different wake up reasons.
157  */
158 typedef enum _NsmSessionState_e
159 {
160   NsmSessionState_Unregistered,        /**< Initial state, equals "not set"                      */
161   NsmSessionState_Inactive,            /**< Session is inactive                                  */
162   NsmSessionState_Active               /**< Session is active                                    */
163 } NsmSessionState_e;
164
165 /**
166  * The enumeration defines the different shutdown reasons.
167  */
168 typedef enum _NsmShutdownReason_e
169 {
170   NsmShutdownReason_NotSet,            /**< Initial value when ShutdownReason not set            */
171   NsmShutdownReason_Normal,            /**< A normal shutdown has been performed                 */
172   NsmShutdownReason_SupplyBad,         /**< Shutdown because of bad supply                       */
173   NsmShutdownReason_SupplyPoor,        /**< Shutdown because of poor supply                      */
174   NsmShutdownReason_ThermalBad,        /**< Shutdown because of bad thermal state                */
175   NsmShutdownReason_ThermalPoor,       /**< Shutdown because of poor thermal state               */
176   NsmShutdownReason_SwlNotActive,      /**< Shutdown after software loading                      */
177   NsmShutdownReason_Last               /**< Last value. Identify valid ShutdownReasons           */
178 } NsmShutdownReason_e;
179
180 /**
181  * The enumeration defines the different start or wake up reasons.
182  */
183 typedef enum _NsmRunningReason_e
184 {
185   NsmRunningReason_NotSet,                       /**< Initial value when reason is not set.                          */
186   NsmRunningReason_WakeupCan,                    /**< Wake up because of CAN activity                                */
187   NsmRunningReason_WakeupMediaEject,             /**< Wake up because of 'Eject' button                              */
188   NsmRunningReason_WakeupMediaInsertion,         /**< Wake up because of media insertion                             */
189   NsmRunningReason_WakeupHevac,                  /**< Wake up because of user uses the HEVAC unit in the car.
190                                                       Even if the HEVAC actually causes activity on the CAN bus a
191                                                       different wakeup reason is required as it could result in a
192                                                       different level of functionality being started                 */
193   NsmRunningReason_WakeupPhone,                  /**< Wake up because of a phone call being received.
194                                                       Even if this is passed as a CAN event a different wakeup reason
195                                                       is required as it could result in a different level of
196                                                       functionality being started                                    */
197   NsmRunningReason_WakeupPowerOnButton,          /**< Startup because user presses the "Power ON" button in the car.
198                                                       Even if this is passed as a CAN event a different wakeup reason
199                                                       is required as it could result in a different level of
200                                                       functionality being started                                    */
201   NsmRunningReason_StartupFstp,                  /**< System was started due to a first switch to power              */
202   NsmRunningReason_StartupSwitchToPower,         /**< System was switched to power                                   */
203   NsmRunningReason_RestartSwRequest,             /**< System was restarted due to an internal SW Request
204                                                       (i.e. SWL or Diagnosis)                                        */
205   NsmRunningReason_RestartInternalHealth,        /**< System was restarted due to an internal health problem         */
206   NsmRunningReason_RestartExternalHealth,        /**< System was restarted due to an external health problem
207                                                       (i.e. external wdog believed node was in failure)              */
208   NsmRunningReason_RestartUnexpected,            /**< System was restarted due to an unexpected kernel restart.
209                                                       This will be the default catch when no other reason is known   */
210   NsmRunningReason_RestartUser,                  /**< Target was reset due to user action (i.e user 3 finger press)  */
211   NsmRunningReason_PlatformEnd = 0x7F,           /**< Last value (127) to identify where the platform defines end
212                                                       (product will start from here on)                              */
213   NsmRunningReason_ProductOffset = NsmRunningReason_PlatformEnd  + 1 /**< product will start from here with index 0  */
214 } NsmRunningReason_e;
215
216
217 /**
218  * The enumeration defines the different node states
219  */
220 typedef enum _NsmNodeState_e
221 {
222   NsmNodeState_NotSet,                 /**< Initial state when node state is not set             */
223   NsmNodeState_StartUp,                /**< Basic system is starting up                          */
224   NsmNodeState_BaseRunning,            /**< Basic system components have been started            */
225   NsmNodeState_LucRunning,             /**< All 'Last user context' components have been started */
226   NsmNodeState_FullyRunning,           /**< All 'foreground' components have been started        */
227   NsmNodeState_FullyOperational,       /**< All components have been started                     */
228   NsmNodeState_ShuttingDown,           /**< The system is shutting down                          */
229   NsmNodeState_ShutdownDelay,          /**< Shutdown request active. System will shutdown soon   */
230   NsmNodeState_FastShutdown,           /**< Fast shutdown active                                 */
231   NsmNodeState_DegradedPower,          /**< Node is in degraded power state                      */
232   NsmNodeState_Shutdown,               /**< Node is completely shut down                         */
233   NsmNodeState_Last                    /**< Last valid entry to identify valid node states       */
234 } NsmNodeState_e;
235
236
237 /** The type defines the structure for a session.                                                */
238 typedef struct _NsmSession_s
239 {
240   char               sName[NSM_MAX_SESSION_NAME_LENGTH];   /**< Name  of the session             */
241   char               sOwner[NSM_MAX_SESSION_OWNER_LENGTH]; /**< Owner of the session             */
242   NsmSeat_e          enSeat;                               /**< Seat  of the session             */
243   NsmSessionState_e  enState;                              /**< State of the session             */
244 } NsmSession_s, *pNsmSession_s;
245
246
247 #ifdef __cplusplus
248 }
249 #endif
250 /** \} */ /* End of SSW_NSM_INTERFACE */
251 /** \} */ /* End of SSW_NSM_TEMPLATE  */
252 #endif /* NODESTATETYPES_H */