chiark / gitweb /
Update the doodle3d class to auto-detect local network boxes, as well as access point...
[cura.git] / Cura / util / printerConnection / printerConnectionManager.py
1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
2
3 from Cura.util import version
4 from Cura.util.printerConnection import dummyConnection
5 from Cura.util.printerConnection import doodle3dConnect
6
7 class connectionEntry(object):
8         def __init__(self, name, priority, icon, connection):
9                 self.name = name
10                 self.priority = priority
11                 self.icon = icon
12                 self.connection = connection
13
14         def __cmp__(self, other):
15                 return self.priority - other.priority
16
17         def __repr__(self):
18                 return self.name
19
20 class PrinterConnectionManager(object):
21         def __init__(self):
22                 self._connectionList = []
23                 if version.isDevVersion():
24                         self._connectionList.append(connectionEntry('Dummy', -1, 5, dummyConnection.dummyConnection()))
25                 self._connectionList.append(connectionEntry('Doodle3D', 100, 27, doodle3dConnect.doodle3dConnect()))
26
27                 #Sort the connections by highest priority first.
28                 self._connectionList.sort(reverse=True)
29
30         #Return the highest priority available connection.
31         def getAvailableConnection(self):
32                 for e in self._connectionList:
33                         if e.connection.isAvailable():
34                                 return e
35                 return None