chiark / gitweb /
Add progress to the new printerconnectionbase.
[cura.git] / Cura / util / printerConnection / printerConnectionBase.py
1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
2
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.
8
9 class printerConnectionBase(object):
10         def __init__(self):
11                 self._callbackList = []
12
13         #Load the file into memory for printing.
14         def loadFile(self, filename):
15                 pass
16
17         #Start printing the previously loaded file
18         def startPrint(self):
19                 pass
20
21         #Abort the previously loaded print file
22         def cancelPrint(self):
23                 pass
24
25         def isPrinting(self):
26                 return False
27
28         #Amount of progression of the current print file. 0.0 to 1.0
29         def printProgress(self):
30                 return 0.0
31
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):
35                 return False
36
37         #Open the active connection to the printer so we can send commands
38         def openActiveConnection(self):
39                 pass
40
41         #Close the active connection to the printer
42         def closeActiveConnection(self):
43                 pass
44
45         #Is the active connection open right now.
46         def isActiveConnectionOpen(self):
47                 return False
48
49         #Returns true if we have the ability to pause the file printing.
50         def hasPause(self):
51                 return False
52
53         def isPaused(self):
54                 return False
55
56         #Pause or unpause the printing depending on the value, if supported.
57         def pause(self, value):
58                 pass
59
60         #Are we able to send a direct coammand with sendCommand at this moment in time.
61         def isAbleToSendDirectCommand(self):
62                 return False
63
64         #Directly send a command to the printer.
65         def sendCommand(self, command):
66                 pass
67
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):
73                 return False
74
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):
78                 return "TODO"
79
80         def addCallback(self, callback):
81                 self._callbackList.append(callback)
82
83         def removeCallback(self, callback):
84                 if callback in self._callbackList:
85                         self._callbackList.remove(callback)
86
87         #Run a callback, this can be ran from a different thread.
88         def _doCallback(self, param=None):
89                 for callback in self._callbackList:
90                         callback(self, param)