mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Merge branch 'master' of https://github.com/Ultimaker/PluggableCura
Conflicts: plugins/USBPrinting/USBPrinterManager.py
This commit is contained in:
commit
4dc6f87a36
2 changed files with 21 additions and 35 deletions
|
@ -95,7 +95,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
return
|
return
|
||||||
self._gcode = gcode_list
|
self._gcode = gcode_list
|
||||||
#Reset line number. If this is not done, first line is sometimes ignored
|
#Reset line number. If this is not done, first line is sometimes ignored
|
||||||
self._gcode.insert(0,"M110 N0")
|
self._gcode.insert(0, "M110")
|
||||||
self._gcode_position = 0
|
self._gcode_position = 0
|
||||||
self._print_start_time_100 = None
|
self._print_start_time_100 = None
|
||||||
self._is_printing = True
|
self._is_printing = True
|
||||||
|
@ -152,8 +152,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
self.setIsConnected(True)
|
self.setIsConnected(True)
|
||||||
return
|
return
|
||||||
self.setIsConnected(False)
|
self.setIsConnected(False)
|
||||||
|
|
||||||
|
|
||||||
## Set the baud rate of the serial. This can cause exceptions, but we simply want to ignore those.
|
## Set the baud rate of the serial. This can cause exceptions, but we simply want to ignore those.
|
||||||
def setBaudRate(self, baud_rate):
|
def setBaudRate(self, baud_rate):
|
||||||
try:
|
try:
|
||||||
|
@ -161,9 +160,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setIsConnected(self, state):
|
def setIsConnected(self, state):
|
||||||
self._is_connecting = False
|
self._is_connecting = False
|
||||||
if self._is_connected != state:
|
if self._is_connected != state:
|
||||||
|
@ -377,4 +374,3 @@ class PrinterConnection(SignalEmitter):
|
||||||
#ret.remove(prev)
|
#ret.remove(prev)
|
||||||
#ret.insert(0, prev)
|
#ret.insert(0, prev)
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -142,35 +142,25 @@ class USBPrinterManager(QObject, SignalEmitter,PluginObject):
|
||||||
|
|
||||||
def serialConectionStateCallback(self,serial_port):
|
def serialConectionStateCallback(self,serial_port):
|
||||||
connection = self.getConnectionByPort(serial_port)
|
connection = self.getConnectionByPort(serial_port)
|
||||||
if connection is not None:
|
if connection.isConnected():
|
||||||
if connection.isConnected():
|
Application.getInstance().addOutputDevice(serial_port, {
|
||||||
Application.getInstance().addOutputDevice(serial_port, {
|
'id': serial_port,
|
||||||
'id': serial_port,
|
'function': self._writeToSerial,
|
||||||
'function': self._writeToSerial,
|
'description': 'Write to USB {0}'.format(serial_port),
|
||||||
'description': 'Write to USB {0}'.format(serial_port),
|
'icon': 'print_usb',
|
||||||
'icon': 'print_usb',
|
'priority': 1
|
||||||
'priority': 1
|
})
|
||||||
})
|
else:
|
||||||
else:
|
Application.getInstance().removeOutputDevice(serial_port)
|
||||||
Application.getInstance().removeOutputDevice(serial_port)
|
|
||||||
|
|
||||||
|
|
||||||
def _writeToSerial(self, serial_port):
|
def _writeToSerial(self, serial_port):
|
||||||
## Create USB control window
|
gcode_list = getattr(Application.getInstance().getController().getScene(), 'gcode_list', None)
|
||||||
#self.view = QQuickView()
|
if gcode_list:
|
||||||
#self.view.setSource(QUrl("plugins/USBPrinting/ControlWindow.qml"))
|
final_list = []
|
||||||
#self.view.show()
|
for gcode in gcode_list:
|
||||||
|
final_list += gcode.split('\n')
|
||||||
#self.view.engine().rootContext().setContextProperty('manager',self)
|
self.sendGCodeByPort(serial_port, gcode_list)
|
||||||
|
|
||||||
for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()):
|
|
||||||
if type(node) is not SceneNode or not node.getMeshData():
|
|
||||||
continue
|
|
||||||
|
|
||||||
gcode = getattr(node.getMeshData(), 'gcode', False)
|
|
||||||
self.sendGCodeByPort(serial_port,gcode.split('\n'))
|
|
||||||
|
|
||||||
|
|
||||||
## Get a list of printer connection objects that are connected.
|
## Get a list of printer connection objects that are connected.
|
||||||
def getActiveConnections(self):
|
def getActiveConnections(self):
|
||||||
return [connection for connection in self._printer_connections if connection.isConnected()]
|
return [connection for connection in self._printer_connections if connection.isConnected()]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue