TG-PlatformPlus/qml/debug/calibrate/Steps6.qml

1037 lines
39 KiB
QML
Raw Normal View History

2026-03-02 14:29:58 +08:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtCharts
import "./common"
Item {
id: self
property var currentStepIndex: -1
property var currentIndex: 0
property var isStart: curTaskIndex == 5
property var stepInstructId: ""
property var stepIncId: ""
property var temperatureInstructId: ""
property var childStepIndex: 1
property var isReadCtm: false
property var imageSoure: "./resource/step2/default.JPG"
property var imageText: ""
property var g_inc: "0°"
property var g_gtf: "0°"
property var realTemps: []
property var progress: stepModel.count > 0 ? (currentIndex / stepModel.count) : 0.0
ListModel{
id: stepModel
}
Component.onCompleted: {
stopBd.connect(onStopBd)
taskActuatorManager.executeFinished.connect(onExecuteFinished)
clearSteps()
}
onIsStartChanged: {
if (isStart) {
startSteps()
}
}
function startSteps()
{
clearSteps()
task6State = "1"
currentStepIndex = 0
stepInstructId = ""
childStepIndex = 1
mw_Digital = []
taskModel.get(curTaskIndex).state = task6State
tipText.visible = true
runIncStep()
}
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, "skip": 0})
}
function clearSteps(){
tipText.visible = false
stepModel.clear()
stepModel.append({"name":"磁场标定", "display":"磁场标定", "tips": "设备是否就绪?", "_state": "0", "src": "./step1.png", "endTime": "", "t":""})
minTemp = 9999
maxTemp = 0
imageSoure = "./resource/step2/default.JPG"
imageText = ""
realTemps = []
for(var i = 0; i < tempModel.count; i++)
{
var temperature = tempModel.get(i).temperature
var bias = tempModel.get(i).bias
var delay = tempModel.get(i).delay
var displaytemp = parseFloat(temperature)
realTemps.push(displaytemp)
var t = displaytemp.toString()
stepModel.append({"name":"设定温度","display":"设定"+displaytemp+"℃", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"打开温箱","display":"打开温箱", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"等待温度稳定","display":"等待温度稳定", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"关闭温箱","display":"关闭温箱", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"设置正一倍磁场","display":"设置正一倍磁场", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"采集正一倍磁场","display":"采集正一倍磁场", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"设置负一倍磁场","display":"设置负一倍磁场", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
stepModel.append({"name":"采集负一倍磁场","display":"采集负一倍磁场", "tips": "", "_state": "0", "src": "./step1.png", "endTime": "", "t":t,"b":bias,"d":delay})
if ( maxTemp < parseFloat(displaytemp) )
{
maxTemp = parseFloat(displaytemp)
}
if(minTemp > parseFloat(displaytemp))
{
minTemp = parseFloat(displaytemp)
}
}
currentStepIndex = -1
currentIndex = 0
}
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
}
QxText{
text: imageText
anchors.left: tTitle.right
anchors.rightMargin: 30
anchors.top: parent.top
anchors.topMargin: 18
font.pixelSize: 20
font.bold: true
color: "#007EFF"
}
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
Item{
width: 20
height: 1
visible: index != 0 && (index-1) %8 != 0
}
Image{
source: "./resource/state"+_state+".png"
width: 20
height: 20
}
QxListText{
text: display
}
}
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" && name == "等待温度稳定" && !isSkipCheckTemperature
Rectangle{
anchors.centerIn: parent
width: 10
height: 10
radius: 2
color: "red"
}
MouseArea{
anchors.fill: parent
onClicked:
{
isSkipCheckTemperature = true
}
}
}
}
ScrollBar.vertical: ScrollBar{}
}
}
Rectangle{
id: stepText
anchors.left: stepLst.right
anchors.leftMargin: 10
width: parent.width / 3
anchors.top: stepLst.top
anchors.bottom: stepLst.bottom
radius: 9
visible: false
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: 20
font.bold: true
color: "#007EFF"
}
Text{
id: txMsg
visible:true
anchors.centerIn: parent
font.pixelSize: 10
color: "#BFBFBF"
text:""
}
}
}
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: m_seri.length > 0 ? "#007EFF" : "#BFBFBF"
QxText{
text:"已就绪"
font.pixelSize: 14
anchors.centerIn: parent
color: "#FFFFFF"
}
MouseArea{
anchors.fill: parent
onClicked: {
if (m_seri.length > 0)
{
tipText.visible = false
getTdInfo()
var px = handelX.zname == "X" ? handelX.zsdz : (handelY.zname == "X" ? handelY.zsdz : handelZ.zsdz)
var py = handelX.zname == "Y" ? handelX.zsdz : (handelY.zname == "Y" ? handelY.zsdz : handelZ.zsdz)
var pz = handelX.zname == "Z" ? handelX.zsdz : (handelY.zname == "Z" ? handelY.zsdz : handelZ.zsdz)
isReadCtm = true
readTimer.start()
zybBd(px, py, pz)
}
}
}
}
}
property var maxT2Value: 1
property var minT2Value: -1
property var maxTValue: 0
property var minTValue: 0
property var minTemp: 0
property var maxTemp: 100
Rectangle{
id: chartRect
anchors.left: stepLst.right
anchors.top: stepLst.top
anchors.bottom: stepLst.bottom
anchors.right: parent.right
anchors.leftMargin: 10
radius: 9
ChartView {
id: chartView
// title: "温度"
//![1]
anchors.fill: parent
legend.alignment: Qt.AlignTop
antialiasing: true
ValueAxis {
id: valueAxisX
titleText: "点数/个"
min: 0
max: maxTValue == 0 ? 20 : maxTValue
labelFormat: "%.0f"
tickCount: 10
}
ValueAxis{
id: valueAxisY
min: 1
max: maxTemp + 10
titleText: "温度/mV"
tickCount: 21
labelFormat: "%.0f"
}
ValueAxis{
id: valueAxisY2
min: minT2Value
max: maxT2Value
titleText: "姿态/V"
tickCount: 21
tickInterval: 0.5
labelFormat: "%.1f"
}
QxLineSeries {
id: lsTemperature
axisX: valueAxisX
axisY: valueAxisY
name: "温箱"
color: "#c93756"
}
QxLineSeries {
id: lsAsTemperature
axisX: valueAxisX
axisY: valueAxisY
name: "tempAs"
color: "#de8204"
}
QxLineSeries {
id: lsAbTemperature
axisX: valueAxisX
axisY: valueAxisY
name: "tempAb"
color: "#cbc13a"
}
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: "#4cd05c"
}
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: "#007dfc"
}
}
}
Timer{
id: readTimer
interval: 1000; running: false; repeat: true
onTriggered: {
runReadTemperature()
}
}
property var isReadMTemp: false
Timer{
id: readMTimer
interval: 15000; running: isReadMTemp; repeat: true
onTriggered: {
var handel = taskModel.get(curTaskIndex)
var firstName = handel.v5 == "数字量" ? "数字" : "模拟"
execute(firstName+"磁通门采集",{"total":1, "skip": 0})
}
}
property var tDelay2: 1000
Timer {
id: closeTimer
interval: tDelay2; running: false; repeat: false
onTriggered: runCloseTemperatureBox()
}
property var handelX: null;
property var handelY: null;
property var handelZ: null;
function getTdInfo(){
for(var i = 0; i < tdModel.count; ++i){
var td = tdModel.get(i);
if(td.bname == "X"){
if (td.lp == "")
td.lp = m_seri[0][0];
if (td.bdys == "")
td.bdys = m_seri[1][0];
handelX = td;
}else if(td.bname == "Y"){
if (td.lp == "")
td.lp = m_seri[0][1];
if (td.bdys == "")
td.bdys = m_seri[1][1];
handelY = td;
}else if(td.bname == "Z"){
if (td.lp == "")
td.lp = m_seri[0][2];
if (td.bdys == "")
td.bdys = m_seri[1][2];
handelZ = td;
}
}
handelX.zmbz = handelX.zsdz
handelY.zmbz = handelY.zsdz
handelZ.zmbz = handelZ.zsdz
handelX.fmbz = handelX.fsdz
handelY.fmbz = handelY.fsdz
handelZ.fmbz = handelZ.fsdz
}
function checkXYZ(x, y, z)
{
var maxCount = 100000.0
if( (Math.abs( parseFloat(x) ) - maxCount) > 0 )
return false
if((Math.abs( parseFloat(y) ) - maxCount) > 0 )
return false
if((Math.abs( parseFloat(z) ) - maxCount) > 0 )
return false
return true
}
function makeImageSource(x, y, z)
{
var imageName = ""
if(x != "0")
{
imageName += "x"
}
if(y != "0")
{
imageName += "y"
}
if(z != "0")
{
imageName += "z"
}
imageSoure = "./resource/step2/" + imageName + ".JPG"
imageText = parseFloat(x).toFixed(0) + "nT " + parseFloat(y).toFixed(0) + "nT " + parseFloat(z).toFixed(0) + "nT"
}
function zybBd(x, y, z)
{
if(!checkXYZ(x, y, z))
return
makeImageSource(x,y,z)
stepModel.get(currentStepIndex)._state = "1"
stepInstructId = execute("亥姆霍兹线圈设定",{"T":800,"X":x,"Y": y,"Z":z})
}
function fybBd(x, y, z)
{
if(!checkXYZ(x, y, z))
return
makeImageSource(x,y,z)
stepModel.get(currentStepIndex)._state = "1"
stepInstructId = execute("亥姆霍兹线圈设定",{"T":800,"X":x,"Y":y,"Z":z})
}
function runHmhz(x , y, z)
{
if(!checkXYZ(x, y, z))
return
console.info("zybBd",x, y, z)
stepModel.get(currentStepIndex)._state = "1"
stepInstructId = execute("亥姆霍兹线圈设定",{"T":800,"X":x,"Y":y,"Z":z})
}
function runStep()
{
var handel = taskModel.get(curTaskIndex)
var group = parseInt(handel.v1)
var groupcount = parseInt(handel.v3)
var total = group*groupcount
tDelay = 3000 + (total * 100)
var firstName = handel.v5 == "数字量" ? "数字" : "模拟"
stepInstructId = execute(firstName+"磁通门采集",{"total":total})
}
property var curSetTemperature: 35
function runTemperature(temperature)
{
curSetTemperature = temperature
stepModel.get(currentStepIndex)._state = "1"
stepInstructId = execute("设置保温箱", {"temperature": temperature})
}
function runOpenTemperatureBox(){
stepModel.get(currentStepIndex)._state = "1"
execute("亥姆霍兹线圈设定",{"T":800,"X":"NAN","Y":"NAN","Z":"NAN"})
stepInstructId = execute("保温箱开关",{"switch": 1})
}
function runCloseTemperatureBox(){
stepInstructId = execute("保温箱开关",{"switch": 0})
}
function runReadTemperature(){
var handel = taskModel.get(curTaskIndex)
var lastName = handel.v5 == "数字量" ? "保温箱" : "保温桶"
var infoA = common.getG("A_Digital")
var mvalue = infoA.m_temp
temperatureInstructId = execute("读取" + lastName,{"mvalue":mvalue})
}
function onStopBd(){
if(isStart)
{
readTimer.stop()
stopExecute(temperatureInstructId)
stopExecute(stepInstructId)
runCloseTemperatureBox()
clearSteps()
}
}
function calZPercentage()
{
if(m_seri.length == 0)
{
return false
}
txMsg.text += handelX.zmbz+ " "+handelY.zmbz+ " "+handelZ.zmbz+ "\n"
var xlp = parseFloat(handelX.lp)
var ylp = parseFloat(handelY.lp)
var zlp = parseFloat(handelZ.lp)
var xbdys = parseFloat(handelX.bdys)
var ybdys = parseFloat(handelY.bdys)
var zbdys = parseFloat(handelZ.bdys)
txMsg.text = "零偏X:" + xlp + " 零偏Y:" + ylp + " 零偏Z:" + zlp + "\n"
txMsg.text += "因数X:" + xbdys + " 因数Y:" + ybdys + " 因数Z:" + zbdys + "\n"
var b5 = parseFloat(xlp + xbdys)
var c5 = parseFloat(ylp + ybdys)
var d5 = parseFloat(zlp + zbdys)
var b6 = parseFloat(xlp - xbdys)
var c6 = parseFloat(ylp - ybdys)
var d6 = parseFloat(zlp - zbdys)
txMsg.text += "B5:" + b5 + " C5:" + c5 + " D5:" + d5 + "\n"
txMsg.text += "B6:" + b6 + " C6:" + c6 + " D6:" + d6 + "\n"
var percentageX = 0.00
var percentageY = 0.00
var percentageZ = 0.00
console.info(xlp,ylp,zlp)
console.info(xbdys,ybdys,zbdys)
console.info(handelX.zclz,handelY.zclz,handelZ.zclz)
txMsg.text += "实际X:" + handelX.zclz + " 实际Y:" + handelY.zclz + " 实际Z:" + handelZ.zclz + "\n"
percentageX = (parseFloat(handelX.zclz) - b5) / xbdys
percentageY = (parseFloat(handelY.zclz) - c5) / ybdys
percentageZ = (parseFloat(handelZ.zclz) - d5) / zbdys
txMsg.text += "百分比X:" + percentageX + "\n百分比Y:" + percentageY + "\n百分比Z:" + percentageZ + "\n"
txMsg.text += handelX.zmbz+ " "+handelY.zmbz+ " "+handelZ.zmbz+ "\n"
if (Math.abs(percentageX) < 0.001 && Math.abs(percentageY) < 0.001 && Math.abs(percentageZ) < 0.001)
{
return true
}
else
{
handelX.zmbz = (parseFloat(handelX.zmbz) *parseFloat(1 - percentageX)) + ""
handelY.zmbz =parseFloat(handelY.zmbz) *(parseFloat(1 - percentageY)) + ""
handelZ.zmbz = (parseFloat(handelZ.zmbz) *parseFloat(1 - percentageZ)) + ""
return false
}
}
function calFPercentage()
{
if(m_seri.length == 0)
{
return false
}
var xlp = parseFloat(handelX.lp)
var ylp = parseFloat(handelY.lp)
var zlp = parseFloat(handelZ.lp)
var xbdys = parseFloat(handelX.bdys)
var ybdys = parseFloat(handelY.bdys)
var zbdys = parseFloat(handelZ.bdys)
txMsg.text = "零偏X:" + xlp + " 零偏Y:" + ylp + " 零偏Z:" + zlp + "\n"
txMsg.text += "因数X:" + xbdys + " 因数Y:" + ybdys + " 因数Z:" + zbdys + "\n"
var b5 = parseFloat(xlp + xbdys)
var c5 = parseFloat(ylp + ybdys)
var d5 = parseFloat(zlp + zbdys)
var b6 = parseFloat(xlp - xbdys)
var c6 = parseFloat(ylp - ybdys)
var d6 = parseFloat(zlp - zbdys)
txMsg.text += "B5:" + b5 + " C5:" + c5 + " D5:" + d5 + "\n"
txMsg.text += "B6:" + b6 + " C6:" + c6 + " D6:" + d6 + "\n"
var percentageX = 0.00
var percentageY = 0.00
var percentageZ = 0.00
txMsg.text += "实际X:" + handelX.fclz + " 实际Y:" + handelY.fclz + " 实际Z:" + handelZ.fclz + "\n"
percentageX = (parseFloat(handelX.fclz) - b6) / xbdys
percentageY = (parseFloat(handelY.fclz) - c6) / ybdys
percentageZ = (parseFloat(handelZ.fclz) - d6) / zbdys
txMsg.text += "百分比X:" + percentageX + "\n百分比Y:" + percentageY + "\n百分比Z:" + percentageZ + "\n"
txMsg.text += handelX.fmbz+ " "+handelY.fmbz+ " "+handelZ.fmbz+ "\n"
if (Math.abs(percentageX) < 0.001 && Math.abs(percentageY) < 0.001 && Math.abs(percentageZ) < 0.001)
{
return true
}
else
{
handelX.fmbz = (parseFloat(handelX.fmbz) *parseFloat(1 + percentageX)) + ""
handelY.fmbz = (parseFloat(handelY.fmbz) *parseFloat(1 + percentageY)) + ""
handelZ.fmbz = (parseFloat(handelZ.fmbz) *parseFloat(1 + percentageZ)) + ""
return false
}
}
property var tempArr: [] // 温度缓存
property var tempArrCount: 25 // 缓存数
function appendTempArr(temp)
{
tempArr.push(parseFloat(temp)); // 将新元素添加到数组末尾
if (tempArr.length > tempArrCount) {
tempArr.shift(); // 如果数组长度大于tempArrCount删除首位元素
}
}
function checkTemperatureCompliance(b) {
var complianceCount = 0;
for (var i = 0; i < tempArr.length; i++) {
if ( Math.abs(parseFloat(curSetTemperature) - parseFloat(tempArr[i])) < parseFloat(b) ) // < 0.001
complianceCount++
}
return complianceCount == tempArr.length // 计算均值
}
property var tDelay: 100
Timer {
id: getTimer
interval: tDelay; running: false; repeat: false
onTriggered: {
runStep()
isReadCtm = false
}
}
property var isSkipCheckTemperature: false
Timer{
id: waitTemperatureTimer
interval: 1000; running: false; repeat: true
onTriggered:{
var handelStep = stepModel.get(currentStepIndex)
if(handelStep.name == "等待温度稳定")
{
if(tempArr.length == tempArrCount)
{
if(checkTemperatureCompliance(handelStep.b))
{
handelStep._state = "2"
handelStep.endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
waitTemperatureTimer.stop()
currentStepIndex++
currentIndex++
tDelay2 = parseInt(handelStep.d)
stepModel.get(currentStepIndex)._state = "1"
closeTimer.start()
}
}
else if (isSkipCheckTemperature)
{
isSkipCheckTemperature = false
handelStep._state = "2"
handelStep.endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
waitTemperatureTimer.stop()
currentStepIndex++
currentIndex++
tDelay2 = parseInt(handelStep.d)
stepModel.get(currentStepIndex)._state = "1"
closeTimer.start()
}
}
}
}
function onExecuteFinished(id)
{
if (id == temperatureInstructId && isStart)
{
var info = common.getG("Incubator")
var infoA = common.getG("A_Digital")
var curHTemperature = info.temp
var curMTemperature = infoA.m_temp
maxTValue++
if(curMTemperature > -1 || curHTemperature > -1)
{
appendTempArr(curHTemperature)
lsMTemperature.append(Number(maxTValue), curMTemperature)
lsTemperature.append(Number(maxTValue), curHTemperature)
lsAsTemperature.append(Number(maxTValue), infoA.x_Atemp)
lsAbTemperature.append(Number(maxTValue), infoA.a_tempb)
lsxAValue.append(Number(maxTValue), infoA.x_Avalue)
lsyAValue.append(Number(maxTValue), infoA.y_Avalue)
lszAValue.append(Number(maxTValue), infoA.z_Avalue)
lsxMValue.append(Number(maxTValue), infoA.x_Mvalue)
lsyMValue.append(Number(maxTValue), infoA.y_Mvalue)
lszMValue.append(Number(maxTValue), infoA.z_Mvalue)
if(maxTemp < Number(curMTemperature))
{
maxTemp = Number(curMTemperature) + 10
}
if (Number(infoA.x_Avalue) > maxT2Value)
{
maxT2Value = Number(infoA.x_Avalue) + 0.1
}
if (Number(infoA.x_Avalue) < minT2Value)
{
minT2Value = Number(infoA.x_Avalue) - 0.1
}
if (Number(infoA.y_Avalue) > maxT2Value)
{
maxT2Value = Number(infoA.y_Avalue) + 0.1
}
if (Number(infoA.y_Avalue) < minT2Value)
{
minT2Value = Number(infoA.y_Avalue) - 0.1
}
if (Number(infoA.z_Avalue) > maxT2Value)
{
maxT2Value = Number(infoA.z_Avalue) + 0.1
}
if (Number(infoA.z_Avalue) < minT2Value)
{
minT2Value = Number(infoA.z_Avalue) - 0.1
}
if (Number(infoA.x_Mvalue) > maxT2Value)
{
maxT2Value = Number(infoA.x_Avalue) + 0.1
}
if (Number(infoA.x_Mvalue) < minT2Value)
{
minT2Value = Number(infoA.x_Mvalue) - 0.1
}
if (Number(infoA.y_Mvalue) > maxT2Value)
{
maxT2Value = Number(infoA.y_Mvalue) + 0.1
}
if (Number(infoA.y_Mvalue) < minT2Value)
{
minT2Value = Number(infoA.y_Mvalue) - 0.1
}
if (Number(infoA.z_Mvalue) > maxT2Value)
{
maxT2Value = Number(infoA.z_Mvalue) + 0.1
}
if (Number(infoA.z_Mvalue) < minT2Value)
{
minT2Value = Number(infoA.z_Mvalue) - 0.1
}
if(maxTValue - minTValue > 20)
minTValue = maxTValue - 20;
}
}
if(id == stepInstructId && isStart)
{
if(currentStepIndex < stepModel.count - 1)
{
var handelStep = stepModel.get(currentStepIndex)
if (handelStep.name != "磁场标定")
handelStep._state = "2"
handelStep.endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
if (handelStep.name == "磁场标定")
{
if( childStepIndex == 1)
{
if(isReadCtm)
{
getTimer.start()
}
else{
isReadCtm = true
var info = common.getG("A_Digital")
handelX.zclz = info.x_Mvalue + ""
handelY.zclz = info.y_Mvalue + ""
handelZ.zclz = info.z_Mvalue + ""
if(calZPercentage())
{
childStepIndex = 2
var px = handelX.zname == "X" ? handelX.fsdz : (handelY.zname == "X" ? handelY.fsdz : handelZ.fsdz)
var py = handelX.zname == "Y" ? handelX.fsdz : (handelY.zname == "Y" ? handelY.fsdz : handelZ.fsdz)
var pz = handelX.zname == "Z" ? handelX.fsdz : (handelY.zname == "Z" ? handelY.fsdz : handelZ.fsdz)
fybBd(px, py, pz)
}
else
{
childStepIndex = 1
var px = handelX.zname == "X" ? handelX.zmbz : (handelY.zname == "X" ? handelY.zmbz : handelZ.zmbz)
var py = handelX.zname == "Y" ? handelX.zmbz : (handelY.zname == "Y" ? handelY.zmbz : handelZ.zmbz)
var pz = handelX.zname == "Z" ? handelX.zmbz : (handelY.zname == "Z" ? handelY.zmbz : handelZ.zmbz)
txMsg.text += "设定X:" + px + " 设定Y:" + py + " 设定Z:" + pz + "\n"
zybBd(px, py, pz)
}
}
}
else if( childStepIndex == 2)
{
if(isReadCtm)
{
getTimer.start()
}
else{
isReadCtm = true
var handelStep = stepModel.get(currentStepIndex)
var info = common.getG("A_Digital")
handelX.fclz = info.x_Mvalue + ""
handelY.fclz = info.y_Mvalue + ""
handelZ.fclz = info.z_Mvalue + ""
if(calFPercentage())
{
handelStep._state = "2"
currentStepIndex++
currentIndex++
if( stepModel.get(currentStepIndex).t != "")
{
runTemperature(stepModel.get(currentStepIndex).t)
}
}
else{
childStepIndex = 2
var px = handelX.zname == "X" ? handelX.fmbz : (handelY.zname == "X" ? handelY.fmbz : handelZ.fmbz)
var py = handelX.zname == "Y" ? handelX.fmbz : (handelY.zname == "Y" ? handelY.fmbz : handelZ.fmbz)
var pz = handelX.zname == "Z" ? handelX.fmbz : (handelY.zname == "Z" ? handelY.fmbz : handelZ.fmbz)
txMsg.text += "设定X:" + px + " 设定Y:" + py + " 设定Z:" + pz + "\n"
fybBd(px, py, pz)
}
}
}
// currentStepIndex++
// currentIndex++
// if( stepModel.get(currentStepIndex).t != "")
// {
// runTemperature(parseFloat(stepModel.get(currentStepIndex).t) )
// }
}
if(handelStep.name == "设定温度")
{
currentStepIndex++
currentIndex++
runOpenTemperatureBox()
}
if(handelStep.name == "打开温箱")
{
currentStepIndex++
currentIndex++
tempArr = []
stepModel.get(currentStepIndex)._state = "1"
isReadMTemp = true // 读温度
waitTemperatureTimer.start()
}
if(handelStep.name == "关闭温箱")
{
currentStepIndex++
currentIndex++
var px = handelX.zname == "X" ? handelX.zmbz : (handelY.zname == "X" ? handelY.zmbz : handelZ.zmbz)
var py = handelX.zname == "Y" ? handelX.zmbz : (handelY.zname == "Y" ? handelY.zmbz : handelZ.zmbz)
var pz = handelX.zname == "Z" ? handelX.zmbz : (handelY.zname == "Z" ? handelY.zmbz : handelZ.zmbz)
runHmhz(px, py, pz)
isReadMTemp = false // 停止读温度
}
if(handelStep.name == "设置正一倍磁场")
{
currentStepIndex++
currentIndex++
stepModel.get(currentStepIndex)._state = "1"
getTimer.start()
}
if(handelStep.name == "采集正一倍磁场")
{
handelStep.endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
mw_Digital.push(common.getG("A_Digital"))
currentStepIndex++
currentIndex++
var px = handelX.zname == "X" ? handelX.fmbz : (handelY.zname == "X" ? handelY.fmbz : handelZ.fmbz)
var py = handelX.zname == "Y" ? handelX.fmbz : (handelY.zname == "Y" ? handelY.fmbz : handelZ.fmbz)
var pz = handelX.zname == "Z" ? handelX.fmbz : (handelY.zname == "Z" ? handelY.fmbz : handelZ.fmbz)
runHmhz(px, py, pz)
}
if(handelStep.name == "设置负一倍磁场")
{
currentStepIndex++
currentIndex++
stepModel.get(currentStepIndex)._state = "1"
getTimer.start()
}
if(handelStep.name == "采集负一倍磁场")
{
handelStep.endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
mw_Digital.push(common.getG("A_Digital"))
currentStepIndex++
currentIndex++
if( stepModel.get(currentStepIndex).t != "")
{
runTemperature( stepModel.get(currentStepIndex).t)
}
}
listView.positionViewAtIndex(currentStepIndex, ListView.End)
}
else{
stepModel.get(currentStepIndex)._state = "2"
stepModel.get(currentStepIndex).endTime = Qt.formatDateTime(new Date(), "MM-dd hh:mm:ss")
mw_Digital.push(common.getG("A_Digital"))
imageSoure = "./resource/step2/default.JPG"
imageText = ""
currentStepIndex = -1
currentIndex = stepModel.count
readTimer.stop()
execute("保温箱开关",{"switch": 0})
task6State = "2"
reportJson["mw_Digital"] = mw_Digital
save_json("mw_Digital.json", {"infos":mw_Digital})
reportJson["realTemps"] = realTemps
save_json("realTemps.json", {"infos":realTemps})
writeMCsv()
execute("亥姆霍兹线圈设定",{"T":800,"X":"NAN","Y":"NAN","Z":"NAN"})
taskModel.get(curTaskIndex).state = task6State
runNextStep()
}
}
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 writeMCsv()
{
// 创建CSV表头
const header = "X轴磁通门输出,Y轴磁通门输出,Z轴磁通门输出,磁通门温度输出\n";
var csvData = header;
var filename = 'M_' + g_sn + "-1_" + Qt.formatDateTime(new Date(startTime), "yyyy-MM-dd_hh-mm-ss") + '.csv';
// 遍历mw_Digital数组将每条结果写入CSV文件
for(var i = 0; i < mw_Digital.length; i++)
{
csvData += mw_Digital[i].x_Mvalue +","+mw_Digital[i].y_Mvalue+","+mw_Digital[i].z_Mvalue+","+mw_Digital[i].m_temp+'\n';
}
save_csv(filename, csvData);
}
}