lamp.hpp
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (c) 2015-2016, Arkadiusz Materek (arekmat@poczta.fm)
*
* Licensed under GNU General Public License 3.0 or later.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef DALI_LAMP_CONTROLLER_HPP_
#define DALI_LAMP_CONTROLLER_HPP_
#include <dali/dali.hpp>
#include "memory.hpp"
namespace dali {
namespace controller {
class Lamp: public ILamp::ILampClient {
public:
class Listener {
public:
virtual void onLampStateChnaged(ILamp::ILampState state) = 0;
};
explicit Lamp(ILamp* lamp, Memory* memoryController);
virtual ~Lamp();
// >>> used only in controller namespace
void onReset();
bool isPowerOn() { return (mLamp->getLevel() > 0); }
bool isFailure();
bool isFading() { return mLamp->isFading(); }
bool isLimitError() { return mLimitError; }
bool isPowerSet() { return mIsPowerSet; }
uint8_t getLevel();
Status setLevel(uint8_t level, uint32_t fadeTime);
uint32_t getFadeTime();
uint32_t getFadeRate();
Status abortFading();
// <<< used only in controller namespace
void setListener(Listener* listener) { mListener = listener; }
void notifyPowerDown() { mLamp->setLevel(0, 0); }
virtual Status powerDirect(uint8_t level, Time time);
virtual Status powerOff();
virtual Status powerScene(uint8_t scene);
virtual Status powerUp();
virtual Status powerDown();
virtual Status powerStepUp();
virtual Status powerStepDown();
virtual Status powerOnAndStepUp();
virtual Status powerStepDownAndOff();
virtual Status powerRecallMinLevel();
virtual Status powerRecallMaxLevel();
virtual Status powerRecallOnLevel();
virtual Status powerRecallFaliureLevel();
Status enableDapcSequence(Time time);
protected:
ILamp* const getLamp() { return mLamp; }
Memory* const getMemoryController() { return mMemoryController; }
enum class Mode {
NORMAL,
CONSTANT_POWER,
};
void setMode(Mode mode, uint8_t param, uint32_t fadeTime);
private:
Lamp(const Lamp& other) = delete;
Lamp& operator=(const Lamp&) = delete;
Status dapcSequence(uint8_t level, Time time);
void onPowerCommand();
// ILamp::ILampClient
void onLampStateChnaged(ILamp::ILampState state) override;
ILamp* const mLamp;
Memory* const mMemoryController;
Mode mMode;
ILamp::ILampState mLampState;
Listener* mListener;
bool mIsPowerSet;
bool mLimitError;
Time mDapcTime;
uint8_t mConstPower;
};
} // namespace controller
} // namespace dali
#endif // DALI_LAMP_CONTROLLER_HPP_