mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47:49 -06:00
Moved camera to own timer, so grabbing can be in a different frequency
CURA-336 and CURA-1036
This commit is contained in:
parent
354d2bc109
commit
bb1fead4c6
1 changed files with 14 additions and 5 deletions
|
@ -72,6 +72,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._update_timer.setSingleShot(False)
|
self._update_timer.setSingleShot(False)
|
||||||
self._update_timer.timeout.connect(self._update)
|
self._update_timer.timeout.connect(self._update)
|
||||||
|
|
||||||
|
self._camera_timer = QTimer()
|
||||||
|
self._camera_timer.setInterval(2000) # Todo: Add preference for camera update interval
|
||||||
|
self._camera_timer.setSingleShot(False)
|
||||||
|
self._camera_timer.timeout.connect(self._update_camera)
|
||||||
|
|
||||||
self._camera_image_id = 0
|
self._camera_image_id = 0
|
||||||
|
|
||||||
self._camera_image = QImage()
|
self._camera_image = QImage()
|
||||||
|
@ -81,6 +86,12 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
def getKey(self):
|
def getKey(self):
|
||||||
return self._key
|
return self._key
|
||||||
|
|
||||||
|
def _update_camera(self):
|
||||||
|
## Request new image
|
||||||
|
url = QUrl("http://" + self._address + ":8080/?action=snapshot")
|
||||||
|
self._image_request = QNetworkRequest(url)
|
||||||
|
self._image_reply = self._manager.get(self._image_request)
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
## Request 'general' printer data
|
## Request 'general' printer data
|
||||||
url = QUrl("http://" + self._address + self._api_prefix + "printer")
|
url = QUrl("http://" + self._address + self._api_prefix + "printer")
|
||||||
|
@ -92,11 +103,6 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._print_job_request = QNetworkRequest(url)
|
self._print_job_request = QNetworkRequest(url)
|
||||||
self._print_job_reply = self._manager.get(self._print_job_request)
|
self._print_job_reply = self._manager.get(self._print_job_request)
|
||||||
|
|
||||||
## Request new image
|
|
||||||
url = QUrl("http://" + self._address +":8080/?action=snapshot")
|
|
||||||
self._image_request = QNetworkRequest(url)
|
|
||||||
self._image_reply = self._manager.get(self._image_request)
|
|
||||||
|
|
||||||
## Convenience function that gets information from the received json data and converts it to the right internal
|
## Convenience function that gets information from the received json data and converts it to the right internal
|
||||||
# values / variables
|
# values / variables
|
||||||
def _spliceJSONData(self):
|
def _spliceJSONData(self):
|
||||||
|
@ -116,6 +122,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
def close(self):
|
def close(self):
|
||||||
self.setConnectionState(ConnectionState.closed)
|
self.setConnectionState(ConnectionState.closed)
|
||||||
self._update_timer.stop()
|
self._update_timer.stop()
|
||||||
|
self._camera_timer.stop()
|
||||||
|
|
||||||
def requestWrite(self, node, file_name = None, filter_by_machine = False):
|
def requestWrite(self, node, file_name = None, filter_by_machine = False):
|
||||||
self._gcode = getattr(Application.getInstance().getController().getScene(), "gcode_list")
|
self._gcode = getattr(Application.getInstance().getController().getScene(), "gcode_list")
|
||||||
|
@ -128,8 +135,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.setConnectionState(ConnectionState.connecting)
|
self.setConnectionState(ConnectionState.connecting)
|
||||||
self._update() # Manually trigger the first update, as we don't want to wait a few secs before it starts.
|
self._update() # Manually trigger the first update, as we don't want to wait a few secs before it starts.
|
||||||
|
self._update_camera()
|
||||||
Logger.log("d", "Connection with printer %s with ip %s started", self._key, self._address)
|
Logger.log("d", "Connection with printer %s with ip %s started", self._key, self._address)
|
||||||
self._update_timer.start()
|
self._update_timer.start()
|
||||||
|
self._camera_timer.start()
|
||||||
|
|
||||||
newImage = pyqtSignal()
|
newImage = pyqtSignal()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue