chiark / gitweb /
7f5e843ed93d1ba89b0f4a94004e18c01d1f075f
[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 getPrintProgress(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 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):
74                 return False
75
76         #Get the temperature of an extruder, returns None is no temperature is known for this extruder
77         def getTemperature(self, extruder):
78                 return None
79
80         #Get the temperature of the heated bed, returns None is no temperature is known for the heated bed
81         def getBedTemperature(self):
82                 return None
83
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):
87                 return "TODO"
88
89         def addCallback(self, callback):
90                 self._callbackList.append(callback)
91
92         def removeCallback(self, callback):
93                 if callback in self._callbackList:
94                         self._callbackList.remove(callback)
95
96         #Run a callback, this can be ran from a different thread.
97         def _doCallback(self, param=None):
98                 for callback in self._callbackList:
99                         callback(self, param)