PrinterOutputDevice.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Cura is released under the terms of the AGPLv3 or higher.
  3. from UM.i18n import i18nCatalog
  4. from UM.OutputDevice.OutputDevice import OutputDevice
  5. from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QTimer
  6. from PyQt5.QtWidgets import QMessageBox
  7. from enum import IntEnum # For the connection state tracking.
  8. from UM.Settings.ContainerRegistry import ContainerRegistry
  9. from UM.Logger import Logger
  10. from UM.Signal import signalemitter
  11. i18n_catalog = i18nCatalog("cura")
  12. ## Printer output device adds extra interface options on top of output device.
  13. #
  14. # The assumption is made the printer is a FDM printer.
  15. #
  16. # Note that a number of settings are marked as "final". This is because decorators
  17. # are not inherited by children. To fix this we use the private counter part of those
  18. # functions to actually have the implementation.
  19. #
  20. # For all other uses it should be used in the same way as a "regular" OutputDevice.
  21. @signalemitter
  22. class PrinterOutputDevice(QObject, OutputDevice):
  23. def __init__(self, device_id, parent = None):
  24. super().__init__(device_id = device_id, parent = parent)
  25. self._container_registry = ContainerRegistry.getInstance()
  26. self._target_bed_temperature = 0
  27. self._bed_temperature = 0
  28. self._num_extruders = 1
  29. self._hotend_temperatures = [0] * self._num_extruders
  30. self._target_hotend_temperatures = [0] * self._num_extruders
  31. self._material_ids = [""] * self._num_extruders
  32. self._hotend_ids = [""] * self._num_extruders
  33. self._progress = 0
  34. self._head_x = 0
  35. self._head_y = 0
  36. self._head_z = 0
  37. self._connection_state = ConnectionState.closed
  38. self._connection_text = ""
  39. self._time_elapsed = 0
  40. self._time_total = 0
  41. self._job_state = ""
  42. self._job_name = ""
  43. self._error_text = ""
  44. self._accepts_commands = True
  45. self._preheat_bed_timeout = 900 # Default time-out for pre-heating the bed, in seconds.
  46. self._preheat_bed_timer = QTimer() # Timer that tracks how long to preheat still.
  47. self._preheat_bed_timer.setSingleShot(True)
  48. self._preheat_bed_timer.timeout.connect(self.cancelPreheatBed)
  49. self._printer_state = ""
  50. self._printer_type = "unknown"
  51. self._camera_active = False
  52. def requestWrite(self, nodes, file_name = None, filter_by_machine = False, file_handler = None):
  53. raise NotImplementedError("requestWrite needs to be implemented")
  54. ## Signals
  55. # Signal to be emitted when bed temp is changed
  56. bedTemperatureChanged = pyqtSignal()
  57. # Signal to be emitted when target bed temp is changed
  58. targetBedTemperatureChanged = pyqtSignal()
  59. # Signal when the progress is changed (usually when this output device is printing / sending lots of data)
  60. progressChanged = pyqtSignal()
  61. # Signal to be emitted when hotend temp is changed
  62. hotendTemperaturesChanged = pyqtSignal()
  63. # Signal to be emitted when target hotend temp is changed
  64. targetHotendTemperaturesChanged = pyqtSignal()
  65. # Signal to be emitted when head position is changed (x,y,z)
  66. headPositionChanged = pyqtSignal()
  67. # Signal to be emitted when either of the material ids is changed
  68. materialIdChanged = pyqtSignal(int, str, arguments = ["index", "id"])
  69. # Signal to be emitted when either of the hotend ids is changed
  70. hotendIdChanged = pyqtSignal(int, str, arguments = ["index", "id"])
  71. # Signal that is emitted every time connection state is changed.
  72. # it also sends it's own device_id (for convenience sake)
  73. connectionStateChanged = pyqtSignal(str)
  74. connectionTextChanged = pyqtSignal()
  75. timeElapsedChanged = pyqtSignal()
  76. timeTotalChanged = pyqtSignal()
  77. jobStateChanged = pyqtSignal()
  78. jobNameChanged = pyqtSignal()
  79. errorTextChanged = pyqtSignal()
  80. acceptsCommandsChanged = pyqtSignal()
  81. printerStateChanged = pyqtSignal()
  82. printerTypeChanged = pyqtSignal()
  83. # Signal to be emitted when some drastic change occurs in the remaining time (not when the time just passes on normally).
  84. preheatBedRemainingTimeChanged = pyqtSignal()
  85. @pyqtProperty(str, notify=printerTypeChanged)
  86. def printerType(self):
  87. return self._printer_type
  88. @pyqtProperty(str, notify=printerStateChanged)
  89. def printerState(self):
  90. return self._printer_state
  91. @pyqtProperty(str, notify = jobStateChanged)
  92. def jobState(self):
  93. return self._job_state
  94. def _updatePrinterType(self, printer_type):
  95. if self._printer_type != printer_type:
  96. self._printer_type = printer_type
  97. self.printerTypeChanged.emit()
  98. def _updatePrinterState(self, printer_state):
  99. if self._printer_state != printer_state:
  100. self._printer_state = printer_state
  101. self.printerStateChanged.emit()
  102. def _updateJobState(self, job_state):
  103. if self._job_state != job_state:
  104. self._job_state = job_state
  105. self.jobStateChanged.emit()
  106. @pyqtSlot(str)
  107. def setJobState(self, job_state):
  108. self._setJobState(job_state)
  109. def _setJobState(self, job_state):
  110. Logger.log("w", "_setJobState is not implemented by this output device")
  111. @pyqtSlot()
  112. def startCamera(self):
  113. self._camera_active = True
  114. self._startCamera()
  115. def _startCamera(self):
  116. Logger.log("w", "_startCamera is not implemented by this output device")
  117. @pyqtSlot()
  118. def stopCamera(self):
  119. self._camera_active = False
  120. self._stopCamera()
  121. def _stopCamera(self):
  122. Logger.log("w", "_stopCamera is not implemented by this output device")
  123. @pyqtProperty(str, notify = jobNameChanged)
  124. def jobName(self):
  125. return self._job_name
  126. def setJobName(self, name):
  127. if self._job_name != name:
  128. self._job_name = name
  129. self.jobNameChanged.emit()
  130. ## Gives a human-readable address where the device can be found.
  131. @pyqtProperty(str, constant = True)
  132. def address(self):
  133. Logger.log("w", "address is not implemented by this output device.")
  134. ## A human-readable name for the device.
  135. @pyqtProperty(str, constant = True)
  136. def name(self):
  137. Logger.log("w", "name is not implemented by this output device.")
  138. return ""
  139. @pyqtProperty(str, notify = errorTextChanged)
  140. def errorText(self):
  141. return self._error_text
  142. ## Set the error-text that is shown in the print monitor in case of an error
  143. def setErrorText(self, error_text):
  144. if self._error_text != error_text:
  145. self._error_text = error_text
  146. self.errorTextChanged.emit()
  147. @pyqtProperty(bool, notify = acceptsCommandsChanged)
  148. def acceptsCommands(self):
  149. return self._accepts_commands
  150. ## Set a flag to signal the UI that the printer is not (yet) ready to receive commands
  151. def setAcceptsCommands(self, accepts_commands):
  152. if self._accepts_commands != accepts_commands:
  153. self._accepts_commands = accepts_commands
  154. self.acceptsCommandsChanged.emit()
  155. ## Get the bed temperature of the bed (if any)
  156. # This function is "final" (do not re-implement)
  157. # /sa _getBedTemperature implementation function
  158. @pyqtProperty(float, notify = bedTemperatureChanged)
  159. def bedTemperature(self):
  160. return self._bed_temperature
  161. ## Set the (target) bed temperature
  162. # This function is "final" (do not re-implement)
  163. # /param temperature new target temperature of the bed (in deg C)
  164. # /sa _setTargetBedTemperature implementation function
  165. @pyqtSlot(int)
  166. def setTargetBedTemperature(self, temperature):
  167. self._setTargetBedTemperature(temperature)
  168. if self._target_bed_temperature != temperature:
  169. self._target_bed_temperature = temperature
  170. self.targetBedTemperatureChanged.emit()
  171. ## The total duration of the time-out to pre-heat the bed, in seconds.
  172. #
  173. # \return The duration of the time-out to pre-heat the bed, in seconds.
  174. @pyqtProperty(int, constant = True)
  175. def preheatBedTimeout(self):
  176. return self._preheat_bed_timeout
  177. ## The remaining duration of the pre-heating of the bed.
  178. #
  179. # This is formatted in M:SS format.
  180. # \return The duration of the time-out to pre-heat the bed, formatted.
  181. @pyqtProperty(str, notify = preheatBedRemainingTimeChanged)
  182. def preheatBedRemainingTime(self):
  183. if not self._preheat_bed_timer.isActive():
  184. return ""
  185. period = self._preheat_bed_timer.remainingTime()
  186. if period <= 0:
  187. return ""
  188. minutes, period = divmod(period, 60000) #60000 milliseconds in a minute.
  189. seconds, _ = divmod(period, 1000) #1000 milliseconds in a second.
  190. if minutes <= 0 and seconds <= 0:
  191. return ""
  192. return "%d:%02d" % (minutes, seconds)
  193. ## Time the print has been printing.
  194. # Note that timeTotal - timeElapsed should give time remaining.
  195. @pyqtProperty(float, notify = timeElapsedChanged)
  196. def timeElapsed(self):
  197. return self._time_elapsed
  198. ## Total time of the print
  199. # Note that timeTotal - timeElapsed should give time remaining.
  200. @pyqtProperty(float, notify=timeTotalChanged)
  201. def timeTotal(self):
  202. return self._time_total
  203. @pyqtSlot(float)
  204. def setTimeTotal(self, new_total):
  205. if self._time_total != new_total:
  206. self._time_total = new_total
  207. self.timeTotalChanged.emit()
  208. @pyqtSlot(float)
  209. def setTimeElapsed(self, time_elapsed):
  210. if self._time_elapsed != time_elapsed:
  211. self._time_elapsed = time_elapsed
  212. self.timeElapsedChanged.emit()
  213. ## Home the head of the connected printer
  214. # This function is "final" (do not re-implement)
  215. # /sa _homeHead implementation function
  216. @pyqtSlot()
  217. def homeHead(self):
  218. self._homeHead()
  219. ## Home the head of the connected printer
  220. # This is an implementation function and should be overriden by children.
  221. def _homeHead(self):
  222. Logger.log("w", "_homeHead is not implemented by this output device")
  223. ## Home the bed of the connected printer
  224. # This function is "final" (do not re-implement)
  225. # /sa _homeBed implementation function
  226. @pyqtSlot()
  227. def homeBed(self):
  228. self._homeBed()
  229. ## Home the bed of the connected printer
  230. # This is an implementation function and should be overriden by children.
  231. # /sa homeBed
  232. def _homeBed(self):
  233. Logger.log("w", "_homeBed is not implemented by this output device")
  234. ## Protected setter for the bed temperature of the connected printer (if any).
  235. # /parameter temperature Temperature bed needs to go to (in deg celsius)
  236. # /sa setTargetBedTemperature
  237. def _setTargetBedTemperature(self, temperature):
  238. Logger.log("w", "_setTargetBedTemperature is not implemented by this output device")
  239. ## Pre-heats the heated bed of the printer.
  240. #
  241. # \param temperature The temperature to heat the bed to, in degrees
  242. # Celsius.
  243. # \param duration How long the bed should stay warm, in seconds.
  244. @pyqtSlot(float, float)
  245. def preheatBed(self, temperature, duration):
  246. Logger.log("w", "preheatBed is not implemented by this output device.")
  247. ## Cancels pre-heating the heated bed of the printer.
  248. #
  249. # If the bed is not pre-heated, nothing happens.
  250. @pyqtSlot()
  251. def cancelPreheatBed(self):
  252. Logger.log("w", "cancelPreheatBed is not implemented by this output device.")
  253. ## Protected setter for the current bed temperature.
  254. # This simply sets the bed temperature, but ensures that a signal is emitted.
  255. # /param temperature temperature of the bed.
  256. def _setBedTemperature(self, temperature):
  257. if self._bed_temperature != temperature:
  258. self._bed_temperature = temperature
  259. self.bedTemperatureChanged.emit()
  260. ## Get the target bed temperature if connected printer (if any)
  261. @pyqtProperty(int, notify = targetBedTemperatureChanged)
  262. def targetBedTemperature(self):
  263. return self._target_bed_temperature
  264. ## Set the (target) hotend temperature
  265. # This function is "final" (do not re-implement)
  266. # /param index the index of the hotend that needs to change temperature
  267. # /param temperature The temperature it needs to change to (in deg celsius).
  268. # /sa _setTargetHotendTemperature implementation function
  269. @pyqtSlot(int, int)
  270. def setTargetHotendTemperature(self, index, temperature):
  271. self._setTargetHotendTemperature(index, temperature)
  272. if self._target_hotend_temperatures[index] != temperature:
  273. self._target_hotend_temperatures[index] = temperature
  274. self.targetHotendTemperaturesChanged.emit()
  275. ## Implementation function of setTargetHotendTemperature.
  276. # /param index Index of the hotend to set the temperature of
  277. # /param temperature Temperature to set the hotend to (in deg C)
  278. # /sa setTargetHotendTemperature
  279. def _setTargetHotendTemperature(self, index, temperature):
  280. Logger.log("w", "_setTargetHotendTemperature is not implemented by this output device")
  281. @pyqtProperty("QVariantList", notify = targetHotendTemperaturesChanged)
  282. def targetHotendTemperatures(self):
  283. return self._target_hotend_temperatures
  284. @pyqtProperty("QVariantList", notify = hotendTemperaturesChanged)
  285. def hotendTemperatures(self):
  286. return self._hotend_temperatures
  287. ## Protected setter for the current hotend temperature.
  288. # This simply sets the hotend temperature, but ensures that a signal is emitted.
  289. # /param index Index of the hotend
  290. # /param temperature temperature of the hotend (in deg C)
  291. def _setHotendTemperature(self, index, temperature):
  292. if self._hotend_temperatures[index] != temperature:
  293. self._hotend_temperatures[index] = temperature
  294. self.hotendTemperaturesChanged.emit()
  295. @pyqtProperty("QVariantList", notify = materialIdChanged)
  296. def materialIds(self):
  297. return self._material_ids
  298. @pyqtProperty("QVariantList", notify = materialIdChanged)
  299. def materialNames(self):
  300. result = []
  301. for material_id in self._material_ids:
  302. if material_id is None:
  303. result.append(i18n_catalog.i18nc("@item:material", "No material loaded"))
  304. continue
  305. containers = self._container_registry.findInstanceContainers(type = "material", GUID = material_id)
  306. if containers:
  307. result.append(containers[0].getName())
  308. else:
  309. result.append(i18n_catalog.i18nc("@item:material", "Unknown material"))
  310. return result
  311. ## List of the colours of the currently loaded materials.
  312. #
  313. # The list is in order of extruders. If there is no material in an
  314. # extruder, the colour is shown as transparent.
  315. #
  316. # The colours are returned in hex-format AARRGGBB or RRGGBB
  317. # (e.g. #800000ff for transparent blue or #00ff00 for pure green).
  318. @pyqtProperty("QVariantList", notify = materialIdChanged)
  319. def materialColors(self):
  320. result = []
  321. for material_id in self._material_ids:
  322. if material_id is None:
  323. result.append("#00000000") #No material.
  324. continue
  325. containers = self._container_registry.findInstanceContainers(type = "material", GUID = material_id)
  326. if containers:
  327. result.append(containers[0].getMetaDataEntry("color_code"))
  328. else:
  329. result.append("#00000000") #Unknown material.
  330. return result
  331. ## Protected setter for the current material id.
  332. # /param index Index of the extruder
  333. # /param material_id id of the material
  334. def _setMaterialId(self, index, material_id):
  335. if material_id and material_id != "" and material_id != self._material_ids[index]:
  336. Logger.log("d", "Setting material id of hotend %d to %s" % (index, material_id))
  337. self._material_ids[index] = material_id
  338. self.materialIdChanged.emit(index, material_id)
  339. @pyqtProperty("QVariantList", notify = hotendIdChanged)
  340. def hotendIds(self):
  341. return self._hotend_ids
  342. ## Protected setter for the current hotend id.
  343. # /param index Index of the extruder
  344. # /param hotend_id id of the hotend
  345. def _setHotendId(self, index, hotend_id):
  346. if hotend_id and hotend_id != self._hotend_ids[index]:
  347. Logger.log("d", "Setting hotend id of hotend %d to %s" % (index, hotend_id))
  348. self._hotend_ids[index] = hotend_id
  349. self.hotendIdChanged.emit(index, hotend_id)
  350. elif not hotend_id:
  351. Logger.log("d", "Removing hotend id of hotend %d.", index)
  352. self._hotend_ids[index] = None
  353. self.hotendIdChanged.emit(index, None)
  354. ## Let the user decide if the hotends and/or material should be synced with the printer
  355. # NB: the UX needs to be implemented by the plugin
  356. def materialHotendChangedMessage(self, callback):
  357. Logger.log("w", "materialHotendChangedMessage needs to be implemented, returning 'Yes'")
  358. callback(QMessageBox.Yes)
  359. ## Attempt to establish connection
  360. def connect(self):
  361. raise NotImplementedError("connect needs to be implemented")
  362. ## Attempt to close the connection
  363. def close(self):
  364. raise NotImplementedError("close needs to be implemented")
  365. @pyqtProperty(bool, notify = connectionStateChanged)
  366. def connectionState(self):
  367. return self._connection_state
  368. ## Set the connection state of this output device.
  369. # /param connection_state ConnectionState enum.
  370. def setConnectionState(self, connection_state):
  371. if self._connection_state != connection_state:
  372. self._connection_state = connection_state
  373. self.connectionStateChanged.emit(self._id)
  374. @pyqtProperty(str, notify = connectionTextChanged)
  375. def connectionText(self):
  376. return self._connection_text
  377. ## Set a text that is shown on top of the print monitor tab
  378. def setConnectionText(self, connection_text):
  379. if self._connection_text != connection_text:
  380. self._connection_text = connection_text
  381. self.connectionTextChanged.emit()
  382. ## Ensure that close gets called when object is destroyed
  383. def __del__(self):
  384. self.close()
  385. ## Get the x position of the head.
  386. # This function is "final" (do not re-implement)
  387. @pyqtProperty(float, notify = headPositionChanged)
  388. def headX(self):
  389. return self._head_x
  390. ## Get the y position of the head.
  391. # This function is "final" (do not re-implement)
  392. @pyqtProperty(float, notify = headPositionChanged)
  393. def headY(self):
  394. return self._head_y
  395. ## Get the z position of the head.
  396. # In some machines it's actually the bed that moves. For convenience sake we simply see it all as head movements.
  397. # This function is "final" (do not re-implement)
  398. @pyqtProperty(float, notify = headPositionChanged)
  399. def headZ(self):
  400. return self._head_z
  401. ## Update the saved position of the head
  402. # This function should be called when a new position for the head is received.
  403. def _updateHeadPosition(self, x, y ,z):
  404. position_changed = False
  405. if self._head_x != x:
  406. self._head_x = x
  407. position_changed = True
  408. if self._head_y != y:
  409. self._head_y = y
  410. position_changed = True
  411. if self._head_z != z:
  412. self._head_z = z
  413. position_changed = True
  414. if position_changed:
  415. self.headPositionChanged.emit()
  416. ## Set the position of the head.
  417. # In some machines it's actually the bed that moves. For convenience sake we simply see it all as head movements.
  418. # This function is "final" (do not re-implement)
  419. # /param x new x location of the head.
  420. # /param y new y location of the head.
  421. # /param z new z location of the head.
  422. # /param speed Speed by which it needs to move (in mm/minute)
  423. # /sa _setHeadPosition implementation function
  424. @pyqtSlot("long", "long", "long")
  425. @pyqtSlot("long", "long", "long", "long")
  426. def setHeadPosition(self, x, y, z, speed = 3000):
  427. self._setHeadPosition(x, y , z, speed)
  428. ## Set the X position of the head.
  429. # This function is "final" (do not re-implement)
  430. # /param x x position head needs to move to.
  431. # /param speed Speed by which it needs to move (in mm/minute)
  432. # /sa _setHeadx implementation function
  433. @pyqtSlot("long")
  434. @pyqtSlot("long", "long")
  435. def setHeadX(self, x, speed = 3000):
  436. self._setHeadX(x, speed)
  437. ## Set the Y position of the head.
  438. # This function is "final" (do not re-implement)
  439. # /param y y position head needs to move to.
  440. # /param speed Speed by which it needs to move (in mm/minute)
  441. # /sa _setHeadY implementation function
  442. @pyqtSlot("long")
  443. @pyqtSlot("long", "long")
  444. def setHeadY(self, y, speed = 3000):
  445. self._setHeadY(y, speed)
  446. ## Set the Z position of the head.
  447. # In some machines it's actually the bed that moves. For convenience sake we simply see it all as head movements.
  448. # This function is "final" (do not re-implement)
  449. # /param z z position head needs to move to.
  450. # /param speed Speed by which it needs to move (in mm/minute)
  451. # /sa _setHeadZ implementation function
  452. @pyqtSlot("long")
  453. @pyqtSlot("long", "long")
  454. def setHeadZ(self, z, speed = 3000):
  455. self._setHeadY(z, speed)
  456. ## Move the head of the printer.
  457. # Note that this is a relative move. If you want to move the head to a specific position you can use
  458. # setHeadPosition
  459. # This function is "final" (do not re-implement)
  460. # /param x distance in x to move
  461. # /param y distance in y to move
  462. # /param z distance in z to move
  463. # /param speed Speed by which it needs to move (in mm/minute)
  464. # /sa _moveHead implementation function
  465. @pyqtSlot("long", "long", "long")
  466. @pyqtSlot("long", "long", "long", "long")
  467. def moveHead(self, x = 0, y = 0, z = 0, speed = 3000):
  468. self._moveHead(x, y, z, speed)
  469. ## Implementation function of moveHead.
  470. # /param x distance in x to move
  471. # /param y distance in y to move
  472. # /param z distance in z to move
  473. # /param speed Speed by which it needs to move (in mm/minute)
  474. # /sa moveHead
  475. def _moveHead(self, x, y, z, speed):
  476. Logger.log("w", "_moveHead is not implemented by this output device")
  477. ## Implementation function of setHeadPosition.
  478. # /param x new x location of the head.
  479. # /param y new y location of the head.
  480. # /param z new z location of the head.
  481. # /param speed Speed by which it needs to move (in mm/minute)
  482. # /sa setHeadPosition
  483. def _setHeadPosition(self, x, y, z, speed):
  484. Logger.log("w", "_setHeadPosition is not implemented by this output device")
  485. ## Implementation function of setHeadX.
  486. # /param x new x location of the head.
  487. # /param speed Speed by which it needs to move (in mm/minute)
  488. # /sa setHeadX
  489. def _setHeadX(self, x, speed):
  490. Logger.log("w", "_setHeadX is not implemented by this output device")
  491. ## Implementation function of setHeadY.
  492. # /param y new y location of the head.
  493. # /param speed Speed by which it needs to move (in mm/minute)
  494. # /sa _setHeadY
  495. def _setHeadY(self, y, speed):
  496. Logger.log("w", "_setHeadY is not implemented by this output device")
  497. ## Implementation function of setHeadZ.
  498. # /param z new z location of the head.
  499. # /param speed Speed by which it needs to move (in mm/minute)
  500. # /sa _setHeadZ
  501. def _setHeadZ(self, z, speed):
  502. Logger.log("w", "_setHeadZ is not implemented by this output device")
  503. ## Get the progress of any currently active process.
  504. # This function is "final" (do not re-implement)
  505. # /sa _getProgress
  506. # /returns float progress of the process. -1 indicates that there is no process.
  507. @pyqtProperty(float, notify = progressChanged)
  508. def progress(self):
  509. return self._progress
  510. ## Set the progress of any currently active process
  511. # /param progress Progress of the process.
  512. def setProgress(self, progress):
  513. if self._progress != progress:
  514. self._progress = progress
  515. self.progressChanged.emit()
  516. ## The current processing state of the backend.
  517. class ConnectionState(IntEnum):
  518. closed = 0
  519. connecting = 1
  520. connected = 2
  521. busy = 3
  522. error = 4