TankValve.qml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. import QtQuick 2.11
  2. import QtQuick.VirtualKeyboard 2.14
  3. import QtQuick.VirtualKeyboard.Settings 2.14
  4. import QtQuick.Controls 1.4
  5. import "modbus.js" as ModbusJs
  6. import "tankValveTest.js" as TankValveTestJs
  7. Item {
  8. id:root
  9. //阀门生产厂家
  10. property string manufacture
  11. //阀门类型
  12. property string type
  13. //阀门编号
  14. property string serialNumber
  15. //使用单位
  16. property string user
  17. //车牌号
  18. property string carplate
  19. //试验次数
  20. property int count
  21. Loader{
  22. id:loader
  23. anchors.fill: parent
  24. anchors.margins: 5
  25. }
  26. function show(){
  27. if(loader.sourceComponent === null){
  28. loader.sourceComponent = componet
  29. }
  30. loader.item.show()
  31. }
  32. function exit(){
  33. if(loader.sourceComponent !== null){
  34. loader.item.exit()
  35. }
  36. }
  37. Component{
  38. id:componet
  39. GroupBox{
  40. id:groupbox
  41. x:width
  42. title: "罐体耐压试验"
  43. property bool running:startStopButton.running
  44. property string upPressure
  45. property string downPressure
  46. property int pressureCnt:0
  47. property var dataArray: []
  48. signal pressureDisplaySigFun(var pressureNumber)
  49. onPressureDisplaySigFun: {
  50. pressureDisplayInput(pressureNumber)
  51. }
  52. function pressureDisplayInput(number){
  53. pressureCnt++
  54. if(pressureCnt <= 61){
  55. dataArray.push(number)
  56. curveDisplay.spline.append(pressureCnt-1,number)
  57. }
  58. else{
  59. dataArray.push(number)
  60. dataArray.shift()
  61. curveDisplay.spline.clear()
  62. for(var i=0; i<61; i++){
  63. curveDisplay.spline.append(i,dataArray[i])
  64. }
  65. }
  66. gauge.value = number
  67. }
  68. onRunningChanged: {
  69. console.log("running:",running)
  70. if(running === true){
  71. if(Number(upPressure) <= Number(downPressure)){
  72. log.show("升压压力必须大于降压压力")
  73. startStopButton.running = false
  74. }
  75. else{
  76. startTimer.restart()
  77. }
  78. }
  79. else{
  80. stopTimer.start()
  81. tankStep.running = false
  82. }
  83. TankValveTestJs.running = running
  84. }
  85. function testStop(){
  86. processWindow.exit()
  87. tankStep.visible = true
  88. }
  89. Timer{
  90. id:stopTimer
  91. repeat: false
  92. interval: 500
  93. onTriggered: {
  94. choosevalve.menuEnable = false
  95. var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
  96. if(ret === false){
  97. log.show("自检错误")
  98. choosevalve.menuEnable = true
  99. return
  100. }
  101. console.log("退出试验,降压中...")
  102. processWindow.show("退出试验,降压中...")
  103. sensorTimer.stop()
  104. TankValveTestJs.valveTestTop(controlSerial,pressureDisplaySigFun,spy,log)
  105. testStop()
  106. choosevalve.menuEnable = true
  107. }
  108. }
  109. Timer{
  110. id:startTimer
  111. repeat: false
  112. interval: 500
  113. onTriggered: {
  114. choosevalve.menuEnable = false
  115. TankValveTestJs.exit = false
  116. console.log("正在自检....")
  117. var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
  118. if(ret === false){
  119. log.show("自检错误")
  120. return
  121. }
  122. console.log("自检正常")
  123. curveDisplay.spline.clear()
  124. groupbox.pressureCnt =0
  125. groupbox.dataArray = []
  126. tankStep.visible = false
  127. processWindow.show("压力降到0kPa")
  128. ret = TankValveTestJs.testInit(controlSerial,pressureDisplaySigFun,spy,log)
  129. if(ret === true){
  130. console.log("试验准备就绪")
  131. processWindow.show("试验准备就绪")
  132. tankStep.running = true
  133. spy.wait(500)
  134. testStop()
  135. }
  136. choosevalve.menuEnable = true
  137. // else{
  138. // console.log("退出试验,降压中...")
  139. // processWindow.show("退出试验,降压中...")
  140. // TankValveTestJs.valveTestTop(controlSerial,pressureDisplaySigFun,spy,log)
  141. // }
  142. // testStop()
  143. }
  144. }
  145. Timer{
  146. id:sensorTimer
  147. property var targetPressure
  148. property var bigValveFlag:false
  149. property var losePressureFlag:false
  150. property var cnt:0
  151. repeat: true
  152. interval: 500
  153. onTriggered: {
  154. cnt++
  155. var ret = ModbusJs.highPressureSensorReadReq(sensorSerial)
  156. if(cnt%2 == 0)
  157. groupbox.pressureDisplayInput(ret.pressureNumber)
  158. //当接近升压目标值时 关闭粗调阀
  159. if(ret.pressureNumber < targetPressure && ret.pressureNumber >(targetPressure-5) && bigValveFlag === true){
  160. bigValveFlag = false
  161. ModbusJs.bigTuningValveControl(controlSerial,false)
  162. console.log("关闭粗调阀门")
  163. }
  164. //当接近降压目标值时 关闭泄气阀
  165. var downPressure = Number(groupbox.downPressure)
  166. if(ret.pressureNumber > downPressure && ret.pressureNumber <(downPressure+15) && losePressureFlag === true){
  167. losePressureFlag = false
  168. ModbusJs.positivePressureTankOutputCtrl(controlSerial,false)
  169. console.log("关闭 泄压 阀门")
  170. }
  171. }
  172. }
  173. Connections{
  174. target: tankStep
  175. onUserClick:{
  176. switch(state){
  177. case "10%":
  178. var num = Number(groupbox.upPressure)*0.1
  179. var obj = ModbusJs.testFixedPressure(controlSerial,num)
  180. if(obj.ret === true){
  181. ModbusJs.pressureSensorCtrl(controlSerial,"高压")
  182. console.log("打开高压传感器阀门")
  183. ModbusJs.positivePressureTankInputCtrl(controlSerial,true)
  184. console.log("打开进气阀门")
  185. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  186. console.log("比例调压阀压力值:",obj.voltage)
  187. if(num > 50){
  188. ModbusJs.bigTuningValveControl(controlSerial,true)
  189. console.log("开启粗调阀门")
  190. sensorTimer.targetPressure = num
  191. sensorTimer.bigValveFlag = true
  192. }
  193. sensorTimer.restart()
  194. }
  195. else{
  196. console.log("计算 压力值 失败")
  197. }
  198. break
  199. case "50%":
  200. num = Number(groupbox.upPressure)*0.5
  201. obj = ModbusJs.testFixedPressure(controlSerial,num)
  202. if(obj.ret === true){
  203. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  204. console.log("压力值:",obj.voltage)
  205. if(num > 50){
  206. ModbusJs.bigTuningValveControl(controlSerial,true)
  207. console.log("开启粗调阀门")
  208. sensorTimer.targetPressure = num
  209. sensorTimer.bigValveFlag = true
  210. }
  211. sensorTimer.restart()
  212. }
  213. else{
  214. console.log("计算 调压值 失败")
  215. }
  216. break
  217. case "60%":
  218. num = Number(groupbox.upPressure)*0.6
  219. obj = ModbusJs.testFixedPressure(controlSerial,num)
  220. if(obj.ret === true){
  221. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  222. console.log("压力值:",obj.voltage)
  223. if(num > 50){
  224. ModbusJs.bigTuningValveControl(controlSerial,true)
  225. console.log("开启粗调阀门")
  226. sensorTimer.targetPressure = num
  227. sensorTimer.bigValveFlag = true
  228. }
  229. sensorTimer.restart()
  230. }
  231. else{
  232. console.log("计算 调压值 失败")
  233. }
  234. break
  235. case "70%":
  236. num = Number(groupbox.upPressure)*0.7
  237. obj = ModbusJs.testFixedPressure(controlSerial,num)
  238. if(obj.ret === true){
  239. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  240. console.log("压力值:",obj.voltage)
  241. if(num > 50){
  242. ModbusJs.bigTuningValveControl(controlSerial,true)
  243. console.log("开启粗调阀门")
  244. sensorTimer.targetPressure = num
  245. sensorTimer.bigValveFlag = true
  246. }
  247. sensorTimer.restart()
  248. }
  249. else{
  250. console.log("计算 调压值 失败")
  251. }
  252. break
  253. case "80%":
  254. num = Number(groupbox.upPressure)*0.8
  255. obj = ModbusJs.testFixedPressure(controlSerial,num)
  256. if(obj.ret === true){
  257. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  258. console.log("压力值:",obj.voltage)
  259. if(num > 50){
  260. ModbusJs.bigTuningValveControl(controlSerial,true)
  261. console.log("开启粗调阀门")
  262. sensorTimer.targetPressure = num
  263. sensorTimer.bigValveFlag = true
  264. }
  265. sensorTimer.restart()
  266. }
  267. else{
  268. console.log("计算 调压值 失败")
  269. }
  270. break
  271. case "90%":
  272. num = Number(groupbox.upPressure)*0.9
  273. obj = ModbusJs.testFixedPressure(controlSerial,num)
  274. if(obj.ret === true){
  275. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  276. console.log("压力值:",obj.voltage)
  277. if(num > 50){
  278. ModbusJs.bigTuningValveControl(controlSerial,true)
  279. console.log("开启粗调阀门")
  280. sensorTimer.targetPressure = num
  281. sensorTimer.bigValveFlag = true
  282. }
  283. sensorTimer.restart()
  284. }
  285. else{
  286. console.log("计算 调压值 失败")
  287. }
  288. break
  289. case "100%":
  290. num = Number(groupbox.upPressure)
  291. obj = ModbusJs.testFixedPressure(controlSerial,num)
  292. if(obj.ret === true){
  293. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  294. console.log("压力值:",obj.voltage)
  295. if(num > 50){
  296. ModbusJs.bigTuningValveControl(controlSerial,true)
  297. console.log("开启粗调阀门")
  298. sensorTimer.targetPressure = num
  299. sensorTimer.bigValveFlag = true
  300. }
  301. sensorTimer.restart()
  302. }
  303. else{
  304. console.log("计算 调压值 失败")
  305. }
  306. break
  307. case "降压":
  308. var downPressure = Number(groupbox.downPressure)
  309. var upPressure = Number(groupbox.upPressure)
  310. obj = ModbusJs.testFixedPressure(controlSerial,downPressure)
  311. if(obj.ret === true){
  312. ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
  313. ModbusJs.bigTuningValveControl(controlSerial,false)
  314. console.log("压力值:",obj.voltage)
  315. console.log("关闭粗调阀门")
  316. if(downPressure < (upPressure - 20) && downPressure > 50){
  317. sensorTimer.losePressureFlag = true
  318. sensorTimer.targetPressure = downPressure
  319. ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
  320. console.log("开启 泄压 阀门")
  321. }
  322. sensorTimer.restart()
  323. }
  324. else{
  325. console.log("计算 调压值 失败")
  326. }
  327. break
  328. }
  329. }
  330. }
  331. function show(){
  332. animationShow.running = true
  333. }
  334. function exit(){
  335. animationExit.running = true
  336. TankValveTestJs.exit = true
  337. }
  338. //加载任务动画效果
  339. NumberAnimation {
  340. id: animationShow
  341. target: groupbox
  342. property: "x"
  343. from: groupbox.x
  344. to: 0
  345. duration: 500
  346. }
  347. NumberAnimation {
  348. id: animationExit
  349. target: groupbox
  350. property: "x"
  351. from: groupbox.x
  352. to: 1024
  353. duration: 500
  354. }
  355. Column{
  356. anchors.left: parent.left
  357. anchors.leftMargin: 2
  358. anchors.top: parent.top
  359. anchors.topMargin: 10
  360. spacing: 0
  361. //参数
  362. Rectangle{
  363. width: 980
  364. height: 70
  365. color: "white"
  366. radius: 6
  367. Row{
  368. spacing: 10
  369. Item {
  370. width: 845
  371. height: 70
  372. Column{
  373. anchors.left: parent.left
  374. anchors.leftMargin: 10
  375. anchors.top: parent.top
  376. anchors.topMargin: 10
  377. spacing: 4
  378. Row{
  379. spacing: 10
  380. InputLine{
  381. id:manufactureInputLine
  382. paraName: "制造单位:"
  383. paraLength: 200
  384. onTextChanged: {
  385. root.manufacture = text
  386. }
  387. }
  388. InputLine{
  389. id:typeInputLine
  390. paraName: "型号:"
  391. paraLength: 150
  392. validator:RegExpValidator {
  393. regExp: /[0-9a-zA-Z.-]*/
  394. }
  395. onTextChanged: {
  396. root.type = text
  397. }
  398. }
  399. InputLine{
  400. id:serialNumberInputLine
  401. paraName: "编号:"
  402. paraLength: 150
  403. validator:RegExpValidator {
  404. regExp: /[0-9a-zA-Z.-]*/
  405. }
  406. text: root.serialNumber
  407. onTextChanged: {
  408. root.serialNumber = text
  409. }
  410. }
  411. // UserComboBox{
  412. // id:countComboBox
  413. // width: 120
  414. // height:25
  415. // bgColor:"#D2D5D9"
  416. // model: ["试验1次","试验2次", "试验3次"]
  417. // onActivated: {
  418. // }
  419. // Binding{
  420. // target: root
  421. // property: "count"
  422. // value: countComboBox.currentIndex+1
  423. // }
  424. // }
  425. }
  426. Row{
  427. spacing: 10
  428. InputLine{
  429. id:userInputLine
  430. paraName: "使用单位:"
  431. paraLength: 200
  432. onTextChanged: {
  433. root.user = text
  434. }
  435. }
  436. CarPlate{
  437. id:carplateInputLine
  438. paraName: "车牌:"
  439. paraLength: 150-55
  440. onPlattextChanged: {
  441. root.carplate = plattext
  442. console.log("TankValve Carplattext:" + plattext)
  443. }
  444. }
  445. InputLine{
  446. id:upPressureInputLine
  447. paraName: "试验压力(kPa):"
  448. paraLength: 89
  449. validator:RegExpValidator {
  450. regExp: /[0-9]*/
  451. }
  452. inputMethodHints: Qt.ImhDigitsOnly
  453. onTextChanged: {
  454. groupbox.upPressure = text
  455. }
  456. }
  457. InputLine{
  458. id:downPressureInputLine
  459. paraName: "设计压力(kPa):"
  460. paraLength: 89
  461. validator:RegExpValidator {
  462. regExp: /[0-9]*/
  463. }
  464. inputMethodHints: Qt.ImhDigitsOnly
  465. onTextChanged: {
  466. groupbox.downPressure = text
  467. }
  468. }
  469. }
  470. }
  471. }
  472. Item {
  473. width: 150
  474. height: 70
  475. // Row{
  476. //anchors.verticalCenter: parent.verticalCenter
  477. // spacing: 20
  478. StartStopButton{
  479. id:startStopButton
  480. anchors.verticalCenter: parent.verticalCenter
  481. anchors.horizontalCenter: parent.horizontalCenter
  482. enabled: {
  483. if(groupbox.upPressure==="")
  484. return false
  485. if(groupbox.downPressure==="")
  486. return false
  487. // if(root.manufacture==="")
  488. // return false
  489. // if(root.type==="")
  490. // return false
  491. // if(root.serialNumber==="")
  492. // return false
  493. // if(root.user==="")
  494. // return false
  495. // if(root.carplate==="")
  496. // return false
  497. return true
  498. }
  499. width: 50
  500. height: 50
  501. //anchors.verticalCenter: parent.verticalCenter
  502. onRunningChanged: {
  503. groupbox.running = running
  504. }
  505. }
  506. // ReportButton{
  507. // width: 50
  508. // height: 50
  509. // anchors.verticalCenter: parent.verticalCenter
  510. // }
  511. // }
  512. }
  513. }
  514. }
  515. //曲线 仪表 结果
  516. Row{
  517. x:-10
  518. //曲线
  519. CurveDisplay{
  520. id:curveDisplay
  521. anchors.verticalCenter: parent.verticalCenter
  522. width: 450
  523. height: 300
  524. axisxMax:60
  525. axisxMin:0
  526. axisyMax:500
  527. axisyMin:0
  528. name:"横轴时间(秒) 纵轴压力(kPa)"
  529. }
  530. //仪表
  531. Rectangle{
  532. width: (300-18)*0.75
  533. height: 300-18
  534. color: "white"
  535. radius: 6
  536. anchors.verticalCenter: parent.verticalCenter
  537. Gauge {
  538. id:gauge
  539. width: parent.width
  540. height: parent.width
  541. anchors.centerIn: parent
  542. value: 0
  543. maximumValue: 1000
  544. minimumValue: 0
  545. tickmarkStepSize:100
  546. labelStepSize:100
  547. Behavior on value { NumberAnimation { duration: 1000 }}
  548. }
  549. }
  550. //试验结果
  551. Item {
  552. width: 338
  553. height: 300
  554. anchors.verticalCenter: parent.verticalCenter
  555. Rectangle{
  556. id:resultWindow
  557. anchors.fill: parent
  558. anchors.margins: 10
  559. color: "white"
  560. radius: 6
  561. ProcessWindow{
  562. id:processWindow
  563. width: 280
  564. height: 50
  565. hideWith:resultWindow.width
  566. anchors.centerIn: parent
  567. }
  568. TankStep{
  569. id:tankStep
  570. upPressure: groupbox.upPressure
  571. downPressure:groupbox.downPressure
  572. }
  573. }
  574. }
  575. }
  576. //记录
  577. Row{
  578. id:record
  579. spacing: 10
  580. property int tableWidth:980
  581. function dataRandomSet(modelData,max){
  582. for(var i=0;i<max; i++){
  583. var number= Math.round(Math.random()*100)
  584. number *= 10
  585. var obj={}
  586. obj.pressure=number
  587. modelData.append(obj)
  588. }
  589. }
  590. Rectangle{
  591. width: record.tableWidth
  592. height: 265
  593. }
  594. // TabView {
  595. // id:tabview1
  596. // width: record.tableWidth
  597. // height: 265
  598. // GraphButton{
  599. // id:graphButton
  600. // x:910
  601. // y:-25
  602. // width: 48
  603. // height: 24
  604. // onUserClicked: {
  605. // var tab = tabview1.getTab(tabview1.currentIndex)
  606. // var axisxMax = tab.item.modelData.count
  607. // generateCurve.show(0,axisxMax,0,50,tab.item.modelData,tab.title,"横轴时间(秒) 纵轴压力(kPa)")
  608. // }
  609. // }
  610. // Tab {
  611. // title: "升压10%保持记录"
  612. // RecordTable{
  613. // }
  614. // }
  615. // Tab {
  616. // title: "升压50%保持记录"
  617. // RecordTable{
  618. // }
  619. // }
  620. // Tab {
  621. // title: "升压60%保持记录"
  622. // RecordTable{
  623. // }
  624. // }
  625. // Tab {
  626. // title: "升压70%保持记录"
  627. // RecordTable{
  628. // }
  629. // }
  630. // Tab {
  631. // title: "升压80%保持记录"
  632. // RecordTable{
  633. // }
  634. // }
  635. // Tab {
  636. // title: "升压90%保持记录"
  637. // RecordTable{
  638. // }
  639. // }
  640. // Tab {
  641. // title: "升压100%保持记录"
  642. // RecordTable{
  643. // }
  644. // }
  645. // Tab {
  646. // title: "降压保持记录"
  647. // RecordTable{
  648. // }
  649. // }
  650. // }
  651. }
  652. }
  653. InputPanel {
  654. id: inputPanel
  655. visible: window.virtualkeyboard
  656. z: 99
  657. x: -13
  658. y: window.height
  659. width: window.width
  660. onActiveChanged: {
  661. if(!active)
  662. {
  663. manufactureInputLine.textFocus = false
  664. typeInputLine.textFocus = false
  665. serialNumberInputLine.textFocus = false
  666. userInputLine.textFocus = false
  667. carplateInputLine.textFocus = false
  668. upPressureInputLine.textFocus = false
  669. downPressureInputLine.textFocus = false
  670. }
  671. }
  672. states:
  673. State {
  674. name: "visible"
  675. when: inputPanel.active
  676. PropertyChanges {
  677. target: inputPanel
  678. y: window.height/2
  679. }
  680. }
  681. transitions: Transition {
  682. from: ""
  683. to: "visible"
  684. reversible: true
  685. ParallelAnimation {
  686. NumberAnimation {
  687. properties: "y"
  688. duration: 250
  689. easing.type: Easing.InOutQuad
  690. }
  691. }
  692. }
  693. Component.onCompleted: {
  694. VirtualKeyboardSettings.styleName = "retro"
  695. VirtualKeyboardSettings.activeLocales=["en_GB","zh_CN"]
  696. VirtualKeyboardSettings.locale = "en_GB";//"fi_FI";
  697. }
  698. }
  699. }
  700. }
  701. }