UltimakerCheckup.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Window 2.1
  6. import UM 1.1 as UM
  7. Item
  8. {
  9. id: wizardPage
  10. property string title
  11. property int leftRow: wizardPage.width*0.40
  12. property int rightRow: wizardPage.width*0.60
  13. anchors.fill: parent;
  14. property bool x_min_pressed: false
  15. property bool y_min_pressed: false
  16. property bool z_min_pressed: false
  17. property bool heater_works: false
  18. property int extruder_target_temp: 0
  19. property int bed_target_temp: 0
  20. UM.I18nCatalog { id: catalog; name:"cura"}
  21. property var checkupProgress: {
  22. "connection": false,
  23. "endstopX": wizardPage.x_min_pressed,
  24. "endstopY": wizardPage.y_min_pressed,
  25. "endstopZ": wizardPage.z_min_pressed,
  26. "nozzleTemp": false,
  27. "bedTemp": false
  28. }
  29. property variant printer_connection: {
  30. if (Cura.USBPrinterManager.connectedPrinterList.rowCount() != 0){
  31. wizardPage.checkupProgress.connection = true
  32. return Cura.USBPrinterManager.connectedPrinterList.getItem(0).printer
  33. }
  34. else {
  35. return null
  36. }
  37. }
  38. function checkTotalCheckUp(){
  39. var allDone = true
  40. for(var property in checkupProgress){
  41. if (checkupProgress[property] == false){
  42. allDone = false
  43. }
  44. }
  45. if (allDone == true){
  46. skipCheckButton.enabled = false
  47. resultText.visible = true
  48. }
  49. }
  50. Component.onCompleted:
  51. {
  52. if (printer_connection != null){
  53. printer_connection.startPollEndstop()
  54. }
  55. }
  56. Component.onDestruction:
  57. {
  58. if (printer_connection != null){
  59. printer_connection.stopPollEndstop()
  60. }
  61. }
  62. Label
  63. {
  64. id: pageTitle
  65. width: parent.width
  66. text: catalog.i18nc("@title", "Check Printer")
  67. wrapMode: Text.WordWrap
  68. font.pointSize: 18;
  69. }
  70. Label
  71. {
  72. id: pageDescription
  73. anchors.top: pageTitle.bottom
  74. anchors.topMargin: UM.Theme.getSize("default_margin").height
  75. width: parent.width
  76. wrapMode: Text.WordWrap
  77. text: catalog.i18nc("@label","It's a good idea to do a few sanity checks on your Ultimaker. You can skip this step if you know your machine is functional");
  78. }
  79. Item{
  80. id: startStopButtons
  81. anchors.top: pageDescription.bottom
  82. anchors.topMargin: UM.Theme.getSize("default_margin").height
  83. anchors.horizontalCenter: parent.horizontalCenter
  84. height: childrenRect.height
  85. width: startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width
  86. Button
  87. {
  88. id: startCheckButton
  89. anchors.top: parent.top
  90. anchors.left: parent.left
  91. //enabled: !alreadyTested
  92. text: catalog.i18nc("@action:button","Start Printer Check");
  93. onClicked: {
  94. checkupContent.visible = true
  95. startCheckButton.enabled = false
  96. printer_connection.homeHead()
  97. }
  98. }
  99. Button
  100. {
  101. id: skipCheckButton
  102. anchors.top: parent.width < wizardPage.width ? parent.top : startCheckButton.bottom
  103. anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2
  104. anchors.left: parent.width < wizardPage.width ? startCheckButton.right : parent.left
  105. anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0
  106. //enabled: !alreadyTested
  107. text: catalog.i18nc("@action:button","Skip Printer Check");
  108. onClicked: {
  109. base.currentPage += 1
  110. }
  111. }
  112. }
  113. Item{
  114. id: checkupContent
  115. anchors.top: startStopButtons.bottom
  116. anchors.topMargin: UM.Theme.getSize("default_margin").height
  117. visible: false
  118. //////////////////////////////////////////////////////////
  119. Label
  120. {
  121. id: connectionLabel
  122. width: wizardPage.leftRow
  123. anchors.left: parent.left
  124. anchors.top: parent.top
  125. wrapMode: Text.WordWrap
  126. text: catalog.i18nc("@label","Connection: ")
  127. }
  128. Label
  129. {
  130. id: connectionStatus
  131. width: wizardPage.rightRow
  132. anchors.left: connectionLabel.right
  133. anchors.top: parent.top
  134. wrapMode: Text.WordWrap
  135. text: Cura.USBPrinterManager.connectedPrinterList.rowCount() > 0 || base.addOriginalProgress.checkUp[0] ? catalog.i18nc("@info:status","Done"):catalog.i18nc("@info:status","Incomplete")
  136. }
  137. //////////////////////////////////////////////////////////
  138. Label
  139. {
  140. id: endstopXLabel
  141. width: wizardPage.leftRow
  142. anchors.left: parent.left
  143. anchors.top: connectionLabel.bottom
  144. wrapMode: Text.WordWrap
  145. text: catalog.i18nc("@label","Min endstop X: ")
  146. }
  147. Label
  148. {
  149. id: endstopXStatus
  150. width: wizardPage.rightRow
  151. anchors.left: endstopXLabel.right
  152. anchors.top: connectionLabel.bottom
  153. wrapMode: Text.WordWrap
  154. text: x_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked")
  155. }
  156. //////////////////////////////////////////////////////////////
  157. Label
  158. {
  159. id: endstopYLabel
  160. width: wizardPage.leftRow
  161. anchors.left: parent.left
  162. anchors.top: endstopXLabel.bottom
  163. wrapMode: Text.WordWrap
  164. text: catalog.i18nc("@label","Min endstop Y: ")
  165. }
  166. Label
  167. {
  168. id: endstopYStatus
  169. width: wizardPage.rightRow
  170. anchors.left: endstopYLabel.right
  171. anchors.top: endstopXLabel.bottom
  172. wrapMode: Text.WordWrap
  173. text: y_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked")
  174. }
  175. /////////////////////////////////////////////////////////////////////
  176. Label
  177. {
  178. id: endstopZLabel
  179. width: wizardPage.leftRow
  180. anchors.left: parent.left
  181. anchors.top: endstopYLabel.bottom
  182. wrapMode: Text.WordWrap
  183. text: catalog.i18nc("@label","Min endstop Z: ")
  184. }
  185. Label
  186. {
  187. id: endstopZStatus
  188. width: wizardPage.rightRow
  189. anchors.left: endstopZLabel.right
  190. anchors.top: endstopYLabel.bottom
  191. wrapMode: Text.WordWrap
  192. text: z_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked")
  193. }
  194. ////////////////////////////////////////////////////////////
  195. Label
  196. {
  197. id: nozzleTempLabel
  198. width: wizardPage.leftRow
  199. anchors.left: parent.left
  200. anchors.top: endstopZLabel.bottom
  201. wrapMode: Text.WordWrap
  202. text: catalog.i18nc("@label","Nozzle temperature check: ")
  203. }
  204. Label
  205. {
  206. id: nozzleTempStatus
  207. width: wizardPage.rightRow * 0.4
  208. anchors.top: nozzleTempLabel.top
  209. anchors.left: nozzleTempLabel.right
  210. wrapMode: Text.WordWrap
  211. text: catalog.i18nc("@info:status","Not checked")
  212. }
  213. Item
  214. {
  215. id: nozzleTempButton
  216. width: wizardPage.rightRow * 0.3
  217. height: nozzleTemp.height
  218. anchors.top: nozzleTempLabel.top
  219. anchors.left: bedTempStatus.right
  220. anchors.leftMargin: UM.Theme.getSize("default_margin").width/2
  221. Button
  222. {
  223. height: nozzleTemp.height - 2
  224. anchors.verticalCenter: parent.verticalCenter
  225. anchors.horizontalCenter: parent.horizontalCenter
  226. text: catalog.i18nc("@action:button","Start Heating")
  227. onClicked:
  228. {
  229. if(printer_connection != null)
  230. {
  231. nozzleTempStatus.text = catalog.i18nc("@info:progress","Checking")
  232. printer_connection.setTargetHotendTemperature(0, 190)
  233. wizardPage.extruder_target_temp = 190
  234. }
  235. }
  236. }
  237. }
  238. Label
  239. {
  240. id: nozzleTemp
  241. anchors.top: nozzleTempLabel.top
  242. anchors.left: nozzleTempButton.right
  243. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  244. width: wizardPage.rightRow * 0.2
  245. wrapMode: Text.WordWrap
  246. text: printer_connection != null ? printer_connection.hotendTemperatures[0] + "°C" : "0°C"
  247. font.bold: true
  248. }
  249. /////////////////////////////////////////////////////////////////////////////
  250. Label
  251. {
  252. id: bedTempLabel
  253. width: wizardPage.leftRow
  254. anchors.left: parent.left
  255. anchors.top: nozzleTempLabel.bottom
  256. wrapMode: Text.WordWrap
  257. text: catalog.i18nc("@label","bed temperature check:")
  258. }
  259. Label
  260. {
  261. id: bedTempStatus
  262. width: wizardPage.rightRow * 0.4
  263. anchors.top: bedTempLabel.top
  264. anchors.left: bedTempLabel.right
  265. wrapMode: Text.WordWrap
  266. text: catalog.i18nc("@info:status","Not checked")
  267. }
  268. Item
  269. {
  270. id: bedTempButton
  271. width: wizardPage.rightRow * 0.3
  272. height: bedTemp.height
  273. anchors.top: bedTempLabel.top
  274. anchors.left: bedTempStatus.right
  275. anchors.leftMargin: UM.Theme.getSize("default_margin").width/2
  276. Button
  277. {
  278. height: bedTemp.height - 2
  279. anchors.verticalCenter: parent.verticalCenter
  280. anchors.horizontalCenter: parent.horizontalCenter
  281. text: catalog.i18nc("@action:button","Start Heating")
  282. onClicked:
  283. {
  284. if(printer_connection != null)
  285. {
  286. bedTempStatus.text = catalog.i18nc("@info:progress","Checking")
  287. printer_connection.setTargetBedTemperature(60)
  288. wizardPage.bed_target_temp = 60
  289. }
  290. }
  291. }
  292. }
  293. Label
  294. {
  295. id: bedTemp
  296. width: wizardPage.rightRow * 0.2
  297. anchors.top: bedTempLabel.top
  298. anchors.left: bedTempButton.right
  299. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  300. wrapMode: Text.WordWrap
  301. text: printer_connection != null ? printer_connection.bedTemperature + "°C": "0°C"
  302. font.bold: true
  303. }
  304. Label
  305. {
  306. id: resultText
  307. visible: false
  308. anchors.top: bedTemp.bottom
  309. anchors.topMargin: UM.Theme.getSize("default_margin").height
  310. anchors.left: parent.left
  311. width: parent.width
  312. wrapMode: Text.WordWrap
  313. text: catalog.i18nc("@label", "Everything is in order! You're done with your CheckUp.")
  314. }
  315. }
  316. Connections
  317. {
  318. target: printer_connection
  319. onEndstopStateChanged:
  320. {
  321. if(key == "x_min")
  322. {
  323. x_min_pressed = true
  324. checkTotalCheckUp()
  325. }
  326. if(key == "y_min")
  327. {
  328. y_min_pressed = true
  329. checkTotalCheckUp()
  330. }
  331. if(key == "z_min")
  332. {
  333. z_min_pressed = true
  334. checkTotalCheckUp()
  335. }
  336. }
  337. onHotendTemperaturesChanged:
  338. {
  339. if(printer_connection.hotendTemperatures[0] > wizardPage.extruder_target_temp - 10 && printer_connection.hotendTemperatures[0] < wizardPage.extruder_target_temp + 10)
  340. {
  341. if(printer_connection != null)
  342. {
  343. nozzleTempStatus.text = catalog.i18nc("@info:status","Works")
  344. wizardPage.checkupProgress.nozzleTemp = true
  345. checkTotalCheckUp()
  346. printer_connection.setTargetHotendTemperature(0, 0)
  347. }
  348. }
  349. }
  350. onBedTemperatureChanged:
  351. {
  352. if(printer_connection.bedTemperature > wizardPage.bed_target_temp - 5 && printer_connection.bedTemperature < wizardPage.bed_target_temp + 5)
  353. {
  354. bedTempStatus.text = catalog.i18nc("@info:status","Works")
  355. wizardPage.checkupProgress.bedTemp = true
  356. checkTotalCheckUp()
  357. printer_connection.setTargetBedTemperature(0)
  358. }
  359. }
  360. }
  361. ExclusiveGroup
  362. {
  363. id: printerGroup;
  364. }
  365. }