503 lines
18 KiB
QML
503 lines
18 KiB
QML
import QtQuick
|
||
import QtQuick.Controls
|
||
import QtQuick.Dialogs
|
||
import QtQuick.Layouts
|
||
|
||
import "./common"
|
||
// import "./Style"
|
||
Item {
|
||
id: self
|
||
signal logTabViewDoubleClick
|
||
|
||
signal queryField
|
||
signal selectPlanClick
|
||
signal createPlanClick
|
||
signal addCmdPlanClick
|
||
signal updatePlans
|
||
signal cmdEditClick(var cmdId)
|
||
signal delCmdPlanClick(var row)
|
||
signal deletePlanClick(var row)
|
||
signal runPlanClick(var row)
|
||
signal runStopPlanClick()
|
||
signal setPlanDialogAcceptClick
|
||
signal cbDeviceActivated
|
||
signal cbInterfaceActived
|
||
signal setPlanClick
|
||
signal editPlanListViewClick
|
||
signal createPlanDialogAcceptClick
|
||
|
||
|
||
property var rowWidth : 600
|
||
property var rowHeight : 30
|
||
property alias _setPlanDialog: setPlanDialog
|
||
property alias _editPlanLstTableView: editPlanLstTableView
|
||
property alias _editPlanListView: editPlanListView
|
||
property alias _createPlanDialog: createPlanDialog
|
||
property alias _tfPlanName: tfPlanName
|
||
property alias _cbDevice: cbDevice
|
||
property alias _cbInterface: cbInterface
|
||
property alias _cbInstruction: cbInstruction
|
||
property var planModel: ListModel{}
|
||
property var devNameArray: []
|
||
property var devModelIdArray: []
|
||
property var interfacesArray: []
|
||
property var deviceIdArray:[]
|
||
property var interfaceNameArray: []
|
||
property var instructionNameArray: []
|
||
property var instructionIdArray: []
|
||
property var planLstModel: ListModel{}
|
||
property var measureItemModel: ListModel{}
|
||
property var measureValueModel: ListModel{}
|
||
|
||
|
||
|
||
Rectangle
|
||
{
|
||
id: titleBar
|
||
width: parent.width
|
||
height: 80
|
||
color: "#f3f3f3"
|
||
border.color: "lightgray"
|
||
border.width: 1
|
||
anchors.top: parent.top
|
||
anchors.horizontalCenter: parent.horizontalCenter
|
||
|
||
Speed{
|
||
id: speed
|
||
anchors.left: parent.left
|
||
anchors.leftMargin: 20
|
||
anchors.bottom: parent.bottom
|
||
anchors.bottomMargin: 5
|
||
}
|
||
}
|
||
|
||
Item{
|
||
anchors.left: parent.left
|
||
anchors.right: parent.right
|
||
anchors.bottom: parent.bottom
|
||
anchors.top: titleBar.bottom
|
||
Component.onCompleted: get_queues()
|
||
Rectangle
|
||
{
|
||
id: editPlanListRect
|
||
width: 500
|
||
height: parent.height-10
|
||
border.width: 1
|
||
border.color: "#999999"
|
||
clip: true
|
||
Rectangle{
|
||
anchors.left : parent.left
|
||
height: 40
|
||
anchors.top: parent.top
|
||
anchors.right: parent.right
|
||
border.width: 1
|
||
color: "#f3f3f3"
|
||
border.color: "lightgray"
|
||
Row
|
||
{
|
||
x: 5
|
||
anchors.verticalCenter: parent.verticalCenter
|
||
spacing: 5
|
||
Button{
|
||
text: "创建"
|
||
visible: isAdmin
|
||
onClicked: createPlanClick()
|
||
}
|
||
Button{
|
||
text: "删除"
|
||
visible: isAdmin
|
||
enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0
|
||
onClicked: deletePlanClick(editPlanListView.currentIndex)
|
||
}
|
||
Button{
|
||
text: "运行"
|
||
enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0
|
||
onClicked: runPlanClick(editPlanListView.currentIndex)
|
||
}
|
||
Button{
|
||
text: "结束"
|
||
visible: true
|
||
enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0
|
||
onClicked: runStopPlanClick()
|
||
}
|
||
Button{
|
||
text: "设置"
|
||
|
||
onClicked: setPlanClick()
|
||
}
|
||
}
|
||
}
|
||
ListView
|
||
{
|
||
id: editPlanListView
|
||
anchors.left: parent.left
|
||
anchors.right: parent.right
|
||
anchors.top: parent.top
|
||
anchors.bottom: parent.bottom
|
||
anchors.topMargin: 40
|
||
anchors.leftMargin: 2
|
||
clip: true
|
||
model: planLstModel
|
||
delegate:
|
||
Rectangle {
|
||
width: editPlanListView.width
|
||
height: 30
|
||
clip: true
|
||
color: editPlanListView.currentIndex == index ? "#beebff" : ((index %2 == 1) ? "#f2f2f2": "white")
|
||
Text {
|
||
x: 5
|
||
anchors.verticalCenter: parent.verticalCenter
|
||
color: "black"
|
||
text: name
|
||
|
||
}
|
||
MouseArea{
|
||
anchors.fill: parent
|
||
onClicked: {
|
||
editPlanListView.currentIndex = index
|
||
editPlanListViewClick()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Rectangle{
|
||
height: parent.height
|
||
anchors.left:editPlanListRect.right
|
||
anchors.right: parent.right
|
||
anchors.leftMargin: 5
|
||
Rectangle{
|
||
anchors.left : parent.left
|
||
height: 40
|
||
anchors.top: parent.top
|
||
anchors.right: parent.right
|
||
border.width: 1
|
||
color: "#f3f3f3"
|
||
border.color: "lightgray"
|
||
Row
|
||
{
|
||
x: 5
|
||
anchors.verticalCenter: parent.verticalCenter
|
||
spacing: 5
|
||
Button{
|
||
text: "添加"
|
||
visible: isAdmin
|
||
enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 && !lstRunning
|
||
onClicked: addCmdPlanClick()
|
||
}
|
||
Button{
|
||
text: "删除"
|
||
visible: isAdmin
|
||
enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 && !lstRunning
|
||
onClicked: delCmdPlanClick(editPlanLstTableView.currentIndex)
|
||
}
|
||
Button{
|
||
text: "保存"
|
||
visible: false
|
||
enabled: editPlanListView.currentIndex > -1 && !lstRunning
|
||
onClicked: updatePlans()
|
||
}
|
||
}
|
||
}
|
||
Item
|
||
{
|
||
anchors.left: parent.left
|
||
anchors.right: parent.right
|
||
anchors.top: parent.top
|
||
anchors.bottom: parent.bottom
|
||
anchors.topMargin: 40
|
||
clip: true
|
||
ListView{
|
||
id: editPlanLstTableView
|
||
header: headerView
|
||
delegate: instructDelegate
|
||
model: planModel
|
||
anchors.fill: parent
|
||
}
|
||
}
|
||
|
||
Component {
|
||
id: instructDelegate
|
||
Rectangle {
|
||
width:editPlanLstTableView.width;
|
||
height: 20;
|
||
color: editPlanLstTableView.currentIndex == index ? "#beebff" : ((index %2 == 1) ? "#f2f2f2": "white")
|
||
z:2;//将表头的z坐标设置在上层,表头在设置属性为overlayHeader时就不会随滑动而消失,始终显示在最上面
|
||
MouseArea{
|
||
anchors.fill: parent
|
||
onPressed:(mouse)=> {
|
||
editPlanLstTableView.currentIndex = index
|
||
mouse.accepted = false
|
||
}
|
||
}
|
||
Row {
|
||
width: 0.9*parent.width;
|
||
height: parent.height;
|
||
anchors.left: parent.left;
|
||
anchors.leftMargin: 0.1*parent.width;
|
||
Label {
|
||
text: index+1;
|
||
font.pixelSize: 12;
|
||
width: 0.25*parent.width;
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
Item
|
||
{
|
||
width: 0.25*parent.width;
|
||
height: parent.height
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
|
||
TextField
|
||
{
|
||
id: tfSpeed
|
||
visible: false
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
onTextChanged: {
|
||
speed = text;
|
||
}
|
||
onEditingFinished: {
|
||
speed = text;
|
||
updatePlans()
|
||
tfSpeed.visible = false;
|
||
}
|
||
}
|
||
Label {
|
||
id: lbSpeed
|
||
visible: !tfSpeed.visible;
|
||
text: speed;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
font.pixelSize: 12;
|
||
}
|
||
MouseArea{
|
||
anchors.fill: parent;
|
||
visible: !tfSpeed.visible;
|
||
onClicked: {
|
||
tfSpeed.visible = true;
|
||
tfSpeed.text = speed;
|
||
}
|
||
}
|
||
}
|
||
Item
|
||
{
|
||
width: 0.25*parent.width;
|
||
height: parent.height
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
|
||
ComboBox
|
||
{
|
||
id: cbSpeed;
|
||
width: 0.25*parent.width;
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
model: ["正向", "反向"]
|
||
currentIndex: direction=="1" ? 0 : 1;
|
||
onActivated: {
|
||
direction = currentIndex == 0 ? "1" : "0"
|
||
updatePlans()
|
||
}
|
||
}
|
||
}
|
||
Item
|
||
{
|
||
width: 0.25*parent.width;
|
||
height: parent.height
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
|
||
TextField
|
||
{
|
||
id: tfRuntime
|
||
visible: false
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
onTextChanged: {
|
||
runtime = text;
|
||
}
|
||
onEditingFinished: {
|
||
runtime = text;
|
||
updatePlans()
|
||
tfRuntime.visible = false;
|
||
}
|
||
}
|
||
Label {
|
||
id: lbRuntime
|
||
text: runtime;
|
||
font.pixelSize: 12;
|
||
visible: !tfRuntime.visible;
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
MouseArea{
|
||
anchors.fill: parent;
|
||
visible: !tfRuntime.visible;
|
||
onClicked: {
|
||
tfRuntime.visible = true;
|
||
tfRuntime.text = runtime;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Component {
|
||
id:headerView;
|
||
Rectangle {
|
||
width:parent.width;
|
||
height: 20;
|
||
color: "lightgrey";
|
||
z:2;//将表头的z坐标设置在上层,表头在设置属性为overlayHeader时就不会随滑动而消失,始终显示在最上面
|
||
|
||
Row {
|
||
width: 0.9*parent.width;
|
||
height: parent.height;
|
||
anchors.left: parent.left;
|
||
anchors.leftMargin: 0.1*parent.width;
|
||
Label {
|
||
text: "序号";
|
||
font.pixelSize: 12;
|
||
width: 0.25*parent.width;
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
Label {
|
||
text: "速度(rpm)";
|
||
font.pixelSize: 12;
|
||
width: 0.25*parent.width;
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
Label {
|
||
text: "转动方向";
|
||
font.pixelSize: 12;
|
||
width: 0.25*parent.width
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
Label {
|
||
text: "运行时间(s)";
|
||
font.pixelSize: 12;
|
||
width: 0.25*parent.width
|
||
anchors.verticalCenter: parent.verticalCenter;
|
||
verticalAlignment: Text.AlignHCenter;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
Dialog {
|
||
id: createPlanDialog
|
||
title: "新建计划"
|
||
standardButtons: Dialog.NoButton
|
||
width: 350
|
||
height: 160
|
||
Column
|
||
{
|
||
anchors.centerIn: parent
|
||
spacing: 30
|
||
Item{
|
||
width: 300
|
||
height: 30
|
||
Text{text: "计划名称"}
|
||
TextField{id: tfPlanName;anchors.right: parent.right;width: 200;height: 30}
|
||
}
|
||
|
||
Row
|
||
{
|
||
width: 300
|
||
height: 30
|
||
spacing: 100
|
||
Button
|
||
{
|
||
text: "确认"
|
||
// style: ButtonStyle{}
|
||
onClicked: createPlanDialog.accept()
|
||
}
|
||
Button
|
||
{
|
||
text: "取消"
|
||
// style: ButtonStyle{}
|
||
onClicked: createPlanDialog.reject()
|
||
}
|
||
}
|
||
}
|
||
onAccepted: createPlanDialogAcceptClick()
|
||
}
|
||
|
||
Dialog {
|
||
id: setPlanDialog
|
||
title: "指令配置"
|
||
standardButtons: Dialog.NoButton
|
||
width: 300
|
||
height: 280
|
||
|
||
Column
|
||
{
|
||
anchors.centerIn: parent
|
||
spacing: 30
|
||
|
||
Item{
|
||
width: 260
|
||
height: 30
|
||
Text{text: "设备"}
|
||
ComboBox{
|
||
id: cbDevice
|
||
width: 200
|
||
height: 30
|
||
anchors.right: parent.right
|
||
model: devNameArray
|
||
onActivated: cbDeviceActivated()
|
||
}
|
||
}
|
||
Item{
|
||
width: 260
|
||
height: 30
|
||
Text{text: "接口"}
|
||
ComboBox{
|
||
id: cbInterface
|
||
width: 200
|
||
height: 30
|
||
anchors.right: parent.right
|
||
model: interfaceNameArray
|
||
onActivated: cbInterfaceActived()
|
||
}
|
||
}
|
||
Item{
|
||
width: 260
|
||
height: 30
|
||
Text{text: "指令"}
|
||
ComboBox{
|
||
id: cbInstruction
|
||
width: 200
|
||
height: 30
|
||
anchors.right: parent.right
|
||
model: instructionNameArray
|
||
}
|
||
}
|
||
|
||
Row
|
||
{
|
||
width: 260
|
||
height: 30
|
||
spacing: 100
|
||
Button
|
||
{
|
||
text: "确认"
|
||
// style: ButtonStyle{}
|
||
onClicked: setPlanDialog.accept()
|
||
}
|
||
Button
|
||
{
|
||
text: "取消"
|
||
// style: ButtonStyle{}
|
||
onClicked: setPlanDialog.reject()
|
||
}
|
||
}
|
||
}
|
||
onAccepted: setPlanDialogAcceptClick()
|
||
}
|
||
}
|