chiark / gitweb /
Add version 0.1 of serial communication with printerConnection.
[cura.git] / Cura / util / printerConnection / doodle3dConnect.py
index bb03cd75e58b82815cba81adb2de184475e7d183..ad3ea51b27883800b6f2bcc45b2c2329262044af 100644 (file)
@@ -25,18 +25,15 @@ class doodle3dConnectionGroup(printerConnectionBase.printerConnectionGroup):
        def getAvailableConnections(self):
                return filter(lambda c: c.isAvailable(), self._connectionMap.values())
 
+       def remove(self, host):
+               del self._connectionMap[host]
+
        def getIconID(self):
                return 27
 
        def getPriority(self):
                return 100
 
-       def __cmp__(self, other):
-               return self.getPriority() - other.getPriority()
-
-       def __repr__(self):
-               return self.name
-
        def _doodle3DThread(self):
                self._waitDelay = 0
                while True:
@@ -119,15 +116,14 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase):
                self.checkThread.start()
 
        #Load the file into memory for printing.
-       def loadFile(self, filename):
+       def loadGCodeData(self, dataStream):
                if self._printing:
                        return False
                self._fileBlocks = []
                self._lineCount = 0
                block = []
                blockSize = 0
-               f = open(filename, "r")
-               for line in f:
+               for line in dataStream:
                        #Strip out comments, we do not need to send comments
                        if ';' in line:
                                line = line[:line.index(';')]
@@ -145,7 +141,6 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase):
                        blockSize += len(line) + 1
                        block.append(line)
                self._fileBlocks.append('\n'.join(block) + '\n')
-               f.close()
                self._doCallback()
                return True
 
@@ -224,12 +219,13 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase):
                                # The Doodle3D box could also be offline, if we reach a high enough errorCount then assume the box is gone.
                                self._errorCount += 1
                                if self._errorCount > 10:
-                                       self._host = None
                                        if self._isAvailable:
                                                self._printing = False
                                                self._isAvailable = False
                                                self._doCallback()
                                        self._sleep(15)
+                                       self._group.remove(self._host)
+                                       return
                                else:
                                        self._sleep(3)
                                continue