[tuxdroid-svn] r610 - in software/gadgets/light_monitor/trunk: . Light_monitor Light_monitor/Script
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-12 14:34:40
|
Author: Paul_R Date: 2007-10-12 16:34:31 +0200 (Fri, 12 Oct 2007) New Revision: 610 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/main.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml software/gadgets/light_monitor/trunk/Light_monitor/about.xml software/gadgets/light_monitor/trunk/Light_monitor/settings.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Disabled the notifications when tux search light/dark * Added a message when the search_light/dark function activated, but the power plug is connected. Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-12 14:34:31 UTC (rev 610) @@ -104,25 +104,32 @@ _me.set_param('test_tab', self.light_measure.test_tab) def on_btnLight_clicked(self, widget, *args): - self.light_measure.val_table = [0] * int(self.light_measure.sample+1) - self.light_measure.light_search = True - self.light_measure.light_value = 3000 + if tux.status.power_plug() == 0: + self.light_measure.val_table = [0] * int(self.light_measure.sample+1) + self.light_measure.light_search = True + self.light_measure.light_value = 3000 self.config_light_search() def on_btnDark_clicked(self, widget, *args): - self.light_measure.val_table = [-1] * int(self.light_measure.sample+1) - self.light_measure.light_search = False - self.light_measure.light_value = 0 + if tux.status.power_plug() == 0: + self.light_measure.val_table = [-1] * int(self.light_measure.sample+1) + self.light_measure.light_search = False + self.light_measure.light_value = 0 self.config_light_search() def config_light_search(self): - self.light_measure.rate_backup = self.light_measure.rate - self.light_measure.rate = 0.1 - self.light_measure.search_light_flag = True - self.light_measure.light_search_state = 0 - self.light_measure.timer = 0 - self.light_measure.count = 0 - tux.cmd.spinl_on_free(8, 1) + if tux.status.power_plug(): + tux.cmd.mouth_open() + tux.tts.speak(_me.string('power_supply')) + tux.cmd.mouth_close() + else: + self.light_measure.rate_backup = self.light_measure.rate + self.light_measure.rate = 0.1 + self.light_measure.search_light_flag = True + self.light_measure.light_search_state = 0 + self.light_measure.timer = 0 + self.light_measure.count = 0 + tux.cmd.spinl_on_free(8, 1) def on_expander_activate(self, widget, *args): self.get_widget('txtValue').set_text(str(self.light_measure.test_tab[0][3])) Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-12 14:34:31 UTC (rev 610) @@ -250,7 +250,11 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - maximum = max(self.val_table[init_val:len(self.val_table)-1]) + try: + maximum = max(self.val_table[init_val:len(self.val_table)-1]) + except: + init_val = len(self.val_table) - 1 - int(time) + maximum = max(self.val_table[init_val:len(self.val_table)-1]) if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*1124): self.__tab[index][8] = int(time) @@ -262,7 +266,12 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - minimum = min(self.val_table[init_val:(len(self.val_table)-1)]) + try: + minimum = min(self.val_table[init_val:(len(self.val_table)-1)]) + except: + init_val = len(self.val_table) - 1 - int(time) + minimum = min(self.val_table[init_val:(len(self.val_table)-1)]) + if minimum <= self.val_table[len(self.val_table)-1] - ((val/100)*1124): self.__tab[index][8] = int(time) return True @@ -273,7 +282,12 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - maximum = max(self.val_table[init_val:len(self.val_table)-1]) + try: + maximum = max(self.val_table[init_val:len(self.val_table)-1]) + except: + init_val = len(self.val_table) - 1 - int(time) + maximum = max(self.val_table[init_val:len(self.val_table)-1]) + for i in range(int(time - timeout)): if self.val_table[int(len(self.val_table)-1-i)] <= self.val_table[len(self.val_table) - 1] - ((val/100)*1124): maximum = max(self.val_table[init_val:len(self.val_table) - i]) @@ -288,7 +302,12 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - maximum = max(self.val_table[init_val:len(self.val_table)-1]) + try: + maximum = max(self.val_table[init_val:len(self.val_table)-1]) + except: + init_val = len(self.val_table) - 1 - int(time) + maximum = max(self.val_table[init_val:len(self.val_table)-1]) + for i in range(int(time - timeout)): if self.val_table[int(len(self.val_table)-1-i)] >= self.val_table[len(self.val_table) - 1] + ((val/100)*1124): minimum = min(self.val_table[init_val:len(self.val_table)-i]) @@ -330,27 +349,25 @@ # ########################################################### def on_light_level(self, args): - try: - self.__on_light_mutex.acquire() - if self.sample_backup != self.sample and self.search_light_flag == False: - self.sample = self.sample_backup - self.val_table = [-2] * int(self.sample) + self.__on_light_mutex.acquire() + if self.sample_backup != self.sample and self.search_light_flag == False: + self.sample = self.sample_backup + self.val_table = [-2] * int(self.sample) - if self.rate_backup != self.rate and self.search_light_flag == False: - self.rate_has_changed() - - if self.tick <= time.time(): - self.tick = time.time() + self.rate - val = (args[0] * 256) + args[1] - self.val_table.append(val) - self.val_table.pop(0) - if self.GUI_on: - self.light_graph_measure.refresh() - self.event_control() - self.__on_light_mutex.release() - except: - print sys.exc_info() + if self.rate_backup != self.rate and self.search_light_flag == False: + self.rate_has_changed() + + if self.tick <= time.time(): + self.tick = time.time() + self.rate + val = (args[0] * 256) + args[1] + self.val_table.append(val) + self.val_table.pop(0) + if self.GUI_on: + self.light_graph_measure.refresh() + self.event_control() + self.__on_light_mutex.release() + def rate_has_changed(self): self.rate = self.rate_backup pts_per_sec = self.sample / (self.rate * self.sample) Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/main.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/main.pyp 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/main.pyp 2007-10-12 14:34:31 UTC (rev 610) @@ -3,30 +3,35 @@ def run_function(): measure = _me.get_param('measure') - measure.val_table = [0] * int(measure.sample+1) - measure.light_search = True - measure.light_value = 3000 - measure.rate_backup = measure.rate - measure.rate = 0.1 - measure.search_light_flag = True - measure.light_search_state = 0 - measure.timer = 0 - measure.count = 0 - tux.cmd.spinl_on_free(8, 1) - count = 0 - while measure.search_light_flag: - pass - path = _me.get_param('MainScript') - path = path.replace('%20', ' ') - if os.path.isfile(path) and os.path.exists(path): - path = _me.get_param('MainScript') - path = "'%s'" % path - tux.sys.shell(path) - else: + if tux.status.power_plug(): tux.cmd.mouth_open() - txt = _me.string('mainscript') - tux.tts.speak(str(txt)) + tux.tts.speak(_me.string('power_supply')) tux.cmd.mouth_close() + else: + measure.val_table = [0] * int(measure.sample+1) + measure.light_search = True + measure.light_value = 3000 + measure.rate_backup = measure.rate + measure.rate = 0.1 + measure.search_light_flag = True + measure.light_search_state = 0 + measure.timer = 0 + measure.count = 0 + tux.cmd.spinl_on_free(8, 1) + count = 0 + while measure.search_light_flag: + pass + path = _me.get_param('MainScript') + path = path.replace('%20', ' ') + if os.path.isfile(path) and os.path.exists(path): + path = _me.get_param('MainScript') + path = "'%s'" % path + tux.sys.shell(path) + else: + tux.cmd.mouth_open() + txt = _me.string('mainscript') + tux.tts.speak(str(txt)) + tux.cmd.mouth_close() Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp 2007-10-12 14:34:31 UTC (rev 610) @@ -1,6 +1,6 @@ def notify_checker(): measure = _me.get_param('measure') - if measure.GUI_on == False: + if measure.GUI_on == False and measure.search_light_flag == False: for i in range(len(measure.event_tab)): temp = measure.event_tab[i][7] if temp == True: Modified: software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml 2007-10-12 14:34:31 UTC (rev 610) @@ -9,6 +9,7 @@ <conf_lblEvent type='str'>Evènement</conf_lblEvent> <widget_lblControl type='str'>Contrôle</widget_lblControl> <gui_conf_accept_bt type='str'>Valider</gui_conf_accept_bt> + <speaker_name type='str'>Bruno8k</speaker_name> <help_text type='str'> </help_text> <conf_lblChange type='str'>Changement</conf_lblChange> @@ -28,7 +29,7 @@ <gui_conf_about_title type='str'>A propos</gui_conf_about_title> <conf_lblChangeD type='str'>Chute et augmente</conf_lblChangeD> <widget_lblValue type='str'>Valeur (%)</widget_lblValue> - <speaker_name type='str'>Bruno8k</speaker_name> + <power_supply type='str'>Vous devez deconnecter l'alimentation</power_supply> <conf_lblSample type='str'>Points</conf_lblSample> <conf_lblType type='str'>Type</conf_lblType> <widget_lblDisplayThreshold type='str'>Afficher le seuil sur le graph.</widget_lblDisplayThreshold> Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-12 14:34:31 UTC (rev 610) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <about> - <gadget_name type='str'>light_monitor</gadget_name> <gadget_author type='str'>Paul Rathgeb</gadget_author> + <gadget_version type='str'>0.0.1</gadget_version> <gadget_description type='str'>Light monitor for tux droid</gadget_description> - <gadget_version type='str'>0.0.1</gadget_version> + <gadget_name type='str'>light_monitor</gadget_name> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-12 14:34:31 UTC (rev 610) @@ -10,22 +10,22 @@ <changeD_rad type='bool'>False</changeD_rad> <threshold type='float'>50.0</threshold> <decrease_rad type='bool'>False</decrease_rad> - <behavior_file_threshold type='NoneType'>None</behavior_file_threshold> + <Sample type='float'>500.0</Sample> <raise type='float'>10.0</raise> <changeU_rad type='bool'>False</changeU_rad> <threshold_notified type='bool'>False</threshold_notified> <config type='list'>[]</config> <behavior_file_change type='NoneType'>None</behavior_file_change> + <drop_rad type='bool'>True</drop_rad> <raise_rad type='bool'>False</raise_rad> <changeD type='float'>10.0</changeD> <drop_time type='float'>1.0</drop_time> <changeU type='float'>10.0</changeU> <raise_time type='float'>1.0</raise_time> <drop type='float'>10.0</drop> - <drop_rad type='bool'>True</drop_rad> <MainScript type='str'> </MainScript> - <Sample type='float'>500.0</Sample> + <behavior_file_threshold type='NoneType'>None</behavior_file_threshold> <threshold_chk type='bool'>False</threshold_chk> <Rate type='float'>0.1</Rate> <changeD_time type='float'>1.0</changeD_time> Modified: software/gadgets/light_monitor/trunk/Light_monitor/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-12 13:43:10 UTC (rev 609) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-12 14:34:31 UTC (rev 610) @@ -4,14 +4,13 @@ <conf_lblThreshold type='str'>Threshold</conf_lblThreshold> <gui_conf_remote_title type='str'>Control</gui_conf_remote_title> <conf_lblRaise type='str'>Raise</conf_lblRaise> - <widget_lblTest type='str'>Notifications</widget_lblTest> + <power_supply type='str'>You must disconnect the power supply</power_supply> <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> @@ -21,17 +20,19 @@ <gui_conf_update_title type='str'>Update</gui_conf_update_title> <widget_lblValue type='str'>Value (%)</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> <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> <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> <conf_lblType type='str'>Type</conf_lblType> <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> @@ -44,10 +45,10 @@ <conf_lblNotifiedBehavior type='str'>Notified</conf_lblNotifiedBehavior> <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> + <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> @@ -55,14 +56,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> - <widget_lblDark type='str'>Search darkness</widget_lblDark> + <conf_lblNotified type='str'>Notified ?</conf_lblNotified> <widget_lblSet type='str'>Add to config</widget_lblSet> <conf_lblValue type='str'>Value (%)</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> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |