373 lines
11 KiB
QML
373 lines
11 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Dialogs
|
|
import "./common"
|
|
|
|
Item{
|
|
property var deviceInfos: []
|
|
property var devModel: ListModel{}
|
|
property var interfaceModel: ListModel{}
|
|
property bool initialized: false
|
|
Component.onCompleted: {
|
|
initJsonModel(tdModel, "tdModel.json")
|
|
for(var i = 0; i < tdModel.count; ++i)
|
|
{
|
|
var handel = tdModel.get(i)
|
|
tdModel.setProperty(i, 'lp', '')
|
|
tdModel.setProperty(i, 'bdys', '')
|
|
}
|
|
initJsonModel(tempModel, "tempModel.json")
|
|
initialized = true
|
|
}
|
|
|
|
Item{
|
|
id: tdItem
|
|
width: parent.width
|
|
y: -21
|
|
height: 275
|
|
Column{
|
|
anchors.fill: parent
|
|
spacing: 12
|
|
|
|
Rectangle{
|
|
|
|
width: 83
|
|
height: 32
|
|
radius: 6
|
|
color: "#007EFF"
|
|
Row{
|
|
anchors.centerIn: parent
|
|
spacing: 4
|
|
Image
|
|
{
|
|
width: 14
|
|
height: 14
|
|
source: "./resource/import.png"
|
|
}
|
|
QxText{
|
|
text:"导入"
|
|
font.pixelSize: 14
|
|
color: "#FFFFFF"
|
|
}
|
|
}
|
|
|
|
MouseArea{
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
fileDialog.visible = true
|
|
}
|
|
}
|
|
}
|
|
ListView{
|
|
model: tdModel
|
|
header: table_td_header
|
|
interactive: false
|
|
width: parent.width
|
|
height: parent.height - 50
|
|
delegate: table_td_delegate
|
|
}
|
|
}
|
|
}
|
|
|
|
Item{
|
|
anchors.top: tdItem.bottom
|
|
width: parent.width
|
|
anchors.bottom: parent.bottom
|
|
|
|
Column{
|
|
anchors.fill: parent
|
|
spacing: 12
|
|
Column{
|
|
spacing: 20
|
|
Item{
|
|
height: 16
|
|
width: parent.width
|
|
|
|
Rectangle{
|
|
width: 3
|
|
height:16
|
|
color: "#007EFF"
|
|
}
|
|
QxText{
|
|
x: 6
|
|
text: "温度阶梯"
|
|
font.bold: true
|
|
font.pixelSize: 18
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
}
|
|
|
|
Row{
|
|
spacing: 29
|
|
Button{
|
|
icon.source: "./resource/add.png"
|
|
width: 101
|
|
height: 32
|
|
onClicked: {
|
|
tempModel.append({"temperature":"0","bias":"0","delay":"0"})
|
|
updateJsonFile(tempModel, "tempModel.json")
|
|
}
|
|
}
|
|
Button{
|
|
icon.source: "./resource/del.png"
|
|
width: 101
|
|
height: 32
|
|
onClicked: {
|
|
if(tempModel.count > 1 && tempListView.currentIndex > -1){
|
|
tempModel.remove(tempListView.currentIndex)
|
|
updateJsonFile(tempModel, "tempModel.json")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Item
|
|
{
|
|
width: parent.width
|
|
height: 329
|
|
clip: true
|
|
ListView{
|
|
id: tempListView
|
|
model: tempModel
|
|
anchors.fill: parent
|
|
header: table_temp_header
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
delegate: table_temp_delegate
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FileDialog {
|
|
id: fileDialog
|
|
title: "请选择文件"
|
|
property var selectedIndex: -1
|
|
fileMode: FileDialog.OpenFile
|
|
nameFilters: [ "Csv files (*.csv)", "All files (*)" ]
|
|
onAccepted: {
|
|
var filePath = selectedFile.toString()
|
|
var path = filePath.replace("file:///","")
|
|
m_seri = calibrate.readFCsv(path)
|
|
for(var i = 0; i < tdModel.count; ++i)
|
|
{
|
|
var handel = tdModel.get(i)
|
|
var lp = ""
|
|
var bdys = ""
|
|
if(handel.bname == "X")
|
|
{
|
|
lp = m_seri[0][0]
|
|
bdys = m_seri[1][0]
|
|
}
|
|
else if(handel.bname == "Y")
|
|
{
|
|
lp = m_seri[0][1]
|
|
bdys = m_seri[1][1]
|
|
}
|
|
else if(handel.bname == "Z")
|
|
{
|
|
lp = m_seri[0][2]
|
|
bdys = m_seri[1][2]
|
|
}
|
|
tdModel.setProperty(i, 'lp', lp)
|
|
tdModel.setProperty(i, 'bdys', bdys)
|
|
}
|
|
}
|
|
onRejected: {
|
|
console.log("Canceled")
|
|
}
|
|
visible: false
|
|
}
|
|
|
|
ListModel{
|
|
id: zxModel
|
|
ListElement{name: "X"}
|
|
ListElement{name: "Y"}
|
|
ListElement{name: "Z"}
|
|
}
|
|
|
|
Component {
|
|
id: table_temp_header
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 40
|
|
color: "#F7F7F7"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 4
|
|
QxHLabel {
|
|
text: "序号"
|
|
}
|
|
QxHLabel {
|
|
text: "目标温度/℃"
|
|
}
|
|
QxHLabel {
|
|
text: "偏差温度/℃"
|
|
}
|
|
QxHLabel {
|
|
text: "延迟/ms"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: table_temp_delegate
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 58
|
|
color: tempListView.currentIndex == index ? "#beebff" : ( index % 2 == 0 ? "#F8FAFF" : "#FFFFFF")
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 4
|
|
|
|
QxLabel {
|
|
text: index+1
|
|
}
|
|
|
|
QxLabel {
|
|
text: temperature
|
|
editMode: true
|
|
onValueChanged: {
|
|
if(temperature != value)
|
|
{
|
|
temperature = value
|
|
updateJsonFile(tempModel, "tempModel.json")
|
|
}
|
|
}
|
|
}
|
|
QxLabel {
|
|
text: bias
|
|
editMode: true
|
|
onValueChanged: {
|
|
if(bias != value)
|
|
{
|
|
bias = value
|
|
updateJsonFile(tempModel, "tempModel.json")
|
|
}
|
|
}
|
|
}
|
|
QxLabel {
|
|
text: delay
|
|
editMode: true
|
|
onValueChanged: {
|
|
if(delay != value)
|
|
{
|
|
delay = value
|
|
updateJsonFile(tempModel, "tempModel.json")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
MouseArea{
|
|
anchors.fill: parent
|
|
onPressed:(mouse)=> {
|
|
tempListView.currentIndex = index
|
|
mouse.accepted = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: table_td_header
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 40
|
|
color: "#F7F7F7"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 6
|
|
QxHLabel {
|
|
text: "探管轴系"
|
|
}
|
|
QxHLabel {
|
|
text: "磁反馈传感器轴系"
|
|
}
|
|
QxHLabel {
|
|
text: "零偏/V"
|
|
}
|
|
QxHLabel {
|
|
text: "标度因数/V/V"
|
|
}
|
|
QxHLabel {
|
|
text: "+磁场设定值/nT"
|
|
}
|
|
QxHLabel {
|
|
text: "-磁场设定值/nT"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: table_td_delegate
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 58
|
|
color: index % 2 == 0 ? "#F8FAFF" : "#FFFFFF"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 6
|
|
|
|
QxLabel {
|
|
text: zname
|
|
}
|
|
QxComboBox {
|
|
text: bname
|
|
cbmodel: zxModel
|
|
onCurrentIndexChanged: {
|
|
if(!initialized)
|
|
return
|
|
if(currentIndex != -1)
|
|
{
|
|
bname = cbmodel.get(currentIndex).name
|
|
}
|
|
updateJsonFile(tdModel, "tdModel.json")
|
|
}
|
|
}
|
|
QxLabel {
|
|
text: lp
|
|
}
|
|
QxLabel {
|
|
text: bdys
|
|
}
|
|
QxLabel {
|
|
text: zsdz
|
|
editMode: true
|
|
onValueChanged: {
|
|
if(!initialized)
|
|
return
|
|
if(zsdz != value)
|
|
{
|
|
zsdz = value
|
|
updateJsonFile(tdModel, "tdModel.json")
|
|
}
|
|
}
|
|
}
|
|
QxLabel {
|
|
text: fsdz
|
|
editMode: true
|
|
onValueChanged: {
|
|
if(!initialized)
|
|
return
|
|
if(fsdz != value)
|
|
{
|
|
fsdz = value
|
|
updateJsonFile(tdModel, "tdModel.json")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|