GroupState.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <GroupState.h>
  2. const GroupState& GroupState::defaultState() {
  3. static GroupState instance;
  4. return instance;
  5. }
  6. GroupId::GroupId()
  7. : deviceId(0),
  8. groupId(0),
  9. deviceType(REMOTE_TYPE_UNKNOWN)
  10. { }
  11. GroupId::GroupId(const GroupId &other)
  12. : deviceId(other.deviceId),
  13. groupId(other.groupId),
  14. deviceType(other.deviceType)
  15. { }
  16. GroupId::GroupId(
  17. const uint16_t deviceId, const uint8_t groupId, const MiLightRemoteType deviceType
  18. )
  19. : deviceId(deviceId),
  20. groupId(groupId),
  21. deviceType(deviceType)
  22. { }
  23. void GroupId::operator=(const GroupId &other) {
  24. deviceId = other.deviceId;
  25. groupId = other.groupId;
  26. deviceType = other.deviceType;
  27. }
  28. bool GroupId::operator==(const GroupId &other) {
  29. return deviceId == other.deviceId
  30. && groupId == other.groupId
  31. && deviceType == other.deviceType;
  32. }
  33. GroupState::GroupState() {
  34. _on = 0;
  35. _brightness = 0;
  36. _hue = 0;
  37. _saturation = 0;
  38. _mode = 0;
  39. _bulbMode = 0;
  40. _kelvin = 0;
  41. _isSetOn = 0;
  42. _isSetHue = 0;
  43. _isSetBrightness = 0;
  44. _isSetSaturation = 0;
  45. _isSetMode = 0;
  46. _isSetKelvin = 0;
  47. _isSetBulbMode = 0;
  48. }
  49. bool GroupState::isSetOn() const { return _isSetOn; }
  50. bool GroupState::isOn() const { return _on; }
  51. void GroupState::setOn(bool on) { _on = on; }
  52. bool GroupState::isSetBrightness() const { return _isSetBrightness; }
  53. uint8_t GroupState::getBrightness() const { return _brightness; }
  54. void GroupState::setBrightness(uint8_t brightness) { _brightness = brightness; }
  55. bool GroupState::isSetHue() const { return _isSetHue; }
  56. uint8_t GroupState::getHue() const { return _hue; }
  57. void GroupState::setHue(uint8_t hue) { _hue = hue; }
  58. bool GroupState::isSetSaturation() const { return _isSetSaturation; }
  59. uint8_t GroupState::getSaturation() const { return _saturation; }
  60. void GroupState::setSaturation(uint8_t saturation) { _saturation = saturation; }
  61. bool GroupState::isSetMode() const { return _isSetMode; }
  62. uint8_t GroupState::getMode() const { return _mode; }
  63. void GroupState::setMode(uint8_t mode) { _mode = mode; }
  64. bool GroupState::isSetKelvin() const { return _isSetKelvin; }
  65. uint8_t GroupState::getKelvin() const { return _kelvin; }
  66. void GroupState::setKelvin(uint8_t kelvin) { _kelvin = kelvin; }
  67. bool GroupState::isSetBulbMode() const { return _isSetBulbMode; }
  68. BulbMode GroupState::getBulbMode() const { return static_cast<BulbMode>(_bulbMode); }
  69. void GroupState::setBulbMode(BulbMode bulbMode) { _bulbMode = bulbMode; }