SatelliteEquipmentControl: update plugin
[openblackhole/openblackhole-enigma2.git] / lib / python / Plugins / SystemPlugins / SatelliteEquipmentControl / plugin.py
1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
3 from Plugins.Plugin import PluginDescriptor
4
5 from Components.ConfigList import ConfigListScreen
6 from Components.ActionMap import ActionMap
7 from Components.config import config
8 from Components.NimManager import nimmanager as nimmgr
9
10 class SecParameterSetup(Screen, ConfigListScreen):
11         skin = """
12                 <screen position="center,center" size="620,455" title="Satellite equipment setup" >
13                         <widget name="config" position="10,10" size="600,450" />
14                 </screen>"""
15         def __init__(self, session):
16                 self.skin = SecParameterSetup.skin
17
18                 self["actions"] = ActionMap(["SetupActions", "MenuActions"],
19                 {
20                         "ok": self.keySave,
21                         "cancel": self.keyCancel,
22                         "menu": self.setDefault,
23                 }, -2)
24
25                 Screen.__init__(self, session)
26                 self.setTitle(_("Satellite equipment setup"))
27                 list = [
28                         (_("Delay after diseqc reset command"), config.sec.delay_after_diseqc_reset_cmd),
29                         (_("Delay after diseqc peripherial poweron command"), config.sec.delay_after_diseqc_peripherial_poweron_cmd),
30                         (_("Delay after continuous tone disable before diseqc"), config.sec.delay_after_continuous_tone_disable_before_diseqc),
31                         (_("Delay after final continuous tone change"), config.sec.delay_after_final_continuous_tone_change),
32                         (_("Delay after last voltage change"), config.sec.delay_after_final_voltage_change),
33                         (_("Delay between diseqc commands"), config.sec.delay_between_diseqc_repeats),
34                         (_("Delay after last diseqc command"), config.sec.delay_after_last_diseqc_command),
35                         (_("Delay after toneburst"), config.sec.delay_after_toneburst),
36                         (_("Delay after change voltage before switch command"), config.sec.delay_after_change_voltage_before_switch_command),
37                         (_("Delay after enable voltage before switch command"), config.sec.delay_after_enable_voltage_before_switch_command),
38                         (_("Delay between switch and motor command"), config.sec.delay_between_switch_and_motor_command),
39                         (_("Delay after set voltage before measure motor power"), config.sec.delay_after_voltage_change_before_measure_idle_inputpower),
40                         (_("Delay after enable voltage before motor command"), config.sec.delay_after_enable_voltage_before_motor_command),
41                         (_("Delay after motor stop command"), config.sec.delay_after_motor_stop_command),
42                         (_("Delay after voltage change before motor command"), config.sec.delay_after_voltage_change_before_motor_command),
43                         (_("Delay before sequence repeat"), config.sec.delay_before_sequence_repeat),
44                         (_("Motor running timeout"), config.sec.motor_running_timeout),
45                         (_("Motor command retries"), config.sec.motor_command_retries) ]
46                 ConfigListScreen.__init__(self, list)
47
48         def setDefault(self):
49                 self.session.openWithCallback(self.setDefaultCallback, MessageBox, _("Set default settings?"), MessageBox.TYPE_YESNO)
50
51         def setDefaultCallback(self, answer):
52                 if answer:
53                         config.sec.delay_after_diseqc_reset_cmd.value = 50
54                         config.sec.delay_after_diseqc_peripherial_poweron_cmd.value = 150
55                         config.sec.delay_after_continuous_tone_disable_before_diseqc.value = 25
56                         config.sec.delay_after_final_continuous_tone_change.value = 10
57                         config.sec.delay_after_final_voltage_change.value = 10
58                         config.sec.delay_between_diseqc_repeats.value = 120
59                         config.sec.delay_after_last_diseqc_command.value = 50
60                         config.sec.delay_after_toneburst.value = 50
61                         config.sec.delay_after_change_voltage_before_switch_command.value = 20
62                         config.sec.delay_after_enable_voltage_before_switch_command.value = 200
63                         config.sec.delay_between_switch_and_motor_command.value = 700
64                         config.sec.delay_after_voltage_change_before_measure_idle_inputpower.value = 500
65                         config.sec.delay_after_enable_voltage_before_motor_command.value = 900
66                         config.sec.delay_after_motor_stop_command.value = 500
67                         config.sec.delay_after_voltage_change_before_motor_command.value = 500
68                         config.sec.delay_before_sequence_repeat.value = 70
69                         config.sec.motor_running_timeout.value = 360
70                         config.sec.motor_command_retries.value = 1
71                         config.sec.delay_after_diseqc_reset_cmd.save()
72                         config.sec.delay_after_diseqc_peripherial_poweron_cmd.save()
73                         config.sec.delay_after_continuous_tone_disable_before_diseqc.save()
74                         config.sec.delay_after_final_continuous_tone_change.save()
75                         config.sec.delay_after_final_voltage_change.save()
76                         config.sec.delay_between_diseqc_repeats.save()
77                         config.sec.delay_after_last_diseqc_command.save()
78                         config.sec.delay_after_toneburst.save()
79                         config.sec.delay_after_change_voltage_before_switch_command.save()
80                         config.sec.delay_after_enable_voltage_before_switch_command.save()
81                         config.sec.delay_between_switch_and_motor_command.save()
82                         config.sec.delay_after_voltage_change_before_measure_idle_inputpower.save()
83                         config.sec.delay_after_enable_voltage_before_motor_command.save()
84                         config.sec.delay_after_motor_stop_command.save()
85                         config.sec.delay_after_voltage_change_before_motor_command.save()
86                         config.sec.delay_before_sequence_repeat.save()
87                         config.sec.motor_running_timeout.save()
88                         config.sec.motor_command_retries.save()
89                         self.close(True)
90
91 session = None
92
93 def confirmed(answer):
94         global session
95         if answer:
96                 session.open(SecParameterSetup)
97
98 def SecSetupMain(Session, **kwargs):
99         global session
100         session = Session
101         session.openWithCallback(confirmed, MessageBox, _("Please do not change any values unless you know what you are doing!"), MessageBox.TYPE_INFO)
102
103 def SecSetupStart(menuid):
104         show = False
105
106         # other menu than "scan"?
107         if menuid != "scan":
108                 return [ ]
109
110         # only show if DVB-S frontends are available
111         for slot in nimmgr.nim_slots:
112                 if slot.isCompatible("DVB-S"):
113                         return [(_("Satellite equipment setup"), SecSetupMain, "satellite_equipment_setup", None)]
114
115         return [ ]
116
117 def Plugins(**kwargs):
118         if (nimmgr.hasNimType("DVB-S")):
119                 return PluginDescriptor(name=_("Satellite equipment setup"), description=_("Setup your satellite equipment"), where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=SecSetupStart)
120         else:
121                 return []