[tuxdroid-svn] r613 - 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-15 13:48:17
|
Author: Paul_R Date: 2007-10-15 15:48:15 +0200 (Mon, 15 Oct 2007) New Revision: 613 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf 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/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: * Added visual icons on graph when a notification happens. 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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/init.pyp 2007-10-15 13:48:15 UTC (rev 613) @@ -20,13 +20,7 @@ #update the radio button status -measure.drop = _me.get_param('drop_rad') -measure.raising = _me.get_param('raise_rad') -measure.changeD = _me.get_param('changeD_rad') -measure.changeU = _me.get_param('changeU_rad') -measure.increase = _me.get_param('increase_rad') -measure.decrease = _me.get_param('decrease_rad') -measure.both = _me.get_param('both_rad') +measure.txtsearch = _me.string('search') # '' the check boxes measure.threshold_chk = _me.get_param('threshold_chk') 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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-15 13:48:15 UTC (rev 613) @@ -28,10 +28,10 @@ self.window.invalidate_rect(gtk.gdk.Rectangle(0,0,width,height),False) def draw(self, context): - rect = self.get_allocation() + self.rect = self.get_allocation() #draw axes #draw a rectangle in the window area - context.rectangle(rect.x, rect.y, rect.width, rect.height) + context.rectangle(self.rect.x, self.rect.y, self.rect.width, self.rect.height) #set a white background context.set_source_rgb(1, 1, 1) context.fill() @@ -42,9 +42,9 @@ #draw horizontal grid with 10 div. and 10 sub-div for i in range(20): - y = (rect.height / 20.0) * float(i) + y = (self.rect.height / 20.0) * float(i) #place correctly the vector - context.move_to(rect.width, y) + context.move_to(self.rect.width, y) if i % 2 == 1: #Minor div: no text context.set_source_rgb(0.2, 0.2, 0.2) @@ -67,11 +67,11 @@ context.set_source_rgb(0.2, 0.2, 0.2) context.set_line_width(0.6) #place correctly the vector - context.move_to(rect.width * temp_tab[i], 0) + context.move_to(self.rect.width * temp_tab[i], 0) #trace a line - context.line_to(rect.width * temp_tab[i], rect.height) + context.line_to(self.rect.width * temp_tab[i], self.rect.height) #replace the vector to draw text - context.move_to(rect.width * temp_tab[i], rect.height - 5) + context.move_to(self.rect.width * temp_tab[i], self.rect.height - 5) #determine the time labels context.show_text(str((self.light_measure_graph.rate * self.light_measure_graph.sample) - ((self.light_measure_graph.rate) * self.light_measure_graph.sample * temp_tab[i])) + " sec.") @@ -79,26 +79,26 @@ #display sample and rate #move the vector in the bottom - context.move_to(5, rect.height - 10) + context.move_to(5, self.rect.height - 10) #display the rate context.show_text("rate = "+str(self.light_measure_graph.rate)+" sec.") - context.move_to(5, rect.height - 20) + context.move_to(5, self.rect.height - 20) #and the samples context.show_text("samples = "+str(self.light_measure_graph.sample)) context.stroke() #determine the coefficients to adjust the curve in the window space - coeff_y = float(rect.height / 1124.00) - coeff_x = float(rect.width / (self.light_measure_graph.sample - 1)) + coeff_y = float(self.rect.height / 1124.00) + coeff_x = float(self.rect.width / (self.light_measure_graph.sample - 1)) #Fill... context.set_line_width(0.6) context.set_source_rgb(0, 0, 1) - context.move_to(rect.x - 2, rect.height + 2) - context.line_to(rect.x, rect.height - (self.light_measure_graph.val_table[0] * coeff_y)) + context.move_to(self.rect.x - 2, self.rect.height + 2) + context.line_to(self.rect.x, self.rect.height - (self.light_measure_graph.val_table[0] * coeff_y)) for i, val in enumerate(self.light_measure_graph.val_table): - context.line_to(rect.x + ((i) * coeff_x), rect.height - (val * coeff_y)) - context.line_to(rect.x + ((i) * coeff_x), rect.height + 5) + context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) + context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) context.close_path() context.set_source_rgba(1.0, 0, 0, 0.2) context.fill() @@ -106,12 +106,47 @@ #and trace the curce context.set_line_width(0.6) context.set_source_rgb(1, 0, 0) - context.move_to(rect.x - 2, rect.height + 2) - context.line_to(rect.x, rect.height - (self.light_measure_graph.val_table[0] * coeff_y)) + context.move_to(self.rect.x - 2, self.rect.height + 2) + context.line_to(self.rect.x, self.rect.height - (self.light_measure_graph.val_table[0] * coeff_y)) for i, val in enumerate(self.light_measure_graph.val_table): - context.line_to(rect.x + ((i) * coeff_x), rect.height - (val * coeff_y)) - context.line_to(rect.x + ((i) * coeff_x), rect.height + 5) + context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) + if self.light_measure_graph.val_table_event[i] == 1: + self.draw_square(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y), [0.7, 0.2, 0.2]) + if self.light_measure_graph.val_table_event[i] == 2: + self.draw_triangle(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y), [0.7, 0.2, 0.2]) + + context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) context.stroke() + + def draw_square(self, x, y, color): + self.context.stroke() + self.context.set_source_rgb(color[0], color[1], color[2]) + self.context.move_to(x - 4, y - 4) + self.context.rectangle(x - 4, y - 4, 8, 8) + self.context.move_to(x, y) + self.context.fill() + self.context.set_source_rgb(1, 0, 0) + + def draw_triangle(self, x, y, color): + self.context.stroke() + self.context.set_source_rgb(color[0], color[1], color[2]) + self.context.move_to(x, y - 5) + self.context.line_to(x + 5, y + 5) + self.context.line_to(x - 5, y + 5) + self.context.line_to(x, y - 5) + self.context.close_path() + self.context.fill() + self.context.move_to(x, y) + self.context.set_source_rgb(1, 0, 0) + + def draw_circle(self, x, y, color): + self.context.stroke() + self.context.set_source_rgb(color[0], color[1], color[2]) + self.context.arc(x, y, 4, 0, 2 * math.pi) + self.context.close_path() + self.context.fill() + self.context.move_to(x, y) + self.context.set_source_rgb(1, 0, 0) class lightMeasure(): def __init__(self): @@ -119,10 +154,14 @@ self.sample = 500.0 self.sample_backup = self.sample self.val_table = [-2] * int(self.sample + 1) + self.val_table_event = [-1] * int(self.sample + 1) self.test_tab = [0] self.rate = 0.1 self.rate_backup = self.rate self.tick = time.time() + self.event_flag = False + self.event = 0 + self.txtsearch = ' ' self.GUI_on = False @@ -146,25 +185,32 @@ self.__tab = self.test_tab else: self.__tab = self.event_tab + if self.search_light_flag == False: for i in range (len(self.__tab)): self.Threshold_control(i) self.Change_control(i) - + if self.event_flag == False and self.__tab[i][5] == True: + if self.__tab[i][7] == True and self.__tab[i][1] == 0: + self.event = 1 + self.event_flag = True + elif self.__tab[i][7] == True and self.__tab[i][1] == 1: + self.event = 2 + self.event_flag = True if self.GUI_on: self.test_tab = self.__tab else: self.event_tab = self.__tab - - if self.search_light_flag: - self.search_light(self.light_search) - else: - #goto test notification every sec. - if self.wait <= time.time(): - self.wait = time.time() + 2.0 - self.test_notification() - + if self.GUI_on: + if self.search_light_flag: + self.search_light(self.light_search) + else: + #goto test notification every sec. + if self.wait <= time.time(): + self.wait = time.time() + 2.0 + self.test_notification() + self.event_flag = False # To prevent notifications at startup if self.start_flag == True: @@ -349,25 +395,37 @@ # ########################################################### def on_light_level(self, args): - 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() + 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.val_table_event = [-1] * 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 + if self.event != 0 and self.event_flag == True: + self.val_table_event.append(self.event) + else: + self.val_table_event.append(-1) + + self.val_table_event.pop(0) + self.event = 0 + 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() + def rate_has_changed(self): self.rate = self.rate_backup pts_per_sec = self.sample / (self.rate * self.sample) @@ -433,5 +491,5 @@ elif self.timer == 0: thread.start_new_thread(tux.cmd.spinl_off, ()) - self.timer = 7 + self.timer = 8 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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp 2007-10-15 13:48:15 UTC (rev 613) @@ -1,5 +1,6 @@ def notify_checker(): measure = _me.get_param('measure') + 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] @@ -14,6 +15,7 @@ def notify_actuator(): event = _me.get_param('measure').event_tab for i in range(len(event)): + _me.get_param('measure').event_flag = False #create text to speach for the default notification if event[i][1] == 0: if event[i][2] == 0: 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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml 2007-10-15 13:48:15 UTC (rev 613) @@ -50,6 +50,7 @@ <conf_lblDefaultBehavior type='str'>Comportement pas défaut</conf_lblDefaultBehavior> <conf_lblBehavior type='str'>Comportement</conf_lblBehavior> <gui_conf_remote_set_bt type='str'>Set</gui_conf_remote_set_bt> + <search type='str'>Je cherche ...</search> <widget_lblChange type='str'>Changement</widget_lblChange> <widget_lblLight type='str'>Trouver lumière</widget_lblLight> <name_to_read type='str'>Moniteur de lumière</name_to_read> Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-15 13:48:15 UTC (rev 613) @@ -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_description type='str'>Light monitor for tux droid</gadget_description> <gadget_version type='str'>0.0.1</gadget_version> - <gadget_description type='str'>Light monitor for tux droid</gadget_description> - <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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-15 13:48:15 UTC (rev 613) @@ -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-15 12:05:10 UTC (rev 612) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-15 13:48:15 UTC (rev 613) @@ -4,13 +4,15 @@ <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> - <power_supply type='str'>You must disconnect the power supply</power_supply> + <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> + <speaker_name type='str'>Ryan8k</speaker_name> <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> @@ -20,19 +22,17 @@ <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> + <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> + <power_supply type='str'>You must disconnect the power supply</power_supply> <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> @@ -45,25 +45,26 @@ <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> - <MainBehavior type='str'>Main behavior</MainBehavior> - <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> + <search type='str'>I seek ...</search> <widget_lblChange type='str'>Change</widget_lblChange> <widget_lblLight type='str'>Search light</widget_lblLight> <name_to_read type='str'>Light monitor</name_to_read> <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> <widget_lblBehavior type='str'>Enable behavior script</widget_lblBehavior> - <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> + <MainBehavior type='str'>Main behavior</MainBehavior> <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) |