pwmfan.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * <one line to give the library's name and an idea of what it does.>
  3. * Copyright 2015 Malte Veerman maldela@halloarsch.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License or (at your option) version 3 or any later version
  9. * accepted by the membership of KDE e.V. (or its successor approved
  10. * by the membership of KDE e.V.), which shall act as a proxy
  11. * defined in Section 14 of version 3 of the license.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef PWMFAN_H
  23. #define PWMFAN_H
  24. #include "temp.h"
  25. #include "fan.h"
  26. class QTextStream;
  27. namespace Fancontrol
  28. {
  29. class PwmFan : public Fan
  30. {
  31. Q_OBJECT
  32. Q_PROPERTY(int pwm READ pwm WRITE setPwm NOTIFY pwmChanged)
  33. Q_PROPERTY(Temp * temp READ temp WRITE setTemp NOTIFY tempChanged)
  34. Q_PROPERTY(bool hasTemp READ hasTemp WRITE setHasTemp NOTIFY hasTempChanged)
  35. Q_PROPERTY(int minTemp READ minTemp WRITE setMinTemp NOTIFY minTempChanged)
  36. Q_PROPERTY(int maxTemp READ maxTemp WRITE setMaxTemp NOTIFY maxTempChanged)
  37. Q_PROPERTY(int minPwm READ minPwm WRITE setMinPwm NOTIFY minPwmChanged)
  38. Q_PROPERTY(int maxPwm READ maxPwm WRITE setMaxPwm NOTIFY maxPwmChanged)
  39. Q_PROPERTY(int minStart READ minStart WRITE setMinStart NOTIFY minStartChanged)
  40. Q_PROPERTY(int minStop READ minStop WRITE setMinStop NOTIFY minStopChanged)
  41. Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
  42. Q_PROPERTY(bool testing READ testing NOTIFY testingChanged)
  43. Q_PROPERTY(int pwmMode READ pwmMode WRITE setPwmMode NOTIFY pwmModeChanged)
  44. public:
  45. explicit PwmFan(Hwmon *parent, uint index);
  46. virtual ~PwmFan();
  47. int pwm() const { return m_pwm; }
  48. Temp * temp() const { return m_temp; }
  49. bool hasTemp() const { return m_hasTemp; }
  50. int minTemp() const { return m_minTemp; }
  51. int maxTemp() const { return m_maxTemp; }
  52. int minPwm() const { return m_minPwm; }
  53. int maxPwm() const { return m_maxPwm; }
  54. int minStart() const { return m_minStart; }
  55. int minStop() const { return m_minStop; }
  56. int pwmMode() const { return m_pwmMode; }
  57. bool active() const;
  58. bool testing() const;
  59. bool setPwm(int pwm, bool write = true);
  60. void setTemp(Temp *temp) { setHasTemp(temp != Q_NULLPTR); if (temp != m_temp) { m_temp = temp; emit tempChanged(); } }
  61. void setHasTemp(bool hasTemp) { if (hasTemp != m_hasTemp) { m_hasTemp = hasTemp; emit hasTempChanged(); } }
  62. void setMinTemp(int minTemp) { if (minTemp != m_minTemp) { m_minTemp = minTemp; emit minTempChanged(); } }
  63. void setMaxTemp(int maxTemp) { if (maxTemp != m_maxTemp) { m_maxTemp = maxTemp; emit maxTempChanged(); } }
  64. void setMinPwm(int minPwm) { if (minPwm != m_minPwm) { m_minPwm = minPwm; emit minPwmChanged(); } }
  65. void setMaxPwm(int maxPwm) { if (maxPwm != m_maxPwm) { m_maxPwm = maxPwm; emit maxPwmChanged(); } }
  66. void setMinStart(int minStart) { if (minStart != m_minStart) { m_minStart = minStart; emit minStartChanged(); } }
  67. void setMinStop(int minStop) { if (minStop != m_minStop) { m_minStop = minStop; emit minStopChanged(); } }
  68. bool setPwmMode(int pwmMode, bool write = true);
  69. void setActive(bool active);
  70. void reset() Q_DECL_OVERRIDE;
  71. Q_INVOKABLE bool test();
  72. Q_INVOKABLE void abortTest();
  73. signals:
  74. void pwmChanged();
  75. void tempChanged();
  76. void hasTempChanged();
  77. void minTempChanged();
  78. void maxTempChanged();
  79. void minPwmChanged();
  80. void maxPwmChanged();
  81. void minStartChanged();
  82. void minStopChanged();
  83. void activeChanged();
  84. void testingChanged();
  85. void pwmModeChanged();
  86. protected slots:
  87. void update();
  88. void continueTest();
  89. // void handlePwmActionReply();
  90. // void handlePwmModeActionReply();
  91. private:
  92. int m_pwm;
  93. QTextStream *m_pwmStream;
  94. QTextStream *m_modeStream;
  95. Temp *m_temp;
  96. bool m_hasTemp;
  97. int m_minTemp;
  98. int m_maxTemp;
  99. int m_minPwm;
  100. int m_maxPwm;
  101. int m_minStart;
  102. int m_minStop;
  103. int m_pwmMode;
  104. int m_zeroRpm;
  105. enum
  106. {
  107. NotStarted,
  108. FindingStop1,
  109. FindingStop2,
  110. FindingStart,
  111. Finished,
  112. Cancelled,
  113. Error
  114. } m_testStatus;
  115. };
  116. }
  117. #endif // PWMFAN_H