hwmon.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <maldela@halloarsch.de>
  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. #include "temp.h"
  25. #include "fan.h"
  26. #include "pwmfan.h"
  27. namespace Fancontrol
  28. {
  29. class Loader;
  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. public slots:
  59. void updateConfig() { emit configUpdateNeeded(); }
  60. void updateSensors() { emit sensorsUpdateNeeded(); }
  61. void setError(const QString &error);
  62. signals:
  63. void fansChanged();
  64. void pwmFansChanged();
  65. void tempsChanged();
  66. void configUpdateNeeded();
  67. void sensorsUpdateNeeded();
  68. void errorChanged(QString, bool = false);
  69. private:
  70. Loader *m_parent;
  71. QString m_name;
  72. const QString m_path;
  73. bool m_valid;
  74. int m_index;
  75. QList<Fan *> m_fans;
  76. QList<PwmFan *> m_pwmFans;
  77. QList<Temp *> m_temps;
  78. };
  79. }
  80. #endif // HWMON_H