[tuxdroid-svn] r607 - in software/gadgets/battery_monitor/trunk: . Battery_monitor_svn Battery_moni
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-12 12:27:17
|
Author: Paul_R Date: 2007-10-12 14:27:15 +0200 (Fri, 12 Oct 2007) New Revision: 607 Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/notify.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml Log: * Added an absolute threshold to notify when the batteries are weak. Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-12 12:27:15 UTC (rev 607) @@ -194,7 +194,8 @@ self.val_table_event = [-1] * int(self.sample) self.charger_event_backup = 3 self.test_tab = [0] - + self.absolute_threshold_flag = False + self.threshold_flag = False self.tick = time.time() + 1 @@ -230,6 +231,9 @@ else: self.event_tab = self.__tab + self.threshold_flag = self.absolute_threshold() + + if self.GUI_on: #goto test notification every sec. if self.wait <= time.time(): @@ -257,7 +261,31 @@ value = (100 * (value)) / 2.5 return value + ########################################################### + # + # Absolute threshold control + # + ########################################################### + def absolute_threshold(self): + + if self.absolute_threshold_flag == False: + val = self.convert_value([0, 1, 0, 4.6]) + val_act = (self.val_table[len(self.val_table)-1]*100) / self.RANGE + val_prev = (self.val_table[len(self.val_table)-2]*100) / self.RANGE + if val_prev >= val and val_act < val: + self.absolute_threshold_flag = True + return True + else: + val = self.convert_value([0, 1, 0, 4.7]) + val_act = (self.val_table[len(self.val_table)-1]*100) / self.RANGE + val_prev = (self.val_table[len(self.val_table)-2]*100) / self.RANGE + if val_prev <= val and val_act > val: + self.absolute_threshold_flag = False + return False + + + ########################################################### # Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/notify.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/notify.pyp 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/notify.pyp 2007-10-12 12:27:15 UTC (rev 607) @@ -1,6 +1,8 @@ def notify_checker(): measure = _me.get_param('measure') - if measure.GUI_on == False: + if measure.threshold_flag == True: + return True + if measure.GUI_on == False: for i in range(len(measure.event_tab)): temp = measure.event_tab[i][7] if temp == True: @@ -13,39 +15,46 @@ def notify_actuator(): event = _me.get_param('measure').event_tab - for i in range(len(event)): - #create text to speach for the default notification - if event[i][1] == 0: - if event[i][2] == 0: - text = _me.string('conf_lblDrop') - elif event[i][2] == 1: - text = _me.string('conf_lblRaise') - elif event[i][2] == 2: - text = _me.string('conf_lblChangeD') - elif event[i][2] == 3: - text = _me.string('conf_lblChangeU') - else: - if event[i][2] == 0: - text = _me.string('conf_lblIncrease') - elif event[i][2] == 1: - text = _me.string('conf_lblDecrease') - elif event[i][2] == 2: - text = _me.string('conf_lblBoth') - - if event[i][7]: - if event[i][5]: - path = event[i][6] - path = path.replace('%20', ' ') - if os.path.isfile(path) and os.path.exists(path): - path = "'%s'" % path - tux.sys.shell_free(path) - event[i][7] = False + if _me.get_param('measure').threshold_flag == True: + _me.get_param('measure').threshold_flag = False + tux.cmd.mouth_open() + tux.tts.speak(_me.string('absolute_threshold')) + tux.cmd.mouth_close() + + else: + for i in range(len(event)): + #create text to speach for the default notification + if event[i][1] == 0: + if event[i][2] == 0: + text = _me.string('conf_lblDrop') + elif event[i][2] == 1: + text = _me.string('conf_lblRaise') + elif event[i][2] == 2: + text = _me.string('conf_lblChangeD') + elif event[i][2] == 3: + text = _me.string('conf_lblChangeU') + else: + if event[i][2] == 0: + text = _me.string('conf_lblIncrease') + elif event[i][2] == 1: + text = _me.string('conf_lblDecrease') + elif event[i][2] == 2: + text = _me.string('conf_lblBoth') + + if event[i][7]: + if event[i][5]: + path = event[i][6] + path = path.replace('%20', ' ') + if os.path.isfile(path) and os.path.exists(path): + path = "'%s'" % path + tux.sys.shell_free(path) + event[i][7] = False + else: + tux.cmd.mouth_open() + tux.tts.speak(text) + tux.cmd.mouth_close() + event[i][7] = False else: - tux.cmd.mouth_open() - tux.tts.speak(text) - tux.cmd.mouth_close() event[i][7] = False - else: - event[i][7] = False - break + break Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-12 12:27:15 UTC (rev 607) @@ -32,7 +32,7 @@ <widget_lblValue type='str'>Valeur (V)</widget_lblValue> <speaker_name type='str'>Bruno8k</speaker_name> <conf_lblSample type='str'>Points</conf_lblSample> - <conf_lblType type='str'>Type</conf_lblType> + <charging type='str'>En charge</charging> <widget_lblDisplayThreshold type='str'>Afficher le seuil sur le graph.</widget_lblDisplayThreshold> <conf_btnModify type='str'>Modifier</conf_btnModify> <widget_lblEvent type='str'>Evènement</widget_lblEvent> @@ -48,6 +48,7 @@ <widget_lblDrop type='str'>Chute</widget_lblDrop> <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> <MainBehavior type='str'>Comportement principal</MainBehavior> + <absolute_threshold type='str'>Batteries faibles</absolute_threshold> <widget_lblBoth type='str'>Deux directions</widget_lblBoth> <conf_lblDefaultBehavior type='str'>Comportement pas défaut</conf_lblDefaultBehavior> <conf_lblBehavior type='str'>Comportement</conf_lblBehavior> @@ -58,7 +59,7 @@ <conf_lblNotNotified type='str'>Non notifié</conf_lblNotNotified> <conf_lblDrop type='str'>Chute</conf_lblDrop> <gui_conf_window_title type='str'>Paramètres</gui_conf_window_title> - <charging type='str'>En charge</charging> + <conf_lblType type='str'>Type</conf_lblType> <widget_lblSet type='str'>Ajouter a la config.</widget_lblSet> <conf_lblValue type='str'>Valeur (V)</conf_lblValue> <conf_lblRate type='str'>Taux de rafraichissement</conf_lblRate> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-12 12:27:15 UTC (rev 607) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <about> + <gadget_author type='str'>Paul Rathgeb</gadget_author> + <gadget_version type='str'>0.0.1</gadget_version> <gadget_description type='str'>Battery monitor for tux droid</gadget_description> - <gadget_author type='str'>Paul Rathgeb</gadget_author> <gadget_name type='str'>battery_monitor</gadget_name> - <gadget_version type='str'>0.0.1</gadget_version> </about> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-12 12:27:15 UTC (rev 607) @@ -2,10 +2,10 @@ <settings> <parameters> <test_tab type='list'>[[1, 0, 0, 0.10000000000000001, 20.0, True, 'None', False, 0]]</test_tab> - <config type='list'>[]</config> - <Rate type='float'>10.0</Rate> <MainScript type='str'> </MainScript> + <Rate type='float'>10.0</Rate> + <config type='list'>[]</config> <Sample type='float'>600.0</Sample> </parameters> <general> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-12 09:44:16 UTC (rev 606) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-12 12:27:15 UTC (rev 607) @@ -5,14 +5,12 @@ <gui_conf_remote_title type='str'>Control</gui_conf_remote_title> <battery type='str'>On battery</battery> <conf_lblRaise type='str'>Raise</conf_lblRaise> - <widget_lblTest type='str'>Notifications</widget_lblTest> <gui_conf_description_lb type='str'>Description</gui_conf_description_lb> <conf_lblEvent type='str'>Event</conf_lblEvent> <widget_lblControl type='str'>Control</widget_lblControl> <gui_conf_accept_bt type='str'>Accept</gui_conf_accept_bt> <help_text type='str'> </help_text> - <conf_lblBehavior type='str'>Behavior script</conf_lblBehavior> <conf_lblChange type='str'>Change</conf_lblChange> <conf_lblBoth type='str'>Both</conf_lblBoth> <widget_lblBtnApply type='str'>Apply changes</widget_lblBtnApply> @@ -22,19 +20,20 @@ <gui_conf_update_title type='str'>Update</gui_conf_update_title> <widget_lblValue type='str'>Value (V)</widget_lblValue> <gui_conf_cancel_bt type='str'>Cancel</gui_conf_cancel_bt> - <widget_lblBoth type='str'>Both direction</widget_lblBoth> + <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> + <conf_lblType type='str'>Type</conf_lblType> <mainscript type='str'>I've found the light !</mainscript> + <conf_btnRemove type='str'>Remove</conf_btnRemove> <gui_conf_delay_lb type='str'>Delay (sec)</gui_conf_delay_lb> <plugged type='str'>Plugged</plugged> <conf_btnBehavior type='str'>Clear path</conf_btnBehavior> <gui_conf_about_title type='str'>About</gui_conf_about_title> <conf_lblChangeD type='str'>Drop and raise</conf_lblChangeD> - <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> + <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> <speaker_name type='str'>Ryan8k</speaker_name> <conf_lblSample type='str'>Samples</conf_lblSample> <charging type='str'>Charging</charging> <widget_lblDisplayThreshold type='str'>Display threshold on graph</widget_lblDisplayThreshold> - <widget_lblDark type='str'>Search darkness</widget_lblDark> <conf_btnModify type='str'>Modify</conf_btnModify> <widget_lblEvent type='str'>Event</widget_lblEvent> <widget_lblNotified type='str'>Notified</widget_lblNotified> @@ -48,9 +47,11 @@ <gui_conf_author_lb type='str'>Author</gui_conf_author_lb> <widget_lblDrop type='str'>Drop</widget_lblDrop> <conf_lblNotified type='str'>Notified ?</conf_lblNotified> - <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> + <MainBehavior type='str'>Main behavior</MainBehavior> + <absolute_threshold type='str'>Weak batteries </absolute_threshold> + <widget_lblBoth type='str'>Both direction</widget_lblBoth> <conf_lblDefaultBehavior type='str'>Default behavior</conf_lblDefaultBehavior> - <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> + <conf_lblBehavior type='str'>Behavior script</conf_lblBehavior> <gui_conf_remote_set_bt type='str'>Set</gui_conf_remote_set_bt> <widget_lblChange type='str'>Change</widget_lblChange> <widget_lblLight type='str'>Search light</widget_lblLight> @@ -58,14 +59,14 @@ <conf_lblNotNotified type='str'>Not notified</conf_lblNotNotified> <conf_lblDrop type='str'>Drop</conf_lblDrop> <gui_conf_window_title type='str'>Parameters</gui_conf_window_title> - <conf_lblType type='str'>Type</conf_lblType> + <widget_lblDark type='str'>Search darkness</widget_lblDark> <widget_lblSet type='str'>Add to config</widget_lblSet> <conf_lblValue type='str'>Value (V)</conf_lblValue> <conf_lblRate type='str'>Refresh rate</conf_lblRate> <widget_lblBehavior type='str'>Enable behavior script</widget_lblBehavior> - <MainBehavior type='str'>Main behavior</MainBehavior> + <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> <conf_lblTime type='str'>Time (sec.)</conf_lblTime> <conf_lblControl type='str'>Control</conf_lblControl> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <widget_lblTest type='str'>Notifications</widget_lblTest> <widget_lblThreshold type='str'>Threshold</widget_lblThreshold> </strings> |