123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 |
- import QtQuick 2.11
- import QtQuick.VirtualKeyboard 2.14
- import QtQuick.VirtualKeyboard.Settings 2.14
- import QtQuick.Controls 1.4
- import "modbus.js" as ModbusJs
- import "peopleCoverHoleValveTest.js" as PeopleCoverHoleValveTestJs
- import Qt.labs.platform 1.1
- Item {
- id:root
- //阀门生产厂家
- property string manufacture
- //阀门类型
- property string type
- //阀门编号
- property string serialNumber
- //使用单位
- property string user
- //车牌号
- property string carplate
- //试验次数
- property int count:1
- //试验类型
- property int testType
- //阀 状态
- property string state
- Loader{
- id:loader
- anchors.fill: parent
- anchors.margins: 5
- }
- function show(){
- if(loader.sourceComponent === null){
- loader.sourceComponent = componet
- }
- loader.item.show()
- }
- function exit(){
- if(loader.sourceComponent !== null){
- loader.item.exit()
- }
- }
- Component{
- id:componet
- GroupBox{
- id:groupbox
- x:width
- title: "人孔盖试验"
- property bool running:startStopButton.running
- property int pressureCnt:0
- property var dataArray: []
- signal pressureDisplaySigFun(var pressureNumber)
- signal resultSigFun(var result)
- property var pointList0:[]
- property var pointList1:[]
- property var pointList2:[]
- property var pointList3:[]
- property var pointList4:[]
- property var pointList5:[]
- property int delayCnt: 0
- property int delayType: 0
- property int currentIndex :0
- onResultSigFun: {
- //需要区分第一次 第二次 第三次
- switch(groupbox.currentIndex){
- case 0:
- resultSetPressure1.paraResult = result.openPressureNumber
- resultSealPressure1.paraResult = result.sealPressureNumber
- break;
- case 1:
- resultSetPressure2.paraResult = result.openPressureNumber
- resultSealPressure2.paraResult = result.sealPressureNumber
- break;
- case 2:
- resultSetPressure3.paraResult = result.openPressureNumber
- resultSealPressure3.paraResult = result.sealPressureNumber
- break;
- }
- }
- function pressureDisplayInput(number){
- pressureCnt++
- //console.log("pressureDisplayInput number:%f", number)
- if(number+2 > curveDisplay.axisyMax ){
- curveDisplay.axisyMax = number +2
- }
- if(pressureCnt <= 61){
- dataArray.push(number)
- curveDisplay.spline.append(pressureCnt-1,number)
- }
- else{
- dataArray.push(number)
- //dataArray.shift()
- curveDisplay.spline.clear()
- curveDisplay.axisxMax = pressureCnt+1
- for(var i=0; i<pressureCnt; i++){
- curveDisplay.spline.append(i,dataArray[i])
- }
- }
- gauge.value = number
- }
- onPressureDisplaySigFun: {
- pressureDisplayInput(pressureNumber)
- }
- onRunningChanged: {
- PeopleCoverHoleValveTestJs.running = running
- if(running === true){
- startTimer.start()
- }
- }
- Timer{
- id:stopTimer
- repeat: false
- interval: 500
- onTriggered: {
- ModbusJs.closeAllValve(controlSerial)
- testStop()
- }
- }
- Timer{
- id:delayTimer
- repeat: false
- interval: 5000
- onTriggered: {
- if(delayType === 0){
- PeopleCoverHoleValveTestJs.airCylinderHoldUp()
- }else{
- PeopleCoverHoleValveTestJs.airCylinderHoldDown()
- }
- delayCnt = 0
- }
- }
- Timer{
- id:startTimer
- repeat: false
- interval: 500
- onTriggered: {
- choosevalve.menuEnable = false
- PeopleCoverHoleValveTestJs.exit = false
- console.log("正在自检....")
- var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
- if(ret === false){
- log.show("自检错误")
- testStop()
- choosevalve.menuEnable = true
- return
- }else{
- }
- curveDisplay.spline.clear()
- groupbox.pressureCnt =0
- groupbox.dataArray = []
- groupbox.currentIndex = 0
- do{
- //let tab = tabview1.getTab(groupbox.currentIndex)
- //let sealPressureModel = tab.item.modelData
- //sealPressureModel.clear()
- var tab = tabview1.getTab(groupbox.currentIndex)
- var tabView = tabview1
- var openPressureModel = tab.item.modelData
- tab = tabview1.getTab(groupbox.currentIndex+3)
- var sealPressureModel = tab.item.modelData
- openPressureModel.clear()
- sealPressureModel.clear()
- reuslt.visible = false
- ret = PeopleCoverHoleValveTestJs.testStart(groupbox.currentIndex,tabview1,processWindow,controlSerial,sensorSerial,
- openPressureModel,sealPressureModel,
- pressureDisplaySigFun,resultSigFun,spy,log)
- if(ret === false){
- processWindow.show("测试退出,泄气中...")
- PeopleCoverHoleValveTestJs.runningBackup = groupbox.running
- PeopleCoverHoleValveTestJs.releasePressure(controlSerial,pressureDisplaySigFun,spy,log)
- }
- spy.wait(500) //延时 确认全关继电器
- groupbox.currentIndex++
- }while(groupbox.currentIndex <root.count && ret === true)
- groupbox.testStop()
- choosevalve.menuEnable = true
- }
- }
- function testStop(){
- processWindow.exit()
- reuslt.visible = true
- startStopButton.running = false
- PeopleCoverHoleValveTestJs.resetio()
- }
- Connections{
- target: reportButton
- onUserClicked:{
- var tab = tabview1.getTab(0)
- var axisxMin = 0;var axisyMin = 0; var axisyMax=50;
- tab = tabview1.getTab(0)
- reportPicture0.generateTabPicture(tab,0,axisxMin,axisyMin,axisyMax)
- groupbox.pointList0 = reportPicture0.pointList;
- tab = tabview1.getTab(1)
- reportPicture1.generateTabPicture(tab,1,axisxMin,axisyMin,axisyMax)
- groupbox.pointList1 = reportPicture1.pointList;
- tab = tabview1.getTab(2)
- reportPicture2.generateTabPicture(tab,2,axisxMin,axisyMin,axisyMax)
- groupbox.pointList2 = reportPicture2.pointList;
- tab = tabview1.getTab(3)
- reportPicture3.generateTabPicture(tab,3,axisxMin,axisyMin,axisyMax)
- groupbox.pointList3 = reportPicture3.pointList;
- tab = tabview1.getTab(4)
- reportPicture4.generateTabPicture(tab,4,axisxMin,axisyMin,axisyMax)
- groupbox.pointList4 = reportPicture4.pointList;
- tab = tabview1.getTab(5)
- reportPicture5.generateTabPicture(tab,5,axisxMin,axisyMin,axisyMax)
- groupbox.pointList5 = reportPicture5.pointList;
- var fileName = root.manufacture+"_"+root.type+"_"+root.serialNumber+"_"+root.carplate
- var text = getWordSaveFileName(fileName)
- saveWordDialog.currentFile = getWordSaveFileName(text)
- saveWordDialog.open()
- }
- }
- FileDialog {
- id: saveWordDialog
- title: "保存为"
- nameFilters: [ "Word files (*.doc)"]
- fileMode: FileDialog.SaveFile
- onAccepted: {
- var savePath = file.toString().substring(8)
- var obj={}
- obj.pointList0 = groupbox.pointList0
- obj.pointList1 = groupbox.pointList1
- obj.pointList2 = groupbox.pointList2
- obj.pointList3 = groupbox.pointList3
- obj.pointList4 = groupbox.pointList4
- obj.pointList5 = groupbox.pointList5
- obj.manufacture = root.manufacture
- obj.type = root.type
- obj.serialNumber = root.serialNumber
- obj.user = root.user
- obj.carplate = root.carplate
- obj.state = root.state
- obj.setPressure = ""
- obj.valve="人孔盖"
- obj.resultSetPressure1 = resultSetPressure1.paraResult
- obj.resultSetPressure2 = resultSetPressure2.paraResult
- obj.resultSetPressure3 = resultSetPressure3.paraResult
- obj.resultSealPressure1 = resultSealPressure1.paraResult
- obj.resultSealPressure2 = resultSealPressure2.paraResult
- obj.resultSealPressure3 = resultSealPressure3.paraResult
- reportWord.generateWord(savePath,obj)
- }
- }
- function show(){
- animationShow.running = true
- }
- function exit(){
- PeopleCoverHoleValveTestJs.exit = true
- animationExit.running = true
- startStopButton.running = false
- stopTimer.start()
- PeopleCoverHoleValveTestJs.resetio()
- PeopleCoverHoleValveTestJs.reset_airCylinder()
- PeopleCoverHoleValveTestJs.exit = true
- }
- //加载任务动画效果
- NumberAnimation {
- id: animationShow
- target: groupbox
- property: "x"
- from: groupbox.x
- to: 0
- duration: 500
- }
- NumberAnimation {
- id: animationExit
- target: groupbox
- property: "x"
- from: groupbox.x
- to: 1024
- duration: 500
- }
- Column{
- anchors.left: parent.left
- anchors.leftMargin: 2
- anchors.top: parent.top
- anchors.topMargin: 10
- spacing: 0
- //参数
- Rectangle{
- width: 980
- height: 70+35
- color: "white"
- radius: 6
- Row{
- spacing: 23
- Item {
- width: 790//820
- height: 70+35
- Column{
- anchors.left: parent.left
- anchors.leftMargin: 10
- anchors.top: parent.top
- anchors.topMargin: 10
- spacing: 8
- Row{
- spacing: 15
- InputLine{
- id:manufactureInputLine
- paraName: "制造单位:"
- paraLength: 180
- onTextChanged: {
- root.manufacture = text
- }
- }
- InputLine{
- id:typeInputLine
- paraName: "型号:"
- paraLength: 180
- validator:RegExpValidator {
- regExp: /[0-9a-zA-Z.-]*/
- }
- onTextChanged: {
- root.type = text
- }
- }
- InputLine{
- id:serialNumberInputLine
- paraName: "编号:"
- paraLength: 180
- validator:RegExpValidator {
- regExp: /[0-9a-zA-Z.-]*/
- }
- onTextChanged: {
- root.serialNumber = text
- }
- }
- }
- Row{
- spacing: 15
- InputLine{
- id:userInputLine
- paraName: "使用单位:"
- paraLength: 180
- onTextChanged: {
- root.user = text
- }
- }
- CarPlate{
- id:carplateInputLine
- paraName: "车牌:"
- paraLength: 180-55
- onPlattextChanged: {
- root.carplate = plattext
- console.log("PeopleCoverHoleValve Carplattext:" + plattext)
- }
- }
- UserComboBox{
- id:valveStateComboBox
- anchors.verticalCenter: parent.verticalCenter
- width: 80
- height:25
- bgColor:"#D2D5D9"
- model: ["在用阀","新阀"]
- onCurrentTextChanged: {
- root.state = currentText
- }
- }
- UserComboBox{
- id:countComboBox
- width: 120
- height:25
- bgColor:"#D2D5D9"
- model: ["试验1次","试验2次", "试验3次"]
- onActivated: {
- }
- Binding{
- target: root
- property: "count"
- value: countComboBox.currentIndex+1
- }
- }
- }
- Row{
- spacing: 15
- Button{
- id:upButton
- text: "压抓上升"
- width: 115
- height: 25
- onClicked: {
- if(delayCnt === 0){
- PeopleCoverHoleValveTestJs.airCylinderUp()
- delayType = 0
- delayCnt = 5
- delayTimer.start()
- }else{
- }
- }
- }
- Button{
- id:downButton
- text: "压抓下降"
- width: 115
- height: 25
- onClicked: {
- //PeopleCoverHoleValveTestJs.airCylinderDown()
- if(delayCnt === 0){
- PeopleCoverHoleValveTestJs.airCylinderDown()
- delayType = 1
- delayCnt = 5
- delayTimer.start()
- }else{
- }
- }
- }
- InputLine{
- id:openPressure_min
- paraName: "最小开启压力(kPa):"
- paraLength: 40
- text: PeopleCoverHoleValveTestJs.openPressureMin
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- inputMethodHints: Qt.ImhDigitsOnly
- onTextChanged: {
- PeopleCoverHoleValveTestJs.openPressureMin = Number(text)
- console.log("openPressureMin:",PeopleCoverHoleValveTestJs.openPressureMin)
- }
- }
- InputLine{
- id:openPressure_max
- paraName: "最大开启压力(kPa):"
- paraLength: 40
- text: PeopleCoverHoleValveTestJs.openPressureMax
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- inputMethodHints: Qt.ImhDigitsOnly
- onTextChanged: {
- PeopleCoverHoleValveTestJs.openPressureMax = Number(text)
- console.log("openPressureMax:",PeopleCoverHoleValveTestJs.openPressureMax)
- }
- }
- InputLine{
- id:max_testtime
- paraName: "压力平稳时间(秒):"
- paraLength: 40
- text: PeopleCoverHoleValveTestJs.maxPressureStableTime
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- inputMethodHints: Qt.ImhDigitsOnly
- onTextChanged: {
- PeopleCoverHoleValveTestJs.maxPressureStableTime = Number(text)
- console.log("maxPressureStableTime:",PeopleCoverHoleValveTestJs.maxPressureStableTime)
- }
- }
- // Button{
- // id:setzero
- // text: "压力传感器标零"
- // width: 120
- // height: 25
- // onClicked: {
- // if(true === ModbusJs.mh_PressureSetZeroReq(sensorSerial)){
- // log.show("压力传感器标零成功")
- // }else{
- // log.show("压力传感器标零失败")
- // }
- // }
- // }
- }
- }
- }
- Item {
- width: 130
- height: 70
- Row{
- anchors.verticalCenter: parent.verticalCenter
- spacing: 30
- StartStopButton{
- id:startStopButton
- width: 50
- height: 50
- anchors.verticalCenter: parent.verticalCenter
- }
- ReportButton{
- id:reportButton
- width: 50
- height: 50
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- }
- }
- }
- //曲线 仪表 结果
- Row{
- x:-10
- //曲线
- CurveDisplay{
- id:curveDisplay
- anchors.verticalCenter: parent.verticalCenter
- width: 450
- height: 300
- axisxMax:60
- axisxMin:0
- axisyMax:35
- axisyMin:0
- name:"横轴时间(秒) 纵轴压力(kPa)"
- }
- //仪表
- Rectangle{
- width: (300-18)*0.75
- height: 300-18
- color: "white"
- radius: 6
- anchors.verticalCenter: parent.verticalCenter
- Gauge {
- id:gauge
- width: parent.width
- height: parent.width
- anchors.centerIn: parent
- value: 0
- maximumValue: 50
- minimumValue: 0
- tickmarkStepSize:5
- labelStepSize:5
- Behavior on value { NumberAnimation { duration: 1000 }}
- }
- }
- //试验结果
- Item {
- width: 338
- height: 300
- anchors.verticalCenter: parent.verticalCenter
- Rectangle{
- id:resultWindow
- anchors.fill: parent
- anchors.margins: 10
- color: "white"
- radius: 6
- ProcessWindow{
- id:processWindow
- width: 280
- height: 50
- hideWith:resultWindow.width
- anchors.centerIn: parent
- }
- Item {
- id:reuslt
- //visible: false
- anchors.fill: parent
- anchors.margins: 10
- property int resultHeight: 25
- Column{
- anchors.centerIn: parent
- ResultDisplayText{
- width: reuslt.width
- height: reuslt.resultHeight
- color: "white"
- paraName: "开启压力"
- paraResult:""
- paraUnit:""
- }
- ResultDisplayText{
- id:resultSetPressure1
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#D2D5D9"
- paraName: "第一次:"
- paraResult:""
- paraUnit:"kPa"
- }
- ResultDisplayText{
- id:resultSetPressure2
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#DFE2E6"
- paraName: "第二次:"
- paraResult:""
- paraUnit:"kPa"
- }
- ResultDisplayText{
- id:resultSetPressure3
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#D2D5D9"
- paraName: "第三次:"
- paraResult:""
- paraUnit:"kPa"
- }
- ResultDisplayText{
- width: reuslt.width
- height: reuslt.resultHeight
- color: "white"
- paraName: ""
- paraResult:""
- paraUnit:""
- }
- ResultDisplayText{
- width: reuslt.width
- height: reuslt.resultHeight
- color: "white"
- paraName: "密封压力"
- paraResult:""
- paraUnit:""
- }
- ResultDisplayText{
- id:resultSealPressure1
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#DFE2E6"
- paraName: "第一次:"
- paraResult:""
- paraUnit:"kPa"
- }
- ResultDisplayText{
- id:resultSealPressure2
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#D2D5D9"
- paraName: "第二次:"
- paraResult:""
- paraUnit:"kPa"
- }
- ResultDisplayText{
- id:resultSealPressure3
- width: reuslt.width
- height: reuslt.resultHeight
- color: "#DFE2E6"
- paraName: "第三次:"
- paraResult:""
- paraUnit:"kPa"
- }
- }
- }
- }
- }
- }
- //记录
- Row{
- id:record
- spacing: 10
- property int tableWidth:980
- function dataRandomSet(modelData,max){
- for(var i=0;i<max; i++){
- var number= Math.round(Math.random()*50)
- var obj={}
- obj.pressure=number
- modelData.append(obj)
- }
- }
- TabView {
- id:tabview1
- width: record.tableWidth
- height: 265-35
- GraphButton{
- id:graphButton
- x:870
- y:-25
- width: 48
- height: 24
- onUserClicked: {
- var tab = tabview1.getTab(tabview1.currentIndex)
- var axisxMax = tab.item.modelData.count
- generateCurve.show(0,axisxMax,0,50,tab.item.modelData,tab.title,"横轴时间(秒) 纵轴压力(kPa)")
- }
- }
- Tab {
- title: "第一次开启记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- Tab {
- title: "第二次开启记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- Tab {
- title: "第三次开启记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- Tab {
- title: "第一次密封记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- Tab {
- title: "第二次密封记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- Tab {
- title: "第三次密封记录"
- active: true
- RecordTable{
- // Component.onCompleted: {
- // record.dataRandomSet(modelData,20)
- // }
- }
- }
- }
- }
- }
- InputPanel {
- id: inputPanel
- visible: window.virtualkeyboard
- z: 99
- x: -13
- y: window.height
- width: window.width
- onActiveChanged: {
- if(!active)
- {
- manufactureInputLine.textFocus = false
- typeInputLine.textFocus = false
- serialNumberInputLine.textFocus = false
- userInputLine.textFocus = false
- carplateInputLine.textFocus = false
- releasePressureTimeMaxInputLine.textFocus = false
- sealPressureTimemaxInputLine.textFocus = false
- }
- }
- states:
- State {
- name: "visible"
- when: inputPanel.active
- PropertyChanges {
- target: inputPanel
- y: window.height/2
- }
- }
- transitions: Transition {
- from: ""
- to: "visible"
- reversible: true
- ParallelAnimation {
- NumberAnimation {
- properties: "y"
- duration: 250
- easing.type: Easing.InOutQuad
- }
- }
- }
- Component.onCompleted: {
- VirtualKeyboardSettings.styleName = "retro"
- VirtualKeyboardSettings.activeLocales=["en_GB","zh_CN"]
- VirtualKeyboardSettings.locale = "en_GB";//"fi_FI";
- }
- }
- }
- }
- }
|