-class nimSlot:
- def __init__(self, slotid, nimtype, name):
- self.slotid = slotid
- self.nimType = nimtype
- self.name = name
-
-class NimManager:
- class parseSats(ContentHandler):
- def __init__(self, satList, satellites, transponders):
- self.isPointsElement, self.isReboundsElement = 0, 0
- self.satList = satList
- self.satellites = satellites
- self.transponders = transponders
-
- def startElement(self, name, attrs):
- if (name == "sat"):
- #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
- tpos = int(attrs.get('position',""))
- if tpos < 0:
- tpos = 3600 + tpos
- tname = attrs.get('name',"").encode("UTF-8")
- self.satellites[tpos] = tname
- self.satList.append( (tpos, tname) )
- self.parsedSat = int(tpos)
- elif (name == "transponder"):
- modulation = int(attrs.get('modulation',"1")) # QPSK default
- system = int(attrs.get('system',"0")) # DVB-S default
- freq = int(attrs.get('frequency',""))
- sr = int(attrs.get('symbol_rate',""))
- pol = int(attrs.get('polarization',""))
- fec = int(attrs.get('fec_inner',"0")) # AUTO default
- if self.parsedSat in self.transponders:
- pass
- else:
- self.transponders[self.parsedSat] = [ ]
-
- self.transponders[self.parsedSat].append((0, freq, sr, pol, fec, system, modulation))
-
- class parseCables(ContentHandler):
- def __init__(self, cablesList, transponders):
- self.isPointsElement, self.isReboundsElement = 0, 0
- self.cablesList = cablesList
- self.transponders = transponders
-
- def startElement(self, name, attrs):
- if (name == "cable"):
- #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
- tname = attrs.get('name',"").encode("UTF-8")
- self.cablesList.append(str(tname))
- self.parsedCab = str(tname)
- elif (name == "transponder"):
- freq = int(attrs.get('frequency',""))
- #sr = int(attrs.get('symbol_rate',""))
- #mod = int(attrs.get('modulation',"3")) # QAM64 default
- #fec = int(attrs.get('fec_inner',"0")) # AUTO default
- if self.parsedCab in self.transponders:
- pass
- else:
- self.transponders[self.parsedCab] = [ ]
- self.transponders[self.parsedCab].append((1, freq))
-
- class parseTerrestrials(ContentHandler):
- def __init__(self, terrestrialsList, transponders):
- self.isPointsElement, self.isReboundsElement = 0, 0
- self.terrestrialsList = terrestrialsList
- self.transponders = transponders
-
- def startElement(self, name, attrs):
- if (name == "terrestrial"):
- #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
- tname = attrs.get('name',"").encode("UTF-8")
- tflags = attrs.get('flags',"")
- self.terrestrialsList.append((tname, tflags))
- self.parsedTer = str(tname)
- elif (name == "transponder"):
- # TODO finish this!
- freq = int(attrs.get('centre_frequency',""))
- bw = int(attrs.get('bandwidth',"3")) # AUTO
- const = int(attrs.get('constellation',"1")) # AUTO
- crh = int(attrs.get('code_rate_hp',"5")) # AUTO
- if crh > 5: # our terrestrial.xml is buggy... 6 for AUTO
- crh = 5
- crl = int(attrs.get('code_rate_lp',"5")) # AUTO
- if crl > 5: # our terrestrial.xml is buggy... 6 for AUTO
- crl = 5
- guard = int(attrs.get('guard_interval',"4")) # AUTO
- transm = int(attrs.get('transmission_mode',"2")) # AUTO
- hierarchy = int(attrs.get('hierarchy_information',"4")) # AUTO
- inv = int(attrs.get('inversion',"2")) # AUTO
- if self.parsedTer in self.transponders:
- pass
- else:
- self.transponders[self.parsedTer] = [ ]
+class NIM(object):
+ def __init__(self, slot, type, description):
+ self.slot = slot
+
+ if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
+ print "warning: unknown NIM type %s, not using." % type
+ type = None
+
+ self.type = type
+ self.description = description
+
+ def isCompatible(self, what):
+ compatible = {
+ None: [None],
+ "DVB-S": ["DVB-S", None],
+ "DVB-C": ["DVB-C", None],
+ "DVB-T": ["DVB-T", None],
+ "DVB-S2": ["DVB-S", "DVB-S2", None]
+ }
+ return what in compatible[self.type]
+
+ def getSlotName(self):
+ # get a friendly description for a slot name.
+ # we name them "Tuner A/B/C/...", because that's what's usually written on the back
+ # of the device.
+ return _("Tuner ") + chr(ord('A') + self.slot)
+
+ slot_name = property(getSlotName)
+
+ def getSlotID(self):
+ return chr(ord('A') + self.slot)
+
+ slot_id = property(getSlotID)
+
+ def getFriendlyType(self):
+ return {
+ "DVB-S": "DVB-S",
+ "DVB-T": "DVB-T",
+ "DVB-S2": "DVB-S2",
+ "DVB-C": "DVB-C",
+ None: _("empty")
+ }[self.type]
+
+ friendly_type = property(getFriendlyType)
+
+ def getFriendlyFullDescription(self):
+ nim_text = self.slot_name + ": "
+
+ if self.empty:
+ nim_text += _("(empty)")
+ else:
+ nim_text += self.description + " (" + self.friendly_type + ")"
+
+ return nim_text