123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779 |
- 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 "tankValveTest.js" as TankValveTestJs
- Item {
- id:root
- //阀门生产厂家
- property string manufacture
- //阀门类型
- property string type
- //阀门编号
- property string serialNumber
- //使用单位
- property string user
- //车牌号
- property string carplate
- //试验次数
- property int count
- 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 string upPressure
- property string downPressure
- property int pressureCnt:0
- property var dataArray: []
- signal pressureDisplaySigFun(var pressureNumber)
- onPressureDisplaySigFun: {
- pressureDisplayInput(pressureNumber)
- }
- function pressureDisplayInput(number){
- pressureCnt++
- if(pressureCnt <= 61){
- dataArray.push(number)
- curveDisplay.spline.append(pressureCnt-1,number)
- }
- else{
- dataArray.push(number)
- dataArray.shift()
- curveDisplay.spline.clear()
- for(var i=0; i<61; i++){
- curveDisplay.spline.append(i,dataArray[i])
- }
- }
- gauge.value = number
- }
- onRunningChanged: {
- console.log("running:",running)
- if(running === true){
- if(Number(upPressure) <= Number(downPressure)){
- log.show("升压压力必须大于降压压力")
- startStopButton.running = false
- }
- else{
- startTimer.restart()
- }
- }
- else{
- stopTimer.start()
- tankStep.running = false
- }
- TankValveTestJs.running = running
- }
- function testStop(){
- processWindow.exit()
- tankStep.visible = true
- }
- Timer{
- id:stopTimer
- repeat: false
- interval: 500
- onTriggered: {
- choosevalve.menuEnable = false
- var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
- if(ret === false){
- log.show("自检错误")
- choosevalve.menuEnable = true
- return
- }
- console.log("退出试验,降压中...")
- processWindow.show("退出试验,降压中...")
- sensorTimer.stop()
- TankValveTestJs.valveTestTop(controlSerial,pressureDisplaySigFun,spy,log)
- testStop()
- choosevalve.menuEnable = true
- }
- }
- Timer{
- id:startTimer
- repeat: false
- interval: 500
- onTriggered: {
- choosevalve.menuEnable = false
- TankValveTestJs.exit = false
- console.log("正在自检....")
- var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
- if(ret === false){
- log.show("自检错误")
- return
- }
- console.log("自检正常")
- curveDisplay.spline.clear()
- groupbox.pressureCnt =0
- groupbox.dataArray = []
- tankStep.visible = false
- processWindow.show("压力降到0kPa")
- ret = TankValveTestJs.testInit(controlSerial,pressureDisplaySigFun,spy,log)
- if(ret === true){
- console.log("试验准备就绪")
- processWindow.show("试验准备就绪")
- tankStep.running = true
- spy.wait(500)
- testStop()
- }
- choosevalve.menuEnable = true
- // else{
- // console.log("退出试验,降压中...")
- // processWindow.show("退出试验,降压中...")
- // TankValveTestJs.valveTestTop(controlSerial,pressureDisplaySigFun,spy,log)
- // }
- // testStop()
- }
- }
- Timer{
- id:sensorTimer
- property var targetPressure
- property var bigValveFlag:false
- property var losePressureFlag:false
- property var cnt:0
- repeat: true
- interval: 500
- onTriggered: {
- cnt++
- var ret = ModbusJs.highPressureSensorReadReq(sensorSerial)
- if(cnt%2 == 0)
- groupbox.pressureDisplayInput(ret.pressureNumber)
- //当接近升压目标值时 关闭粗调阀
- if(ret.pressureNumber < targetPressure && ret.pressureNumber >(targetPressure-5) && bigValveFlag === true){
- bigValveFlag = false
- ModbusJs.bigTuningValveControl(controlSerial,false)
- console.log("关闭粗调阀门")
- }
- //当接近降压目标值时 关闭泄气阀
- var downPressure = Number(groupbox.downPressure)
- if(ret.pressureNumber > downPressure && ret.pressureNumber <(downPressure+15) && losePressureFlag === true){
- losePressureFlag = false
- ModbusJs.positivePressureTankOutputCtrl(controlSerial,false)
- console.log("关闭 泄压 阀门")
- }
- }
- }
- Connections{
- target: tankStep
- onUserClick:{
- switch(state){
- case "10%":
- var num = Number(groupbox.upPressure)*0.1
- var obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.pressureSensorCtrl(controlSerial,"高压")
- console.log("打开高压传感器阀门")
- ModbusJs.positivePressureTankInputCtrl(controlSerial,true)
- console.log("打开进气阀门")
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("比例调压阀压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 压力值 失败")
- }
- break
- case "50%":
- num = Number(groupbox.upPressure)*0.5
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "60%":
- num = Number(groupbox.upPressure)*0.6
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "70%":
- num = Number(groupbox.upPressure)*0.7
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "80%":
- num = Number(groupbox.upPressure)*0.8
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "90%":
- num = Number(groupbox.upPressure)*0.9
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "100%":
- num = Number(groupbox.upPressure)
- obj = ModbusJs.testFixedPressure(controlSerial,num)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- console.log("压力值:",obj.voltage)
- if(num > 50){
- ModbusJs.bigTuningValveControl(controlSerial,true)
- console.log("开启粗调阀门")
- sensorTimer.targetPressure = num
- sensorTimer.bigValveFlag = true
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- case "降压":
- var downPressure = Number(groupbox.downPressure)
- var upPressure = Number(groupbox.upPressure)
- obj = ModbusJs.testFixedPressure(controlSerial,downPressure)
- if(obj.ret === true){
- ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
- ModbusJs.bigTuningValveControl(controlSerial,false)
- console.log("压力值:",obj.voltage)
- console.log("关闭粗调阀门")
- if(downPressure < (upPressure - 20) && downPressure > 50){
- sensorTimer.losePressureFlag = true
- sensorTimer.targetPressure = downPressure
- ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
- console.log("开启 泄压 阀门")
- }
- sensorTimer.restart()
- }
- else{
- console.log("计算 调压值 失败")
- }
- break
- }
- }
- }
- function show(){
- animationShow.running = true
- }
- function exit(){
- animationExit.running = true
- TankValveTestJs.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
- color: "white"
- radius: 6
- Row{
- spacing: 10
- Item {
- width: 845
- height: 70
- Column{
- anchors.left: parent.left
- anchors.leftMargin: 10
- anchors.top: parent.top
- anchors.topMargin: 10
- spacing: 4
- Row{
- spacing: 10
- InputLine{
- id:manufactureInputLine
- paraName: "制造单位:"
- paraLength: 200
- onTextChanged: {
- root.manufacture = text
- }
- }
- InputLine{
- id:typeInputLine
- paraName: "型号:"
- paraLength: 150
- validator:RegExpValidator {
- regExp: /[0-9a-zA-Z.-]*/
- }
- onTextChanged: {
- root.type = text
- }
- }
- InputLine{
- id:serialNumberInputLine
- paraName: "编号:"
- paraLength: 150
- validator:RegExpValidator {
- regExp: /[0-9a-zA-Z.-]*/
- }
- text: root.serialNumber
- onTextChanged: {
- root.serialNumber = text
- }
- }
- // 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: 10
- InputLine{
- id:userInputLine
- paraName: "使用单位:"
- paraLength: 200
- onTextChanged: {
- root.user = text
- }
- }
- CarPlate{
- id:carplateInputLine
- paraName: "车牌:"
- paraLength: 150-55
- onPlattextChanged: {
- root.carplate = plattext
- console.log("TankValve Carplattext:" + plattext)
- }
- }
- InputLine{
- id:upPressureInputLine
- paraName: "试验压力(kPa):"
- paraLength: 89
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- inputMethodHints: Qt.ImhDigitsOnly
- onTextChanged: {
- groupbox.upPressure = text
- }
- }
- InputLine{
- id:downPressureInputLine
- paraName: "设计压力(kPa):"
- paraLength: 89
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- inputMethodHints: Qt.ImhDigitsOnly
- onTextChanged: {
- groupbox.downPressure = text
- }
- }
- }
- }
- }
- Item {
- width: 150
- height: 70
- // Row{
- //anchors.verticalCenter: parent.verticalCenter
- // spacing: 20
- StartStopButton{
- id:startStopButton
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- enabled: {
- if(groupbox.upPressure==="")
- return false
- if(groupbox.downPressure==="")
- return false
- // if(root.manufacture==="")
- // return false
- // if(root.type==="")
- // return false
- // if(root.serialNumber==="")
- // return false
- // if(root.user==="")
- // return false
- // if(root.carplate==="")
- // return false
- return true
- }
- width: 50
- height: 50
- //anchors.verticalCenter: parent.verticalCenter
- onRunningChanged: {
- groupbox.running = running
- }
- }
- // 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:500
- 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: 1000
- minimumValue: 0
- tickmarkStepSize:100
- labelStepSize:100
- 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
- }
- TankStep{
- id:tankStep
- upPressure: groupbox.upPressure
- downPressure:groupbox.downPressure
- }
- }
- }
- }
- //记录
- 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()*100)
- number *= 10
- var obj={}
- obj.pressure=number
- modelData.append(obj)
- }
- }
- Rectangle{
- width: record.tableWidth
- height: 265
- }
- // TabView {
- // id:tabview1
- // width: record.tableWidth
- // height: 265
- // GraphButton{
- // id:graphButton
- // x:910
- // 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: "升压10%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压50%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压60%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压70%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压80%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压90%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "升压100%保持记录"
- // RecordTable{
- // }
- // }
- // Tab {
- // title: "降压保持记录"
- // RecordTable{
- // }
- // }
- // }
- }
- }
- 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
- upPressureInputLine.textFocus = false
- downPressureInputLine.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";
- }
- }
- }
- }
- }
|