1 from Components.HTMLComponent import *
2 from Components.GUIComponent import *
3 from Screen import Screen
4 from Components.ActionMap import ActionMap
5 from Components.Label import Label
6 from Components.MenuList import MenuList
7 from ServiceReference import ServiceReference
8 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation
15 TYPE_VALUE_HEX_DEC = 3
18 def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
21 #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
22 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
23 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a))
25 if type(b) is not str:
26 if valueType == TYPE_VALUE_HEX:
27 b = ("0x%0" + str(param) + "x") % b
28 elif valueType == TYPE_VALUE_DEC:
30 elif valueType == TYPE_VALUE_HEX_DEC:
31 b = ("0x%0" + str(param) + "x (%dd)") % (b, b)
36 res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b))
40 class ServiceInfoList(HTMLComponent, GUIComponent):
41 def __init__(self, source):
42 GUIComponent.__init__(self)
43 self.l = eListboxPythonMultiContent()
45 self.l.setList(self.list)
46 self.l.setFont(0, gFont("Regular", 23))
50 def postWidgetCreate(self, instance):
51 self.instance.setContent(self.l)
52 self.instance.setItemHeight(25)
54 class ServiceInfo(Screen):
55 def __init__(self, session):
56 Screen.__init__(self, session)
58 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
62 "red": self.information,
64 "yellow": self.transponder,
68 service = session.nav.getCurrentService()
69 if service is not None:
70 self.info = service.info()
71 self.feinfo = service.frontendStatusInfo()
72 print self.info.getInfoObject(iServiceInformation.sCAIDs);
77 self["red"] = Label("Serviceinfo")
78 self["green"] = Label("PIDs")
79 self["yellow"] = Label("Transponder")
80 self["blue"] = Label("Tuner status")
84 self["infolist"] = ServiceInfoList(tlist)
85 self.onShown.append(self.information)
87 def information(self):
88 if self.session.nav.getCurrentlyPlayingServiceReference() is not None:
89 name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
92 Labels = ( ("Name", name, TYPE_TEXT),
93 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
94 ("Videoformat", self.getServiceInfoValue(iServiceInformation.sAspect), TYPE_TEXT),
95 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8))
99 Labels = ( ("VideoPID", self.getServiceInfoValue(iServiceInformation.sVideoPID), TYPE_VALUE_HEX_DEC, 4),
100 ("AudioPID", self.getServiceInfoValue(iServiceInformation.sAudioPID), TYPE_VALUE_HEX_DEC, 4),
101 ("PCRPID", self.getServiceInfoValue(iServiceInformation.sPCRPID), TYPE_VALUE_HEX_DEC, 4),
102 ("PMTPID", self.getServiceInfoValue(iServiceInformation.sPMTPID), TYPE_VALUE_HEX_DEC, 4),
103 ("TXTPID", self.getServiceInfoValue(iServiceInformation.sTXTPID), TYPE_VALUE_HEX_DEC, 4),
104 ("TSID", self.getServiceInfoValue(iServiceInformation.sTSID), TYPE_VALUE_HEX_DEC, 4),
105 ("ONID", self.getServiceInfoValue(iServiceInformation.sONID), TYPE_VALUE_HEX_DEC, 4),
106 ("SID", self.getServiceInfoValue(iServiceInformation.sSID), TYPE_VALUE_HEX_DEC, 4))
107 self.fillList(Labels)
109 def transponder(self):
110 frontendData = self.feinfo.getFrontendData(True)
111 Labels = self.getFEData(frontendData)
112 self.fillList(Labels)
115 frontendData = self.feinfo.getFrontendData(False)
116 Labels = self.getFEData(frontendData)
117 self.fillList(Labels)
119 def getFEData(self, frontendData):
120 if frontendData is None:
122 if frontendData["tuner_type"] == "DVB-S":
123 return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
124 ("Type", frontendData["tuner_type"], TYPE_TEXT),
125 ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
126 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
127 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
128 ("Polarization", frontendData["polarization"], TYPE_TEXT),
129 ("Inversion", frontendData["inversion"], TYPE_TEXT),
130 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
132 elif frontendData["tuner_type"] == "DVB-C":
133 return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
134 ("Type", frontendData["tuner_type"], TYPE_TEXT),
135 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
136 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
137 ("Modulation", frontendData["modulation"], TYPE_TEXT),
138 ("Inversion", frontendData["inversion"], TYPE_TEXT),
139 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
141 elif frontendData["tuner_type"] == "DVB-T":
142 return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
143 ("Type", frontendData["tuner_type"], TYPE_TEXT),
144 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
145 ("Inversion", frontendData["inversion"], TYPE_TEXT),
146 ("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
147 ("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
148 ("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
149 ("Constellation", frontendData["constellation"], TYPE_TEXT),
150 ("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
151 ("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
152 ("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
155 def fillList(self, Labels):
162 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2]))
164 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2], item[3]))
166 self["infolist"].l.setList(tlist)
168 def getServiceInfoValue(self, what):
169 if self.info is None:
172 v = self.info.getInfo(what)
174 v = self.info.getInfoString(what)