TG-PlatformPlus/qml/debug/gamma/SettingTestInfo.qml

237 lines
6.9 KiB
QML

import QtQuick
import QtQuick.Controls
import "./common"
GroupBox{
Component.onCompleted: {
sig_readRegisterFinished.connect(on_readRegisterFinished)
}
Column{
anchors.fill: parent
spacing: 30
Row{
spacing: 30
SetLabel{text: "测试人员:"}
SetTextField{
text: g_user
readonly: true
}
}
Row{
spacing: 30
SetLabel{text: "测试地点:"}
SetTextField{
text: g_settingLocation
onValueChanged: g_settingLocation = value
}
}
Row{
spacing: 30
SetLabel{text: "测试单位:"}
SetTextField{
text: g_settingCompany
onValueChanged: g_settingCompany = value
}
}
Row{
spacing: 30
SetLabel{text: "探管设置:"}
ListView{
id: table_set
model: table_set_model
header: table_set_header
interactive: false
width: 1100
height: 300
delegate: table_tanguan_delegate
}
}
Row{
spacing: 30
SetLabel{text: "寄存器操作:"}
QxTitleButton{
text:"读取寄存器数据"
onClicked:{
execute("读取寄存器")
}
}
QxTitleButton{
text:"写入寄存器数据"
onClicked:{
var PowerStat = []
var VoltageThreshold = []
var CurrentThreshold = []
for(var i = 0; i < table_set_model.count; i++)
{
PowerStat.push(table_set_model.get(i).v1)
VoltageThreshold.push(table_set_model.get(i).v2)
CurrentThreshold.push(table_set_model.get(i).v3)
}
g_PowerStat = PowerStat
g_VoltageThreshold = VoltageThreshold
g_CurrentThreshold = CurrentThreshold
common.setG("PowerStat", JSON.stringify(PowerStat))
common.setG("VoltageThreshold", JSON.stringify(VoltageThreshold))
common.setG("CurrentThreshold", JSON.stringify(CurrentThreshold))
console.info("PowerStat", PowerStat, "VoltageThreshold", VoltageThreshold, "CurrentThreshold", CurrentThreshold)
executeVirtualTask("写入寄存器", ["写供电开关寄存器", "写电压阈值寄存器", "写电流阈值寄存器",])
}
}
}
Row{
spacing: 30
SetLabel{text: "定时任务:"}
TimeSelector{}
}
Row{
spacing: 30
SetLabel{text: "测试概要:"}
Rectangle
{
width: 1100
height: 100
border.color: "black"
border.width: 1
TextEdit{
anchors.fill: parent
font.pixelSize: 15
text: g_settingSummary
onEditingFinished: {
g_settingSummary = text
}
}
}
}
}
Component {
id: table_set_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
}
QxSwitch {
text: v1
onValueChanged:{
if(v1 != value)
v1 = value
}
}
QxLabel {
text: v2
editMode: true
onValueChanged:{
if(v2 != value)
v2 = value
}
}
QxLabel {
text: v3
editMode: true
onValueChanged:{
if(v3 != value)
v3 = value
}
}
QxLabel {
text: index + 1
}
QxLabel {
text: v4
editMode: true
onValueChanged:{
if(v4 != value)
v4 = value
}
}
}
Rectangle{
color:"#222"
width: 1
height: parent.height
z: 1
}
}
}
function on_readRegisterFinished()
{
var PowerStat = common.getG("PowerStat")
var VoltageThreshold = common.getG("VoltageThreshold")
var CurrentThreshold = common.getG("CurrentThreshold")
g_PowerStat = PowerStat
g_VoltageThreshold = VoltageThreshold
g_CurrentThreshold = CurrentThreshold
appendSetModel(PowerStat, 1)
appendSetModel(VoltageThreshold, 2)
appendSetModel(CurrentThreshold, 3)
}
function appendSetModel(datas, col)
{
if ( Array.isArray(datas) )
{
if (datas.length == 8)
{
for (var i=0; i<8; i++)
{
table_set_model.setProperty(i, "v"+col, datas[i].toString())
}
}
}
}
}