- 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
- for x in self.cablesList:
- self.cablesList.remove(x)
- 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")
- tflags = int(attrs.get('flags',"0"))
- self.cablesList.append((tname, tflags))
- self.parsedCab = tname
- elif (name == "transponder"):
- freq = int(attrs.get('frequency',""))
- while freq > 999999:
- freq /= 10
- sr = int(attrs.get('symbol_rate',"0"))
- 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, sr, mod, fec))
-
- 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] = [ ]
-
- self.transponders[self.parsedTer].append((2, freq, bw, const, crh, crl, guard, transm, hierarchy, inv))