Parcourir la source

在标准管理页面增加 保压时间 设定, 修复报告生成进度提示,修复界面onclicked 无法触发、主要是外面检查项与电磁阀开关

guoqiang il y a 2 ans
Parent
commit
92379ec412
10 fichiers modifiés avec 101 ajouts et 33 suppressions
  1. 21 3
      PageStandard.qml
  2. 17 16
      PageTest.qml
  3. 3 5
      TestService.cpp
  4. 4 2
      UserRadioButton.qml
  5. 2 2
      UserTableView.qml
  6. 38 1
      UserTristate.qml
  7. 1 1
      ValveTest.pro.user
  8. 11 0
      report.cpp
  9. 3 0
      report.h
  10. 1 3
      tank.cpp

+ 21 - 3
PageStandard.qml

@@ -21,7 +21,6 @@ Item {
     property var v_threshold: [0.0, 0.0, 0.0, 0.0]
 
 
-
     function check_volume(){
 
         for(var i=0; i<4-1; i++){
@@ -115,7 +114,26 @@ Item {
 
         title: title_str
 
-        Column {
+        Rectangle{
+            id:rect_items
+            //anchors.centerIn: parent
+            //width: 1000
+            //height: 700
+
+            width: groupbox_all.width
+            height: groupbox_all.height
+
+            x:20
+            y: !inputPanel.active ? 0 : Math.min(0, main_window.height - inputPanel.height - activeFocusItemBottom)
+            Behavior on y {
+                NumberAnimation {
+                    duration: 250
+                    easing.type: Easing.InOutQuad
+                }
+            }
+
+
+            Column {
             id: column
 
             //width: 600
@@ -477,7 +495,7 @@ Item {
                 }
             }
         }
-
+        }
     }
 
     Component.onCompleted: {

+ 17 - 16
PageTest.qml

@@ -88,17 +88,17 @@ Item{
                             //console.log("switch 1 onCheckedChanged")
                             switch1.text = switch1.checked ? "进气阀开":"进气阀关"
 
-
-                        }
-                        onClicked: {
-                            //console.log("switch 1 clicked")
-
                             if(switch1.checked){
                                 testService.valve_open(TestService.Valve_ID_INTAKE)
                             }else{
                                 testService.valve_close(TestService.Valve_ID_INTAKE)
                             }
 
+
+                        }
+                        onClicked: {
+                            //console.log("switch 1 clicked")
+
                         }
                     }
 
@@ -108,13 +108,15 @@ Item{
                         onCheckedChanged: {
                             switch2.text = switch2.checked ? "真空阀开":"真空阀关"
 
-                        }
-                        onClicked: {
                             if(switch2.checked){
                                 testService.valve_open(TestService.Valve_ID_VACUUM)
                             }else{
                                 testService.valve_close(TestService.Valve_ID_VACUUM)
                             }
+
+                        }
+                        onClicked: {
+
                         }
                     }
                     UserSwitch{
@@ -123,17 +125,16 @@ Item{
                         onCheckedChanged: {
                             switch3.text = switch3.checked ? "泄气阀开":"泄气阀关"
 
-                        }
-
-                        onClicked: {
                             if(switch3.checked){
-                                //switch3.checked = testService.valve_open(TestService.Valve_ID_VENT) === true? true:false
                                 testService.valve_open(TestService.Valve_ID_VENT)
                             }else{
-                                //switch3.checked = testService.valve_close(TestService.Valve_ID_VENT) === true? true:false
                                 testService.valve_close(TestService.Valve_ID_VENT)
                             }
                         }
+
+                        onClicked: {
+
+                        }
                     }
 
 
@@ -142,16 +143,16 @@ Item{
                         text: "全部关"
                         onCheckedChanged: {
                             switch4.text = switch4.checked ? "全部开":"全部关"
-
-                        }
-
-                        onClicked: {
                             if(switch4.checked){
                                 testService.valve_open(TestService.Valve_ID_All)
                             }else{
                                 testService.valve_close(TestService.Valve_ID_All)
                             }
                         }
+
+                        onClicked: {
+
+                        }
                     }
 
 

+ 3 - 5
TestService.cpp

@@ -1091,9 +1091,10 @@ Ret_Value  TestService::Pressure_Relief(const TestExpect& expect)
             count++;
         }else{
             count=0;
+            last_pressure = current_pressure;
         }
 
-        if((count > 5) ||(current_pressure < 0.01)){
+        if((count > 20) ||(current_pressure < 0.01)){
             //关闭泄压阀
             vent_v.Close();
              break;
@@ -1146,7 +1147,7 @@ Ret_Value  TestService::Pressure_Relief()
 
         current_pressure = calculate_averagepressure();
 
-        if(current_pressure < 0.1){
+        if(current_pressure < 0.2){
             qDebug(" Pressure_Relief finished 222");
             count++;
         }else{
@@ -1559,9 +1560,6 @@ void TestService::run()
                             case QMessageBox::Abort:
                                 bQuit = true;
                                 break;
-                            case QMessageBox::Ok:
-                                bQuit = true;
-                                break;
                             default:
                                 break;
                             }

+ 4 - 2
UserRadioButton.qml

@@ -13,7 +13,8 @@ RadioButton {
           x: control.leftPadding
           y: parent.height / 2 - height / 2
           radius: 9
-          border.color: control.down ? "#17a81a" : "#0099cc"
+          //border.color: control.down ? "#17a81a" : "#0099cc"
+          border.color: control.checked ? "#0099cc" : "#0099cc"
 
           Rectangle {
               width: 12
@@ -21,7 +22,8 @@ RadioButton {
               x: 3  // (56 - 34) / 2
               y: 3
               radius: 6
-              color: control.down ? "#17a81a" : "#0099cc"
+              //color: control.down ? "#17a81a" : "#0099cc"
+              color: control.checked ? "#0099cc" : "#0099cc"
               visible: control.checked
           }
       }

+ 2 - 2
UserTableView.qml

@@ -124,7 +124,7 @@ Rectangle {
                          id:utr
                          state: display
                          onUsateChanged: {
-                            //console.log("b row:"+row+",utr value :" + utr.value +", result:" + model.display)
+                            //console.log("b row:"+row+",utr state :" + utr.state +", result:" + model.display)
 
                              if("0" === state)
                                 model.display = "0"
@@ -133,7 +133,7 @@ Rectangle {
                              if("2" === state)
                                 model.display = "2"
 
-                            // console.log("a row:"+row +", name:"+tableModel.rows[row].name +", display:" + model.display)
+                             //console.log("a row:"+row +", name:"+tableModel.rows[row].name +", display:" + model.display)
 
                              var itemJson={}
 

+ 38 - 1
UserTristate.qml

@@ -1,5 +1,6 @@
 import QtQuick 2.12
 import QtQuick.Controls 2.12
+import QtQuick.Controls 1.4
 
 Item {
     id:root
@@ -13,6 +14,7 @@ Item {
     property  string text_state1:"合格"
     property  string text_state2:"不合格"
     property  string text_state3:"无此项"
+
     signal usateChanged
 
     state: "0"
@@ -42,8 +44,10 @@ Item {
     ButtonGroup{
         id:group
         buttons: row.children
+
+        /*
         onClicked:{
-            //console.log("tristate clicked:", button.text)
+            console.log("tristate clicked:", button.text)
             var old_state = state
 
             if(text_state1 === button.text){
@@ -54,20 +58,36 @@ Item {
                 state = "2"
             }
 
+            console.log("tristate old_state:", old_state)
+            console.log("tristate state:", state)
+
             if(old_state !== state){
                 //value = value_tmp
                 root.usateChanged()
             }
         }
+
+        */
+
     }
 
     Row{
         id: row
+
+
         UserRadioButton{
             id:rb1
             checked: true
             text: text_state1
             font.pixelSize: fontsize
+            onCheckedChanged: {
+
+                if("0" !== root.state){
+                    //console.log("rb1 onCheckedChanged, rootstate:" , root.state)
+                    root.state = "0"
+                    root.usateChanged()
+                }
+            }
 
         }
 
@@ -76,6 +96,14 @@ Item {
             checked: false
             text: text_state2
             font.pixelSize: fontsize
+            onCheckedChanged: {
+                if("1" !== root.state){
+                    //console.log("rb2 onCheckedChanged, rootstate:" , root.state)
+                    root.state = "1"
+                    root.usateChanged()
+                }
+            }
+
         }
 
         UserRadioButton{
@@ -83,6 +111,15 @@ Item {
             checked: false
             text: text_state3
             font.pixelSize: fontsize
+
+            onCheckedChanged: {
+                if("2" !== root.state){
+                    //console.log("rb3 onCheckedChanged, rootstate:" , root.state)
+                    root.state = "2"
+                    root.usateChanged()
+                }
+            }
+
         }
     }
 }

+ 1 - 1
ValveTest.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 8.0.0, 2023-05-19T11:13:32. -->
+<!-- Written by QtCreator 8.0.0, 2023-06-13T10:14:45. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 11 - 0
report.cpp

@@ -56,9 +56,17 @@ ReportWoker::~ReportWoker()
 {
 
 }
+void ReportWoker::init()
+{
+    CoInitializeEx(NULL,COINIT_MULTITHREADED);//解决非主线程无法调用word问题
+    qDebug()<< "ReportWorker init";
+}
+
 void ReportWoker::makeReport(Tanker& tanker, QString& word_path, QString& pic_dir)
 {
+    //CoInitializeEx(NULL,COINIT_MULTITHREADED);//解决非主线程无法调用word问题
     make_report(tanker, word_path, pic_dir);
+    //CoUninitialize();
 }
 
 bool ReportWoker::make_report(Tanker& tanker, QString word_path, QString pic_dir)
@@ -528,8 +536,11 @@ Report::Report()
     worker->moveToThread(&workerThread);
     connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
     connect(this, &Report::operate, worker, &ReportWoker::makeReport);
+    connect(this, &Report::oninit, worker, &ReportWoker::init);
     connect(worker, &ReportWoker::onProgress, this, &Report::recvProgress);
     workerThread.start();
+
+    emit oninit();
 }
 
 Report::~Report()

+ 3 - 0
report.h

@@ -3,6 +3,7 @@
 
 #include "tank.h"
 #include<QThread>
+#include<windows.h>
 
 #define BOOKMARK_COMPANYNAME        "bm_companyname"
 #define BOOKMARK_CARPLATE           "bm_carplate"
@@ -147,6 +148,7 @@ public:
 
 public slots:
     void makeReport(Tanker& tanker, QString& word_path, QString& pic_dir);
+    void init();
 
 signals:
     void onProgress(const QString&);
@@ -173,6 +175,7 @@ public slots:
 signals:
     void operate(Tanker& , QString& , QString& );
     void onProgress(QString);
+    void oninit();
 
 };
 

+ 1 - 3
tank.cpp

@@ -45,7 +45,7 @@ Compartment::~Compartment()
 
 int Compartment::get_addpressure_timeout()
 {
-    int timeout = 0;
+    int timeout = 5*60;
 
     if(m_volume > 10000){
         timeout = 15*60;
@@ -55,8 +55,6 @@ int Compartment::get_addpressure_timeout()
         timeout = 5*60;
     }
 
-    timeout = 5*60;
-
     return timeout;
 }