PrinterOutputDevice.py 24 KB

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