[tuxdroid-svn] r596 - 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-10 13:30:19
|
Author: Paul_R Date: 2007-10-10 15:30:13 +0200 (Wed, 10 Oct 2007) New Revision: 596 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.glade software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.glade software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/init.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/about.xml software/gadgets/light_monitor/trunk/Light_monitor/settings.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Cleanup all non used variables and remove all strings * Set the .glade files as binary. Property changes on: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:30:13 UTC (rev 596) @@ -230,8 +230,8 @@ False, 0] self.measure.event_tab = _me.get_param('config') - if self.verify_tab(value): + if self.verify_tab(value): self.measure.event_tab[(index-1)] = value _me.set_param('config', self.measure.event_tab) self.value_list.clear() @@ -394,9 +394,7 @@ def on_btnBehavior_clicked(self, widget, *args): self.get_widget('conf_behavior').set_filename('None') index = self.value_list.get_value(self.__iter, 0) - print self.measure.event_tab[index-1][6] self.measure.event_tab[index-1][6] = None - print self.measure.event_tab[index-1][6] self.value_list.clear() for i in range(len(self.measure.event_tab)): Property changes on: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream 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-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:30:13 UTC (rev 596) @@ -101,7 +101,6 @@ 0] self.light_measure.test_tab[0] = value _me.set_param('test_tab', value) - print self.light_measure.test_tab def on_btnLight_clicked(self, widget, *args): self.light_measure.val_table = [0] * int(self.light_measure.sample+1) @@ -120,8 +119,6 @@ self.light_measure.rate = 0.1 self.light_measure.search_light_flag = True self.light_measure.light_search_state = 0 - #self.light_measure.tick = 2 - self.light_measure.ok_flag = False self.light_measure.timer = 0 self.light_measure.count = 0 tux.cmd.spinl_on_free(8, 1) @@ -136,11 +133,9 @@ # ########################################################### def on_cbb_conf_event_changed(self, widget, *args): - print 'cbb event' if self.get_widget('cbbEvent').get_active() == 0: for i in range (4): self.get_widget('cbbType').remove_text(0) - print 'remove' self.get_widget('cbbType').append_text(_me.string('conf_lblDrop')) self.get_widget('cbbType').append_text(_me.string('conf_lblRaise')) self.get_widget('cbbType').append_text(_me.string('conf_lblChangeD')) Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/init.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/init.pyp 2007-10-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/init.pyp 2007-10-10 13:30:13 UTC (rev 596) @@ -1,8 +1,6 @@ sys.path.append(_me.get_path('root') + '/Scripts/Python') -try: - from lightGraph_class import lightMeasure -except: - print sys.exc_info() +from lightGraph_class import lightMeasure + measure = lightMeasure() @@ -19,7 +17,7 @@ measure.val_changeU_time = float(_me.get_param('changeU_time')) measure.val_threshold = float(_me.get_param('threshold')) measure.test_tab = _me.get_param('test_tab') -print measure.test_tab + #update the radio button status measure.drop = _me.get_param('drop_rad') @@ -51,7 +49,6 @@ def destroy(): - print ' Remove' tux.monitoring.remove(_me.get_param('monitor_id')) _me.insert_funct('destroy', destroy) 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-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-10 13:30:13 UTC (rev 596) @@ -59,14 +59,6 @@ if i != 18: context.show_text(str((10-(i/2))*10)+"%") context.stroke() - - #draw the threshold line - if self.light_measure_graph.threshold_chk == True: - context.set_source_rgb(0,0,1) - context.set_line_width(0.9) - context.move_to(0, rect.height - (rect.height * (self.light_measure_graph.val_threshold / 100.0))) - context.line_to(rect.width, rect.height - (rect.height * (self.light_measure_graph.val_threshold / 100.0))) - context.stroke() #draw vertical division #create a tab with the wanted divisions @@ -131,22 +123,15 @@ self.rate = 0.1 self.rate_backup = self.rate self.tick = time.time() - self.threshold_chk = False - #Events flags - self.threshold_event = False - self.change_event = False - self.GUI_on = False - + self.GUI_on = False self.start_flag = True - self.wait = 0 - self.temp = 1124 - self.ok_flag = False + self.wait = time.time() + 2.0 self.light_search = True self.search_light_flag = False - self.search_dark_flag = False + self.__on_light_mutex = threading.Lock() self.__timeout_mutex = threading.Lock() @@ -176,11 +161,10 @@ self.search_light(self.light_search) else: #goto test notification every sec. - if self.wait == 0: - self.wait = 10 + if self.wait <= time.time(): + self.wait = time.time() + 2.0 self.test_notification() - else: - self.wait -= 1 + # To prevent notifications at startup if self.start_flag == True: @@ -266,13 +250,8 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - #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]) - #print sys.exc_info() - + if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*1124): self.__tab[index][8] = int(time) return True @@ -282,31 +261,19 @@ def Raise_control(self, time, val, timeout, index): if timeout != 0: timeout -= 1 - init_val = len(self.val_table) - 1 - int(time) + timeout - #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]) - #print sys.exc_info() - + init_val = len(self.val_table) - 1 - int(time) + timeout 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 else: - self.__tab[index][8] = timeoutt + self.__tab[index][8] = timeout def ChangeD_control(self, time, val, timeout, index): if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - #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]) - + 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]) @@ -321,12 +288,7 @@ if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout - #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]) @@ -348,11 +310,9 @@ if self.test_tab[0][5] == True: path = self.test_tab[0][6] path = path.replace('%20', ' ') - #print path if os.path.isfile(path) and os.path.exists(path): path = self.test_tab[0][6] path = "'%s'" % path - #print path tux.sys.shell_free(path) elif self.test_tab[0][1] == 0: thread.start_new_thread(self.test_default_behavior, (self.changetext,)) @@ -371,9 +331,6 @@ ########################################################### def on_light_level(self, args): try: - #print self.rate - #print self.rate_backup - print 'on light level' self.__on_light_mutex.acquire() if self.sample_backup != self.sample and self.search_light_flag == False: self.sample = self.sample_backup @@ -393,7 +350,6 @@ self.__on_light_mutex.release() except: print sys.exc_info() - #sys.exit() def rate_has_changed(self): self.rate = self.rate_backup @@ -425,7 +381,6 @@ def search_light(self, light): self.count += 1 detect = False - print 'search light 1' if self.light_search_state == 0 and tux.status.spin_counter() == 0 and self.count > 2: self.light_search_state = 1 if light == True: @@ -435,17 +390,13 @@ self.light_value = min(self.val_table[len(self.val_table) - self.count: len(self.val_table)]) self.light_value += 10 self.timer = 10 - print 'end fisrt step' elif self.light_search_state == 1: - self.timer_control() - print 'find ...' - + self.timer_control() if light: if self.val_table[len(self.val_table)-1] >= (self.light_value): thread.start_new_thread(tux.cmd.spinl_off, ()) detect = True - print 'found' else: if self.val_table[len(self.val_table)-1] <= (self.light_value): thread.start_new_thread(tux.cmd.spinl_off, ()) @@ -454,11 +405,7 @@ if detect: self.search_light_flag = False self.light_search_state = 0 - print '====================================================' - print self.rate - #self.rate = self.rate_backup - def timer_control(self): self.timer -= 1 if self.timer > 2: 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-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/main.pyp 2007-10-10 13:30:13 UTC (rev 596) @@ -10,7 +10,6 @@ measure.rate = 0.1 measure.search_light_flag = True measure.light_search_state = 0 - measure.ok_flag = False measure.timer = 0 measure.count = 0 tux.cmd.spinl_on_free(8, 1) @@ -20,15 +19,12 @@ path = _me.get_param('MainScript') path = path.replace('%20', ' ') if os.path.isfile(path) and os.path.exists(path): - print 'tick' path = _me.get_param('MainScript') path = "'%s'" % path tux.sys.shell(path) else: - print 'play behavior' tux.cmd.mouth_open() txt = _me.string('mainscript') - print txt 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-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp 2007-10-10 13:30:13 UTC (rev 596) @@ -26,36 +26,26 @@ text = _me.string('conf_lblChangeU') else: if event[i][2] == 0: - print 'Increase text' text = _me.string('conf_lblIncrease') elif event[i][2] == 1: - print 'Decrease text' text = _me.string('conf_lblDecrease') elif event[i][2] == 2: - print 'Both text' text = _me.string('conf_lblBoth') - print 'End threshold text' if event[i][7]: - print 'first notification step' if event[i][5]: path = event[i][6] path = path.replace('%20', ' ') - print 'notification enable' if os.path.isfile(path) and os.path.exists(path): - print 'script found and valid' path = "'%s'" % path tux.sys.shell_free(path) event[i][7] = False else: - print 'default behavior' tux.cmd.mouth_open() tux.tts.speak(text) tux.cmd.mouth_close() event[i][7] = False else: - print 'notification disabled' event[i][7] = False - print 'notification done' break Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-10 13:30:13 UTC (rev 596) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <about> + <gadget_description type='str'>Light monitor for tux droid</gadget_description> <gadget_author type='str'>Paul Rathgeb</gadget_author> + <gadget_name type='str'>light_monitor</gadget_name> <gadget_version type='str'>0.0.1</gadget_version> - <gadget_name type='str'>light_monitor</gadget_name> - <gadget_description type='str'>Light monitor for tux droid</gadget_description> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-10 13:30:13 UTC (rev 596) @@ -10,22 +10,22 @@ <changeD_rad type='bool'>False</changeD_rad> <threshold type='float'>50.0</threshold> <decrease_rad type='bool'>False</decrease_rad> - <Sample type='float'>500.0</Sample> + <behavior_file_threshold type='NoneType'>None</behavior_file_threshold> <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> - <behavior_file_threshold type='NoneType'>None</behavior_file_threshold> + <Sample type='float'>500.0</Sample> <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-10 12:48:07 UTC (rev 595) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-10 13:30:13 UTC (rev 596) @@ -4,12 +4,14 @@ <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> <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> @@ -19,19 +21,16 @@ <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> - <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> + <widget_lblBoth type='str'>Both direction</widget_lblBoth> <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> - <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,9 +43,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> - <widget_lblBoth type='str'>Both direction</widget_lblBoth> + <conf_lblNotified type='str'>Notified ?</conf_lblNotified> + <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> <conf_lblDefaultBehavior type='str'>Default behavior</conf_lblDefaultBehavior> - <conf_lblBehavior type='str'>Behavior script</conf_lblBehavior> + <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> <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> @@ -54,7 +54,7 @@ <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_lblNotified type='str'>Notified ?</conf_lblNotified> + <widget_lblDark type='str'>Search darkness</widget_lblDark> <widget_lblSet type='str'>Add to config</widget_lblSet> <conf_lblValue type='str'>Value (%)</conf_lblValue> <conf_lblRate type='str'>Refresh rate</conf_lblRate> @@ -62,6 +62,6 @@ <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> <conf_lblTime type='str'>Time (sec.)</conf_lblTime> <conf_lblControl type='str'>Control</conf_lblControl> - <widget_lblTest type='str'>Notifications</widget_lblTest> + <conf_btnRemove type='str'>Remove</conf_btnRemove> <widget_lblThreshold type='str'>Threshold</widget_lblThreshold> </strings> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |