hwmon.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <malte.veerman@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. #ifndef HWMON_H
  20. #define HWMON_H
  21. #include <QtCore/QObject>
  22. #include <QtCore/QString>
  23. #include <QtCore/QList>
  24. namespace Fancontrol
  25. {
  26. class Loader;
  27. class Fan;
  28. class Temp;
  29. class PwmFan;
  30. class Hwmon : public QObject
  31. {
  32. Q_OBJECT
  33. Q_PROPERTY(QString name READ name CONSTANT)
  34. Q_PROPERTY(QString path READ path CONSTANT)
  35. Q_PROPERTY(int index READ index CONSTANT)
  36. Q_PROPERTY(QList<QObject *> fans READ fansAsObjects NOTIFY fansChanged)
  37. Q_PROPERTY(QList<QObject *> pwmFans READ pwmFansAsObjects NOTIFY pwmFansChanged)
  38. Q_PROPERTY(QList<QObject *> temps READ tempsAsObjects NOTIFY tempsChanged)
  39. public:
  40. explicit Hwmon(const QString &path, Loader *parent = Q_NULLPTR);
  41. void initialize();
  42. QString name() const { return m_name; }
  43. QString path() const { return m_path; }
  44. int index() const { return m_index; }
  45. QList<Fan *> fans() const { return m_fans; }
  46. QList<PwmFan *> pwmFans() const { return m_pwmFans; }
  47. QList<Temp *> temps() const { return m_temps; }
  48. QList<QObject *> fansAsObjects() const;
  49. QList<QObject *> pwmFansAsObjects() const;
  50. QList<QObject *> tempsAsObjects() const;
  51. Q_INVOKABLE void testFans();
  52. Q_INVOKABLE void abortTestingFans();
  53. Fan * fan(int i) const;
  54. PwmFan * pwmFan(int i) const;
  55. Temp * temp(int i) const;
  56. bool isValid() const { return m_valid; }
  57. bool testing() const;
  58. void toDefault() const;
  59. signals:
  60. void fansChanged();
  61. void pwmFansChanged();
  62. void tempsChanged();
  63. void configUpdateNeeded();
  64. void sensorsUpdateNeeded();
  65. void error(QString, bool = false);
  66. protected:
  67. QString m_name;
  68. int m_index;
  69. Loader *const m_parent;
  70. bool m_valid;
  71. QList<Fan *> m_fans;
  72. QList<PwmFan *> m_pwmFans;
  73. QList<Temp *> m_temps;
  74. private:
  75. const QString m_path;
  76. };
  77. }
  78. #endif // HWMON_H