1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
5 import httplib as httpclient
9 from Cura.util.printerConnection import printerConnectionBase
11 class dummyConnectionGroup(printerConnectionBase.printerConnectionGroup):
13 super(dummyConnectionGroup, self).__init__("Dummy")
14 self._list = [dummyConnection("Dummy 1"), dummyConnection("Dummy 2")]
16 def getAvailableConnections(self):
19 #Dummy printer class which is always
20 class dummyConnection(printerConnectionBase.printerConnectionBase):
21 def __init__(self, name):
22 super(dummyConnection, self).__init__(name)
24 self._printing = False
26 self._progressLine = 0
28 self.printThread = threading.Thread(target=self._dummyThread)
29 self.printThread.daemon = True
30 self.printThread.start()
32 #Load the file into memory for printing.
33 def loadFile(self, filename):
37 f = open(filename, "r")
39 #Strip out comments, we do not need to send comments
41 line = line[:line.index(';')]
42 #Strip out whitespace at the beginning/end this saves data to send.
51 #Start printing the previously loaded file
53 if self._printing or self._lineCount < 1:
55 self._progressLine = 0
58 #Abort the previously loaded print file
59 def cancelPrint(self):
60 self._printing = False
65 #Amount of progression of the current print file. 0.0 to 1.0
66 def getPrintProgress(self):
67 if self._lineCount < 1:
69 return float(self._progressLine) / float(self._lineCount)
71 # Return if the printer with this connection type is available
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):
78 return "DUMMY!\n%i %i\n%i" % (self._progressLine, self._lineCount, self._printing)
80 def _dummyThread(self):
82 if not self._printing:
87 self._progressLine += 1
88 if self._progressLine == self._lineCount:
89 self._printing = False