-from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr, iDVBFrontendPtr, iDVBFrontend, eDVBFrontendParametersSatellite, eDVBFrontendParameters
+from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, \
+ eDVBDiseqcCommand, eDVBFrontendParametersSatellite, eDVBFrontendParameters,\
+ iDVBFrontend
+
from Screens.Screen import Screen
from Screens.ScanSetup import ScanSetup
from Screens.MessageBox import MessageBox
from Components.ActionMap import ActionMap
from Components.NimManager import nimmanager
from Components.MenuList import MenuList
-from Components.config import config, ConfigSubsection, configElement_nonSave, configNothing, getConfigListEntry, configSelection, currentConfigSelectionElement, configSatlist
+from Components.config import ConfigSatlist, ConfigNothing, ConfigSelection, ConfigSubsection, KEY_LEFT, KEY_RIGHT, getConfigListEntry
+
+from time import sleep
class PositionerSetup(Screen):
skin = """
def __init__(self, session, feid):
self.skin = PositionerSetup.skin
Screen.__init__(self, session)
-
- self.session.nav.stopService()
-
self.feid = feid
+ self.oldref = None
- self.diseqc = Diseqc(self.feid)
- self.tuner = Tuner(self.diseqc.getFrontend())
- self.tuner.tune((0,0,0,0,0,0,0,0,0))
-
- #self.session.nav.stopService()
+ if not self.openFrontend():
+ self.oldref = session.nav.getCurrentlyPlayingServiceReference()
+ session.nav.stopService() # try to disable foreground service
+ if not self.openFrontend():
+ if session.pipshown: # try to disable pip
+ session.pipshown = False
+ del session.pip
+ if not self.openFrontend():
+ self.frontend = None # in normal case this should not happen
+
+ self.frontendStatus = { }
+
+ self.diseqc = Diseqc(self.frontend)
+ self.tuner = Tuner(self.frontend)
+ self.tuner.tune((0,0,0,0,0,0))
self.createConfig()
self["agc"] = Label()
self["ber"] = Label()
self["lock"] = Label()
- self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, frontendfkt = self.diseqc.getFrontend)
- self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, frontendfkt = self.diseqc.getFrontend)
- self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, frontendfkt = self.diseqc.getFrontend)
- self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, frontendfkt = self.diseqc.getFrontend)
- self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, frontendfkt = self.diseqc.getFrontend)
- self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, frontendfkt = self.diseqc.getFrontend)
- self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, frontendfkt = self.diseqc.getFrontend)
+ self["snr_percentage"] = TunerInfo(TunerInfo.SNR_PERCENTAGE, statusDict = self.frontendStatus)
+ self["agc_percentage"] = TunerInfo(TunerInfo.AGC_PERCENTAGE, statusDict = self.frontendStatus)
+ self["ber_value"] = TunerInfo(TunerInfo.BER_VALUE, statusDict = self.frontendStatus)
+ self["snr_bar"] = TunerInfo(TunerInfo.SNR_BAR, statusDict = self.frontendStatus)
+ self["agc_bar"] = TunerInfo(TunerInfo.AGC_BAR, statusDict = self.frontendStatus)
+ self["ber_bar"] = TunerInfo(TunerInfo.BER_BAR, statusDict = self.frontendStatus)
+ self["lock_state"] = TunerInfo(TunerInfo.LOCK_STATE, statusDict = self.frontendStatus)
self["frequency"] = Label()
self["symbolrate"] = Label()
self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"],
{
"ok": self.go,
- "cancel": self.close,
+ "cancel": self.keyCancel,
"up": self.up,
"down": self.down,
"left": self.left,
self.statusTimer = eTimer()
self.statusTimer.timeout.get().append(self.updateStatus)
self.statusTimer.start(50, False)
-
+
+ def restartPrevService(self, yesno):
+ if yesno:
+ if self.frontend:
+ self.frontend = None
+ del self.raw_channel
+ self.session.nav.playService(self.oldref)
+ self.close(None)
+
+ def keyCancel(self):
+ if self.oldref:
+ self.session.openWithCallback(self.restartPrevService, MessageBox, _("Zap back to service before positioner setup?"), MessageBox.TYPE_YESNO)
+ else:
+ self.restartPrevService(False)
+
+ def openFrontend(self):
+ res_mgr = eDVBResourceManager.getInstance()
+ if res_mgr:
+ self.raw_channel = res_mgr.allocateRawChannel(self.feid)
+ if self.raw_channel:
+ self.frontend = self.raw_channel.getFrontend()
+ if self.frontend:
+ return True
+ else:
+ print "getFrontend failed"
+ else:
+ print "getRawChannel failed"
+ else:
+ print "getResourceManager instance failed"
+ return False
+
def createConfig(self):
- config.positioner = ConfigSubsection()
- config.positioner.tune = configElement_nonSave("tune", configNothing, 0, None)
- config.positioner.move = configElement_nonSave("move", configNothing, 0, None)
- config.positioner.finemove = configElement_nonSave("finemove", configNothing, 0, None)
- config.positioner.limits = configElement_nonSave("limits", configNothing, 0, None)
- config.positioner.goto0 = configElement_nonSave("goto0", configNothing, 0, None)
+ self.positioner_tune = ConfigNothing()
+ self.positioner_move = ConfigNothing()
+ self.positioner_finemove = ConfigNothing()
+ self.positioner_limits = ConfigNothing()
+ self.positioner_goto0 = ConfigNothing()
storepos = []
for x in range(1,255):
storepos.append(str(x))
- config.positioner.storage = configElement_nonSave("storage", configSelection, 0, storepos)
-
+ self.positioner_storage = ConfigSelection(choices = storepos)
+
def createSetup(self):
- self.list.append(getConfigListEntry(_("Tune"), config.positioner.tune))
- self.list.append(getConfigListEntry(_("Positioner movement"), config.positioner.move))
- self.list.append(getConfigListEntry(_("Positioner fine movement"), config.positioner.finemove))
- self.list.append(getConfigListEntry(_("Set limits"), config.positioner.limits))
- self.list.append(getConfigListEntry(_("Positioner storage"), config.positioner.storage))
- self.list.append(getConfigListEntry(_("Goto 0"), config.positioner.goto0))
+ self.list.append((_("Tune"), self.positioner_tune, "tune"))
+ self.list.append((_("Positioner movement"), self.positioner_move, "move"))
+ self.list.append((_("Positioner fine movement"), self.positioner_finemove, "finemove"))
+ self.list.append((_("Set limits"), self.positioner_limits, "limits"))
+ self.list.append((_("Positioner storage"), self.positioner_storage, "storage"))
+ self.list.append((_("Goto 0"), self.positioner_goto0, "goto0"))
self["list"].l.setList(self.list)
-
+
def go(self):
pass
-
+
def getCurrentConfigPath(self):
- return self["list"].getCurrent()[1].parent.configPath
-
+ return self["list"].getCurrent()[2]
+
def up(self):
if not self.isMoving:
self["list"].instance.moveSelection(self["list"].instance.moveUp)
self.updateColors(self.getCurrentConfigPath())
-
+
def down(self):
if not self.isMoving:
self["list"].instance.moveSelection(self["list"].instance.moveDown)
self.updateColors(self.getCurrentConfigPath())
-
+
def left(self):
- self["list"].handleKey(config.key["prevElement"])
-
+ self["list"].handleKey(KEY_LEFT)
+
def right(self):
- self["list"].handleKey(config.key["nextElement"])
-
+ self["list"].handleKey(KEY_RIGHT)
+
def updateColors(self, entry):
if entry == "tune":
self.red.setText(_("Tune"))
self.green.setText("")
self.yellow.setText("")
self.blue.setText("")
-
+
def redKey(self):
entry = self.getCurrentConfigPath()
if entry == "move":
print "stepping west"
self.diseqccommand("moveWest", 0xFF) # one step
elif entry == "storage":
- print "store at position", (config.positioner.storage.value + 1)
- self.diseqccommand("store", config.positioner.storage.value + 1)
+ print "store at position", int(self.positioner_storage.value)
+ self.diseqccommand("store", int(self.positioner_storage.value))
elif entry == "limits":
self.diseqccommand("limitWest")
-
+
def yellowKey(self):
entry = self.getCurrentConfigPath()
if entry == "move":
print "stepping east"
self.diseqccommand("moveEast", 0xFF) # one step
elif entry == "storage":
- print "move to position", (config.positioner.storage.value + 1)
- self.diseqccommand("moveTo", config.positioner.storage.value + 1)
+ print "move to position", int(self.positioner_storage.value)
+ self.diseqccommand("moveTo", int(self.positioner_storage.value))
elif entry == "limits":
self.diseqccommand("limitEast")
-#
+
def blueKey(self):
entry = self.getCurrentConfigPath()
if entry == "move":
self.tuner.retune()
def updateStatus(self):
+ if self.frontend:
+ self.frontend.getFrontendStatus(self.frontendStatus)
self["snr_percentage"].update()
self["agc_percentage"].update()
self["ber_value"].update()
self["ber_bar"].update()
self["lock_state"].update()
transponderdata = self.tuner.getTransponderData()
- self["frequency_value"].setText(str(transponderdata["frequency"]))
- self["symbolrate_value"].setText(str(transponderdata["symbol_rate"]))
- self["fec_value"].setText(str(transponderdata["fec_inner"]))
- if transponderdata["tuner_locked"] == 1 and self.isMoving and self.stopOnLock:
+ self["frequency_value"].setText(str(transponderdata.get("frequency")))
+ self["symbolrate_value"].setText(str(transponderdata.get("symbol_rate")))
+ self["fec_value"].setText(str(transponderdata.get("fec_inner")))
+ if self.frontendStatus.get("tuner_locked", 0) == 1 and self.isMoving and self.stopOnLock:
self.diseqccommand("stop")
self.isMoving = False
self.stopOnLock = False
def tune(self, transponder):
if transponder is not None:
self.tuner.tune(transponder)
-
+
class Diseqc:
- def __init__(self, feid = 0):
- self.ready = False
- self.feid = feid
- res_mgr = eDVBResourceManagerPtr()
- if eDVBResourceManager.getInstance(res_mgr) == 0:
- self.raw_channel = iDVBChannelPtr()
- if res_mgr.allocateRawChannel(self.raw_channel, self.feid) == 0:
- self.frontend = iDVBFrontendPtr()
- if self.raw_channel.getFrontend(self.frontend) == 0:
- self.ready = True
- else:
- print "getFrontend failed"
- else:
- print "getRawChannel failed"
- else:
- print "getResourceManager instance failed"
-
- def getFrontend(self):
- return self.frontend
-
+ def __init__(self, frontend):
+ self.frontend = frontend
+
def command(self, what, param = 0):
- if self.ready:
+ if self.frontend:
cmd = eDVBDiseqcCommand()
if what == "moveWest":
string = 'e03169' + ("%02x" % param)
string = 'e03167'
else:
string = 'e03160' #positioner stop
+
print "diseqc command:",
print string
-
cmd.setCommandString(string)
+ self.frontend.setTone(iDVBFrontend.toneOff)
+ sleep(0.015) # wait 15msec after disable tone
self.frontend.sendDiseqc(cmd)
-
+ if string == 'e03160': #positioner stop
+ sleep(0.05)
+ self.frontend.sendDiseqc(cmd) # send 2nd time
+
class Tuner:
def __init__(self, frontend):
self.frontend = frontend
-
+
def tune(self, transponder):
print "tuning to transponder with data", transponder
parm = eDVBFrontendParametersSatellite()
parm.inversion = transponder[4]
parm.orbital_position = transponder[5]
parm.system = 0 # FIXMEE !! HARDCODED DVB-S (add support for DVB-S2)
- parm.modulation = 1 # FIXMEE !! HARDCODED QPSK
+ parm.modulation = 1 # FIXMEE !! HARDCODED QPSK
feparm = eDVBFrontendParameters()
feparm.setDVBS(parm, True)
self.lastparm = feparm
- self.frontend.tune(feparm)
-
+ if self.frontend:
+ self.frontend.tune(feparm)
+
def retune(self):
- self.frontend.tune(self.lastparm)
-
+ if self.frontend:
+ self.frontend.tune(self.lastparm)
+
def getTransponderData(self):
- return self.frontend.readTransponderData(True)
+ ret = { }
+ if self.frontend:
+ self.frontend.getTransponderData(ret, True)
+ return ret
+
+tuning = None
class TunerScreen(ScanSetup):
skin = """
def __init__(self, session, feid):
self.feid = feid
ScanSetup.__init__(self, session)
-
self["introduction"].setText("")
-
+
def createSetup(self):
self.typeOfTuningEntry = None
self.satEntry = None
-
self.list = []
- self.typeOfTuningEntry = getConfigListEntry(_('Tune'), config.tuning.type)
+ self.typeOfTuningEntry = getConfigListEntry(_('Tune'), tuning.type)
self.list.append(self.typeOfTuningEntry)
- self.satEntry = getConfigListEntry(_('Satellite'), config.tuning.sat)
+ self.satEntry = getConfigListEntry(_('Satellite'), tuning.sat)
self.list.append(self.satEntry)
- if currentConfigSelectionElement(config.tuning.type) == "manual_transponder":
- self.list.append(getConfigListEntry(_('Frequency'), config.scan.sat.frequency))
- self.list.append(getConfigListEntry(_('Inversion'), config.scan.sat.inversion))
- self.list.append(getConfigListEntry(_('Symbol Rate'), config.scan.sat.symbolrate))
- self.list.append(getConfigListEntry(_("Polarity"), config.scan.sat.polarization))
- self.list.append(getConfigListEntry(_("FEC"), config.scan.sat.fec))
- elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder":
- self.list.append(getConfigListEntry(_("Transponder"), config.tuning.transponder))
+ if tuning.type.value == "manual_transponder":
+ self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
+ self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
+ self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
+ self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
+ self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
+ elif tuning.type.value == "predefined_transponder":
+ self.list.append(getConfigListEntry(_("Transponder"), tuning.transponder))
self["config"].list = self.list
self["config"].l.setList(self.list)
if self["config"].getCurrent() == self.typeOfTuningEntry:
self.createSetup()
elif self["config"].getCurrent() == self.satEntry:
- self.updateSats()
self.createSetup()
- def createConfig(self):
- config.tuning = ConfigSubsection()
-
- config.tuning.type = configElement_nonSave("config.tuning.type", configSelection, 0, (("manual_transponder", _("Manual transponder")), ("predefined_transponder", _("Predefined satellite"))))
-
- config.tuning.sat = configElement_nonSave("config.tuning.sat", configSatlist, 192, nimmanager.getRotorSatListForNim(self.feid))
- ScanSetup.createConfig(self)
- self.updateSats()
-
- def updateSats(self):
- satnum = config.tuning.sat.value
- satlist = config.tuning.sat.vals
- if len(satlist):
- transponderlist = nimmanager.getTransponders(satlist[satnum][1])
- list = []
+ def createConfig(self, foo):
+ global tuning
+ if not tuning:
+ tuning = ConfigSubsection()
+ tuning.type = ConfigSelection(
+ default = "manual_transponder",
+ choices = { "manual_transponder" : _("Manual transponder"),
+ "predefined_transponder" : _("Predefined transponder") } )
+ tuning.sat = ConfigSatlist(list=nimmanager.getRotorSatListForNim(self.feid))
+ tuning.sat.addNotifier(self.tuningSatChanged)
+ self.updateTransponders()
+ TunerScreenConfigCreated = True
+ ScanSetup.createConfig(self, None)
+
+ def tuningSatChanged(self, *parm):
+ self.updateTransponders()
+
+ def updateTransponders(self):
+ if len(tuning.sat.choices):
+ transponderlist = nimmanager.getTransponders(int(tuning.sat.value))
+ tps = []
+ cnt=0
for x in transponderlist:
if x[3] == 0:
pol = "H"
fec = "FEC_8_9"
elif x[4] == 6:
fec = "FEC_None"
- list.append(str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec)
- config.tuning.transponder = configElement_nonSave("config.tuning.transponder", configSelection, 0, list)
-
+ tps.append(str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec)
+ tuning.transponder = ConfigSelection(choices=tps)
+
def keyGo(self):
- returnvalue = (0, 0, 0, 0, 0, 0, 0)
- satpos = config.tuning.sat.vals[config.tuning.sat.value][1]
- if currentConfigSelectionElement(config.tuning.type) == "manual_transponder":
- returnvalue = (config.scan.sat.frequency.value[0], config.scan.sat.symbolrate.value[0], config.scan.sat.polarization.value, config.scan.sat.fec.value, config.scan.sat.inversion.value, satpos)
- elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder":
- transponder = nimmanager.getTransponders(config.tuning.sat.vals[config.tuning.sat.value][1])[config.tuning.transponder.value]
- returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, config.tuning.sat.vals[config.tuning.sat.value][1], satpos)
+ returnvalue = (0, 0, 0, 0, 0, 0)
+ satpos = int(tuning.sat.value)
+ if tuning.type.value == "manual_transponder":
+ returnvalue = (
+ self.scan_sat.frequency.value,
+ self.scan_sat.symbolrate.value,
+ self.scan_sat.polarization.index,
+ self.scan_sat.fec.index,
+ self.scan_sat.inversion.index,
+ satpos)
+ elif tuning.type.value == "predefined_transponder":
+ transponder = nimmanager.getTransponders(satpos)[tuning.transponder.index]
+ returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, satpos)
self.close(returnvalue)
def keyCancel(self):
<screen position="140,165" size="400,100" title="select Slot">
<widget name="nimlist" position="20,10" size="360,75" />
</screen>"""
-
+
def __init__(self, session):
Screen.__init__(self, session)
nimlist = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
nimMenuList = []
for x in nimlist:
- nimMenuList.append((_("NIM ") + (["A", "B", "C", "D"][x]) + ": " + nimmanager.getNimName(x) + " (" + nimmanager.getNimTypeName(x) + ")", x))
+ n = nimmanager.nim_slots[x]
+ nimMenuList.append((n.friendly_full_name, x))
self["nimlist"] = MenuList(nimMenuList)
self.session.open(PositionerSetup, selection[1])
def PositionerMain(session, **kwargs):
- nimList = nimmanager.getNimListOfType(nimmanager.nimType["DVB-S"])
+ nimList = nimmanager.getNimListOfType("DVB-S")
if len(nimList) == 0:
session.open(MessageBox, _("No positioner capable frontend found."), MessageBox.TYPE_ERROR)
else:
else:
session.open(MessageBox, _("No tuner is configured for use with a diseqc positioner!"), MessageBox.TYPE_ERROR)
+def PositionerSetupStart(menuid, **kwargs):
+ if menuid == "scan":
+ return [(_("Positioner setup"), PositionerMain, "positioner_setup", None)]
+ else:
+ return []
+
def Plugins(**kwargs):
- return PluginDescriptor(name="Positioner setup", description="Setup your positioner", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=PositionerMain)
+ if (nimmanager.hasNimType("DVB-S")):
+ return PluginDescriptor(name=_("Positioner setup"), description="Setup your positioner", where = PluginDescriptor.WHERE_MENU, fnc=PositionerSetupStart)
+ else:
+ return []