RDK Documentation (Open Sourced RDK Components)
powerModeTest.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup sample
26 * @{
27 **/
28 
29 
30 #include <iostream>
31 #include "host.hpp"
32 #include "dsUtl.h"
33 #include "dsError.h"
34 #include "manager.hpp"
35 #include "list.hpp"
36 #include "libIBus.h"
37 #include "sleepMode.hpp"
38 #include <string>
39 #include "list.hpp"
40 #include "dsConstant.hpp"
41 int main(int argc, char *argv[])
42 {
43 
44  char c = 'c';
45  string sleep_mode_str;
46  int ret;
47  IARM_Bus_Init("powerModeTest");
49 
50 
51  try
52  {
53 
55 
56  while(1)
57  {
58  printf("GetPreferredSleepMode - 'g'\n");
59  printf("SetPreferredSleepMode - 's'\n");
60  printf("All Sleep Modes - 'l' \n");
61  printf("Exit - 'x'\n");
62  c = getchar();
63  switch(c)
64  {
65  case 'g':
66  {
68  std::cout << "preffered sleep mode is" << mode.toString() << std::endl;
69  break;
70  }
71  case 's':
72  {
73  std::cout << "Please provide the sleep mode" << std::endl;
74  std::cin >> sleep_mode_str;
75  const device::SleepMode &mode= device::SleepMode::getInstance(sleep_mode_str);
77  std::cout << "Standby mode set retruned " << ret << std::endl;
78  break;
79  }
80  case 'l':
81  {
82  int i;
83  std::cout << "LIst of Sleep Modes" << std::endl;
85  for(i=0;i < sleepModes.size(); i++)
86  {
87 
88  std::cout<<i<<std::endl<<sleepModes.at(i).toString()<<std::endl;
89  }
90  break;
91  }
92  case 'x':
93  {
96  IARM_Bus_Term();
97  return 0;
98  }
99  }
100  }
101  }
102  catch (...) {
105  IARM_Bus_Term();
106  printf("Exception Caught during [%s]\r\n", argv[0]);
107  }
108 
109  return 0;
110 }
111 
112 
113 /** @} */
114 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
device::Host::getAvailableSleepModes
List< SleepMode > getAvailableSleepModes()
This function is used to get the available sleep modes.
Definition: host.cpp:456
device::List
This class is implemented using templates and it is used to maintain a container with the list of sup...
Definition: list.hpp:51
device::SleepMode::getInstance
static SleepMode & getInstance(int id)
This function is used to get an instance of SleepMode against the specified id, only if the id passed...
Definition: sleepMode.cpp:74
dsConstant.hpp
This file defines DSConstant class which is inherited by most of the device settings classes.
manager.hpp
It contains class referenced by manager.cpp file.
dsError.h
Device Settings HAL error codes.
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
dsUtl.h
Device Settings HAL utilities.
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
device::Host::setPreferredSleepMode
int setPreferredSleepMode(const SleepMode)
This API is used to set the Preferred sleep Mode and implements the low power mode for RDK platform.
Definition: host.cpp:444
device::Manager::Initialize
static void Initialize()
This API is used to initialize the Device Setting module. Each API should be called by any client of ...
Definition: manager.cpp:97
device::Host::getPreferredSleepMode
SleepMode getPreferredSleepMode()
This API is used to gets the Preferred sleep Mode and implements the low power mode for RDK platform....
Definition: host.cpp:422
libIBus.h
RDK IARM-Bus API Declarations.
device::SleepMode
This class extends DSConstant to implement SleepMode. It is used to manage the sleep modes for device...
Definition: sleepMode.hpp:51
device::DSConstant::toString
virtual const std::string & toString() const
This function is used to the get the data member name in string format.
Definition: dsConstant.hpp:152
device::Manager::DeInitialize
static void DeInitialize()
This API is used to deinitialize the device settings module. DeInitialize() must be called to release...
Definition: manager.cpp:138
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38
sleepMode.hpp
This file defines SleepMode class for device settings.