TG-PlatformPlus/qml/debug/testfixture/Test.qml

401 lines
13 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "./common"
Item {
id: self
property var curTestInfo: null
property var errorState: 0
property var curTaskId: 0
property var curTaskState: 0
signal sig_updateWorkstate()
signal sig_stopTask(var state)
property var cards: []
property var curCardIndex: 0
property bool isFinish: true
Timer {
id: testTimer
interval: 10
running: false
repeat: true
onTriggered: {
running = false
errorState = Number(common.getG("ErrorState"))
curTestInfo = common.getG("test_info")
// console.info("curTestInfo:", JSON.stringify(curTestInfo))
curTaskState = common.getG("task_state")
if (curTestInfo != 0)
{
curTestInfo.errorState = errorState
if(errorState != 0)
{
tipText.visible = true
}
sig_updateWorkstate()
}
if (curTaskState == 2 && cbTestProgram.currentText != "全流程")
{
if(cards.length > 0)
{
curTaskId = execute(cbTestProgram.currentText, {"pos": cards.pop()})
isFinish = false
}
else{
isFinish = true
}
sig_stopTask("finish")
}
else if (cbTestProgram.currentText == "全流程")
{
if (curTaskState == 3)
{
isFinish = true
sig_stopTask("finish")
}
else if (curTaskState == 2)
{
sig_stopTask("finish")
}
}
running = true
}
}
Item
{
id: btnBar
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 20
height: 152
z:2
Rectangle
{
id: rectBtn
width: 253
height: 152
radius: 9
QxToolButton{
width: 197
height: 107
anchors.centerIn: parent
text: isFinish ? "开始执行" : "结束执行"
textColor: text == "开始执行" ? "#FFFFFF" : "#007EFF"
iconSource: text == "开始执行" ? "../resource/start.png" : "../resource/stop.png"
bgmSource: text == "开始执行" ? "../resource/startbutton.png" : "../resource/stopbutton.png"
onClicked: {
if(isFinish)
{
// executeVirtualTask("初始化连接温箱", ["断开保温箱", "连接保温箱"])
cards = []
if(cbCard4.checked){
cards.push(4)
}
if(cbCard3.checked){
cards.push(3)
}
if(cbCard2.checked){
cards.push(2)
}
if(cbCard1.checked){
cards.push(1)
}
if (cbTestProgram.currentText == "全流程")
{
cards = []
curTaskId = execute(cbTestProgram.currentText)
}
else
{
if(cards.length > 0)
{
curTaskId = execute(cbTestProgram.currentText, {"pos": cards.pop()})
}
}
isFinish = false
testTimer.start()
}
else
{
testTimer.stop()
stopExecute(curTaskId)
sig_stopTask("")
isFinish = true
tipText.visible = false
}
}
}
}
Rectangle{
id: taskList
anchors.leftMargin: 22
anchors.left: rectBtn.right
anchors.right: parent.right
height: 152
radius: 9
Row
{
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 40
anchors.rightMargin: 40
anchors.verticalCenter: parent.verticalCenter
spacing: 20
Item{
width: 253
height: 100
// border.color: "#D2D2D2"
// border.width: 1
// radius: 9
Column
{
anchors.verticalCenter: parent.verticalCenter
spacing: 20
Row{
spacing: 5
CheckBox{
id: cbCard1
text: "板1"
enabled: cbTestProgram.currentIndex != 0
font.pixelSize: 15
checked: true
}
CheckBox{
id: cbCard2
text: "板2"
enabled: cbTestProgram.currentIndex != 0
font.pixelSize: 15
checked: true
}
CheckBox{
id: cbCard3
text: "板3"
enabled: cbTestProgram.currentIndex != 0
font.pixelSize: 15
checked: true
}
CheckBox{
id: cbCard4
text: "板4"
enabled: cbTestProgram.currentIndex != 0
font.pixelSize: 15
checked: true
}
}
ComboBox{
id: cbTestProgram
width: 190
height: 40
font.pixelSize: 15
model: ["全流程", "烧写测试程序", "功能测试", "烧写出厂程序"]
currentIndex: 0
}
}
}
Rectangle{
width: 1
height: 50
anchors.verticalCenter: parent.verticalCenter
color: "#D2D2D2"
}
Item{
width: 10
height:1
}
Item{
width: 400
height: 100
anchors.verticalCenter: parent.verticalCenter
Text{
id: taskCard
font.pixelSize: 36
visible: curTestInfo!= null
text: "当前板号:"+ (!!curTestInfo ? curTestInfo.position : "")
color: "#007EFF"
anchors.top: parent.top
}
Text{
id: taskName
font.pixelSize: 36
visible: curTestInfo!= null
text: "当前任务:"+ (!!curTestInfo ? curTestInfo.cmdname : "")
color: "#007EFF"
anchors.bottom: parent.bottom
}
}
}
}
}
Item{
anchors.top: btnBar.bottom
anchors.left: btnBar.left
anchors.right: btnBar.right
anchors.bottom: parent.bottom
anchors.topMargin: 19
z:1
Rectangle{
id: stepText
anchors.fill: parent
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: "./resource/bgm.jpg"
Column{
Row{
ImageItem{
cardId: 4
}
ImageItem{
cardId: 3
}
}
Row{
ImageItem{
cardId: 2
}
ImageItem{
cardId: 1
}
}
}
}
}
}
Rectangle{
id: tipText
z: 2
width: 315
height: 170
radius: 19
color: "#FFFFFF"
visible: false
property var second: 0
anchors.centerIn: parent
onVisibleChanged:{
if(visible)
{
tipText.second = 5
skipTimer.start()
}
}
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: 20
text: skipTimer.running ? "当前任务出错" + "\n"+tipText.second+"s后自动跳过" : "当前任务出错"
}
Timer{
id: skipTimer
interval: 1000
running: false
repeat: true
onTriggered: {
if(tipText.second > 0)
{
tipText.second--
}
else
{
skipTimer.stop()
var wait_info = {'start':2}
common.setG('ErrorState',0 )
common.setG('wait_info',JSON.stringify(wait_info) )
tipText.visible = false
}
}
}
}
Item{
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 16
width: 180
height: 50
Row{
spacing: 20
QxTipButton{
id: continueBtn
width: 80
height: 39
text: "重试"
textColor: "#007EFF"
bgmSource: "../resource/stopbutton.png"
onClicked: {
skipTimer.stop()
var wait_info = {'start':1}
common.setG('wait_info',JSON.stringify(wait_info) )
tipText.visible = false
}
}
QxTipButton{
id: stopSkipBtn
width: 80
height: 39
text: "暂停"
textColor: "#007EFF"
bgmSource: "../resource/stopbutton.png"
Shortcut {
sequence: "Space"
onActivated: {
if(tipText.visible)
{
stopSkipBtn.clicked()
}
}
}
onClicked: {
if (stopSkipBtn.text == "暂停")
{
skipTimer.stop()
stopSkipBtn.text = "跳过"
}
else{
var wait_info = {'start':2}
common.setG('ErrorState',0 )
common.setG('wait_info',JSON.stringify(wait_info) )
tipText.visible = false
stopSkipBtn.text = "暂停"
}
}
}
}
}
}
}