RDK Documentation (Open Sourced RDK Components)
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
setFPTextTimeFormat.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 // TODO: Include your class to test here.
21 
22 
23 /**
24 * @defgroup devicesettings
25 * @{
26 * @defgroup sample
27 * @{
28 **/
29 
30 
31 #include <iostream>
32 #include "host.hpp"
33 #include "frontPanelConfig.hpp"
35 #include "manager.hpp"
36 #include "dsUtl.h"
37 #include "dsError.h"
38 #include "list.hpp"
39 #include <exception>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <unistd.h>
43 #include <string.h>
44 
45 #include "libIBus.h"
46 #include "dsMgr.h"
47 
48 void _EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
49 void _EventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
50 {
51  if (strcmp(owner,IARM_BUS_DSMGR_NAME) == 0)
52  {
53  printf("Ds Mgr Event Handler called %d ......... \r\n",eventId);
54  switch (eventId) {
56  {
58  printf("EVENT_TIME_FORMAT_CHANGE Event %d Recvd \r\n",eventId);
59  printf("Time Format change to %s \r\n",eventData->data.FPDTimeFormat.eTimeFormat == dsFPD_TIME_12_HOUR ?"12_HR":"24_HR");
60  try {
61  printf("Set Time format \r\n");
63  printf("Set Time format over\r\n");
64  }
65  catch (...) {
66  printf("Exception Caught during setting time format \r\n");
67  }
68  }
69  break;
70  default:
71  break;
72  }
73  }
74 }
75 
76 
77 
78 int main(int argc, char *argv[])
79 {
80  if (argc != 2) {
81  printf("%s : <Timezone - 0(12_HR)-1(24_HR)> >\r\n", argv[0]);
82  return 0;
83  }
84 
85  int timzone = atoi((const char *)argv[1]);
86 
87 
88  IARM_Bus_Init("TestTimeFormat");
90 
91  IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,
93  _EventHandler);
94 
96 
97  try {
98 
99  printf("Before setting - Time zone read from DS is %d \r\n",device::FrontPanelConfig::getInstance().getTextDisplay("Text").getCurrentTimeFormat());
101  printf("After setting - Time zone read from DS is now %d \r\n",device::FrontPanelConfig::getInstance().getTextDisplay("Text").getCurrentTimeFormat());
102 
103  }
104  catch (...) {
105  printf("Exception Caught during [%s]\r\n", argv[0]);
106  }
107 
108  sleep(5);
109 
111 
112 
114  IARM_Bus_Term();
115 
116  return 0;
117 }
118 
119 
120 /** @} */
121 /** @} */
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
device::FrontPanelConfig::getTextDisplay
FrontPanelTextDisplay & getTextDisplay(int id)
This function gets the FrontPanelTextDisplay instance corresponding to the specified id,...
Definition: frontPanelConfig.cpp:224
device::FrontPanelConfig::getInstance
static FrontPanelConfig & getInstance()
This API gets the instance of the FrontPanelConfig. When called for the first time,...
Definition: frontPanelConfig.cpp:82
IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE
@ IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE
Definition: dsMgr.h:62
frontPanelTextDisplay.hpp
Classes and structures for front panel text display are defined here.
manager.hpp
It contains class referenced by manager.cpp file.
IARM_Bus_RegisterEventHandler
IARM_Result_t IARM_Bus_RegisterEventHandler(const char *ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler)
This API register to listen to event and provide the callback function for event notification....
Definition: iarmMgrMocks.cpp:43
dsError.h
Device Settings HAL error codes.
device::FrontPanelTextDisplay::setTime
void setTime(const int uiHours, const int uiMinutes)
This API sets the time of the LED display by switching the text display to time mode.
Definition: frontPanelTextDisplay.cpp:377
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::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
libIBus.h
RDK IARM-Bus API Declarations.
frontPanelConfig.hpp
Structures and classes to manage front panel are defined here.
dsFPD_TIME_12_HOUR
@ dsFPD_TIME_12_HOUR
Definition: dsTypes.h:847
device::FrontPanelTextDisplay::setTimeFormat
void setTimeFormat(const int iTimeFormat)
This API sets the time format of the LED display to either 12hr or 24hr format.
Definition: frontPanelTextDisplay.cpp:332
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
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
_DSMgr_EventData_t
Definition: dsMgr.h:81