// import QtQuick // import QtQuick.Controls // Page { // title: qsTr("Page 1") // Rectangle // { // anchors.fill: parent // color: "lightblue" // } // Label { // text: qsTr("You are on Page 1.") // anchors.centerIn: parent // } // } import QtQuick import QtQuick.Controls import QtQuick.Dialogs import QtQuick.Layouts import "./common" // import "./Style" Page { id: self signal logTabViewDoubleClick signal selectChartsDialogAcceptClick signal queryField signal selectPlanClick signal createPlanClick signal addCmdPlanClick signal updatePlans signal jsBtnClick() signal cmdEditClick(var cmdId) signal delCmdPlanClick(var row) signal deletePlanClick(var cmdPlanId) signal runPlanClick(var cmdPlanId) signal runStopPlanClick(var cmdPlanId) signal editPlanListViewClick signal createPlanDialogAcceptClick signal createCmdDialogAcceptClick signal logExplorerClick // Explorer中查看日志 signal logCleanClick // 清空日志 property var rowWidth : 600 property var rowHeight : 30 property alias _cbCmdInstrument: cbCmdInstrument property alias _cbCmdType : cbCmdType property alias _cbCmdModule : cbCmdModule property alias _tfCmdName : tfCmdName property alias _tfCmdWord : tfCmdWord property alias _teCmdData : teCmdData property alias _tfCs : tfCs property alias _tfYdcd : tfYdcd property alias _cbEncode : cbEncode property alias _cbDecode : cbDecode property alias _sendCheck : sendCheck property alias _receiveCheck : receiveCheck property var jsText : "" // base64编码 property alias _tfYmsm : tfYmsm property alias _editPlanLstTableView: editPlanLstTableView property alias _editPlanListView: editPlanListView property alias _createPlanDialog: createPlanDialog property alias _tfPlanName: tfPlanName property alias _tfPlanRemark: tfPlanRemark property alias _selectCharts: selectCharts property alias _createCmdDialog: createCmdDialog // property alias _tabCharts: tabCharts property var planModel: ListModel{} 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 } QxTitleButton{ width: 40 height: 40 anchors.left: speed.right anchors.leftMargin: 20 anchors.verticalCenter: parent.verticalCenter text: "编辑\n指令" enabled: !lstRunning visible: isAdmin onClicked: cmdEditClick(planCmdId) } } SplitView{ 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 QxTitleButton{ text: "创建" visible: isAdmin onClicked: createPlanClick() } QxTitleButton{ text: "删除" visible: isAdmin enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 onClicked: deletePlanClick(planLstModel.get(editPlanListView.currentIndex).id) } QxTitleButton{ text: "运行" enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 onClicked: runPlanClick(planLstModel.get(editPlanListView.currentIndex).id) } QxTitleButton{ text: !lstRunning ? "运行" : "结束" visible: false enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 onClicked: !lstRunning ? runPlanClick(planLstModel.get(editPlanListView.currentIndex).id) : runStopPlanClick(planLstModel.get(editPlanListView.currentIndex).id) } } } 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") QxText { x: 5 anchors.verticalCenter: parent.verticalCenter color: "black" text: !!model.name ? model.name.replace(planFirstName,"") : "" onTextChanged: { if(text == "") { model.name = text } } } 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 QxTitleButton{ text: "+" visible: isAdmin enabled: editPlanListView.currentIndex > -1 && planLstModel.count > 0 && !lstRunning onClicked: addCmdPlanClick() } QxTitleButton{ text: "-" visible: isAdmin enabled: editPlanLstTableView.currentRow > -1 && editPlanListView.currentIndex > -1 && planLstModel.count > 0 && !lstRunning onClicked: delCmdPlanClick(editPlanLstTableView.currentRow) } QxTitleButton{ text: "保存" visible: false enabled: editPlanListView.currentIndex > -1 && !lstRunning onClicked: updatePlans() } } } TableView{ id: editPlanLstTableView anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom anchors.topMargin: 40 // headerDelegate: Rectangle{ // anchors.top: parent.top // width: parent.width // height: 25 // color: "white" // QxText { // anchors.centerIn: parent // font.pointSize: 10 // text: styleData.value // } // Rectangle{ // width: 1 // height: parent.height // visible: styleData.value !== "序号" // color: "lightgray" // } // Rectangle{ // y: parent.height // width: parent.width // height: 1 // color: "lightgray" // } // } // rowDelegate: Rectangle{ // height: 20 // color : editPlanLstTableView.currentRow === styleData.row ? "#beebff": ( (styleData.row %2 == 0) ? "#f2f2f2": "white" ) // } // itemDelegate: Item { // clip: true // QxText { // visible: styleData.role === "id" // x: 5 // anchors.centerIn: parent // color: "#999999" // elide: styleData.elideMode // font.pointSize: 10 // text: styleData.row + 1 // } // QxText{ // z: 2 // visible: styleData.role === "asd"&& !tp.visible // text: !!model ? model.asd : "" // } // QxTextInput{ // z: 2 // id: tp // visible: false // onTextChanged: { // if( styleData.role === "asd" ) // model.asd = text // else if(styleData.role === "rsd") // model.rsd = text // else if(styleData.role === "speed") // model.speed = text // else if(styleData.role === "displayruntime") // model.displayruntime = text // updatePlans() // } // onFocusChanged: { // if(!focus) // visible = false // } // Connections{ // target: self // function onEditPlanListViewClick() // { // tp.visible = false // } // } // } // QxText{ // z: 2 // visible: styleData.role === "rsd" && !tp.visible // text: !!model ? model.rsd : "" // } // QxText{ // z: 2 // visible: styleData.role === "speed"&& !tp.visible // text: !!model ? model.speed : "" // } // Item{ // anchors.fill: parent // visible: styleData.role === "direction" // QxText { // text: !!model ? ( model.direction == "0" ? "反向" : "正向" ) : "" // } // MouseArea{ // anchors.fill: parent // onClicked: { // if(model.direction == "1") // model.direction = "0" // else // model.direction = "1" // updatePlans() // } // } // } // QxText{ // z: 2 // visible: styleData.role === "displayruntime"&& !tp.visible // text: !!model ? model.displayruntime : "" // } // MouseArea{ // visible: styleData.role !== "direction" && styleData.role !== "id" // anchors.fill: parent // onClicked: { // tp.text = styleData.value // tp.focus = true // tp.visible = true // } // } // Rectangle{ // width: 1 // height: parent.height // visible: styleData.role !== "id" // color: "lightgray" // } // } Rectangle{ width: parent.width height: 1 color: "lightgray" } // TableViewColumn { // id: planNoCol // title: "序号" // role: "id" // width: 80 // } // TableViewColumn { // id: planAsdCol // visible: false // title: "加速度 (r/s2)" // role: "asd" // width: (editPlanLstTableView.width - 82 ) /3 // } // TableViewColumn { // id: planRsdCol // visible: false // title: "减速度 (r/s2)" // role: "rsd" // width: planAsdCol.width // } // TableViewColumn { // id: planSpeedCol // title: "速度 (rpm)" // role: "speed" // width: planAsdCol.width // } // TableViewColumn { // id: planDirectionCol // title: "转动方向" // role: "direction" // width: planAsdCol.width // } // TableViewColumn { // id: planRunTimeCol // title: "运行时间 (s)" // role: "displayruntime" // width: planAsdCol.width // } model: planModel } } } // TabView{ // id:tabCharts // anchors.left: parent.left // anchors.right: parent.right // anchors.bottom: parent.bottom // anchors.top: titleBar.bottom // style: TabViewStyle { // frameOverlap: 1 // tab: Rectangle { // color: styleData.selected ? "#f2f2f2" :"#ffffff" // border.color: "#d2d2d2" // implicitWidth: Math.max(t_text.width + 30, 80) // implicitHeight: 25 // radius: 2 // Item { // width: parent.width - 12 // height: 25 // QxText { // id: t_text // visible: !t_input.visible // anchors.centerIn: parent // text: styleData.title // font.pointSize: 10 // color: "black" // MouseArea{ // anchors.fill: parent // enabled: styleData.selected // onClicked: tabCharts.currentIndex = styleData.index // onDoubleClicked:{ // t_input.text = "" // t_input.visible = true // t_input.forceActiveFocus() // } // } // } // QxTextInput // { // id: t_input // width: t_text.width // height: t_text.height // font.pointSize: 10 // focus: true // visible: false // property var isSelected: tabCharts.currentIndex === styleData.index // anchors.centerIn: parent // onIsSelectedChanged:{ // if( t_input.text != "" && t_input.text != t_text.text ) // { // t_text.text = t_input.text // tabCharts.getTab(styleData.index).item.name = t_input.text // } // visible = false // } // onAccepted:{ // if( t_input.text != "" ) // { // t_text.text = t_input.text // tabCharts.getTab(styleData.index).item.name = t_input.text // } // visible = false // } // } // } // Rectangle{ // anchors.right: parent.right // anchors.verticalCenter: parent.verticalCenter // anchors.rightMargin: 2 // border.width: 1 // border.color: styleData.selected ? "#da4e3a" : "#ababab" // color: styleData.selected ? "#e08458" : "#cecece" // width: 10 // height: 10 // Image { // anchors.centerIn: parent // width: 8 // height: 8 // source:"./resource/tabclose.png" // } // MouseArea{ // anchors.fill: parent // onClicked:{ // tabCharts.getTab(styleData.index).item.removeTab() // tabCharts.removeTab(styleData.index) // } // } // } // } // frame: Rectangle { color: "#efefef" } // } // } Dialog{ id: selectCharts title: "创建图表" standardButtons: Dialog.NoButton visible: false width: 800 height: 650 Column { anchors.centerIn: parent spacing: 5 Row { GroupBox{ width: 398 height: 600 title: "测量项" clip: true Item { anchors.fill: parent clip: true ListView { id: lstMeasureItem anchors.fill: parent delegate: Rectangle{ width: 390 height: 30 color: lstMeasureItem.currentIndex === index ? "#beebff" : "#efefef" QxText{ text: name anchors.verticalCenter: parent.verticalCenter } MouseArea{ anchors.fill: parent onClicked: { lstMeasureItem.currentIndex = index } } } model:measureItemModel } } } GroupBox{ width: 398 height: 600 title: "测量值" ListView { id: lstMeasureValue anchors.fill: parent model:measureValueModel delegate: Rectangle{ width: 390 height: visible ? 30 : 0 color: "#efefef" visible: lstMeasureItem.currentIndex > -1 ? (measureItemModel.get(lstMeasureItem.currentIndex).name===parentName) : false CheckBox{ text: name checked: isChecked // style: CheckBoxStyle{} anchors.verticalCenter: parent.verticalCenter } MouseArea{ anchors.fill: parent onClicked: { model.isChecked = !model.isChecked } } } } } } Row { anchors.right: parent.right spacing: 20 Button { text: "确认" // style: ButtonStyle{} onClicked: selectCharts.accept() } Button { text: "取消" // style: ButtonStyle{} onClicked: selectCharts.reject() } } } onAccepted: selectChartsDialogAcceptClick() } Dialog { id: createPlanDialog title: "新建计划" standardButtons: Dialog.NoButton width: 350 height: 200 Column { anchors.centerIn: parent spacing: 30 Item{ width: 300 height: 30 QxText{text: "计划名称"} QxTextField{id: tfPlanName;anchors.right: parent.right;width: 200;height: 30} } Item{ width: 300 height: 30 QxText{text:"备注"} QxTextField{id: tfPlanRemark;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: createCmdDialog title: "创建指令" standardButtons: Dialog.NoButton visible: false width: 600 height: 650 Column { anchors.centerIn: parent spacing: 5 Item{ width: rowWidth height: rowHeight QxText{text: "所属仪器"} ComboBox{id: cbCmdInstrument;model:selectTypes;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text: "指令分类"} ComboBox{id: cbCmdType;model:selectTypes;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text: "被测模块"} ComboBox{id: cbCmdModule;model:selectTypes;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text: "指令名称"} QxTextField{id: tfCmdName;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text:"指令字"} QxRegTextField{id:tfCmdWord;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: 200 QxText{text:"指令数据"} QxTextArea{id:teCmdData; anchors.right: parent.right;width: 500;height: 200} } Item{ width: rowWidth height: rowHeight Item{ width: rowWidth/2-10 height: rowHeight anchors.left: parent.left QxText{text:"超时"} QxTextField{id:tfCs; x: 138; y: 0;anchors.right: parent.right;width: 160;height: 30 ;anchors.rightMargin: 30} QxText{anchors.left: tfCs.right;text:"ms" ;anchors.leftMargin: 5} } Item{ width: rowWidth/2-15 height: rowHeight anchors.right: parent.right QxText{text:"应答长度"} QxTextField{id:tfYdcd; y: 0;anchors.right: parent.right;width: 180;height: 30 ;} } } Item{ width: rowWidth height: rowHeight QxText{text:"编码"} ComboBox{id: cbEncode;model:codec_display_lists;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text:"解码"} ComboBox{id: cbDecode; model:codec_display_lists;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text:"发送校验"} ComboBox{id: sendCheck;model:check_display_lists;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text:"接收校验"} ComboBox{id: receiveCheck;model:check_display_lists;anchors.right: parent.right;width: 500;height: 30} } Item{ width: rowWidth height: rowHeight QxText{text:"脚本"} Button{ id:jsBtn;text:"编辑";anchors.right: parent.right;width: 100;height: 30 onClicked: jsBtnClick() } } Item{ width: rowWidth height: rowHeight QxText{text:"备注"} QxTextField{id:tfYmsm;anchors.right: parent.right;width: 500;height: 30} } Row { anchors.right: parent.right spacing: 20 Button { text: "确认" // style: ButtonStyle{} onClicked: createCmdDialog.accept() } Button { text: "取消" // style: ButtonStyle{} onClicked: createCmdDialog.reject() } } } onAccepted: createCmdDialogAcceptClick() } }