Init basesystem source codes.
[staging/basesystem.git] / systemservice / power_service / server / include / ss_power_config.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_PowerService
19 /// \brief    This file supports power service configuration.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
23 #define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_
24
25
26 #include <system_service/ss_system_types.h>
27 #include <system_service/ss_templates.h>
28 #include <native_service/ns_config_parser_if.h>
29 #include <list>
30 #include <string>
31 #include "ss_power_powerservicelog.h"
32
33 typedef std::list<SS_String> RequiredModuleList;
34 typedef RequiredModuleList::iterator RequiredModuleListIter;
35
36 #define SS_PWR__CWORD56__REP_HIST_SIZE     (10u)
37 #define SS_PWR_PUB_CMD_HIST_SIZE      (5u)
38 #define SS_PWR_ERR_HIST_SIZE          (5u)
39 #define SS_PWR_V_HIST_SIZE            (10u)
40 #define SS_PWR_DEBUG_DUMP_MAX_SIZE    (4096u)
41
42 typedef struct _PowerConfigParams {  // NOLINT (readability/naming)  // LCOV_EXCL_BR_LINE 14:it will be called when poweron
43   typedef struct {
44     SI_32 timeout;
45     struct {
46       BOOL enabled;
47       SI_32 timeout;
48       SI_32 tries;
49     } hysteresis;
50   } PowerOffInfo;
51
52   SS_String power_logic_plugin;
53   PowerOffInfo lvi1;
54   PowerOffInfo lvi2;
55   PowerOffInfo shutdown;
56   RequiredModuleList wakeup_modules;
57   RequiredModuleList shutdown_modules;
58   RequiredModuleList lvi2_modules;
59 } PowerConfigParams;
60
61 class PowerConfiguration {
62  public:
63   // define all the configuration parmeters that will be used to get data
64   static const char * kPowerLogicPlugin;
65   static const char * kLVI1Timeout;
66   static const char * kLVI1HysteresisTimeout;
67   static const char * kLVI1HysteresisEnabled;
68   static const char * kLVI1HysteresisTries;
69   static const char * kLVI2Timeout;
70   static const char * kLVI2HysteresisTimeout;
71   static const char * kLVI2HysteresisEnabled;
72   static const char * kLVI2HysteresisTries;
73   static const char * kShutdownTimeout;
74   static const char * kShutdownHysteresisTimeout;
75   static const char * kShutdownHysteresisEnabled;
76   static const char * kShutdownHysteresisTries;
77
78   /// < defines the names in the xml file that are used to get required modules names
79   static const char * kRequiredWakeupModules;  /// < once all the modules have been wakened up send wake-up complete
80   static const char * kRequiredShutdownModules;  /// < once all the modules have been shutdown send shutdown complete
81   static const char * kRequiredLvi2Modules;  /// < once all the modules have been wakened up send wake-up complete
82
83   ////////////////////////////////////////////////////////////////////////////////////////////
84   ///  PowerConfiguration
85   ///  \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
86   ///  connection is  to be disconnected or to be paused or to be played simultaneously.
87   ///
88   /// \param [in] f_configFileName  Configuration file name.
89   ///
90   /// \return NA
91   ///
92   ////////////////////////////////////////////////////////////////////////////////////////////
93   explicit PowerConfiguration(std::string f_configfilename);
94
95   ////////////////////////////////////////////////////////////////////////////////////////////
96   ///  ~PowerConfiguration
97   ///  \brief Here it is checked whether the new connection is to be connected or not, if yes then whether the old
98   ///  connection is  to be disconnected or to be paused or to be played simultaneously.
99   ///
100   /// \param [in] pRequestingSrc
101   ///         Source* - Pointer to the requesting source.
102   ///
103   /// \return bool
104   ///         bool - TRUE or FALSE
105   ////////////////////////////////////////////////////////////////////////////////////////////
106   virtual ~PowerConfiguration();
107
108   ////////////////////////////////////////////////////////////////////////////////////////////
109   ///  LoadParameters
110   ///  \brief Load module parameters from configuration file.
111   ///
112   /// \param [in] params - Ref to variable which to store the loaded module parameters.
113   ///
114   /// \return bool
115   ///         bool - TRUE or FALSE
116   ////////////////////////////////////////////////////////////////////////////////////////////
117   BOOL LoadParameters(PowerConfigParams & params);  // NOLINT (runtime/references)
118
119   ////////////////////////////////////////////////////////////////////////////////////////////
120   ///  LoadDefaultParameters
121   ///  \brief Laod default power services parameters.
122   ///
123   /// \param [in] params - Ref to variable for which to store the default module parameters.
124   ///
125   /// \return none
126   ////////////////////////////////////////////////////////////////////////////////////////////
127   void LoadDefaultParameters(PowerConfigParams & params);  // NOLINT (runtime/references)
128
129   ////////////////////////////////////////////////////////////////////////////////////////////
130   ///  PrintConfigInfo
131   ///  \brief Print configuration information.
132   ///
133   /// \param [in] params - Ref to variable containing the configuration parameters to load.params
134   ///
135   /// \return none.
136   ////////////////////////////////////////////////////////////////////////////////////////////
137   void PrintConfigInfo(PowerConfigParams & f_params);  // NOLINT (runtime/references)
138
139  protected:
140   PowerConfiguration(const PowerConfiguration &);
141   PowerConfiguration & operator =(const PowerConfiguration &);  // NOLINT (runtime/references)
142
143  private:
144   std::string m_ConfigFileName;
145 };
146
147 #endif  // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_CONFIG_H_