RecoveryValve.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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 QtQuick.Controls.Styles 1.4
  6. import QtQuick.Layouts 1.3
  7. import QtTest 1.14
  8. //import "modbus.js" as ModbusJs
  9. //import "breatheTest.js" as BreatheTestJs
  10. import Qt.labs.platform 1.1
  11. Item{
  12. id:root
  13. property var pagetype:rootitem.Page_Type_ValveTest
  14. //车辆单位
  15. property string organize
  16. //车牌号
  17. property string carplate
  18. //总容积
  19. property string total_volume
  20. //油仓数量
  21. property string compartment_num
  22. //当前油仓ID
  23. property int compartment_id
  24. //当前油仓体积
  25. property int volume
  26. property int test_direction:0
  27. //
  28. property string state
  29. property string pressure:"0.00"
  30. property int pressureCnt:0
  31. property var syskpArray: []
  32. property var valvekpArray: []
  33. property var allArray: []
  34. property real m_maxY: 0.0
  35. property real m_minY: 0.0
  36. property bool bStart: false;
  37. /*
  38. Loader{
  39. id:loader
  40. anchors.fill: parent
  41. //anchors.margins: 5
  42. sourceComponent: componet
  43. }
  44. */
  45. /*
  46. function show(){
  47. if(loader.sourceComponent === null){
  48. loader.sourceComponent = componet
  49. console.debug("avans 1111")
  50. }
  51. loader.item.show()
  52. }
  53. function exit(){
  54. if(loader.sourceComponent !== null){
  55. loader.item.exit()
  56. }
  57. }
  58. */
  59. function update_pressure(pressure_map){
  60. //textstring += pressure_map.pressure+":"
  61. //textstring += pressure_map.direction.toString()+":"
  62. //textstring += pressure_map.stage.toString()+":"
  63. //textstring += pressure_map.step.toString()+":"
  64. console.debug("avans 1111 update_pressure: ", pressure_map.pressure)
  65. pressure = pressure_map.pressure
  66. add_record(pressure_map.pressure)
  67. pressureDisplayInput(Number(pressure_map.pressure))
  68. if(pressure_map.step === 3){ // keep pressure
  69. if(pressure_map.stage === 0){ //sys test
  70. syskpArray.push(Number(pressure_map.pressure))
  71. //console.debug("avans 1111 sys keep pressure: ", pressure_map.pressure)
  72. }else if(pressure_map.stage === 1){ //valve test
  73. valvekpArray.push(Number(pressure_map.pressure))
  74. }
  75. }
  76. allArray.push(Number(pressure_map.pressure))
  77. }
  78. function add_record(str){
  79. var obj={}
  80. obj.pressure = str
  81. recordtable.modelData.append(obj)
  82. }
  83. function cleardata(){
  84. recordtable.modelData.clear()
  85. allArray = []
  86. syskpArray = []
  87. valvekpArray = []
  88. curveDisplay.spline.clear()
  89. pressureCnt =0
  90. resulttable.systemPressure_delta = " ";
  91. resulttable.systemPressure_fontcolor="black"
  92. resulttable.systemPressure_pass = "未知";
  93. resulttable.valvePressure_delta = " ";
  94. resulttable.valvePressure_fontcolor ="black"
  95. resulttable.valvePressure_pass = "未知";
  96. statetable.state_str1 = " ";
  97. statetable.state_str2 = " ";
  98. }
  99. function pressureDisplayInput(number){
  100. pressureCnt++
  101. m_maxY = (m_maxY < number)? number:m_maxY
  102. m_minY = (m_minY > number)? number:m_minY
  103. curveDisplay.setRange_Y(m_minY-2.0, m_maxY+2.0)
  104. if(pressureCnt <= 180){
  105. //dataArray.push(number)
  106. curveDisplay.spline.append(pressureCnt-1,number)
  107. }
  108. else{
  109. curveDisplay.setRange_X(0, pressureCnt-1)
  110. curveDisplay.spline.append(pressureCnt-1,number)
  111. /*
  112. dataArray.push(number)
  113. dataArray.shift()
  114. curveDisplay.spline.clear()
  115. for(var i=0; i<61; i++){
  116. curveDisplay.spline.append(i,dataArray[i])
  117. }
  118. */
  119. }
  120. //gauge.value = number
  121. }
  122. function show_systemresult(delta, bPassed)
  123. {
  124. if(bPassed){
  125. resulttable.systemPressure_delta = delta;
  126. resulttable.systemPressure_fontcolor="green"
  127. resulttable.systemPressure_pass = "合格";
  128. }else{
  129. resulttable.systemPressure_delta = delta;
  130. resulttable.systemPressure_fontcolor="red"
  131. resulttable.systemPressure_pass = "超标";
  132. }
  133. console.log("sysTestGeneratePicture")
  134. groupbox.sysTestGeneratePicture()
  135. }
  136. function show_valveresult(delta, bPassed)
  137. {
  138. if(bPassed){
  139. resulttable.valvePressure_delta = delta;
  140. resulttable.valvePressure_fontcolor ="green"
  141. resulttable.valvePressure_pass = "合格";
  142. }else{
  143. resulttable.valvePressure_delta = delta;
  144. resulttable.valvePressure_fontcolor="red"
  145. resulttable.valvePressure_pass = "超标";
  146. }
  147. console.log("valveTestGeneratePicture")
  148. groupbox.valveTestGeneratePicture()
  149. }
  150. function update_runstate(str1, str2)
  151. {
  152. statetable.state_str1 = str1;
  153. statetable.state_str2 = str2;
  154. }
  155. function test_stoped(){
  156. startStopButton.running = false;
  157. console.log("allTestGeneratePicture")
  158. groupbox.allTestGeneratePicture()
  159. }
  160. // Component{
  161. // id:componet
  162. DynamicGroupBox{
  163. id:groupbox
  164. //x:width
  165. //x:0
  166. title: "油气回收系统密封检测 第"+compartment_id+"仓: 容积"+volume+"(L)"
  167. //width: 1024
  168. //height: 768
  169. anchors.centerIn: parent
  170. anchors.fill: parent
  171. function show(){
  172. animationShow.running = true
  173. }
  174. function exit(){
  175. //BreatheTestJs.exit = true
  176. animationExit.running = true
  177. //startStopButton.running = false
  178. //stopTimer.start()
  179. }
  180. function allTestGeneratePicture(){
  181. var filename = root.carplate+"_"+root.compartment_id+"_all"
  182. reportPicture_all.delayms = 100
  183. reportPicture_all.generatePicture(filename, allArray)
  184. }
  185. function sysTestGeneratePicture(){
  186. var filename = root.carplate+"_"+root.compartment_id+"_sys"
  187. reportPicture_sys.delayms = 100
  188. reportPicture_sys.generatePicture(filename, syskpArray)
  189. }
  190. function valveTestGeneratePicture(){
  191. var filename = root.carplate+"_"+root.compartment_id+"_valve"
  192. reportPicture_valve.delayms = 100
  193. reportPicture_valve.generatePicture(filename, valvekpArray)
  194. }
  195. /*
  196. //加载任务动画效果
  197. NumberAnimation {
  198. id: animationShow
  199. target: groupbox
  200. property: "x"
  201. from: groupbox.x
  202. to: 0
  203. duration: 500
  204. }
  205. NumberAnimation {
  206. id: animationExit
  207. target: groupbox
  208. property: "x"
  209. from: groupbox.x
  210. to: 1024
  211. duration: 500
  212. }
  213. */
  214. //报告
  215. Connections{
  216. target: reportButton
  217. onUserClicked:{
  218. //if(allArray.length > 0){
  219. //console.log("allTestGeneratePicture")
  220. //groupbox.allTestGeneratePicture()
  221. // }
  222. //if(syskpArray.length > 0){
  223. //console.log("sysTestGeneratePicture")
  224. //groupbox.sysTestGeneratePicture()
  225. // }
  226. // if(valvekpArray.length > 0){
  227. // console.log("valveTestGeneratePicture")
  228. // groupbox.valveTestGeneratePicture()
  229. // }
  230. //testService.reportpic_Ready(compartment_id);
  231. if(testService.check_alltest_ok()){
  232. var fileName = root.carplate
  233. var text = getWordSaveFileName(fileName)
  234. console.log(text)
  235. saveWordDialog.currentFile = getWordSaveFileName(fileName)
  236. saveWordDialog.open()
  237. }
  238. }
  239. }
  240. FileDialog {
  241. id: saveWordDialog
  242. title: "保存为"
  243. //nameFilters: [ "Word files (*.doc)"]
  244. nameFilters: [ "Word files (*.doc)", "Text files (*.pdf)"]
  245. fileMode: FileDialog.SaveFile
  246. onAccepted: {
  247. var savePath = file.toString().substring(8)
  248. console.log("saveWordDialog savePath:")
  249. console.log(savePath)
  250. //reportWord.generateBreatheValveWord(savePath,para,obj1,obj2,obj3)
  251. testService.genReport(savePath, "D:/tmp/")
  252. }
  253. }
  254. Column{
  255. anchors.left: parent.left
  256. anchors.leftMargin: 3
  257. anchors.top: parent.top
  258. anchors.topMargin: 10
  259. spacing: 0
  260. Row{
  261. x:-10
  262. CurveDisplay{
  263. id:curveDisplay
  264. anchors.verticalCenter: parent.verticalCenter
  265. width: 900
  266. height: 460
  267. axisxMax:180
  268. axisxMin:0
  269. axisyMax:14
  270. axisyMin:0
  271. name:"横轴时间(秒) 纵轴压力(kPa)"
  272. }
  273. Item {
  274. id:button_root
  275. width: 360
  276. height: 460
  277. Column{
  278. id:button_column
  279. spacing: 10
  280. Rectangle{
  281. id:buttonWindow
  282. //anchors.fill: parent
  283. width: 350
  284. height: 70
  285. color: "white"
  286. radius: 6
  287. border.color: "black"
  288. Row{
  289. anchors.verticalCenter: parent.verticalCenter
  290. anchors.horizontalCenter: parent.horizontalCenter
  291. spacing: 50
  292. StartStopButton{
  293. id:startStopButton
  294. width: 50
  295. height: 50
  296. anchors.verticalCenter: parent.verticalCenter
  297. onRunningChanged: {
  298. if(running){
  299. //clearCurveDisplay()
  300. cleardata()
  301. bStart = testService.tstart(compartment_id, test_direction)
  302. if(!bStart){
  303. running=false;
  304. }
  305. }else{
  306. if(bStart){
  307. testService.tstop(compartment_id)
  308. bStart=false
  309. }
  310. }
  311. }
  312. }
  313. ReportButton{
  314. id:reportButton
  315. width: 50
  316. height: 50
  317. anchors.verticalCenter: parent.verticalCenter
  318. }
  319. }
  320. }
  321. Rectangle{
  322. id:test_selrect
  323. //anchors.fill: parent
  324. anchors.margins: 10
  325. width: 350
  326. height: 50
  327. color: "white"
  328. radius: 6
  329. border.color: "black"
  330. UserComboBox{
  331. id:test_comboBox
  332. //anchors.fill:parent
  333. implicitWidth:350
  334. implicitHeight:50
  335. bgColor:"#D2D5D9"
  336. model: ["正压密闭性检测","负压密闭性检测"]
  337. onCurrentTextChanged: {
  338. //root.standard_name = currentText
  339. test_direction = currentIndex
  340. console.log("choose test direction : "+test_direction)
  341. if(0 == currentIndex){
  342. resulttable.titlestr = currentText
  343. }else{
  344. resulttable.titlestr = currentText
  345. }
  346. }
  347. }
  348. }
  349. Rectangle{
  350. id:pressureWindow
  351. //anchors.fill: parent
  352. anchors.margins: 10
  353. width: 350
  354. height: 100
  355. color: "white"
  356. radius: 6
  357. border.color: "black"
  358. Text {
  359. id: pressurekpa
  360. anchors.right: pressureWindow.right
  361. anchors.verticalCenter: parent.verticalCenter
  362. text: qsTr("kPa ")
  363. //font: 40
  364. font.bold: true
  365. font.pixelSize: 35
  366. }
  367. Rectangle{
  368. id:pressure_rect
  369. anchors.verticalCenter: parent.verticalCenter
  370. anchors.right: pressurekpa.left;
  371. width: 250
  372. height: 80
  373. LCDNumber{
  374. id:lcd_pressure
  375. anchors.centerIn: parent
  376. text: root.pressure
  377. }
  378. }
  379. }
  380. Rectangle{
  381. id:resultWindow
  382. //anchors.fill: parent
  383. anchors.margins: 5
  384. width: 350
  385. height: 100
  386. color: "white"
  387. radius: 6
  388. border.color: "black"
  389. ResultTable{
  390. id:resulttable
  391. anchors.fill: parent
  392. }
  393. }
  394. Rectangle{
  395. id:stateWindow
  396. //anchors.fill: parent
  397. anchors.margins: 5
  398. width: 350
  399. height: 100
  400. color: "white"
  401. radius: 6
  402. border.color: "black"
  403. StateTable{
  404. id:statetable
  405. anchors.fill: parent
  406. }
  407. }
  408. }
  409. }
  410. }
  411. Row{
  412. id: records
  413. spacing: 10
  414. function dataRandomSet(modelData,max){
  415. for(var i=0;i<max; i++){
  416. //var number= Math.round(Math.random()*10)
  417. var number= Math.random()*10
  418. //number *= 10
  419. var obj={}
  420. obj.pressure= 0 - number.toFixed(3)
  421. modelData.append(obj)
  422. }
  423. }
  424. Rectangle{
  425. width: 1250
  426. height: 240
  427. color: "white"
  428. radius: 6
  429. GroupBox{
  430. id:groupboxrecord
  431. //x:width
  432. //x:0
  433. title: "历史数据"
  434. anchors.fill: parent
  435. anchors.margins: 0
  436. RecordTable{
  437. id:recordtable
  438. Component.onCompleted: {
  439. //records.dataRandomSet(modelData,500)
  440. }
  441. }
  442. }
  443. }
  444. }
  445. }
  446. }
  447. // }
  448. ReportPicture{
  449. id:reportPicture_sys
  450. }
  451. ReportPicture{
  452. id:reportPicture_valve
  453. }
  454. ReportPicture{
  455. id:reportPicture_all
  456. }
  457. function pad_with_zeroes(number, length) {
  458. var my_string = '' + number;
  459. while (my_string.length < length) {
  460. my_string = '0' + my_string;
  461. }
  462. return my_string;
  463. }
  464. function getWordSaveFileName( para){
  465. var date = new Date;
  466. var year = date.getFullYear()
  467. var month = pad_with_zeroes(date.getMonth()+1,2)
  468. var day = pad_with_zeroes(date.getDate(),2)
  469. var hour = pad_with_zeroes(date.getHours(),2)
  470. var minute = pad_with_zeroes(date.getMinutes(),2)
  471. var second = pad_with_zeroes(date.getSeconds(),2)
  472. var time = year+month+day+hour+minute+second
  473. return "file:///"+time+"_"+para
  474. }
  475. Timer {
  476. id: timer;
  477. interval: 300;//设置定时器定时时间为500ms,默认1000ms
  478. repeat: true //是否重复定时,默认为false
  479. running: false //是否开启定时,默认是false,当为true的时候,进入此界面就开始定时
  480. triggeredOnStart: false // 是否开启定时就触发onTriggered,一些特殊用户可以用来设置初始值。
  481. onTriggered: {
  482. //qreal y = 12/2 + (12/2.0)*sin(pressureCnt)
  483. pressureDisplayInput(12/2 + (12/2.0)*Math.sin(Math.PI*pressureCnt/60))
  484. }
  485. //restart ,start,stop,定时器的调用方式,顾名思义
  486. }
  487. Component.onCompleted: {
  488. //timer.start()
  489. }
  490. }