def resetTimer(self): self.remainingTime = KTglob.getTodaysTimeInSeconds() config.plugins.KiddyTimer.remainingTime.value = int(self.remainingTime) config.plugins.KiddyTimer.remainingTime.save() sRemainingTime = KTglob.getTimeFromSeconds(self.remainingTime , True ) self["RemainingTime"].setText(_("Remaining time: %s") %sRemainingTime)
def timerHasToRun(self): curStartTime = time.localtime() iPluginStart = KTglob.getSecondsFromClock( [curStartTime[3], curStartTime[4]]) iMonitorEnd = KTglob.getSecondsFromClock( config.plugins.KiddyTimer.monitorEndTime.getValue()) iMonitorStart = KTglob.getSecondsFromClock( config.plugins.KiddyTimer.monitorStartTime.getValue()) return (iPluginStart < iMonitorEnd) & (iPluginStart >= iMonitorStart)
def startObserve(self): curStartTime = time.localtime() iPluginStart = KTglob.getSecondsFromClock( [curStartTime[3],curStartTime[4]] ) iMonitorStart = KTglob.getSecondsFromClock(config.plugins.KiddyTimer.monitorStartTime.getValue()) # If we are after Pluginstart, then sleep until next day if (iPluginStart > iMonitorStart): iMonitorStart += 86400 iObserveTimerStep = (iMonitorStart - iPluginStart)*1000 + 1000 print "[KiddyTimer] setting plugin idle for ms=", iObserveTimerStep self.observeTimer.start(iObserveTimerStep, False)
def renderScreen(self): self["TimerSlider"].setValue(int(kiddyTimer.remainingPercentage * 100)) self["TimerGraph"].setPixmapNum(kiddyTimer.curImg) self.sTimeLeft = KTglob.getTimeFromSeconds( (kiddyTimer.remainingTime + 59), False ) # Add 59 Seconds to show one minute if less than 1 minute left... self["TimerText"].setText(self.sTimeLeft) self["TimerSliderText"].setText(self.sTimeLeft) self["TimerTransparentText"].setText(self.sTimeLeft) if config.plugins.KiddyTimer.timerStyle.value == "clock": self["TimerGraph"].show() self["TimerText"].show() self["TimerSlider"].hide() self["TimerSliderText"].hide() self["TimerTransparent"].hide() self["TimerTransparentText"].hide() elif config.plugins.KiddyTimer.timerStyle.value == "smiley": self["TimerGraph"].hide() self["TimerText"].hide() self["TimerSlider"].show() self["TimerSliderText"].show() self["TimerTransparent"].hide() self["TimerTransparentText"].hide() else: self["TimerGraph"].hide() self["TimerText"].hide() self["TimerSlider"].hide() self["TimerSliderText"].hide() self["TimerTransparent"].show() self["TimerTransparentText"].show()
def renderScreen(self): self["TimerSlider"].setValue(int(kiddyTimer.remainingPercentage*100)) self["TimerGraph"].setPixmapNum(kiddyTimer.curImg) self.sTimeLeft = KTglob.getTimeFromSeconds( (kiddyTimer.remainingTime + 59) , False ) # Add 59 Seconds to show one minute if less than 1 minute left... self["TimerText"].setText(self.sTimeLeft) self["TimerSliderText"].setText(self.sTimeLeft) self["TimerTransparentText"].setText(self.sTimeLeft) if config.plugins.KiddyTimer.timerStyle.value == "clock": self["TimerGraph"].show() self["TimerText"].show() self["TimerSlider"].hide() self["TimerSliderText"].hide() self["TimerTransparent"].hide() self["TimerTransparentText"].hide() elif config.plugins.KiddyTimer.timerStyle.value == "smiley": self["TimerGraph"].hide() self["TimerText"].hide() self["TimerSlider"].show() self["TimerSliderText"].show() self["TimerTransparent"].hide() self["TimerTransparentText"].hide() else: self["TimerGraph"].hide() self["TimerText"].hide() self["TimerSlider"].hide() self["TimerSliderText"].hide() self["TimerTransparent"].show() self["TimerTransparentText"].show()
def save(self): if self.remainingTime > KTglob.getTodaysTimeInSeconds(): self.resetTimer() for x in self["config"].list: x[1].save() configfile.save() if config.plugins.KiddyTimer.enabled.value: kiddyTimer.startTimer() self.close()
def __init__(self, session): self.session = session Screen.__init__(self, self.session) ProtectedScreen.__init__(self) # Lets get a list of elements for the config list self.list = [ getConfigListEntry(_("Enabled"), config.plugins.KiddyTimer.enabled), getConfigListEntry(_("PIN"), config.plugins.KiddyTimer.pin), getConfigListEntry(_("Don't monitor TV started before"), config.plugins.KiddyTimer.monitorStartTime ), getConfigListEntry(_("Don't monitor TV started after"), config.plugins.KiddyTimer.monitorEndTime ), getConfigListEntry(_("Style of timer"), config.plugins.KiddyTimer.timerStyle ), getConfigListEntry(_("Timeout for activation dialog"), config.plugins.KiddyTimer.activationDialogTimeout ) ] for i in range(0,7): self.list.append(getConfigListEntry(KTglob.DAYNAMES[i], config.plugins.KiddyTimer.dayTimes[i].timeValue)) ConfigListScreen.__init__(self, self.list) self["config"].list = self.list self.skin_path = KTglob.plugin_path self.kiddyTimerStopped = False; # Temporarily stop timer as long as we are in the setup screen if kiddyTimer.active: self.kiddyTimerStopped = True; kiddyTimer.stopTimer() # Plugin Information self.remainingTime = config.plugins.KiddyTimer.remainingTime.value sRemainingTime = KTglob.getTimeFromSeconds(self.remainingTime , True ) self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=KTglob.PLUGIN_BASE,version=KTglob.PLUGIN_VERSION)) self["RemainingTime"] = Label(_("Remaining time: %s") %sRemainingTime) self["LastDayStarted"] = Label(_("Last day started: %s") % config.plugins.KiddyTimer.lastStartDay.getValue()) # BUTTONS self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self["key_yellow"] = Button(_("Reset clock")) self["key_blue"] = Button(_("Move clock")) self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"], { "save": self.save, "cancel": self.cancel, "green": self.save, "red": self.cancel, "ok": self.save, "blue": self.keyPositioner, "yellow": self.resetTimer }, -2)
def __init__(self, session): self.session = session Screen.__init__(self, self.session) ProtectedScreen.__init__(self) # Lets get a list of elements for the config list self.list = [ getConfigListEntry(_("Enabled"), config.plugins.KiddyTimer.enabled), getConfigListEntry(_("PIN"), config.plugins.KiddyTimer.pin), getConfigListEntry(_("Don't monitor TV started before"), config.plugins.KiddyTimer.monitorStartTime ), getConfigListEntry(_("Don't monitor TV started after"), config.plugins.KiddyTimer.monitorEndTime ), getConfigListEntry(_("Style of timer"), config.plugins.KiddyTimer.timerStyle ), getConfigListEntry(_("Timeout for activation dialog"), config.plugins.KiddyTimer.activationDialogTimeout ) ] for i in range(0,7): self.list.append(getConfigListEntry(KTglob.DAYNAMES[i], config.plugins.KiddyTimer.dayTimes[i].timeValue)) ConfigListScreen.__init__(self, self.list) self["config"].list = self.list self.skin_path = KTglob.plugin_path self.kiddyTimerStopped = False; # Plugin Information self.remainingTime = config.plugins.KiddyTimer.remainingTime.value sRemainingTime = KTglob.getTimeFromSeconds(self.remainingTime , True ) self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=KTglob.PLUGIN_BASE,version=KTglob.PLUGIN_VERSION)) self["RemainingTime"] = Label(_("Remaining time: %s") %sRemainingTime) self["LastDayStarted"] = Label(_("Last day started: %s") % config.plugins.KiddyTimer.lastStartDay.getValue()) # BUTTONS self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self["key_yellow"] = Button(_("Reset clock")) self["key_blue"] = Button(_("Move clock")) self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"], { "save": self.save, "cancel": self.cancel, "green": self.save, "red": self.cancel, "ok": self.save, "blue": self.keyPositioner, "yellow": self.resetTimer }, -2)
def setCurrentDayTime(self,iDayTime=PARAM_NONE): if iDayTime == PARAM_NONE: iDayTime = KTglob.getTodaysTimeInSeconds() self.currentDayTime = iDayTime
def timerHasToRun(self): curStartTime = time.localtime() iPluginStart = KTglob.getSecondsFromClock( [curStartTime[3],curStartTime[4]] ) iMonitorEnd = KTglob.getSecondsFromClock(config.plugins.KiddyTimer.monitorEndTime.getValue()) iMonitorStart = KTglob.getSecondsFromClock(config.plugins.KiddyTimer.monitorStartTime.getValue()) return (iPluginStart < iMonitorEnd) & (iPluginStart >= iMonitorStart)
def setCurrentDayTime(self, iDayTime=PARAM_NONE): if iDayTime == PARAM_NONE: iDayTime = KTglob.getTodaysTimeInSeconds() self.currentDayTime = iDayTime