359 lines
12 KiB
QML
359 lines
12 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Dialogs
|
|
import "./common"
|
|
// import "./Style"
|
|
Rectangle {
|
|
id: self
|
|
gradient: Gradient {
|
|
GradientStop { position: 0.0; color: "lightblue" }
|
|
GradientStop { position: 1.0; color: "white" }
|
|
}
|
|
property var currentHisory: null
|
|
property var historyInfo: null
|
|
onVisibleChanged: {
|
|
if(visible)
|
|
{
|
|
historyInfo = get_json("history.json")
|
|
table_history_model.clear()
|
|
var history_temp = []
|
|
for(var info in historyInfo)
|
|
{
|
|
history_temp.push(info)
|
|
}
|
|
for(var i = history_temp.length-1; i >=0; i--)
|
|
{
|
|
table_history_model.append(historyInfo[history_temp[i]])
|
|
}
|
|
if(table_history_model.count > 0)
|
|
{
|
|
currentHisory = table_history_model.get(0)
|
|
|
|
appendTgModel(JSON.parse(currentHisory.PowerStat), 1)
|
|
appendTgModel(JSON.parse(currentHisory.VoltageThreshold), 2)
|
|
appendTgModel(JSON.parse(currentHisory.CurrentThreshold), 3)
|
|
appendTgModel(JSON.parse(currentHisory.SNs), 4)
|
|
}
|
|
}
|
|
}
|
|
GroupBox{
|
|
id: group_history
|
|
anchors.top: parent.top
|
|
anchors.left:parent.left
|
|
anchors.right:parent.right
|
|
anchors.margins: 1
|
|
height: parent.height *2.8/4
|
|
clip: true
|
|
ListView{
|
|
id: table_history
|
|
model: table_history_model
|
|
header: table_history_header
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
anchors.fill: parent
|
|
delegate: table_history_delegate
|
|
}
|
|
}
|
|
ListModel{
|
|
id: table_history_model
|
|
}
|
|
Component {
|
|
id: table_history_delegate
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 30
|
|
color: index == table_history.currentIndex ? "#F3F3F3" : "white"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 6
|
|
QxLabel {
|
|
text: index+1
|
|
}
|
|
QxLabel {
|
|
text: Qt.formatDateTime(new Date(parseInt(startTime)), "yyyy-MM-dd hh:mm:ss")
|
|
}
|
|
QxLabel {
|
|
text: Qt.formatDateTime(new Date(parseInt(endTime)), "yyyy-MM-dd hh:mm:ss")
|
|
}
|
|
QxLabel {
|
|
text: tdCount
|
|
}
|
|
QxLabel {
|
|
text: csvFile
|
|
}
|
|
Item {
|
|
width: parent.width/parent.childcount
|
|
|
|
height: 30
|
|
clip: true
|
|
|
|
Rectangle{
|
|
width: 1
|
|
height: parent.height
|
|
color: "#222"
|
|
anchors.right: parent.right
|
|
}
|
|
Rectangle{
|
|
width: parent.width
|
|
height: 1
|
|
color: "#222"
|
|
anchors.bottom: parent.bottom
|
|
}
|
|
Row
|
|
{
|
|
anchors.centerIn: parent
|
|
Button{
|
|
text:"导入振动"
|
|
onClicked:{
|
|
fileDialog.selectedIndex = index
|
|
fileDialog.visible = true
|
|
}
|
|
}
|
|
Button{
|
|
text:"查看"
|
|
onClicked:{
|
|
|
|
if(index > -1)
|
|
{
|
|
var start = new Date(parseInt(table_history_model.get(index).startTime)).toISOString().slice(0, 24)
|
|
var stop = new Date(parseInt(table_history_model.get(index).endTime)).toISOString().slice(0, 24)
|
|
updateGrafanaTime(start, stop)
|
|
bar.currentIndex = 1
|
|
}
|
|
}
|
|
}
|
|
Button{
|
|
text:"删除"
|
|
onClicked:{
|
|
delete historyInfo[table_history_model.get(index).startTime]
|
|
console.info(JSON.stringify(historyInfo))
|
|
save_json("history.json",historyInfo)
|
|
table_history_model.remove(index)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
MouseArea{
|
|
width: parent.width * 5 / 6
|
|
height: parent.height
|
|
onClicked: {
|
|
table_history.currentIndex = index
|
|
currentHisory = table_history_model.get(index)
|
|
appendTgModel(JSON.parse(currentHisory.PowerStat), 1)
|
|
appendTgModel(JSON.parse(currentHisory.VoltageThreshold), 2)
|
|
appendTgModel(JSON.parse(currentHisory.CurrentThreshold), 3)
|
|
appendTgModel(JSON.parse(currentHisory.SNs), 4)
|
|
}
|
|
}
|
|
Rectangle{
|
|
color:"#222"
|
|
width: 1
|
|
height: parent.height
|
|
z: 1
|
|
}
|
|
}
|
|
}
|
|
Component {
|
|
id: table_history_header
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 30
|
|
color: "#f0f0f0"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 6
|
|
QxLabel {
|
|
text: "序号"
|
|
}
|
|
QxLabel {
|
|
text: "开始时间"
|
|
}
|
|
QxLabel {
|
|
text: "结束时间"
|
|
}
|
|
QxLabel {
|
|
text: "通道数量"
|
|
}
|
|
QxLabel {
|
|
text: "振动文件"
|
|
}
|
|
QxLabel {
|
|
text: "操作"
|
|
}
|
|
}
|
|
Rectangle{
|
|
color:"#222"
|
|
width: 1
|
|
height: parent.height
|
|
z: 1
|
|
}
|
|
}
|
|
}
|
|
|
|
GroupBox {
|
|
id: infoPanel
|
|
anchors.left: parent.left
|
|
anchors.top: group_history.bottom
|
|
anchors.bottom: parent.bottom
|
|
anchors.leftMargin: 2
|
|
width: (parent.width *1/3) - 2
|
|
Column
|
|
{
|
|
anchors.centerIn: parent
|
|
SetLabel{text:"实验时间: "+ ( !!currentHisory ? Qt.formatDateTime(new Date(parseInt(currentHisory.startTime)), "yyyy-MM-dd hh:mm:ss") : ""); width:300}
|
|
SetLabel{text:"实验人员: "+ ( !!currentHisory ? currentHisory.user:""); width:300}
|
|
SetLabel{text:"实验地址: "+ ( !!currentHisory ? currentHisory.settingLocation:""); width:300}
|
|
SetLabel{text:"实验单位: "+ ( !!currentHisory ? currentHisory.settingCompany:""); width:300}
|
|
SetLabel{text:"测试概要: "+ ( !!currentHisory ? currentHisory.settingSummary:""); width:300}
|
|
}
|
|
}
|
|
|
|
ListModel{
|
|
id: table_tanguan_model
|
|
ListElement{name:"第1路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第2路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第3路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第4路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第5路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第6路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第7路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
ListElement{name:"第8路"; v1:"0"; v2:"30000"; v3:"350"; v4:""}
|
|
}
|
|
|
|
ListView{
|
|
id: table_tanguan
|
|
model: table_tanguan_model
|
|
header: table_tanguan_header
|
|
interactive: false
|
|
anchors.top: group_history.bottom
|
|
anchors.left:infoPanel.right
|
|
anchors.right:parent.right
|
|
anchors.rightMargin: 2
|
|
anchors.bottom: parent.bottom
|
|
width: (parent.width *2/3) - 2
|
|
delegate: table_tanguan_delegate
|
|
}
|
|
|
|
Component {
|
|
id: table_tanguan_header
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 30
|
|
color: "#f0f0f0"
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 7
|
|
QxLabel {
|
|
text: "序号"
|
|
}
|
|
QxLabel {
|
|
text: "通道名称"
|
|
}
|
|
QxLabel {
|
|
text: "供电开关状态设置"
|
|
}
|
|
QxLabel {
|
|
text: "电压阈值设置(mV)"
|
|
}
|
|
QxLabel {
|
|
text: "电流阈值设置(mA)"
|
|
}
|
|
QxLabel {
|
|
text: "探管编号"
|
|
}
|
|
QxLabel {
|
|
text: "待测设备SN"
|
|
}
|
|
}
|
|
Rectangle{
|
|
color:"#222"
|
|
width: 1
|
|
height: parent.height
|
|
z: 1
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: table_tanguan_delegate
|
|
Rectangle {
|
|
width: parent ? parent.width : 0
|
|
height: 30
|
|
z:2
|
|
Row {
|
|
width: parent.width
|
|
height: parent.height
|
|
property var childcount: 7
|
|
QxLabel {
|
|
text: index + 1
|
|
}
|
|
QxLabel {
|
|
text: name
|
|
}
|
|
QxLabel {
|
|
text: v1 == "0" ? "关" : "开"
|
|
}
|
|
QxLabel {
|
|
text: v2
|
|
}
|
|
QxLabel {
|
|
text: v3
|
|
}
|
|
QxLabel {
|
|
text: index + 1
|
|
}
|
|
QxLabel {
|
|
text: v4
|
|
}
|
|
}
|
|
Rectangle{
|
|
color:"#222"
|
|
width: 1
|
|
height: parent.height
|
|
z: 1
|
|
}
|
|
}
|
|
}
|
|
|
|
FileDialog {
|
|
id: fileDialog
|
|
title: "请选择文件"
|
|
property var selectedIndex: -1
|
|
fileMode: FileDialog.OpenFile
|
|
nameFilters: [ "Csv files (*.csv)", "All files (*)" ]
|
|
onAccepted: {
|
|
var filePath = selectedFile.toString()
|
|
var zdFile = filePath.match(/[^\/\\]+$/)[0]
|
|
|
|
var path = filePath.replace("file:///","")
|
|
gamma.csvToInfluxdb(zdFile, table_history_model.get(selectedIndex).startTime,path)
|
|
table_history_model.setProperty(selectedIndex, "csvFile", zdFile)
|
|
historyInfo[table_history_model.get(selectedIndex).startTime]["csvFile"] = zdFile
|
|
save_json("history.json", historyInfo)
|
|
|
|
}
|
|
onRejected: {
|
|
console.log("Canceled")
|
|
}
|
|
visible: false
|
|
}
|
|
function appendTgModel(datas, col)
|
|
{
|
|
|
|
if (datas.length == 8)
|
|
{
|
|
for (var i=0; i<8; i++)
|
|
{
|
|
table_tanguan_model.setProperty(i, "v"+col, datas[i])
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|