Calibration.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. import QtQuick 2.11
  2. import QtQuick.Controls 1.4
  3. import QtQuick.Layouts 1.14
  4. import "modbus.js" as ModbusJs
  5. Item {
  6. Loader{
  7. id:loader
  8. anchors.fill: parent
  9. anchors.margins: 5
  10. }
  11. function show(){
  12. if(loader.sourceComponent === null){
  13. loader.sourceComponent = componet
  14. }
  15. loader.item.show()
  16. }
  17. function exit(){
  18. if(loader.sourceComponent !== null){
  19. loader.item.exit()
  20. }
  21. }
  22. Component{
  23. id:componet
  24. GroupBox{
  25. id:groupbox
  26. x:width
  27. title: "标定模式"
  28. //property int readPressure_index: 0;
  29. Timer{
  30. id:componetTimer
  31. repeat: false
  32. interval: 1000
  33. onTriggered: {
  34. var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
  35. if(ret === false)
  36. log.show("自检错误")
  37. else{
  38. log.show("自检正常")
  39. ModbusJs.closeAllValve(controlSerial)
  40. //打开三个传感阀
  41. ModbusJs.highPressureSensorCtrl(controlSerial,true)
  42. ModbusJs.lowPressureSensorCtrl(controlSerial,true)
  43. ModbusJs.negativePumpPowerCtrl(controlSerial,true)
  44. sensorTimer.start()
  45. //sensorTimer.running = true
  46. }
  47. //1000 会造成启动慢 延迟赋值
  48. //gauge.maximumValue = 1
  49. }
  50. }
  51. Timer{
  52. id:sensorTimer
  53. repeat: true
  54. triggeredOnStart: false
  55. interval: 1000
  56. onTriggered: {
  57. var obj
  58. if(comboBox1.currentText === "低压传感器"){
  59. obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
  60. if(obj.ret === false){
  61. log.show("低压传感器"+"通讯错误")
  62. }
  63. else{
  64. gauge_low.value = obj.pressureNumber //parseInt(obj.pressureNumber)
  65. //gauge_low.realValue = obj.pressureNumber
  66. }
  67. }else if(comboBox1.currentText === "高压传感器"){
  68. obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
  69. if(obj.ret === false){
  70. log.show("高压传感器"+"通讯错误")
  71. }
  72. else{
  73. gauge_high.value = obj.pressureNumber//parseInt(obj.pressureNumber)
  74. //gauge_high.realValue = obj.pressureNumber
  75. }
  76. }else if(comboBox1.currentText === "负压传感器"){
  77. obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
  78. if(obj.ret === false){
  79. log.show("负压传感器"+"通讯错误")
  80. }
  81. else{
  82. gauge_negative.value = obj.pressureNumber // parseInt(obj.pressureNumber)
  83. //gauge_negative.realValue = obj.pressureNumber
  84. }
  85. }
  86. }
  87. }
  88. function show(){
  89. animationShow.running = true
  90. componetTimer.start()
  91. }
  92. function exit(){
  93. sensorTimer.stop()
  94. animationExit.running = true
  95. ModbusJs.closeAllValve(controlSerial)
  96. }
  97. //加载任务动画效果
  98. NumberAnimation {
  99. id: animationShow
  100. target: groupbox
  101. property: "x"
  102. from: groupbox.x
  103. to: 0
  104. duration: 500
  105. }
  106. NumberAnimation {
  107. id: animationExit
  108. target: groupbox
  109. property: "x"
  110. from: groupbox.x
  111. to: 1024
  112. duration: 500
  113. }
  114. Column{
  115. anchors.left: parent.left
  116. anchors.leftMargin: 2
  117. anchors.top: parent.top
  118. anchors.topMargin: 10
  119. spacing: 30
  120. Rectangle{
  121. width: 980
  122. height: 75
  123. color: "white"
  124. radius: 6
  125. Row{
  126. //anchors.fill: parent
  127. anchors.centerIn: parent.Center
  128. spacing: 20
  129. Button{
  130. id:positive_relif
  131. text: "打开正压罐泄压阀"
  132. //anchors.horizontalCenter: parent.horizontalCenter
  133. onClicked: {
  134. ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
  135. }
  136. }
  137. Button{
  138. id:negitive_relif
  139. text: "打开负压罐泄压阀"
  140. //anchors.horizontalCenter: parent.horizontalCenter
  141. onClicked: {
  142. ModbusJs.negativePressureTankOutputCtrl(controlSerial,true)
  143. }
  144. }
  145. Row{
  146. spacing: 5
  147. Text {
  148. anchors.verticalCenter: parent.verticalCenter
  149. text: qsTr("读取压力值:")
  150. font.bold: true
  151. font.pixelSize: 13
  152. }
  153. UserComboBox{
  154. id:comboBox1
  155. anchors.verticalCenter: parent.verticalCenter
  156. width: 145
  157. height: 25
  158. bgColor:"#D2D5D9"
  159. model: ["不读取","高压传感器","低压传感器", "负压传感器"]
  160. onActivated: {
  161. if(currentText === "不读取"){
  162. low_zero.enabled = false;
  163. high_zero.enabled = false;
  164. neg_zero.enabled = false;
  165. }else if(currentText === "高压传感器"){
  166. low_zero.enabled = false;
  167. high_zero.enabled = true;
  168. neg_zero.enabled = false;
  169. }else if(currentText === "低压传感器"){
  170. low_zero.enabled = true;
  171. high_zero.enabled = false;
  172. neg_zero.enabled = false;
  173. }else if(currentText === "负压传感器"){
  174. low_zero.enabled = false;
  175. high_zero.enabled = false;
  176. neg_zero.enabled = true;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. Row{
  184. x:-10
  185. spacing: 50
  186. anchors.horizontalCenter: parent.horizontalCenter
  187. Rectangle{
  188. width: 300*0.75
  189. height: 300
  190. color: "white"
  191. radius: 6
  192. anchors.verticalCenter: parent.verticalCenter
  193. Column{
  194. anchors.fill: parent
  195. spacing: 20
  196. Button{
  197. id:high_zero
  198. text: "高压传感器标零"
  199. enabled: false
  200. anchors.horizontalCenter: parent.horizontalCenter
  201. onClicked: {
  202. if(ModbusJs.highPressureSetZeroReq(sensorSerial)){
  203. }else{
  204. log.show("高压传感器:"+"标零失败!")
  205. }
  206. }
  207. }
  208. Gauge {
  209. id:gauge_high
  210. width: parent.width
  211. height: parent.width
  212. //anchors.centerIn: parent
  213. value: 0.0
  214. //realValue:0.0
  215. maximumValue: 1000
  216. minimumValue: {
  217. return 0
  218. }
  219. Behavior on value { NumberAnimation { duration: 1000 }}
  220. }
  221. }
  222. }
  223. Rectangle{
  224. width: 300*0.75
  225. height: 300
  226. color: "white"
  227. radius: 6
  228. anchors.verticalCenter: parent.verticalCenter
  229. Column{
  230. anchors.fill: parent
  231. spacing: 20
  232. Button{
  233. id:low_zero
  234. text: "低压传感器标零"
  235. enabled: false
  236. anchors.horizontalCenter: parent.horizontalCenter
  237. onClicked: {
  238. if(ModbusJs.lowPressureSetZeroReq(sensorSerial)){
  239. }else{
  240. log.show("低压传感器:"+"标零失败!")
  241. }
  242. }
  243. }
  244. Gauge {
  245. id:gauge_low
  246. width: parent.width
  247. height: parent.width
  248. anchors.centerIn: parent
  249. value: 0.0
  250. //realValue:0.0
  251. maximumValue: 1000
  252. minimumValue: {
  253. return 0
  254. }
  255. Behavior on value { NumberAnimation { duration: 1000 }}
  256. }
  257. }
  258. }
  259. Rectangle{
  260. width: 300*0.75
  261. height: 300
  262. color: "white"
  263. radius: 6
  264. anchors.verticalCenter: parent.verticalCenter
  265. Column{
  266. anchors.fill: parent
  267. spacing: 20
  268. Button{
  269. id:neg_zero
  270. text: "负压传感器标零"
  271. enabled: false
  272. anchors.horizontalCenter: parent.horizontalCenter
  273. onClicked: {
  274. if(ModbusJs.negativePressureSetZeroReq(sensorSerial)){
  275. }else{
  276. log.show("负压传感器:"+"标零失败!")
  277. }
  278. }
  279. }
  280. Gauge {
  281. id:gauge_negative
  282. width: parent.width
  283. height: parent.width
  284. anchors.centerIn: parent
  285. value: 0.0
  286. //realValue:0.0
  287. maximumValue: 900
  288. minimumValue: {
  289. return -100
  290. }
  291. Behavior on value { NumberAnimation { duration: 1000 }}
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }