TG-PlatformPlus/qml/debug/hsvp/Steps4.qml

372 lines
13 KiB
QML

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 == 3
property var stepInstructId: ""
property var childStepIndex: 0
property var imageSoure: "./resource/step2/default.JPG"
property var imageText: ""
property var m_DigitalYz: []
property var progress: stepModel.count > 0 ? (currentIndex / stepModel.count) : 0.0
property var imageNames: ["1-1", "1-2", "1-3","1-4","2-1", "2-2", "2-3","2-4","3-1", "3-2", "3-3","3-4"]
ListModel{
id: stepModel
}
Component.onCompleted: {
stopBd.connect(onStopBd)
taskActuatorManager.executeFinished.connect(onExecuteFinished)
clearSteps()
}
onIsStartChanged: {
if (isStart) {
console.info("开始步骤")
startSteps()
}
}
ListModel{
id: _hmhzModel
}
function startSteps()
{
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)
templateName = "calculation.xlsx"
calibrate.setHmhzParams(firstPath + appPath + "/template/" + templateName, data)
var list = calibrate.getHmhzList(firstPath + appPath + "/template/" + templateName)
_hmhzModel.clear()
for (var i = 0; i < list.length; i++) {
var item = list[i]
_hmhzModel.append({ "v1": parseFloat(item.v1).toFixed(0), "v2": parseFloat(item.v2).toFixed(0), "v3": parseFloat(item.v3).toFixed(0), "v4": parseFloat(item.v4).toFixed(0), "azi": parseFloat(item.azi).toFixed(2) })
}
m_DigitalYz = []
clearSteps()
task4State = "1"
currentStepIndex = 0
taskModel.get(curTaskIndex).state = task4State
tipText.visible = true
}
function clearSteps(){
tipText.visible = false
stepModel.clear()
currentStepIndex = -1
imageSoure = "./resource/step2/default.JPG"
imageText = ""
currentIndex = 0
for(var i = 0; i < _hmhzModel.count; i++)
{
var handel = _hmhzModel.get(i)
var detialText = ""
detialText += "X [" + handel.v2 + "] "
detialText += "Y [" + handel.v3 + "] "
detialText += "Z [" + handel.v4 + "]"
stepModel.append({ "_state": "0","detialText":detialText,"azi":handel.azi,"cazi":"", "endTime": ""})
}
}
function checkAzi(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/ 1.5
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: "方位角 "+azi+"°"
}
QxListText{
text: detialText
color: "#007EFF"
}
}
QxListText{
anchors.right: stateText.left
anchors.rightMargin: 5
text: "Azi: "+cazi + "°"
color: checkAzi(azi,cazi) ? "#007EFF" : "red"
visible: _state == "2"
}
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: imageSoure
QxText{
text: imageText
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"
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: "设备是否放置就绪?"
}
}
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: {
runHmhz()
}
}
}
}
}
property var tDelay: 6000
Timer {
id: getTimer
interval: tDelay; running: false; repeat: false
onTriggered: {
runStep()
currentStepIndex++
if (currentIndex < stepModel.count-1)
currentIndex++
console.info("currentIndex: " + currentIndex, "currentStepIndex: " + currentStepIndex,"stepModel.count",stepModel.count)
}
}
function makeImageSource(handel)
{
var imageName = ""
if(handel.v2 != "0")
{
imageName += "x"
}
if(handel.v3 != "0")
{
imageName += "y"
}
if(handel.v4 != "0")
{
imageName += "z"
}
imageSoure = "./resource/step2/" + imageName + ".JPG"
imageText = handel.v2 + "nT " + handel.v3 + "nT " + handel.v4 + "nT"
}
function runHmhz()
{
tipText.visible = false
var handel = _hmhzModel.get(currentStepIndex)
stepModel.get(currentStepIndex)._state = "1"
makeImageSource(handel)
childStepIndex = 1
stepInstructId = execute("亥姆霍兹线圈设定",{"T":handel.v1,"X":handel.v2,"Y":handel.v3,"Z":handel.v4})
}
function runStep()
{
tipText.visible = false
var handel = taskModel.get(curTaskIndex)
stepModel.get(currentStepIndex)._state = "1"
var group = parseFloat(handel.v1)
var groupcount = parseFloat(handel.v3)
var total = group*groupcount
var firstName = handel.v5 == "数字量" ? "数字" : "模拟"
childStepIndex = 2
stepInstructId = execute(firstName+"加速度计采集",{"total":total})
}
function onStopBd(){
if(isStart)
{
stopExecute(stepInstructId)
clearSteps()
}
}
function onExecuteFinished(id)
{
if(id == stepInstructId && isStart)
{
if(currentStepIndex < stepModel.count)
{
if(childStepIndex == 1)
{
getTimer.start()
}
else
{
var a_Digital = common.getG("A_Digital")
var x_value = (a_Digital && a_Digital.x_Mvalue !== undefined) ? a_Digital.x_Mvalue : ""
var y_value = (a_Digital && a_Digital.y_Mvalue !== undefined) ? a_Digital.y_Mvalue : ""
var z_value = (a_Digital && a_Digital.z_Mvalue !== undefined) ? a_Digital.z_Mvalue : ""
var m_temp = (a_Digital && a_Digital.m_temp !== undefined) ? a_Digital.m_temp : ""
var templateName = "MWD.xlsx"
calibrate.setMValue(firstPath + appPath + "/template/" + templateName,{"hx": x_value, "hy": y_value, "hz": z_value, "th": m_temp})
var data = calibrate.getMWD(firstPath + appPath + "/template/" + templateName)
stepModel.get(currentStepIndex-1).cazi = parseFloat(data.zai).toFixed(2) + ""
m_DigitalYz.push(a_Digital)
stepModel.get(currentStepIndex-1)._state = "2"
stepModel.get(currentStepIndex-1).endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
runHmhz()
}
}
else{
var a_Digital = common.getG("A_Digital")
var x_value = (a_Digital && a_Digital.x_Mvalue !== undefined) ? a_Digital.x_Mvalue : ""
var y_value = (a_Digital && a_Digital.y_Mvalue !== undefined) ? a_Digital.y_Mvalue : ""
var z_value = (a_Digital && a_Digital.z_Mvalue !== undefined) ? a_Digital.z_Mvalue : ""
var m_temp = (a_Digital && a_Digital.m_temp !== undefined) ? a_Digital.m_temp : ""
var templateName = "MWD.xlsx"
calibrate.setMValue(firstPath + appPath + "/template/" + templateName,{"hx": x_value, "hy": y_value, "hz": z_value, "th": m_temp})
var data = calibrate.getMWD(firstPath + appPath + "/template/" + templateName)
stepModel.get(currentStepIndex-1).cazi = parseFloat(data.zai).toFixed(2) + ""
m_DigitalYz.push(a_Digital)
stepModel.get(currentStepIndex-1)._state = "2"
stepModel.get(currentStepIndex-1).endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
currentIndex = stepModel.count
currentStepIndex = -1
imageSoure = "./resource/step2/default.JPG"
imageText = ""
task4State = "2"
taskModel.get(curTaskIndex).state = task4State
reportJson["m_DigitalYz"] = m_DigitalYz
execute("亥姆霍兹线圈设定",{"T":800,"X":"NAN","Y":"NAN","Z":"NAN"})
runNextStep()
skLayout.currentIndex = curTaskIndex
}
}
}
}