Thermostat pour piloter jusqu'à 4 radiateurs avec fil pilote
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.6 KiB

  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. /*
  3. * Qt mutizone MQTT thermostat
  4. *
  5. * Copyright (C) 2019 Richard Genoud
  6. *
  7. */
  8. #ifndef SETTINGS_H
  9. #define SETTINGS_H
  10. #include <QSettings>
  11. #include <QDateTime>
  12. #include <QVector>
  13. #include <QTime>
  14. #define MAX_NB_ZONES 4
  15. #define FORCE_OFF (-256)
  16. #define FORCE_ON (99)
  17. enum power_states {
  18. OFF,
  19. ON,
  20. AUTO,
  21. MAX_POWER_STATES
  22. };
  23. struct Heater {
  24. QString ctrl_topic;
  25. };
  26. struct Program {
  27. double temperature;
  28. uint8_t DoW;
  29. QTime start_time;
  30. QTime end_time;
  31. };
  32. struct Room {
  33. QString name;
  34. QString sensor_topic;
  35. QString availability_topic;
  36. double default_temperature;
  37. QVector<struct Heater> heaters;
  38. QVector<struct Program> progs;
  39. };
  40. struct Brocker {
  41. QString address;
  42. int port;
  43. };
  44. class Settings : public QSettings
  45. {
  46. Q_OBJECT
  47. public:
  48. static Settings *getInstance(void);
  49. int nbZones(void);
  50. enum power_states getPowerState(void) { return m_state; }
  51. void setPowerState(enum power_states state);
  52. const QDateTime &getEndHoliday(void) { return m_end_holiday; }
  53. void setEndHoliday(const QDateTime &endDate);
  54. const struct Room &getRoom(int idx) { return m_rooms.at(idx); }
  55. void setRoomDefaultTemperature(int idx, double temperature);
  56. void setRoomPrograms(int idx, QVector<struct Program> &progs);
  57. struct Brocker m_broker;
  58. private:
  59. explicit Settings(QObject *parent = Q_NULLPTR);
  60. ~Settings(void);
  61. static Settings *_singleton;
  62. void set_rooms_default_config(void);
  63. int read_config(void);
  64. enum power_states m_state;
  65. QDateTime m_end_holiday;
  66. QVector<struct Room> m_rooms;
  67. };
  68. #endif // SETTINGS_H
  69. /* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */