浏览代码

improved error handling and speed testing

Malte Veerman 8 年之前
父节点
当前提交
4ab9cad2c7
共有 4 个文件被更改,包括 24 次插入11 次删除
  1. 0 1
      fancontrol-gui/package/contents/ui/Application.qml
  2. 7 6
      import/qml/ErrorDialog.qml
  3. 1 1
      import/qml/FanItem.qml
  4. 16 3
      import/src/pwmfan.cpp

+ 0 - 1
fancontrol-gui/package/contents/ui/Application.qml

@@ -123,7 +123,6 @@ ApplicationWindow {
         id: errorDialog
         visible: false
         modality: Qt.ApplicationModal
-        base: Fancontrol.base
     }
 
     Action {

+ 7 - 6
import/qml/ErrorDialog.qml

@@ -21,14 +21,12 @@
 import QtQuick 2.4
 import QtQuick.Dialogs 1.2
 import QtQuick.Controls 1.2
+import Fancontrol.Qml 1.0 as Fancontrol
 
 
 Dialog {
     id: dialog
 
-    property alias text: text.text
-    property QtObject base
-
     title: i18n("Error")
     width: text.implicitWidth + 20
     standardButtons: StandardButton.Close
@@ -37,11 +35,14 @@ Dialog {
     Label {
         id: text
         anchors.centerIn: parent
-        text: !!base ? base.error : ""
+        text: ""
     }
     
     Connections {
-        target: base
-        onCriticalError: dialog.open()
+        target: Fancontrol.base
+        onCriticalError: {
+            text.text = Fancontrol.base.error;
+            dialog.open();
+        }
     }
 }

+ 1 - 1
import/qml/FanItem.qml

@@ -436,7 +436,7 @@ Rectangle {
             SpinBox {
                 id: minStartInput
                 Layout.fillWidth: true
-                minimumValue: 1
+                minimumValue: 0
                 maximumValue: 100
                 decimals: 1
                 value: !!fan ? Math.round(fan.minStart / 2.55) : 0

+ 16 - 3
import/src/pwmfan.cpp

@@ -264,9 +264,9 @@ bool PwmFan::setPwm(int pwm, bool write)
 
 bool PwmFan::setPwmEnable(int pwmEnable, bool write)
 {
-    if (pwmEnable < 0 || pwmEnable > 2)
+    if (pwmEnable < 0)
     {
-        emit error(i18n("PwmEnable cannot exceed 0-2!"), true);
+        emit error(i18n("PwmEnable cannot be less than 0!"), true);
         return false;
     }
 
@@ -415,7 +415,19 @@ void PwmFan::continueTest()
     case FindingStop1:
         if (rpm() > 0)
         {
-            setPwm(qMin(m_pwm * 0.95, m_pwm - 5.0));
+            if (m_pwm == 0)
+            {
+                error(i18n("Fan never stops."), false);
+                setMinStart(0);
+                setMinStop(0);
+                setMinPwm(0);
+                setPwm(255);
+                m_testStatus = Finished;
+                emit testStatusChanged();
+                return;
+            }
+            
+            setPwm(qMax(0, (int)qMin(m_pwm * 0.95, m_pwm - 5.0)));
             m_zeroRpm = 0;
         }
         else
@@ -478,6 +490,7 @@ void PwmFan::continueTest()
                 emit testStatusChanged();
                 m_zeroRpm = 0;
                 setMinStop(qMin(255, m_pwm + 5));
+                setMinPwm(qMin(m_minPwm, m_minStop));
                 setPwm(255);
 //                qDebug() << "Finished testing PwmFan" << m_index;
             }