PageTest.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. import QtQuick 2.15
  2. import QtQuick.Layouts 1.3
  3. import QtQuick.Controls 2.14
  4. import QtQuick.Controls.Styles 1.2
  5. import TService 1.0
  6. Item{
  7. id: root
  8. //anchors.fill: parent
  9. //width:1024
  10. //height: 768
  11. //anchors.centerIn: parent
  12. property var pagetype:rootitem.Page_Type_Testing
  13. property string title_str:"手动测试"
  14. property double pressvalue: 1.22
  15. property bool bSelfTest_Started: false
  16. property string selfTest_State_str:""
  17. property string selfTest_Result_str:""
  18. function show_pressure(pressure_str){
  19. lcd_pressure.text = pressure_str;
  20. }
  21. function show_selftestState(str){
  22. selfTest_State_str = str
  23. }
  24. function show_selftestResult(str){
  25. selfTest_Result_str = str
  26. }
  27. function selftestStop(){
  28. var ret1 = testService.tstop(0);
  29. if(ret1){
  30. bSelfTest_Started = false;
  31. //selftest_result.text = ""
  32. selftest_button.text = "开始"
  33. readbutton.enabled = true;
  34. adjustbutton.enabled = true;
  35. //timer.stop()
  36. }
  37. }
  38. // Component{
  39. // id:componet
  40. DynamicGroupBox{
  41. id:groupbox
  42. //x:width
  43. //x:0
  44. anchors.centerIn: parent
  45. anchors.fill: parent
  46. title: title_str
  47. Column{
  48. spacing: 10
  49. anchors.centerIn: parent
  50. DynamicGroupBox{
  51. id:relays_control
  52. title: "电磁阀控制"
  53. width: 800
  54. height: 100
  55. Row{
  56. anchors.centerIn: parent
  57. //columns: 4
  58. //rows:1
  59. //columnSpacing: 80
  60. //rowSpacing: 30
  61. spacing: 60
  62. UserSwitch{
  63. id:switch1
  64. text: "进气阀关"
  65. onCheckedChanged: {
  66. //console.log("switch 1 onCheckedChanged")
  67. switch1.text = switch1.checked ? "进气阀开":"进气阀关"
  68. }
  69. onClicked: {
  70. //console.log("switch 1 clicked")
  71. if(switch1.checked){
  72. testService.valve_open(TestService.Valve_ID_ROUGH_0)
  73. }else{
  74. testService.valve_close(TestService.Valve_ID_ROUGH_0)
  75. }
  76. }
  77. }
  78. UserSwitch{
  79. id:switch2
  80. text: "泄气阀关"
  81. onCheckedChanged: {
  82. switch2.text = switch2.checked ? "泄气阀开":"泄气阀关"
  83. }
  84. onClicked: {
  85. if(switch2.checked){
  86. testService.valve_open(TestService.Valve_ID_ROUGH_1)
  87. }else{
  88. testService.valve_close(TestService.Valve_ID_ROUGH_1)
  89. }
  90. }
  91. }
  92. UserSwitch{
  93. id:switch3
  94. text: "传感阀关"
  95. onCheckedChanged: {
  96. switch3.text = switch3.checked ? "传感阀开":"传感阀关"
  97. }
  98. onClicked: {
  99. if(switch3.checked){
  100. testService.valve_open(TestService.Valve_ID_ROUGH_2)
  101. }else{
  102. testService.valve_close(TestService.Valve_ID_ROUGH_2)
  103. }
  104. }
  105. }
  106. UserSwitch{
  107. id:switch4
  108. text: "校准阀关"
  109. onCheckedChanged: {
  110. switch4.text = switch4.checked ? "校准阀开":"校准阀关"
  111. }
  112. onClicked: {
  113. if(switch4.checked){
  114. testService.valve_open(TestService.Valve_ID_CALIBRATION)
  115. }else{
  116. testService.valve_close(TestService.Valve_ID_CALIBRATION)
  117. }
  118. }
  119. }
  120. }
  121. }
  122. DynamicGroupBox{
  123. id:adjust_control
  124. title: "调节阀控制"
  125. width: 800
  126. height: 100
  127. Row{
  128. anchors.verticalCenter: parent.verticalCenter
  129. anchors.left: parent.left
  130. spacing: 20
  131. Text {
  132. id: text1
  133. //anchors.top: parent.top
  134. //anchors.bottom: parent.bottom
  135. //anchors.centerIn: parent
  136. anchors.verticalCenter: parent.verticalCenter
  137. text: qsTr("调压阀:")
  138. font.pixelSize: 20
  139. }
  140. UserButton {
  141. id: adjustbutton;
  142. text: "调压";
  143. font.pixelSize: 20
  144. anchors.verticalCenter: parent.verticalCenter
  145. width: 120
  146. height: 45
  147. onClicked: {
  148. //var str_number = voltage.text
  149. var num = Number(voltage.text)
  150. if((num>0) && (num<1000)){
  151. testService.adjust_Pressure(voltage.text)
  152. }else{
  153. console.log("input voltage invalid")
  154. log.show("Voltage invalid, please retry")
  155. }
  156. }
  157. }
  158. InputLine{
  159. id:voltage
  160. paraName: "Voltage:"
  161. paraLength: 60
  162. anchors.verticalCenter: parent.verticalCenter
  163. validator:RegExpValidator {
  164. regExp: /[0-9]*/
  165. }
  166. onTextChanged: {
  167. //root.manufacture = text
  168. }
  169. }
  170. }
  171. }
  172. DynamicGroupBox{
  173. id:pressure
  174. title: "实时压力"
  175. width: 800
  176. height: 100
  177. Row{
  178. anchors.verticalCenter: parent.verticalCenter
  179. anchors.left: parent.left
  180. spacing: 20
  181. Timer {
  182. id: timer;
  183. interval: 1000;//设置定时器定时时间为500ms,默认1000ms
  184. repeat: true //是否重复定时,默认为false
  185. running: false //是否开启定时,默认是false,当为true的时候,进入此界面就开始定时
  186. triggeredOnStart: false // 是否开启定时就触发onTriggered,一些特殊用户可以用来设置初始值。
  187. onTriggered: {
  188. lcd_pressure.text = testService.read_PressureValue();
  189. }
  190. //restart ,start,stop,定时器的调用方式,顾名思义
  191. }
  192. UserButton {
  193. id: readbutton;
  194. text: "开始";
  195. font.pixelSize: 20
  196. anchors.verticalCenter: parent.verticalCenter
  197. implicitWidth: 120
  198. implicitHeight: 45
  199. onEnabledChanged: {
  200. if(timer.running){
  201. timer.stop()
  202. text= "开始"
  203. }else{
  204. //timer.start()
  205. //text= "停止"
  206. }
  207. }
  208. onClicked: {
  209. if(timer.running){
  210. timer.stop()
  211. text= "开始"
  212. }else{
  213. timer.start()
  214. text= "停止"
  215. }
  216. //lcd_pressure.text = pressvalue.toFixed(3).toString()
  217. }
  218. }
  219. Rectangle{
  220. id:pressureWindow
  221. //anchors.fill: parent
  222. anchors.verticalCenter: parent.verticalCenter
  223. width: 120
  224. height: 40
  225. //color: "white"
  226. radius: 4
  227. LCDNumber{
  228. id:lcd_pressure
  229. anchors.centerIn: parent
  230. //anchors.verticalCenter: parent.verticalCenter
  231. text: "5.00"
  232. fontsize: 40
  233. }
  234. }
  235. Text {
  236. id: kpa
  237. anchors.left: lcd_pressure.right
  238. anchors.verticalCenter: parent.verticalCenter
  239. text: qsTr("kPa")
  240. //font: 40
  241. font.bold: true
  242. font.pixelSize: 25
  243. }
  244. }
  245. }
  246. DynamicGroupBox{
  247. id:selftest
  248. title: "系统自测"
  249. width: 800
  250. height: 100
  251. Row{
  252. anchors.verticalCenter: parent.verticalCenter
  253. anchors.left: parent.left
  254. spacing: 30
  255. UserButton {
  256. id: selftest_button;
  257. text: "开始";
  258. font.pixelSize: 20
  259. //height: 40
  260. //width: 160
  261. implicitWidth: 120
  262. implicitHeight: 45
  263. onClicked: {
  264. //var str_number = voltage.text
  265. if(false == bSelfTest_Started){
  266. //bSelfTest_Started = true;
  267. //selftest_result.text= "测试通过"
  268. if(timer.running){
  269. timer.stop()
  270. }
  271. var ret = testService.tselfstart(0, 0)
  272. if(ret){
  273. bSelfTest_Started = true;
  274. readbutton.enabled = false;
  275. adjustbutton.enabled = false;
  276. text = "停止"
  277. selfTest_State_str=""
  278. selfTest_Result_str=""
  279. //timer.start()
  280. }else{
  281. }
  282. }else{
  283. var ret1 = testService.tstop(0);
  284. if(ret1){
  285. bSelfTest_Started = false;
  286. //selftest_result.text = ""
  287. text = "开始"
  288. readbutton.enabled = true;
  289. adjustbutton.enabled = true;
  290. //timer.stop()
  291. }
  292. }
  293. }
  294. }
  295. Text {
  296. id: selftest_state
  297. anchors.verticalCenter: parent.verticalCenter
  298. text: qsTr("自测状态:")+selfTest_State_str
  299. font.pixelSize: 20
  300. }
  301. Text {
  302. id: selftest_result
  303. anchors.verticalCenter: parent.verticalCenter
  304. text: qsTr("自测结果:")+selfTest_Result_str
  305. font.pixelSize: 20
  306. }
  307. }
  308. }
  309. }
  310. }
  311. // }
  312. }