1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
3 #Base class for different printer connection implementations.
4 # A printer connection can connect to printers in different ways, trough network, USB or carrier pigeons.
5 # Each printer connection has different capabilities that you can query with the "has" functions.
6 # Each printer connection has a state that you can query with the "is" functions.
7 # Each printer connection has callback objects that receive status updates from the printer when information changes.
9 class printerConnectionBase(object):
11 self._callbackList = []
13 #Load the file into memory for printing.
14 def loadFile(self, filename):
17 #Start printing the previously loaded file
21 #Abort the previously loaded print file
22 def cancelPrint(self):
28 #Amount of progression of the current print file. 0.0 to 1.0
29 def getPrintProgress(self):
32 #Returns true if we need to establish an active connection.
33 # Depending on the type of the connection some types do not need an active connection (Doodle3D WiFi Box for example)
34 def hasActiveConnection(self):
37 #Open the active connection to the printer so we can send commands
38 def openActiveConnection(self):
41 #Close the active connection to the printer
42 def closeActiveConnection(self):
45 #Is the active connection open right now.
46 def isActiveConnectionOpen(self):
49 #Returns true if we have the ability to pause the file printing.
56 #Pause or unpause the printing depending on the value, if supported.
57 def pause(self, value):
60 #Are we able to send a direct coammand with sendCommand at this moment in time.
61 def isAbleToSendDirectCommand(self):
64 #Directly send a command to the printer.
65 def sendCommand(self, command):
68 # Return if the printer with this connection type is available for possible printing right now.
69 # It is used to auto-detect which connection should default to the print button.
70 # This means the printer is detected, but no connection has been made yet.
71 # Example: COM port is detected, but no connection has been made.
72 # Example: WiFi box is detected and is ready to print with a printer connected
73 def isAvailable(self):
76 #Get the temperature of an extruder, returns None is no temperature is known for this extruder
77 def getTemperature(self, extruder):
80 #Get the temperature of the heated bed, returns None is no temperature is known for the heated bed
81 def getBedTemperature(self):
84 # Get the connection status string. This is displayed to the user and can be used to communicate
85 # various information to the user.
86 def getStatusString(self):
89 def addCallback(self, callback):
90 self._callbackList.append(callback)
92 def removeCallback(self, callback):
93 if callback in self._callbackList:
94 self._callbackList.remove(callback)
96 #Run a callback, this can be ran from a different thread.
97 def _doCallback(self, param=None):
98 for callback in self._callbackList: