RDK Documentation (Open Sourced RDK Components)
indicator.hpp
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 #include <iostream>
20 #include "ledmgr_types.hpp"
21 #include "pthread.h"
22 #include "frontPanelIndicator.hpp"
23 #include <glib.h>
24 
25 
26 class indicator
27 {
28  public:
29  typedef struct
30  {
31  bool isValid;
32  indicatorState_t state;
33  const blinkPattern_t *pattern_ptr;
34  int pattern_repetitions;
35  unsigned char sequence_read_offset;
36  unsigned int intensity;
37  unsigned int color;
39 
40  private:
41  std::string m_name;
42  pthread_mutex_t m_mutex;
43  guint m_source_id;
44  device::FrontPanelIndicator *m_indicator;
45 
46  indicatorState_t m_state;
47  const blinkPattern_t *m_pattern_ptr;
48  int m_pattern_repetitions;
49  unsigned char m_sequence_read_offset;
50  unsigned int m_preflare_brightness;
51 
52  indicatorProperties_t m_saved_properties;
53 
54  public:
55  /* Configure with appropriate identifier.*/
56  indicator(const std::string &name);
57  ~indicator();
58  const std::string& getName() const;
59  int setState(indicatorState_t state);
60  int setBlink(const blinkPattern_t *pattern, int repetitions = -1);
61  void setColor(const unsigned int color);
62  int timerCallback(void);
63  void saveState();
64  void restoreState();
65  void executeFlare(const unsigned int percentage_increase, const unsigned int length_ms);
66  void flareCallback(void);
67  private:
68  int step();
69  int registerCallback(unsigned int milliseconds);
70  void setBrightness(unsigned int intensity);
71  int enableIndicator(bool enable);
72 
73 };
74 
indicator::registerCallback
int registerCallback(unsigned int milliseconds)
This API register timer callback function in order to complete the blinking pattern iteration count.
Definition: indicator.cpp:263
indicator::setColor
void setColor(const unsigned int color)
This API sets the indicator color.
Definition: indicator.cpp:109
indicator::timerCallback
int timerCallback(void)
This API requests to process the pattern iteration steps.
Definition: indicator.cpp:246
indicator::executeFlare
void executeFlare(const unsigned int percentage_increase, const unsigned int length_ms)
Register Flare callback function to set indicator brightness as flare.
Definition: indicator.cpp:431
indicator::setBlink
int setBlink(const blinkPattern_t *pattern, int repetitions=-1)
This API enables the indicator to blink with the specified blinking pattern.
Definition: indicator.cpp:148
indicator::setState
int setState(indicatorState_t state)
This API cancel the current blinking indicator if any, to change the state .
Definition: indicator.cpp:285
indicator::enableIndicator
int enableIndicator(bool enable)
This API sets the indicator state.
Definition: indicator.cpp:326
indicator::flareCallback
void flareCallback(void)
API to perform indicator brightness with flare value.
Definition: indicator.cpp:468
indicator
Definition: indicator.hpp:26
frontPanelIndicator.hpp
Structures and classes for front panel indicator are defined here.
indicator::step
int step()
This API is to register timer callback function depends on iteration pattern(indefinite iteration and...
Definition: indicator.cpp:188
device::FrontPanelIndicator
This class extents DSConstant to manage front panel indicators color, blink sequence and brightness.
Definition: frontPanelIndicator.hpp:55
indicator::saveState
void saveState()
This API saves all the current indicator related properties.
Definition: indicator.cpp:346
indicator::indicatorProperties_t
Definition: indicator.hpp:29
indicator::restoreState
void restoreState()
API to restore the indicator properties from saved indicator properties.
Definition: indicator.cpp:378
indicator::setBrightness
void setBrightness(unsigned int intensity)
This API sets the brightness of the specified LED.
Definition: indicator.cpp:127
indicator::getName
const std::string & getName() const
API to return the indicator name.
Definition: indicator.cpp:98