import QtQuick import QtQuick.Controls import QtQuick.Layouts import "./common" Item { id: self property var currentStepIndex: -1 property var currentIndex: 0 property var isStart: curTaskIndex == 1 property var stepInstructId: "" property var progress: stepModel.count > 0 ? (currentIndex / (stepModel.count)) : 0.0 property var imageNames: ["1-1", "1-3","2-1", "2-2", "2-3","2-4"] property var imageTexts: ["东北上", "东南下", "北上东", "上南东", "南下东","下北东"] property var lstDetialTexts: ["X [东] Y [北] Z [上]","X [东] Y [南] Z [下]","X [北] Y [上] Z [东]","X [上] Y [南] Z [东]","X [南] Y [下] Z [东]","X [下] Y [北] Z [东]"] property var a_DigitalYz: [] ListModel{ id: stepModel ListElement{name:"方位1标定"; tips: "请放置到1方位"; _state: "0"; src: "./step1.png"; endTime: ""; inc: ""; gtf: ""; tinc: "180"; tgtf: ""} ListElement{name:"方位2标定"; tips: "请放置到2方位"; _state: "0"; src: "./step3.png"; endTime: ""; inc: ""; gtf: ""; tinc: "0"; tgtf: ""} ListElement{name:"方位3标定"; tips: "请放置到3方位"; _state: "0"; src: "./step5.png"; endTime: ""; inc: ""; gtf: ""; tinc: "90"; tgtf: "0"} ListElement{name:"方位4标定"; tips: "请放置到4方位"; _state: "0"; src: "./step6.png"; endTime: ""; inc: ""; gtf: ""; tinc: "90"; tgtf: "90"} ListElement{name:"方位5标定"; tips: "请放置到5方位"; _state: "0"; src: "./step7.png"; endTime: ""; inc: ""; gtf: ""; tinc: "90"; tgtf: "180"} ListElement{name:"方位6标定"; tips: "请放置到6方位"; _state: "0"; src: "./step8.png"; endTime: ""; inc: ""; gtf: ""; tinc: "90"; tgtf: "270"} } Component.onCompleted: { stopBd.connect(onStopBd) taskActuatorManager.executeFinished.connect(onExecuteFinished) } onIsStartChanged: { if (isStart) { startSteps() } } function startSteps() { clearSteps() task2State = "1" currentStepIndex = 0 a_DigitalYz = [] taskModel.get(curTaskIndex).state = task2State tipText.visible = true } function clearSteps(){ tipText.visible = false for(var i = 0; i < stepModel.count; i++) { stepModel.get(i)._state = "0" } currentStepIndex = -1 currentIndex = 0 } function checkInc(a1, a2) { var a1 = parseFloat(a1).toFixed(2) var a2 = parseFloat(a2).toFixed(2) if (a1 > 180) a1 = a1 - 180 if (a2 > 180) a2 = a2 - 180 if (a1 < 0) a1 = a1 + 180 if (a2 < 0) a2 = a2 + 180 if (Math.abs(a1 - a2) <= 0.1) { return true } return false } function checkGtf(a1, a2) { var a1 = parseFloat(a1).toFixed(2) var a2 = parseFloat(a2).toFixed(2) if (a1 > 360) a1 = a1 - 360 if (a2 > 360) a2 = a2 - 360 if (a1 < 0) a1 = a1 + 360 if (a2 < 0) a2 = a2 + 360 if (Math.abs(a1 - a2) <= 0.1) { return true } return false } Rectangle{ id: stepLst width: parent.width/ 2 anchors.top: parent.top anchors.bottom: parent.bottom radius: 9 clip: true QxText{ id: tTitle text: "标定进度" font.pixelSize: 20 anchors.left: parent.left anchors.leftMargin: 30 anchors.top: parent.top anchors.topMargin: 18 } ListView{ id: listView model: stepModel boundsBehavior: Flickable.StopAtBounds anchors.top: tTitle.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom anchors.leftMargin: 30 anchors.topMargin: 39 delegate: Item{ id: itemDelegate width: ListView.view.width height: 42 Row{ spacing: 10 Image{ source: "./resource/state"+_state+".png" width: 20 height: 20 } QxListText{ text: imageNames[index] } QxListText{ text: lstDetialTexts[index] color: "#007EFF" } } QxListText{ id: incText text: "Inc:"+inc+"°" visible: _state == "2" && inc != "" color: checkInc(inc,tinc) ? "#007EFF" : "red" anchors.right: gtfText.visible ? gtfText.left : stateText.left anchors.rightMargin: 5 } QxListText{ id: gtfText text: "Gtf:"+gtf+"°" visible: _state == "2" && tgtf != "" && gtf != "" color: checkGtf(gtf,tgtf) ? "#007EFF" : "red" anchors.right: stateText.left anchors.rightMargin: 5 } QxListText{ id: stateText text: _state == "0" ? "未完成" :(_state == "2" ? endTime : "进行中") color: _state == "0" ? "#BFBFBF" :(_state == "2" ? "#007EFF" : "#40A362") anchors.right: parent.right anchors.rightMargin: 49 } } } } Rectangle{ id: stepText anchors.left: stepLst.right anchors.leftMargin: 10 anchors.right: parent.right anchors.top: stepLst.top anchors.bottom: stepLst.bottom radius: 9 Image{ anchors.left: parent.left anchors.leftMargin: 23 anchors.right: parent.right anchors.rightMargin: 23 anchors.top: parent.top anchors.topMargin: 24 anchors.bottom: parent.bottom anchors.bottomMargin: 24 source: currentStepIndex > -1 ? "./resource/step1/"+ imageNames[currentStepIndex]+".JPG" : "./resource/step1/default.jpg" QxText{ text: currentStepIndex > -1 ? imageTexts[currentStepIndex] : "" anchors.top: parent.top anchors.right: parent.right anchors.rightMargin: 20 anchors.topMargin: 20 font.pixelSize: 25 font.bold: true color: "#007EFF" } } } Rectangle{ id: tipText width: 315 height: 170 radius: 19 color: "#FFFFFF" border.color: "#e5e5e5" border.width: 1 anchors.centerIn: parent visible: false Row { spacing: 4 anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 37 Image{ width: 20 height: 20 source: "./resource/tip.png" } QxText{ font.pixelSize: 16 text: "请放置到" + imageNames[currentStepIndex] + " " + imageTexts[currentStepIndex] + "方位" } } Rectangle{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.bottomMargin: 37 width: 129 height: 39 radius: 8 color: "#007EFF" QxText{ text:"已就绪" font.pixelSize: 14 anchors.centerIn: parent color: "#FFFFFF" } MouseArea{ anchors.fill: parent onClicked: { runStep() } } } } function runStep() { tipText.visible = false var handel = taskModel.get(curTaskIndex) stepModel.get(currentStepIndex)._state = "1" var group = parseInt(handel.v1) var groupcount = parseInt(handel.v3) var total = group*groupcount var firstName = handel.v5 == "数字量" ? "数字" : "模拟" stepInstructId = execute(firstName+"加速度计采集",{"total":total}) } function onStopBd(){ if(isStart) { stopExecute(stepInstructId) clearSteps() } } function onExecuteFinished(id) { if(id == stepInstructId && isStart) { var a_Digital = common.getG("A_Digital") var x_value = (a_Digital && a_Digital.x_Avalue !== undefined) ? a_Digital.x_Avalue : "" var y_value = (a_Digital && a_Digital.y_Avalue !== undefined) ? a_Digital.y_Avalue : "" var z_value = (a_Digital && a_Digital.z_Avalue !== undefined) ? a_Digital.z_Avalue : "" var x_temp = (a_Digital && a_Digital.x_Atemp !== undefined) ? a_Digital.x_Atemp : "" var y_temp = (a_Digital && a_Digital.y_Atemp !== undefined) ? a_Digital.y_Atemp : "" var z_temp = (a_Digital && a_Digital.z_Atemp !== undefined) ? a_Digital.z_Atemp : "" var templateName = "MWD.xlsx" calibrate.setAValue(firstPath + appPath + "/template/" + templateName,{"ax": x_value, "ay": y_value, "az": z_value, "tx": x_temp, "ty": y_temp, "tz": z_temp}) var data = calibrate.getMWD(firstPath + appPath + "/template/" + templateName) a_DigitalYz.push(a_Digital) stepModel.get(currentStepIndex).inc = parseFloat(data.inc).toFixed(2) + "" stepModel.get(currentStepIndex).gtf = parseFloat(data.gtf).toFixed(2) + "" stepModel.get(currentStepIndex)._state = "2" stepModel.get(currentStepIndex).endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss") if(currentStepIndex < stepModel.count-1) { tipText.visible = true currentStepIndex++ currentIndex++ } else{ task2State = "2" currentIndex = stepModel.count currentStepIndex = -1 taskModel.get(curTaskIndex).state = task2State reportJson["a_DigitalYz"] = a_DigitalYz save_json("a_DigitalYz.json", {"infos":a_DigitalYz}) runNextStep() skLayout.currentIndex = curTaskIndex } } } }