494 lines
17 KiB
QML
494 lines
17 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import QtCharts
|
|
import CustomPlot 1.0
|
|
import "./common"
|
|
Rectangle {
|
|
id: self
|
|
property var currentStepIndex: -1
|
|
property var currentIndex: 0
|
|
property var maxTValue: 0
|
|
property var minTValue: 0
|
|
property var minTemp: 0
|
|
property var maxTemp: 90
|
|
property var stepInstructId: ""
|
|
property var stepIncId: ""
|
|
property var targetTemperature: 35
|
|
property var currentTemperature: 0
|
|
property var progress: stepModel.count > 0 ? (currentIndex / stepModel.count) : 0.0
|
|
property var imageNames: ["方位1", "方位2"]
|
|
property var lstDetialTexts: ["Inc 126.24° Gtf 45°", "Inc 54.76° Gtf 225°"]
|
|
property var g_inc: "0°"
|
|
property var g_gtf: "0°"
|
|
property var taskId: ""
|
|
property var taskSrc: ""
|
|
property var taskName: ""
|
|
gradient: Gradient {
|
|
GradientStop { position: 0.0; color: "#ecf3fb" } // 左上角颜色
|
|
GradientStop { position: 1.0; color: "#b7d6fb" } // 右上角颜色
|
|
orientation: Gradient.Horizontal
|
|
}
|
|
ListModel{
|
|
id: stepModel
|
|
ListElement{name:"方位1标定"; tips: "请放置到1方位"; _state: "0"; src: "./step1.png"; endTime: ""}
|
|
ListElement{name:"方位2标定"; tips: "请放置到2方位"; _state: "0"; src: "./方位2.png"; endTime: ""}
|
|
}
|
|
Component.onCompleted: {
|
|
// stopBd.connect(onStopBd)
|
|
taskActuatorManager.executeFinished.connect(onExecuteFinished)
|
|
}
|
|
|
|
function startSteps()
|
|
{
|
|
aw_Digital = []
|
|
clearSteps()
|
|
task5State = "1"
|
|
stepIncId = ""
|
|
stepInstructId = ""
|
|
currentStepIndex = 0
|
|
taskModel.get(curTaskIndex).state = task5State
|
|
tipText.visible = true
|
|
runIncStep()
|
|
}
|
|
|
|
function clearSteps(){
|
|
tipText.visible = false
|
|
for(var i = 0; i < stepModel.count; i++)
|
|
{
|
|
stepModel.get(i)._state = "0"
|
|
}
|
|
currentStepIndex = -1
|
|
currentIndex = 0
|
|
}
|
|
Item
|
|
{
|
|
id: btnBar
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.top: parent.top
|
|
anchors.topMargin: 13
|
|
anchors.leftMargin: 24
|
|
anchors.rightMargin: 24
|
|
height: 152
|
|
z:2
|
|
|
|
Rectangle
|
|
{
|
|
id: rectBtn
|
|
width: 253
|
|
height: 152
|
|
radius: 9
|
|
QxToolButton{
|
|
width: 195
|
|
height: 107
|
|
text:"开始测试"
|
|
textColor: "#FFFFFF"
|
|
iconSource: "../resource/start.png"// : "../resource/stop.png"
|
|
bgmSource: text == "开始测试" ? "../resource/startbutton.png" : "../resource/stopbutton.png"
|
|
anchors.centerIn: parent
|
|
onClicked: {
|
|
self.visible = false
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle{
|
|
id: taskList
|
|
anchors.leftMargin: 22
|
|
anchors.left: rectBtn.right
|
|
anchors.right: parent.right
|
|
height: 152
|
|
radius: 9
|
|
Row{
|
|
spacing: 10
|
|
anchors.centerIn: parent
|
|
Item{
|
|
id: textItem
|
|
width: 100; height: 100
|
|
Label{
|
|
text: taskName
|
|
font.pixelSize: 28
|
|
anchors.centerIn: parent
|
|
}
|
|
}
|
|
Image{
|
|
anchors.verticalCenter: textItem.verticalCenter
|
|
source: taskSrc
|
|
width: 572
|
|
height: 79
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Item{
|
|
anchors.top: btnBar.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
anchors.leftMargin: 24
|
|
anchors.rightMargin: 24
|
|
anchors.topMargin: 19
|
|
anchors.bottomMargin: 13
|
|
z:1
|
|
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
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
Image{
|
|
source: "./resource/state"+_state+".png"
|
|
width: 20
|
|
height: 20
|
|
}
|
|
|
|
QxListText{
|
|
text: imageNames[index]
|
|
}
|
|
|
|
QxListText{
|
|
text: lstDetialTexts[index]
|
|
color: "#007EFF"
|
|
}
|
|
}
|
|
QxListText{
|
|
text: _state == "0" ? "未完成" :(_state == "2" ? endTime : "进行中")
|
|
color: _state == "0" ? "#BFBFBF" :(_state == "2" ? "#007EFF" : "#40A362")
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.right: stopButton.left
|
|
anchors.rightMargin: 10
|
|
}
|
|
Rectangle
|
|
{
|
|
id: stopButton
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 49
|
|
width: _state == "1" ? 30: 0
|
|
height: 30
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
radius: 5
|
|
border.width: 1
|
|
border.color: "#e5e5e5"
|
|
visible: _state == "1"
|
|
Rectangle{
|
|
anchors.centerIn: parent
|
|
width: 10
|
|
height: 10
|
|
radius: 2
|
|
color: "red"
|
|
}
|
|
MouseArea{
|
|
anchors.fill: parent
|
|
onClicked:
|
|
{
|
|
_state = "2"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle{
|
|
id: tipText
|
|
width: 315
|
|
height: 170
|
|
radius: 19
|
|
z:2
|
|
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: "当前方位 Inc:" + g_inc + " Gtf:" + g_gtf
|
|
}
|
|
}
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Rectangle{
|
|
id: chartRect
|
|
anchors.left: stepLst.right
|
|
anchors.top: stepLst.top
|
|
anchors.bottom: stepLst.bottom
|
|
anchors.right: parent.right
|
|
anchors.leftMargin: 10
|
|
radius: 9
|
|
CustomPlot
|
|
{
|
|
id: customPlot
|
|
anchors.fill: parent
|
|
}
|
|
// ChartView {
|
|
// id: chartView
|
|
// // title: "温度"
|
|
// //![1]
|
|
// anchors.fill: parent
|
|
// legend.alignment: Qt.AlignTop
|
|
// antialiasing: true
|
|
// ValueAxis {
|
|
// id: valueAxisX
|
|
// titleText: "点数/个"
|
|
// min: minTValue
|
|
// max: maxTValue == 0 ? 20 : maxTValue
|
|
// labelFormat: "%.0f"
|
|
// tickCount: 10
|
|
// }
|
|
// ValueAxis{
|
|
// id: valueAxisY
|
|
// min: minTemp > 30 ? minTemp - 30 : 0
|
|
// max: maxTemp + 10
|
|
// titleText: "温度/mV"
|
|
// tickCount: 21
|
|
// tickInterval: 0.5
|
|
// labelFormat: "%.0f"
|
|
// }
|
|
// ValueAxis{
|
|
// id: valueAxisY2
|
|
// min: -1
|
|
// max: 1
|
|
// titleText: "姿态/V"
|
|
// tickCount: 21
|
|
// tickInterval: 0.5
|
|
// labelFormat: "%.1f"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsAsTemperature
|
|
// axisX: valueAxisX
|
|
// axisY: valueAxisY
|
|
// name: "tempAs"
|
|
// color: "#de8204"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsAbTemperature
|
|
// axisX: valueAxisX
|
|
// axisY: valueAxisY
|
|
// name: "tempAb"
|
|
// color: "#ce743a"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsMTemperature
|
|
// axisX: valueAxisX
|
|
// axisY: valueAxisY
|
|
// name: "tempM"
|
|
// color: "#316846"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsxAValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "ax"
|
|
// color: "#2695B4"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsyAValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "ay"
|
|
// color: "#bf3eff"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lszAValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "az"
|
|
// color: "#ec610a"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsxMValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "mx"
|
|
// color: "#6016b8"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lsyMValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "my"
|
|
// color: "#76D3D9"
|
|
// }
|
|
// QxLineSeries {
|
|
// id: lszMValue
|
|
// axisX: valueAxisX
|
|
// axisYRight: valueAxisY2
|
|
// name: "mz"
|
|
// color: "#437b5a"
|
|
// }
|
|
// }
|
|
|
|
}
|
|
}
|
|
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, "skip": 0})
|
|
}
|
|
|
|
function runIncStep()
|
|
{
|
|
var handel = taskModel.get(curTaskIndex)
|
|
var group = parseInt(handel.v1)
|
|
var groupcount = parseInt(handel.v3)
|
|
var total = group*groupcount
|
|
var firstName = handel.v5 == "数字量" ? "数字" : "模拟"
|
|
stepIncId = execute(firstName+"加速度计采集",{"total": 1})
|
|
}
|
|
|
|
function onStopBd(){
|
|
if(isStart)
|
|
{
|
|
stopExecute(stepInstructId)
|
|
clearSteps()
|
|
}
|
|
}
|
|
Timer {
|
|
interval: 1; running: parent.visible; repeat: running
|
|
onTriggered:
|
|
{
|
|
var keys = []
|
|
var datas = []
|
|
for(var i = 0; i < 5000; i++)
|
|
{
|
|
keys.push(Number(i))
|
|
datas.push(Math.random() * (20 - 10) + 10)
|
|
}
|
|
customPlot.setGraphData(keys, datas)
|
|
}
|
|
}
|
|
function onExecuteFinished(id)
|
|
{
|
|
if(id == stepInstructId && isStart)
|
|
{
|
|
console.info("onExecuteFinished",currentStepIndex)
|
|
var info = common.getG("A_Digital")
|
|
currentTemperature = info.x_Atemp
|
|
lsAsTemperature.append(Number(maxTValue), currentTemperature)
|
|
lsAbTemperature.append(Number(maxTValue), info.a_tempb)
|
|
lsMTemperature.append(Number(maxTValue), info.m_temp)
|
|
lsxAValue.append(Number(maxTValue), info.x_Avalue)
|
|
lsyAValue.append(Number(maxTValue), info.y_Avalue)
|
|
lszAValue.append(Number(maxTValue), info.z_Avalue)
|
|
lsxMValue.append(Number(maxTValue), info.x_Mvalue)
|
|
lsyMValue.append(Number(maxTValue), info.y_Mvalue)
|
|
lszMValue.append(Number(maxTValue), info.z_Mvalue)
|
|
|
|
if(maxTValue - minTValue > 20)
|
|
minTValue = maxTValue - 20;
|
|
maxTValue++
|
|
if ( maxTemp < parseFloat(currentTemperature) )
|
|
{
|
|
maxTemp = parseFloat(currentTemperature)
|
|
}
|
|
console.info("currentStepIndex:",currentStepIndex,"currentTemperature:" + currentTemperature,"targetTemperature:" + targetTemperature)
|
|
if (currentStepIndex >= 0)
|
|
{
|
|
if(stepModel.get(currentStepIndex)._state == "2")
|
|
{
|
|
|
|
}
|
|
else{
|
|
aw_Digital.push(info)
|
|
runStep()
|
|
}
|
|
}
|
|
}
|
|
else if(id == stepIncId && isStart)
|
|
{
|
|
if(tipText.visible)
|
|
{
|
|
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)
|
|
g_inc = parseFloat(data.inc).toFixed(2) + "°"
|
|
g_gtf = parseFloat(data.gtf).toFixed(2) + "°"
|
|
runIncStep()
|
|
}
|
|
}
|
|
}
|
|
|
|
function show()
|
|
{
|
|
visible = true
|
|
}
|
|
|
|
|
|
}
|