import QtQuick 2.11 //import QtQuick.VirtualKeyboard 2.14 //import QtQuick.VirtualKeyboard.Settings 2.14 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 import QtTest 1.14 //import "modbus.js" as ModbusJs //import "breatheTest.js" as BreatheTestJs import Qt.labs.platform 1.1 Item{ id:root property var pagetype:rootitem.Page_Type_ValveTest //车辆单位 property string organize //车牌号 property string carplate //总容积 property string total_volume //油仓数量 property string compartment_num //当前油仓ID property int compartment_id //当前油仓体积 property int volume property int test_direction:0 // property string state property string pressure:"0.00" property int pressureCnt:0 property var syskpArray: [] property var valvekpArray: [] property var allArray: [] property real m_maxY: 0.0 property real m_minY: 0.0 property bool bStart: false; /* Loader{ id:loader anchors.fill: parent //anchors.margins: 5 sourceComponent: componet } */ /* function show(){ if(loader.sourceComponent === null){ loader.sourceComponent = componet console.debug("avans 1111") } loader.item.show() } function exit(){ if(loader.sourceComponent !== null){ loader.item.exit() } } */ function update_pressure(pressure_map){ //textstring += pressure_map.pressure+":" //textstring += pressure_map.direction.toString()+":" //textstring += pressure_map.stage.toString()+":" //textstring += pressure_map.step.toString()+":" console.debug("avans 1111 update_pressure: ", pressure_map.pressure) pressure = pressure_map.pressure add_record(pressure_map.pressure) pressureDisplayInput(Number(pressure_map.pressure)) if(pressure_map.step === 3){ // keep pressure if(pressure_map.stage === 0){ //sys test syskpArray.push(Number(pressure_map.pressure)) //console.debug("avans 1111 sys keep pressure: ", pressure_map.pressure) }else if(pressure_map.stage === 1){ //valve test valvekpArray.push(Number(pressure_map.pressure)) } } allArray.push(Number(pressure_map.pressure)) } function add_record(str){ var obj={} obj.pressure = str recordtable.modelData.append(obj) } function cleardata(){ recordtable.modelData.clear() allArray = [] syskpArray = [] valvekpArray = [] curveDisplay.spline.clear() pressureCnt =0 resulttable.systemPressure_delta = " "; resulttable.systemPressure_fontcolor="black" resulttable.systemPressure_pass = "未知"; resulttable.valvePressure_delta = " "; resulttable.valvePressure_fontcolor ="black" resulttable.valvePressure_pass = "未知"; statetable.state_str1 = " "; statetable.state_str2 = " "; } function pressureDisplayInput(number){ pressureCnt++ m_maxY = (m_maxY < number)? number:m_maxY m_minY = (m_minY > number)? number:m_minY curveDisplay.setRange_Y(m_minY-2.0, m_maxY+2.0) if(pressureCnt <= 180){ //dataArray.push(number) curveDisplay.spline.append(pressureCnt-1,number) } else{ curveDisplay.setRange_X(0, pressureCnt-1) curveDisplay.spline.append(pressureCnt-1,number) /* dataArray.push(number) dataArray.shift() curveDisplay.spline.clear() for(var i=0; i<61; i++){ curveDisplay.spline.append(i,dataArray[i]) } */ } //gauge.value = number } function show_systemresult(delta, bPassed) { if(bPassed){ resulttable.systemPressure_delta = delta; resulttable.systemPressure_fontcolor="green" resulttable.systemPressure_pass = "合格"; }else{ resulttable.systemPressure_delta = delta; resulttable.systemPressure_fontcolor="red" resulttable.systemPressure_pass = "超标"; } } function show_valveresult(delta, bPassed) { if(bPassed){ resulttable.valvePressure_delta = delta; resulttable.valvePressure_fontcolor ="green" resulttable.valvePressure_pass = "合格"; }else{ resulttable.valvePressure_delta = delta; resulttable.valvePressure_fontcolor="red" resulttable.valvePressure_pass = "超标"; } } function update_runstate(str1, str2) { statetable.state_str1 = str1; statetable.state_str2 = str2; } function test_stoped(){ startStopButton.running = false; } // Component{ // id:componet DynamicGroupBox{ id:groupbox //x:width //x:0 title: "油气回收系统密封检测 第"+compartment_id+"仓: 容积"+volume+"(L)" //width: 1024 //height: 768 anchors.centerIn: parent anchors.fill: parent function show(){ animationShow.running = true } function exit(){ //BreatheTestJs.exit = true animationExit.running = true //startStopButton.running = false //stopTimer.start() } function allTestGeneratePicture(){ var filename = root.carplate+"_"+root.compartment_id+"_all" reportPicture_all.delayms = 300 reportPicture_all.generatePicture(filename, allArray) } function sysTestGeneratePicture(){ var filename = root.carplate+"_"+root.compartment_id+"_sys" reportPicture_sys.delayms = 500 reportPicture_sys.generatePicture(filename, syskpArray) } function valveTestGeneratePicture(){ var filename = root.carplate+"_"+root.compartment_id+"_valve" reportPicture_valve.delayms = 800 reportPicture_valve.generatePicture(filename, valvekpArray) } /* //加载任务动画效果 NumberAnimation { id: animationShow target: groupbox property: "x" from: groupbox.x to: 0 duration: 500 } NumberAnimation { id: animationExit target: groupbox property: "x" from: groupbox.x to: 1024 duration: 500 } */ //报告 Connections{ target: reportButton onUserClicked:{ //if(allArray.length > 0){ console.log("allTestGeneratePicture") groupbox.allTestGeneratePicture() // } //if(syskpArray.length > 0){ console.log("sysTestGeneratePicture") groupbox.sysTestGeneratePicture() // } // if(valvekpArray.length > 0){ console.log("valveTestGeneratePicture") groupbox.valveTestGeneratePicture() // } testService.reportpic_Ready(compartment_id); if(testService.check_alltest_ok()){ var fileName = root.carplate var text = getWordSaveFileName(fileName) console.log(text) saveWordDialog.currentFile = getWordSaveFileName(fileName) saveWordDialog.open() } } } FileDialog { id: saveWordDialog title: "保存为" //nameFilters: [ "Word files (*.doc)"] nameFilters: [ "Word files (*.doc)", "Text files (*.pdf)"] fileMode: FileDialog.SaveFile onAccepted: { var savePath = file.toString().substring(8) console.log("saveWordDialog savePath:") console.log(savePath) //reportWord.generateBreatheValveWord(savePath,para,obj1,obj2,obj3) testService.genReport(savePath, "D:/tmp/") } } Column{ anchors.left: parent.left anchors.leftMargin: 3 anchors.top: parent.top anchors.topMargin: 10 spacing: 0 Row{ x:-10 CurveDisplay{ id:curveDisplay anchors.verticalCenter: parent.verticalCenter width: 900 height: 460 axisxMax:180 axisxMin:0 axisyMax:14 axisyMin:0 name:"横轴时间(秒) 纵轴压力(kPa)" } Item { id:button_root width: 360 height: 460 Column{ id:button_column spacing: 10 Rectangle{ id:buttonWindow //anchors.fill: parent width: 350 height: 70 color: "white" radius: 6 border.color: "black" Row{ anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter spacing: 50 StartStopButton{ id:startStopButton width: 50 height: 50 anchors.verticalCenter: parent.verticalCenter onRunningChanged: { if(running){ //clearCurveDisplay() cleardata() bStart = testService.tstart(compartment_id, test_direction) if(!bStart){ running=false; } }else{ if(bStart){ testService.tstop(compartment_id) bStart=false } } } } ReportButton{ id:reportButton width: 50 height: 50 anchors.verticalCenter: parent.verticalCenter } } } Rectangle{ id:test_selrect //anchors.fill: parent anchors.margins: 10 width: 350 height: 50 color: "white" radius: 6 border.color: "black" UserComboBox{ id:test_comboBox //anchors.fill:parent implicitWidth:350 implicitHeight:50 bgColor:"#D2D5D9" model: ["正压密闭性检测","负压密闭性检测"] onCurrentTextChanged: { //root.standard_name = currentText test_direction = currentIndex console.log("choose test direction : "+test_direction) if(0 == currentIndex){ resulttable.titlestr = currentText }else{ resulttable.titlestr = currentText } } } } Rectangle{ id:pressureWindow //anchors.fill: parent anchors.margins: 10 width: 350 height: 100 color: "white" radius: 6 border.color: "black" Text { id: pressurekpa anchors.right: pressureWindow.right anchors.verticalCenter: parent.verticalCenter text: qsTr("kPa ") //font: 40 font.bold: true font.pixelSize: 35 } Rectangle{ id:pressure_rect anchors.verticalCenter: parent.verticalCenter anchors.right: pressurekpa.left; width: 250 height: 80 LCDNumber{ id:lcd_pressure anchors.centerIn: parent text: root.pressure } } } Rectangle{ id:resultWindow //anchors.fill: parent anchors.margins: 5 width: 350 height: 100 color: "white" radius: 6 border.color: "black" ResultTable{ id:resulttable anchors.fill: parent } } Rectangle{ id:stateWindow //anchors.fill: parent anchors.margins: 5 width: 350 height: 100 color: "white" radius: 6 border.color: "black" StateTable{ id:statetable anchors.fill: parent } } } } } Row{ id: records spacing: 10 function dataRandomSet(modelData,max){ for(var i=0;i