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 printProgress(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
69 # This means the printer is detected, but no connection has been made yet.
70 # Example: COM port is detected, but no connection has been made.
71 # Example: WiFi box is detected
72 def isAvailable(self):
75 # Get the connection status string. This is displayed to the user and can be used to communicate
76 # various information to the user.
77 def getStatusString(self):
80 def addCallback(self, callback):
81 self._callbackList.append(callback)
83 def removeCallback(self, callback):
84 if callback in self._callbackList:
85 self._callbackList.remove(callback)
87 #Run a callback, this can be ran from a different thread.
88 def _doCallback(self, param=None):
89 for callback in self._callbackList: