tux-droid-svn Mailing List for Tux Droid CE (Page 217)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Paul_R <c2m...@c2...> - 2007-10-12 08:55:42
|
Author: Paul_R Date: 2007-10-12 10:55:41 +0200 (Fri, 12 Oct 2007) New Revision: 605 Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade 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: * Changed the widget glade to minimize the expander at startup Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade =================================================================== (Binary files differ) 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 08:08:07 UTC (rev 604) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-12 08:55:41 UTC (rev 605) @@ -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> @@ -58,7 +58,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 08:08:07 UTC (rev 604) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-12 08:55:41 UTC (rev 605) @@ -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_name type='str'>battery_monitor</gadget_name> - <gadget_author type='str'>Paul Rathgeb</gadget_author> <gadget_description type='str'>Battery monitor for tux droid</gadget_description> - <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 08:08:07 UTC (rev 604) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-12 08:55:41 UTC (rev 605) @@ -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 08:08:07 UTC (rev 604) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-12 08:55:41 UTC (rev 605) @@ -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> <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> + <charging type='str'>Charging</charging> <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> @@ -48,9 +47,10 @@ <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> @@ -58,14 +58,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> - <charging type='str'>Charging</charging> + <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> |
From: Paul_R <c2m...@c2...> - 2007-10-12 08:08:08
|
Author: Paul_R Date: 2007-10-12 10:08:07 +0200 (Fri, 12 Oct 2007) New Revision: 604 Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.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/strings.xml Log: * Removed the 'search' buttons in the widget window. Modified: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-12 08:01:17 UTC (rev 603) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-12 08:08:07 UTC (rev 604) @@ -18,9 +18,7 @@ def new(self): self.get_widget("window1").set_title(_me.string('name_to_read')) self.get_widget("lblThreshold").set_text(_me.string('widget_lblTest')) - - self.get_widget("lblBtnDark").set_label(_me.string('widget_lblDark')) - self.get_widget("lblBtnLight").set_label(_me.string('widget_lblLight')) + self.get_widget("btnAdd").set_label(_me.string('widget_lblSet')) self.get_widget('txtValue').set_text('1.0') 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 08:01:17 UTC (rev 603) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-12 08:08:07 UTC (rev 604) @@ -22,7 +22,6 @@ <conf_lblChangeU type='str'>Augmente et chute</conf_lblChangeU> <gui_conf_cancel_bt type='str'>Annuler</gui_conf_cancel_bt> <gui_conf_rate_lb type='str'>Taux de rafraichissement :</gui_conf_rate_lb> - <conf_lblType type='str'>Type</conf_lblType> <mainscript type='str'>J'ai trouvé la lumière !</mainscript> <conf_btnRemove type='str'>Enlever</conf_btnRemove> <gui_conf_delay_lb type='str'>Délai (sec)</gui_conf_delay_lb> @@ -33,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> - <charging type='str'>En charge</charging> + <conf_lblType type='str'>Type</conf_lblType> <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> @@ -47,6 +46,7 @@ <conf_lblNotifiedBehavior type='str'>Notifié</conf_lblNotifiedBehavior> <gui_conf_author_lb type='str'>Auteur</gui_conf_author_lb> <widget_lblDrop type='str'>Chute</widget_lblDrop> + <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> <MainBehavior type='str'>Comportement principal</MainBehavior> <widget_lblBoth type='str'>Deux directions</widget_lblBoth> <conf_lblDefaultBehavior type='str'>Comportement pas défaut</conf_lblDefaultBehavior> @@ -58,7 +58,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> - <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> + <charging type='str'>En charge</charging> <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 08:01:17 UTC (rev 603) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-12 08:08:07 UTC (rev 604) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <about> - <gadget_description type='str'>Light monitor for tux droid</gadget_description> + <gadget_name type='str'>battery_monitor</gadget_name> <gadget_author type='str'>Paul Rathgeb</gadget_author> - <gadget_name type='str'>light_monitor</gadget_name> + <gadget_description type='str'>Battery monitor for tux droid</gadget_description> <gadget_version type='str'>0.0.1</gadget_version> </about> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-12 08:01:17 UTC (rev 603) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-12 08:08:07 UTC (rev 604) @@ -32,7 +32,7 @@ <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> <speaker_name type='str'>Ryan8k</speaker_name> <conf_lblSample type='str'>Samples</conf_lblSample> - <charging type='str'>Charging</charging> + <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> @@ -58,7 +58,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_lblType type='str'>Type</conf_lblType> + <charging type='str'>Charging</charging> <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> |
From: Paul_R <c2m...@c2...> - 2007-10-12 08:01:46
|
Author: Paul_R Date: 2007-10-12 10:01:17 +0200 (Fri, 12 Oct 2007) New Revision: 603 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp Log: * Fix a bug in the widget window : It was possible to enter a change time lower than the refresh rate. 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-11 15:13:12 UTC (rev 602) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-12 08:01:17 UTC (rev 603) @@ -193,8 +193,8 @@ except: self.get_widget('txtTime').set_text('0.1') - if float(self.get_widget('txtTime').get_text()) < 0.1: - self.get_widget('txtTime').set_text('0.1') + if float(self.get_widget('txtTime').get_text()) < self.light_measure.rate: + self.get_widget('txtTime').set_text(str(self.light_measure.rate)) if float(self.get_widget('txtTime').get_text()) > self.light_measure.rate * self.light_measure.sample: self.get_widget('txtTime').set_text(str(self.light_measure.rate * self.light_measure.sample)) Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |
Author: Paul_R Date: 2007-10-11 17:13:12 +0200 (Thu, 11 Oct 2007) New Revision: 602 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/GUI/conf/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.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 event pattern in the graph. 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-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-11 15:13:12 UTC (rev 602) @@ -4,6 +4,7 @@ import os import threading import thread +import math sys.path.append('/opt/tuxdroid/api/python') from tux import * @@ -12,6 +13,9 @@ super(Graph, self).__init__() self.connect("expose_event", self.expose) self.context = None + self.battery = ' ' + self.plugged = ' ' + self.charging = ' ' def expose(self, widget, event): #when an event occur, update the context @@ -84,38 +88,87 @@ #replace the vector to draw text self.context.move_to(self.rect.width * temp_tab[i], self.rect.height - 5) #determine the time labels - self.context.show_text(str((self.measure_graph.rate * self.measure_graph.sample) - ((self.measure_graph.rate) * - self.measure_graph.sample * temp_tab[i])) + " sec.") + txt = ((self.measure_graph.rate * self.measure_graph.sample)/60 - (self.measure_graph.rate * self.measure_graph.sample * temp_tab[i])/60) + txt = str('%.2f' % txt) + self.context.show_text(str(txt) + " min.") self.context.stroke() def draw_label(self): #display sample and rate #move the vector in the bottom - self.context.move_to(5, self.rect.height - 10) - #display the rate - self.context.show_text("rate = "+str(self.measure_graph.rate)+" sec.") - self.context.move_to(5, self.rect.height - 20) - #and the samples - self.context.show_text("samples = "+str(self.measure_graph.sample)) + self.draw_circle(5, self.rect.height - 7, [0.2, 0.2, 0.7]) + self.context.set_source_rgb(0.2, 0.2, 0.2) + self.context.move_to(10, self.rect.height - 2) + self.context.show_text(self.battery) + + self.draw_square(5, self.rect.height - 20, [0.2, 0.2, 0.7]) + self.context.set_source_rgb(0.2, 0.2, 0.2) + self.context.move_to(10, self.rect.height - 15) + self.context.show_text(self.plugged) + + self.draw_triangle(5, self.rect.height - 33, [0.2, 0.2, 0.7]) + self.context.set_source_rgb(0.2, 0.2, 0.2) + self.context.move_to(10, self.rect.height - 28) + self.context.show_text(self.charging) + self.context.stroke() def draw_curve(self): - coeff_y = float(self.rect.height / 340.00) + coeff_y = float(self.rect.height / self.measure_graph.RANGE) coeff_x = float(self.rect.width / (self.measure_graph.sample - 1)) self.fill(coeff_x, coeff_y) #and trace the curce self.context.set_line_width(0.6) - self.context.set_source_rgb(1, 0, 0) + self.context.set_source_rgb(0, 0, 1) self.context.move_to(self.rect.x - 2, self.rect.height + 2) self.context.line_to(self.rect.x, self.rect.height - (self.measure_graph.val_table[0] * coeff_y)) + temp_event = 0 for i, val in enumerate(self.measure_graph.val_table): self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) + if self.measure_graph.val_table_event[i] == 0: + self.draw_circle(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y), [0.2, 0.2, 0.7]) + if self.measure_graph.val_table_event[i] == 1: + self.draw_square(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y), [0.2, 0.2, 0.7]) + if self.measure_graph.val_table_event[i] == 2: + self.draw_triangle(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y), [0.2, 0.2, 0.7]) + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) self.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(0, 0, 1) - + 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(0, 0, 1) + + + 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(0, 0, 1) + + def fill(self, coeff_x, coeff_y): #determine the coefficients to adjust the curve in the window space #Fill... @@ -127,28 +180,31 @@ self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) self.context.close_path() - self.context.set_source_rgba(1.0, 0, 0, 0.2) + self.context.set_source_rgba(0, 0, 1, 0.2) self.context.fill() class Measure(): - def __init__(self): - #Initial value - self.sample = 500.0 + def __init__(self, sample, rate): + self.rate = rate + self.rate_backup = self.rate + self.sample = sample self.sample_backup = self.sample - self.val_table = [-2] * int(self.sample + 1) + self.val_table = [-2] * int(self.sample) + self.val_table_event = [-1] * int(self.sample) + self.charger_event_backup = 3 self.test_tab = [0] - self.rate = 1.0 - self.rate_backup = self.rate - self.tick = time.time() + self.rate + + + + self.tick = time.time() + 1 self.average = 0 self.count = 0 self.GUI_on = False self.start_flag = True self.wait = time.time() + 2.0 + self.RANGE = 340.0 - - self.__on_battery_mutex = threading.Lock() self.__timeout_mutex = threading.Lock() @@ -165,10 +221,11 @@ self.__tab = self.event_tab for i in range (len(self.__tab)): - self.Threshold_control(i) - self.Change_control(i) + val = self.convert_value(self.__tab[i]) + self.Threshold_control(i, val) + self.Change_control(i, val) - if self.GUI_on: + if self.GUI_on: self.test_tab = self.__tab else: self.event_tab = self.__tab @@ -187,45 +244,58 @@ for i in range (len(self.event_tab)): self.event_tab[i][7] = False + def convert_value(self, table): + if table[1] == 1: + #threshold event + value = table[3] + #100% in the graph = 2.5V + value = (100 * (value - 4)) / 2.5 + return value + else: + value = table[3] + #100% in the graph = 2.5V + value = (100 * (value)) / 2.5 + return value + + - ########################################################### # # Threshold control # ########################################################### - def Threshold_control(self, index): + def Threshold_control(self, index, val): if self.__tab[index][1] == 1: if self.__tab[index][7] != True: if self.__tab[index][2] == 0: #Increasing threshold control - if self.Increase_control(self.__tab[index][3]) == True: + if self.Increase_control(val) == True: self.__tab[index][7] = True elif self.__tab[index][2] == 1: #Decreasing threshold control - if self.Decrease_control(self.__tab[index][3]) == True: + if self.Decrease_control(val) == True: self.__tab[index][7] = True elif self.__tab[index][2] == 2: #Both direction theshold control - if self.Both_control(self.__tab[index][3]) == True: + if self.Both_control(val) == True: self.__tab[index][7] = True def Increase_control(self, value): - val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 - val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 + 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 <= value and val_act > value: return True def Decrease_control(self, val): - val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 - val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 + 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: return True def Both_control(self, val): - val_act = (self.val_table[int(len(self.val_table)-1)]*100) / 1124.0 - val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / 1124.0 + val_act = (self.val_table[int(len(self.val_table)-1)]*100) / self.RANGE + val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / self.RANGE if val_prev <= val and val_act > val or val_prev >= val and val_act < val: return True @@ -235,7 +305,7 @@ # Changes control # ########################################################### - def Change_control(self, i): + def Change_control(self, i, val): #Changements control if self.__tab[i][1] == 0: pts_per_sec = self.sample / (self.rate * self.sample) @@ -243,30 +313,30 @@ if self.__tab[i][7] != True: # Drop change part : if self.__tab[i][2] == 0: - if self.Drop_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + if self.Drop_control(time, val, self.__tab[i][8], i) == True: self.__tab[i][7] = True # Raise change part if self.__tab[i][2] == 1: - if self.Raise_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + if self.Raise_control(time, val, self.__tab[i][8], i) == True: self.__tab[i][7] = True # Drop and Raise change if self.__tab[i][2] == 2: - if self.ChangeD_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + if self.ChangeD_control(time, val, self.__tab[i][8], i) == True: self.__tab[i][7] = True # Raise and Drop change if self.__tab[i][2] == 3: - if self.ChangeU_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + if self.ChangeU_control(time, val, self.__tab[i][8], i) == True: self.__tab[i][7] = True def Drop_control(self, time, val, timeout, index): #timeout control : to prevent multiple notifications with the same event if timeout != 0: - timeout -= 1 + timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout 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): + + if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*self.RANGE): self.__tab[index][8] = int(time) return True else: @@ -277,7 +347,7 @@ timeout -= 1 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): + if minimum <= self.val_table[len(self.val_table)-1] - ((val/100)*self.RANGE): self.__tab[index][8] = int(time) return True else: @@ -289,7 +359,7 @@ init_val = len(self.val_table) - 1 - int(time) + timeout 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): + if self.val_table[int(len(self.val_table)-1-i)] <= self.val_table[len(self.val_table) - 1] - ((val/100)*self.RANGE): maximum = max(self.val_table[init_val:len(self.val_table) - i]) if maximum >= self.val_table[len(self.val_table) - 1 - i] + val: self.__tab[index][8] = int(time) @@ -304,7 +374,7 @@ init_val = len(self.val_table) - 1 - int(time) + timeout 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): + if self.val_table[int(len(self.val_table)-1-i)] >= self.val_table[len(self.val_table) - 1] + ((val/100)*self.RANGE): minimum = min(self.val_table[init_val:len(self.val_table)-i]) if minimum <= self.val_table[len(self.val_table) - 1 - i] - val: self.__tab[index][8] = int(time) @@ -344,27 +414,46 @@ # ########################################################### def on_battery_level(self, args): - self.__on_battery_mutex.acquire() - self.average += (args[0] * 256) + args[1] - self.count += 1 - if self.sample_backup != self.sample: - self.sample = self.sample_backup - self.val_table = [-2] * int(self.sample) - if self.rate_backup != self.rate: - self.rate_has_changed() - - if self.tick <= time.time(): - self.tick = time.time() + self.rate - val = self.average / self.count - val = val - 530 - self.val_table.append(val) - self.val_table.pop(0) - self.average = 0 - self.count = 0 - if self.GUI_on: - self.graph_measure.refresh() - self.event_control() - self.__on_battery_mutex.release() + try: + self.__on_battery_mutex.acquire() + self.average += (args[0] * 256) + args[1] + self.count += 1 + if self.sample_backup != self.sample: + 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: + self.rate_has_changed() + + if self.tick <= time.time(): + self.tick = time.time() + self.rate + val = self.average / self.count + val = val - 530 + charger_event = -1 + #Event control + if tux.status.power_plug(): + charger_event = 1 + if tux.status.charger_state(): + charger_event = 2 + elif self.charger_event_backup > 0: + charger_event = 0 + + if self.charger_event_backup != charger_event: + self.charger_event_backup = charger_event + else: + charger_event = -1 + self.val_table.append(val) + self.val_table.pop(0) + self.val_table_event.append(charger_event) + self.val_table_event.pop(0) + self.average = 0 + self.count = 0 + if self.GUI_on: + self.graph_measure.refresh() + self.event_control() + self.__on_battery_mutex.release() + except: + print sys.exc_info() Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp 2007-10-11 15:13:12 UTC (rev 602) @@ -253,7 +253,7 @@ self.__iter = 0 self.value_list.clear() for i in range(len(self.measure.event_tab)): - self.add_row(i) + self.add_row(i) ########################################################### # @@ -408,6 +408,12 @@ # ########################################################### def verify_value(self): + if self.get_widget('cbb_conf_event').get_active() == 0: + maximum = 2.5 + minimum = 0.025 + else: + maximum = 6.5 + minimum = 4.0 try: float(self.get_widget('txt_conf_time').get_text()) except: @@ -421,10 +427,10 @@ try: float(self.get_widget('txt_conf_value').get_text()) except: - self.get_widget('txt_conf_value').set_text('1') + self.get_widget('txt_conf_value').set_text(str(minimum)) - if float(self.get_widget('txt_conf_value').get_text()) < 1: - self.get_widget('txt_conf_value').set_text('1') - if float(self.get_widget('txt_conf_value').get_text()) > 100: - self.get_widget('txt_conf_value').set_text('100') + if float(self.get_widget('txt_conf_value').get_text()) < minimum: + self.get_widget('txt_conf_value').set_text(str(minimum)) + if float(self.get_widget('txt_conf_value').get_text()) > maximum: + self.get_widget('txt_conf_value').set_text(str(maximum)) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-11 15:13:12 UTC (rev 602) @@ -45,7 +45,9 @@ self.get_widget('txtTime').set_text(str(tab[0][4])) self.get_widget('chkNotify').set_active(tab[0][5]) self.get_widget('Behavior').set_filename(tab[0][6]) + + thread.start_new_thread(self.update, ()) ########################################################### @@ -57,6 +59,12 @@ self.measure.changetext = _me.string('conf_lblChange') self.measure.thresholdtext = _me.string('conf_lblThreshold') + try: + self.graph.battery = _me.string('battery') + self.graph.plugged = _me.string('plugged') + self.graph.charging = _me.string('charging') + except: + print sys.exc_info() ########################################################### # @@ -169,24 +177,31 @@ def verify_value(self): + if self.get_widget('cbbEvent').get_active() == 0: + maximum = 2.5 + minimum = 0.025 + else: + maximum = 6.5 + minimum = 4.0 + try: float(self.get_widget('txtTime').get_text()) except: self.get_widget('txtTime').set_text('1.0') - if float(self.get_widget('txtTime').get_text()) < 1.0: - self.get_widget('txtTime').set_text('1.0') + if float(self.get_widget('txtTime').get_text()) < self.measure.rate: + self.get_widget('txtTime').set_text(str(self.measure.rate)) if float(self.get_widget('txtTime').get_text()) > self.measure.rate * self.measure.sample: self.get_widget('txtTime').set_text(str(self.measure.rate * self.measure.sample)) try: float(self.get_widget('txtValue').get_text()) except: - self.get_widget('txtValue').set_text('1') + self.get_widget('txtValue').set_text(str(minimum)) - if float(self.get_widget('txtValue').get_text()) < 1: - self.get_widget('txtValue').set_text('1') - if float(self.get_widget('txtValue').get_text()) > 100: - self.get_widget('txtValue').set_text('100') + if float(self.get_widget('txtValue').get_text()) < minimum: + self.get_widget('txtValue').set_text(str(minimum)) + if float(self.get_widget('txtValue').get_text()) > maximum: + self.get_widget('txtValue').set_text(str(maximum)) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp 2007-10-11 15:13:12 UTC (rev 602) @@ -1,47 +1,20 @@ sys.path.append(_me.get_path('root') + '/Scripts/Python') from Battery_class import Measure -measure = Measure() +measure = Measure(float(_me.get_param('Sample')), float(_me.get_param('Rate'))) _me.set_param('measure', measure) - -#update the values -measure.val_drop = float(_me.get_param('drop')) -measure.val_raise = float(_me.get_param('raise')) -measure.val_changeD = float(_me.get_param('changeD')) -measure.val_changeU = float(_me.get_param('changeU')) -measure.val_drop_time = float(_me.get_param('drop_time')) -measure.val_raise_time = float(_me.get_param('raise_time')) -measure.val_changeD_time = float(_me.get_param('changeD_time')) -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') - - -#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') - -# '' the check boxes -measure.threshold_chk = _me.get_param('threshold_chk') -#measure.change_control() - +print 'test' # update the sample and rate values +''' if _me.get_param('Rate') != (0 or None or '') and float(_me.get_param('Rate')) != measure.rate: - measure.tick = 1 measure.rate = float(_me.get_param('Rate')) + measure.rate_backup = measure.rate if _me.get_param('Sample') != (0 or None or '' or '1') and float(_me.get_param('Sample')) != measure.sample: - measure.val_table = [0] * int(_me.get_param('Sample')) - measure.sample = float(_me.get_param('Sample')) - -measure.threshold_behavior = _me.get_param('behavior_file_threshold') -measure.change_behavior = _me.get_param('behavior_file_change') + measure.sample = float(_me.get_param('Sample')) + measure.sample_backup = measure.sample +''' measure.event_tab = _me.get_param('config') - +measure.test_tab = _me.get_param('test_tab') monitor_id = tux.monitoring.insert(0x25, measure.on_battery_level) _me.set_param('monitor_id', monitor_id) 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-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-11 15:13:12 UTC (rev 602) @@ -3,6 +3,7 @@ <conf_lblIncrease type='str'>Augmente</conf_lblIncrease> <conf_lblThreshold type='str'>Seuil</conf_lblThreshold> <gui_conf_remote_title type='str'>Contrôle</gui_conf_remote_title> + <battery type='str'>Sur batteries</battery> <conf_lblRaise type='str'>Accroissement</conf_lblRaise> <widget_lblTest type='str'>Notifications</widget_lblTest> <gui_conf_description_lb type='str'>Description</gui_conf_description_lb> @@ -21,16 +22,18 @@ <conf_lblChangeU type='str'>Augmente et chute</conf_lblChangeU> <gui_conf_cancel_bt type='str'>Annuler</gui_conf_cancel_bt> <gui_conf_rate_lb type='str'>Taux de rafraichissement :</gui_conf_rate_lb> + <conf_lblType type='str'>Type</conf_lblType> <mainscript type='str'>J'ai trouvé la lumière !</mainscript> <conf_btnRemove type='str'>Enlever</conf_btnRemove> <gui_conf_delay_lb type='str'>Délai (sec)</gui_conf_delay_lb> + <plugged type='str'>Connecté</plugged> <conf_btnBehavior type='str'>Supprimer</conf_btnBehavior> <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> + <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> @@ -57,7 +60,7 @@ <gui_conf_window_title type='str'>Paramètres</gui_conf_window_title> <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> <widget_lblSet type='str'>Ajouter a la config.</widget_lblSet> - <conf_lblValue type='str'>Valeur (%)</conf_lblValue> + <conf_lblValue type='str'>Valeur (V)</conf_lblValue> <conf_lblRate type='str'>Taux de rafraichissement</conf_lblRate> <widget_lblBehavior type='str'>Activer le script</widget_lblBehavior> <widget_lblChangeD type='str'>Changement inf.</widget_lblChangeD> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-11 15:13:12 UTC (rev 602) @@ -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_description type='str'>Light monitor for tux droid</gadget_description> - <gadget_name type='str'>light_monitor</gadget_name> </about> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-11 15:13:12 UTC (rev 602) @@ -1,35 +1,12 @@ <?xml version='1.0' encoding='UTF-8'?> <settings> <parameters> - <change_notified type='bool'>False</change_notified> - <chk_ThresholdBehavior type='bool'>False</chk_ThresholdBehavior> - <increase_rad type='bool'>True</increase_rad> - <chk_ChangeBehavior type='bool'>False</chk_ChangeBehavior> - <changeU_time type='float'>1.0</changeU_time> - <test_tab type='list'>[[1, 0, 0, 10.0, 2.0, True, 'None', False, 0]]</test_tab> - <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> - <raise type='float'>10.0</raise> - <changeU_rad type='bool'>False</changeU_rad> - <threshold_notified type='bool'>False</threshold_notified> + <test_tab type='list'>[[1, 0, 0, 0.10000000000000001, 20.0, True, 'None', False, 0]]</test_tab> <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> + <Rate type='float'>10.0</Rate> <MainScript type='str'> </MainScript> - <behavior_file_threshold type='NoneType'>None</behavior_file_threshold> - <threshold_chk type='bool'>False</threshold_chk> - <Rate type='float'>1.0</Rate> - <changeD_time type='float'>1.0</changeD_time> - <both_rad type='bool'>False</both_rad> + <Sample type='float'>600.0</Sample> </parameters> <general> <gui_state> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-11 07:44:02 UTC (rev 601) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-11 15:13:12 UTC (rev 602) @@ -3,13 +3,16 @@ <conf_lblIncrease type='str'>Increase</conf_lblIncrease> <conf_lblThreshold type='str'>Threshold</conf_lblThreshold> <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> @@ -17,19 +20,19 @@ <conf_lblDecrease type='str'>Decrease</conf_lblDecrease> <gui_conf_version_lb type='str'>Version</gui_conf_version_lb> <gui_conf_update_title type='str'>Update</gui_conf_update_title> - <widget_lblValue type='str'>Value (%)</widget_lblValue> + <widget_lblValue type='str'>Value (V)</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> + <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> - <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> + <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> <speaker_name type='str'>Ryan8k</speaker_name> <conf_lblSample type='str'>Samples</conf_lblSample> - <conf_lblType type='str'>Type</conf_lblType> + <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> @@ -44,10 +47,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> - <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> <widget_lblChange type='str'>Change</widget_lblChange> <widget_lblLight type='str'>Search light</widget_lblLight> @@ -55,14 +58,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_lblNotified type='str'>Notified ?</conf_lblNotified> + <conf_lblType type='str'>Type</conf_lblType> <widget_lblSet type='str'>Add to config</widget_lblSet> - <conf_lblValue type='str'>Value (%)</conf_lblValue> + <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> - <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> |
From: Paul_R <c2m...@c2...> - 2007-10-11 07:44:29
|
Author: Paul_R Date: 2007-10-11 09:44:02 +0200 (Thu, 11 Oct 2007) New Revision: 601 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/about.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml Log: * Split the draw function's in the Graph class into smaller sub-functions. 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-10 15:04:47 UTC (rev 600) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-11 07:44:02 UTC (rev 601) @@ -19,7 +19,7 @@ self.context.rectangle(event.area.x, event.area.y, event.area.width, event.area.height) self.context.clip() - self.draw(self.context) + self.draw() return False def refresh(self): @@ -27,92 +27,110 @@ width,height = self.window.get_size() self.window.invalidate_rect(gtk.gdk.Rectangle(0,0,width,height),False) - def draw(self, context): - rect = self.get_allocation() - #draw axes + def draw(self): + self.rect = self.get_allocation() + + self.draw_space() + self.draw_hor_div() + self.draw_ver_div() + self.draw_label() + self.draw_curve() + + def draw_space(self): + #draw axes #draw a rectangle in the window area - context.rectangle(rect.x, rect.y, rect.width, rect.height) + self.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() + self.context.set_source_rgb(1, 1, 1) + self.context.fill() #draw a black border - context.set_source_rgb(0, 0, 0) - context.set_line_width(1) - context.stroke() - + self.context.set_source_rgb(0, 0, 0) + self.context.set_line_width(1) + self.context.stroke() + + + def draw_hor_div(self): #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) + self.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) - context.set_line_width(0.4) - context.line_to(0, y) + self.context.set_source_rgb(0.2, 0.2, 0.2) + self.context.set_line_width(0.4) + self.context.line_to(0, y) else: #Major div: place text - context.set_source_rgb(0, 0, 0) - context.set_line_width(0.6) - context.line_to(0, y) - context.set_source_rgb(0.2, 0.2, 0.2) + self.context.set_source_rgb(0, 0, 0) + self.context.set_line_width(0.6) + self.context.line_to(0, y) + self.context.set_source_rgb(0.2, 0.2, 0.2) if i != 18: - context.show_text(str(6.5 - (0.125 * i))+' V') - context.stroke() - - #draw vertical division + self.context.show_text(str(6.5 - (0.125 * i))+' V') + self.context.stroke() + + def draw_ver_div(self): + #draw vertical division #create a tab with the wanted divisions temp_tab = [0.25, 0.5, 0.75] for i in range(3): - context.set_source_rgb(0.2, 0.2, 0.2) - context.set_line_width(0.6) + self.context.set_source_rgb(0.2, 0.2, 0.2) + self.context.set_line_width(0.6) #place correctly the vector - context.move_to(rect.width * temp_tab[i], 0) + self.context.move_to(self.rect.width * temp_tab[i], 0) #trace a line - context.line_to(rect.width * temp_tab[i], rect.height) + self.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) + self.context.move_to(self.rect.width * temp_tab[i], self.rect.height - 5) #determine the time labels - context.show_text(str((self.measure_graph.rate * self.measure_graph.sample) - ((self.measure_graph.rate) * + self.context.show_text(str((self.measure_graph.rate * self.measure_graph.sample) - ((self.measure_graph.rate) * self.measure_graph.sample * temp_tab[i])) + " sec.") - context.stroke() + self.context.stroke() + def draw_label(self): #display sample and rate #move the vector in the bottom - context.move_to(5, rect.height - 10) + self.context.move_to(5, self.rect.height - 10) #display the rate - context.show_text("rate = "+str(self.measure_graph.rate)+" sec.") - context.move_to(5, rect.height - 20) + self.context.show_text("rate = "+str(self.measure_graph.rate)+" sec.") + self.context.move_to(5, self.rect.height - 20) #and the samples - context.show_text("samples = "+str(self.measure_graph.sample)) - context.stroke() - - #determine the coefficients to adjust the curve in the window space - coeff_y = float(rect.height / 340.00) - coeff_x = float(rect.width / (self.measure_graph.sample - 1)) + self.context.show_text("samples = "+str(self.measure_graph.sample)) + self.context.stroke() - #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.measure_graph.val_table[0] * coeff_y)) - for i, val in enumerate(self.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.close_path() - context.set_source_rgba(1.0, 0, 0, 0.2) - context.fill() + def draw_curve(self): + coeff_y = float(self.rect.height / 340.00) + coeff_x = float(self.rect.width / (self.measure_graph.sample - 1)) + self.fill(coeff_x, coeff_y) + #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.measure_graph.val_table[0] * coeff_y)) + self.context.set_line_width(0.6) + self.context.set_source_rgb(1, 0, 0) + self.context.move_to(self.rect.x - 2, self.rect.height + 2) + self.context.line_to(self.rect.x, self.rect.height - (self.measure_graph.val_table[0] * coeff_y)) for i, val in enumerate(self.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.stroke() + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) + self.context.stroke() + + def fill(self, coeff_x, coeff_y): + #determine the coefficients to adjust the curve in the window space + #Fill... + self.context.set_line_width(0.6) + self.context.set_source_rgb(0, 0, 1) + self.context.move_to(self.rect.x - 2, self.rect.height + 2) + self.context.line_to(self.rect.x, self.rect.height - (self.measure_graph.val_table[0] * coeff_y)) + for i, val in enumerate(self.measure_graph.val_table): + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - (val * coeff_y)) + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) + self.context.close_path() + self.context.set_source_rgba(1.0, 0, 0, 0.2) + self.context.fill() + + class Measure(): def __init__(self): #Initial value @@ -326,33 +344,30 @@ # ########################################################### def on_battery_level(self, args): - try: - print 'battery received' - self.__on_battery_mutex.acquire() - self.average += (args[0] * 256) + args[1] - self.count += 1 - if self.sample_backup != self.sample: - self.sample = self.sample_backup - self.val_table = [-2] * int(self.sample) - if self.rate_backup != self.rate: - self.rate_has_changed() + self.__on_battery_mutex.acquire() + self.average += (args[0] * 256) + args[1] + self.count += 1 + if self.sample_backup != self.sample: + self.sample = self.sample_backup + self.val_table = [-2] * int(self.sample) + if self.rate_backup != self.rate: + self.rate_has_changed() - if self.tick <= time.time(): - print self.average - self.tick = time.time() + self.rate - val = self.average / self.count - val = val - 530 - self.val_table.append(val) - self.val_table.pop(0) - self.average = 0 - self.count = 0 - if self.GUI_on: - self.graph_measure.refresh() - self.event_control() - self.__on_battery_mutex.release() - except: - print sys.exc_info() + if self.tick <= time.time(): + self.tick = time.time() + self.rate + val = self.average / self.count + val = val - 530 + self.val_table.append(val) + self.val_table.pop(0) + self.average = 0 + self.count = 0 + if self.GUI_on: + self.graph_measure.refresh() + self.event_control() + self.__on_battery_mutex.release() + + def rate_has_changed(self): self.rate = self.rate_backup pts_per_sec = self.sample / (self.rate * self.sample) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-10 15:04:47 UTC (rev 600) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/about.xml 2007-10-11 07:44:02 UTC (rev 601) @@ -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/battery_monitor/trunk/Battery_monitor_svn/settings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-10 15:04:47 UTC (rev 600) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml 2007-10-11 07:44:02 UTC (rev 601) @@ -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'>1.0</Rate> <changeD_time type='float'>1.0</changeD_time> Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-10 15:04:47 UTC (rev 600) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml 2007-10-11 07:44:02 UTC (rev 601) @@ -4,14 +4,12 @@ <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> @@ -21,17 +19,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 +44,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 +55,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> |
Author: Paul_R Date: 2007-10-10 17:04:47 +0200 (Wed, 10 Oct 2007) New Revision: 600 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/GUI/conf/other.glade software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/main.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: * Change the previous battery_monitor to accord with the last changes made in the light_monitor gadget 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-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-10 15:04:47 UTC (rev 600) @@ -34,7 +34,7 @@ context.rectangle(rect.x, rect.y, rect.width, rect.height) #set a white background context.set_source_rgb(1, 1, 1) - context.fill_preserve() + context.fill() #draw a black border context.set_source_rgb(0, 0, 0) context.set_line_width(1) @@ -56,16 +56,9 @@ context.set_line_width(0.6) context.line_to(0, y) context.set_source_rgb(0.2, 0.2, 0.2) - context.show_text(str((10-(i/2))*10)+"%") + if i != 18: + context.show_text(str(6.5 - (0.125 * i))+' V') context.stroke() - - #draw the threshold line - if self.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.measure_graph.val_threshold / 100.0))) - context.line_to(rect.width, rect.height - (rect.height * (self.measure_graph.val_threshold / 100.0))) - context.stroke() #draw vertical division #create a tab with the wanted divisions @@ -86,55 +79,58 @@ #display sample and rate #move the vector in the bottom - context.move_to(10, rect.height - 10) + context.move_to(5, rect.height - 10) #display the rate context.show_text("rate = "+str(self.measure_graph.rate)+" sec.") - context.move_to(10, rect.height - 20) + context.move_to(5, rect.height - 20) #and the samples context.show_text("samples = "+str(self.measure_graph.sample)) context.stroke() #determine the coefficients to adjust the curve in the window space - coeff_y = float(rect.height / 1024.00) + coeff_y = float(rect.height / 340.00) coeff_x = float(rect.width / (self.measure_graph.sample - 1)) - - #trace the curve - context.move_to(rect.x, rect.height) - context.set_source_rgb(1.0, 0, 0) + + #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.measure_graph.val_table[0] * coeff_y)) for i, val in enumerate(self.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.close_path() + context.set_source_rgba(1.0, 0, 0, 0.2) + context.fill() + + #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.measure_graph.val_table[0] * coeff_y)) + for i, val in enumerate(self.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.stroke() class Measure(): def __init__(self): #Initial value self.sample = 500.0 - self.val_table = [0] * int(self.sample + 1) - self.value = 0 - self.timecontrol = time.time() + self.sample_backup = self.sample + self.val_table = [-2] * int(self.sample + 1) + self.test_tab = [0] self.rate = 1.0 - self.threshold_chk = False - - self.increase = False - self.decrease = False - self.both = False - self.drop = False - self.raising = False - self.changeD = False - self.changeU = False - - #Events flags - self.threshold_event = False - self.change_event = False - - self.GUI_on = False - self.notify = True - - self.timeout = 0 + self.rate_backup = self.rate + self.tick = time.time() + self.rate + self.average = 0 + self.count = 0 + 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.__on_battery_mutex = threading.Lock() self.__timeout_mutex = threading.Lock() @@ -145,88 +141,73 @@ # ########################################################### def event_control(self): - if self.GUI_on == False: - for i in range (len(self.event_tab)): - self.Threshold_control(i) - self.Change_control(i) + if self.GUI_on: + self.__tab = self.test_tab + else: + self.__tab = self.event_tab + + for i in range (len(self.__tab)): + self.Threshold_control(i) + self.Change_control(i) - #Gadget or test notifications - else: - self.test_func() - #disable gadget notifications - self.notify = False - + if self.GUI_on: + self.test_tab = self.__tab + else: + self.event_tab = self.__tab + + if self.GUI_on: #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: - self.change_event = False - self.threshold_event = False + self.test_tab[0][7] = False self.start_flag = False for i in range (len(self.event_tab)): self.event_tab[i][7] = False - - def change_control(self): - # Determine how many point must be checked for changes events - pts_per_sec = self.sample / (self.rate * self.sample) - - if self.val_drop_time >= 0.1 and self.val_drop > 0: - self.drop_point = int(self.val_drop_time * pts_per_sec) - self.set_timeout(self.drop_point) - if self.val_raise_time >= 0.1 and self.val_raise > 0: - self.raise_point = int(self.val_raise_time * pts_per_sec) - self.set_timeout(self.raise_point) - if self.val_changeD_time >= 0.1 and self.val_changeD > 0: - self.changeD_point = int(self.val_changeD_time * pts_per_sec) - self.set_timeout(self.changeD_point) - if self.val_changeU_time >= 0.1 and self.val_changeU > 0: - self.changeU_point = int(self.val_changeU_time * pts_per_sec) - self.set_timeout(self.changeU_point) - + ########################################################### # # Threshold control # ########################################################### def Threshold_control(self, index): - if self.event_tab[index][1] == 1: - if self.event_tab[index][7] != True: - if self.event_tab[index][2] == 0: + if self.__tab[index][1] == 1: + if self.__tab[index][7] != True: + if self.__tab[index][2] == 0: #Increasing threshold control - if self.Increase_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True - elif self.event_tab[index][2] == 1: + if self.Increase_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True + elif self.__tab[index][2] == 1: #Decreasing threshold control - if self.Decrease_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True - elif self.event_tab[index][2] == 2: + if self.Decrease_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True + elif self.__tab[index][2] == 2: #Both direction theshold control - if self.Both_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True + if self.Both_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True def Increase_control(self, value): - val_act = (self.val_table[len(self.val_table)-1]*100) / 1024.0 - val_prev = (self.val_table[len(self.val_table)-2]*100) / 1024.0 + val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 + val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 if val_prev <= value and val_act > value: return True def Decrease_control(self, val): - val_act = (self.val_table[len(self.val_table)-1]*100) / 1024.0 - val_prev = (self.val_table[len(self.val_table)-2]*100) / 1024.0 + val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 + val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 if val_prev >= val and val_act < val: return True def Both_control(self, val): - val_act = (self.val_table[int(len(self.val_table)-1)]*100) / 1024.0 - val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / 1024.0 + val_act = (self.val_table[int(len(self.val_table)-1)]*100) / 1124.0 + val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / 1124.0 if val_prev <= val and val_act > val or val_prev >= val and val_act < val: return True @@ -238,96 +219,64 @@ ########################################################### def Change_control(self, i): #Changements control - if self.event_tab[i][1] == 0: + if self.__tab[i][1] == 0: pts_per_sec = self.sample / (self.rate * self.sample) - time = int(self.event_tab[i][4] * pts_per_sec) - if self.event_tab[i][7] != True: + time = int(self.__tab[i][4] * pts_per_sec) + if self.__tab[i][7] != True: # Drop change part : - if self.event_tab[i][2] == 0: - if self.Drop_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 0: + if self.Drop_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Raise change part - if self.event_tab[i][2] == 1: - if self.Raise_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 1: + if self.Raise_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Drop and Raise change - if self.event_tab[i][2] == 2: - if self.ChangeD_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 2: + if self.ChangeD_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Raise and Drop change - if self.event_tab[i][2] == 3: - if self.ChangeU_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True - + if self.__tab[i][2] == 3: + if self.ChangeU_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True + + def Drop_control(self, time, val, timeout, index): #timeout control : to prevent multiple notifications with the same event 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]) - - if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*1024): - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.set_timeout(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) return True else: - if self.GUI_on: - self.set_timeout(timeout) - else: - self.event_tab[index][8] = timeout + self.__tab[index][8] = timeout 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]) - + 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)*1024): - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.set_timeout(int(time)) + if minimum <= self.val_table[len(self.val_table)-1] - ((val/100)*1124): + self.__tab[index][8] = int(time) return True else: - if self.GUI_on: - self.set_timeout(timeout) - else: - self.event_tab[index][8] = timeout + 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)*1024): + 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]) if maximum >= self.val_table[len(self.val_table) - 1 - i] + val: - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.set_timeout(int(time)) + self.__tab[index][8] = int(time) return True - if self.GUI_on: - self.set_timeout(timeout) - else: - self.event_tab[index][8] = timeout + self.__tab[index][8] = timeout return False @@ -335,25 +284,14 @@ 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)*1024): + 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]) if minimum <= self.val_table[len(self.val_table) - 1 - i] - val: - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.set_timeout(int(time)) + self.__tab[index][8] = int(time) return True - if self.GUI_on: - self.set_timeout(timeout) - else: - self.event_tab[index][8] = timeout + self.__tab[index][8] = timeout return False @@ -362,107 +300,76 @@ # Test functions # ########################################################### - def test_func(self): - if self.threshold_event != True: - #Decrease threshold control - if self.decrease: - if self.Decrease_control(self.val_threshold) == True: - self.threshold_event = True - #Increasing threshold control - if self.increase: - if self.Increase_control(self.val_threshold) == True: - self.threshold_event = True - #Both direction theshold control - if self.both: - if self.Both_control(self.val_threshold) == True: - self.threshold_event = True - - #Changements control - if self.change_event != True: - timeout = self.get_timeout() - # Drop change part : - if self.drop == True and self.val_drop_time > 0.0: - if self.Drop_control(self.drop_point, self.val_drop, timeout, 0) == True: - self.change_event = True - # Raise change part - if self.raising == True and self.val_raise_time > 0.0: - if self.Raise_control(self.raise_point, self.val_raise, timeout, 0) == True: - self.change_event = True - # Drop and Raise change - if self.changeD == True and self.val_changeD_time > 0.0: - if self.ChangeD_control(self.changeD_point, self.val_changeD, timeout, 0) == True: - self.change_event = True - # Raise and Drop change - if self.changeU == True and self.val_changeU_time > 0.0: - if self.ChangeU_control(self.changeU_point, self.val_changeU, timeout, 0) == True: - self.change_event = True - - def test_notification(self): - if self.threshold_event == True: - if self.threshold_notified: - path = self.change_behavior - path = "'%s'" % path - if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior) and os.path.exists(self.threshold_behavior): - self.threshold_event = False + if self.test_tab[0][7] == True: + self.test_tab[0][7] = False + if self.test_tab[0][5] == True: + path = self.test_tab[0][6] + path = path.replace('%20', ' ') + if os.path.isfile(path) and os.path.exists(path): + path = self.test_tab[0][6] + path = "'%s'" % path tux.sys.shell_free(path) - else: - self.threshold_event = False - thread.start_new_thread(self.test_default_behavior, (self.thresholdtext,)) - else: - self.threshold_event = False - - elif self.change_event == True: - if self.change_notified: - path = self.change_behavior - path = "'%s'" % path - if self.change_behavior_chk and os.path.isfile(self.change_behavior) and os.path.exists(self.change_behavior): - self.change_event = False - tux.sys.shell_free(path) - else: - self.change_event = False + elif self.test_tab[0][1] == 0: thread.start_new_thread(self.test_default_behavior, (self.changetext,)) - else: - self.change_event = False - + elif self.test_tab[0][1] == 1: + thread.start_new_thread(self.test_default_behavior, (self.thresholdtext,)) + def test_default_behavior(self, txt): tux.cmd.mouth_open() tux.tts.speak(txt) tux.cmd.mouth_close() - - + ########################################################### # # Acquire # ########################################################### def on_battery_level(self, args): - self.__on_battery_mutex.acquire() - if self.timecontrol <= time.time(): - self.timecontrol = 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.graph_measure.refresh() - self.event_control() - self.__on_battery_mutex.release() + try: + print 'battery received' + self.__on_battery_mutex.acquire() + self.average += (args[0] * 256) + args[1] + self.count += 1 + if self.sample_backup != self.sample: + self.sample = self.sample_backup + self.val_table = [-2] * int(self.sample) + if self.rate_backup != self.rate: + self.rate_has_changed() + + if self.tick <= time.time(): + print self.average + self.tick = time.time() + self.rate + val = self.average / self.count + val = val - 530 + self.val_table.append(val) + self.val_table.pop(0) + self.average = 0 + self.count = 0 + if self.GUI_on: + self.graph_measure.refresh() + self.event_control() + self.__on_battery_mutex.release() + except: + print sys.exc_info() - - ########################################################### - # - # Timeout management - # - ########################################################### - def set_timeout(self, val): - self.__timeout_mutex.acquire() - self.timeout = val - self.__timeout_mutex.release() - - def get_timeout(self): - self.__timeout_mutex.acquire() - val = self.timeout - self.__timeout_mutex.release() - return val + def rate_has_changed(self): + self.rate = self.rate_backup + pts_per_sec = self.sample / (self.rate * self.sample) + for i in range(len(self.event_tab)): + if self.event_tab[i][1] == 0: + if self.event_tab[i][4] <= self.rate: + self.event_tab[i][4] = self.rate + elif self.event_tab[i][4] >= self.rate * self.sample: + self.event_tab[i][4] = self.rate * self.sample + self.event_tab[i][8] = int(self.event_tab[i][4] * pts_per_sec) + if self.test_tab[0][1] == 0: + if self.test_tab[0][4] <= self.rate: + self.test_tab[0][4] = self.rate + elif self.test_tab[0][4] >= self.rate * self.sample: + self.test_tab[0][4] = self.rate * self.sample + self.test_tab[0][8] = int(self.test_tab[0][4] * pts_per_sec) + self.test_tab[0][8] = int(self.test_tab[0][4] * pts_per_sec) + Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp 2007-10-10 15:04:47 UTC (rev 600) @@ -10,10 +10,14 @@ def new(self): self.measure = _me.get_param('measure') - _me.insert_funct('refresh_tree', self.refresh_tree) + _me.insert_funct('refresh_tree', self.refresh_tree) + _me.insert_funct('verify_tab', self.verify_tab) self.updates_commons() self.make_viewtree() self.update_labels() + + + def updates_commons(self): # Window title @@ -60,7 +64,7 @@ ########################################################### # - # Light configuration control + # Battery configuration control # ########################################################### def make_viewtree(self): @@ -120,7 +124,8 @@ self.get_widget('cbb_conf_event').set_active(0) self.get_widget('txt_conf_value').set_text('1.0') self.get_widget('txt_conf_time').set_text('0.1') - self.gadget_viewer.connect("row_activated", self.on_row_selected) + self.gadget_viewer.get_selection().connect("changed",self.on_row_selected) + #self.gadget_viewer.connect("row_activated", self.on_row_selected) self.measure.event_tab = _me.get_param('config') self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblChange')) self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblThreshold')) @@ -129,7 +134,6 @@ for i in range(len(self.measure.event_tab)): self.add_row(i) - ########################################################### # # Update the labels @@ -137,6 +141,7 @@ ########################################################### def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) + self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) @@ -149,6 +154,7 @@ self.get_widget("lbl_conf_sample").set_text(_me.string('conf_lblSample')) self.get_widget("lbl_conf_rate").set_text(_me.string('conf_lblRate')) self.get_widget("lblControlFrame").set_text(_me.string('conf_lblControl')) + self.get_widget("lblScript").set_text(_me.string('MainBehavior')) ########################################################### @@ -156,15 +162,16 @@ # On row selected # ########################################################### - def on_row_selected(self, treeview, path, view_column): - self.iter = self.value_list.get_iter(path) - index = self.value_list.get_value(self.iter, 0) - event = self.value_list.get_value(self.iter, 1) - typet = self.value_list.get_value(self.iter, 2) - value = self.value_list.get_value(self.iter, 3) - time = self.value_list.get_value(self.iter, 4) - notify = self.value_list.get_value(self.iter, 5) - behavior = self.value_list.get_value(self.iter, 6) + def on_row_selected(self, obj): + path = obj.get_selected_rows() + self.__iter = self.value_list.get_iter(path[1][0]) + index = self.value_list.get_value(self.__iter, 0) + event = self.value_list.get_value(self.__iter, 1) + typet = self.value_list.get_value(self.__iter, 2) + value = self.value_list.get_value(self.__iter, 3) + time = self.value_list.get_value(self.__iter, 4) + notify = self.value_list.get_value(self.__iter, 5) + behavior = self.value_list.get_value(self.__iter, 6) if event == _me.string('conf_lblChange'): self.get_widget('cbb_conf_event').set_active(0) @@ -200,15 +207,15 @@ self.get_widget('conf_behavior').set_filename(behavior) else: self.get_widget('conf_behavior').set_filename('None') + - ########################################################### # # On row modified # ########################################################### def on_btn_conf_modify_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab = _me.get_param('config') length = len(_me.get_param('config')) @@ -225,11 +232,13 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab[(index-1)] = value - _me.set_param('config', self.measure.event_tab) - self.value_list.clear() - for i in range(len(self.measure.event_tab)): - self.add_row(i) + + if self.verify_tab(value): + self.measure.event_tab[(index-1)] = value + _me.set_param('config', self.measure.event_tab) + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) ########################################################### # @@ -237,11 +246,11 @@ # ########################################################### def on_btn_conf_remove_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab =_me.get_param('config') self.measure.event_tab.pop(index - 1) _me.set_param('config', self.measure.event_tab) - self.iter = 0 + self.__iter = 0 self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) @@ -265,14 +274,27 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab.append(value) - self.refresh_tree() + if self.verify_tab(value): + self.measure.event_tab.append(value) + self.refresh_tree() def refresh_tree(self): _me.set_param('config', self.measure.event_tab) self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) + + + def verify_tab(self, tab): + for i in range(len(self.measure.event_tab)): + if self.measure.event_tab[i][1] == tab[1]: + if self.measure.event_tab[i][2] == tab[2]: + if self.measure.event_tab[i][3] == tab[3]: + if self.measure.event_tab[i][4] == tab[4]: + if self.measure.event_tab[i][5] == tab[5]: + if self.measure.event_tab[i][6] == tab[6]: + return False + return True ########################################################### # @@ -349,8 +371,9 @@ def on_accept_clicked(self, widget, *args): _me.set_param('Rate', float(self.get_widget('txt_conf_rate').get_text())) _me.set_param('Sample',float(self.get_widget('txt_conf_sample').get_text())) - self.measure.rate = _me.get_param('Rate') - self.measure.sample = _me.get_param('Sample') + _me.set_param(('MainScript'), str(self.get_widget('mainScript').get_filename())) + self.measure.rate_backup = _me.get_param('Rate') + self.measure.sample_backup = _me.get_param('Sample') _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) @@ -372,7 +395,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) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab[index-1][6] = None self.value_list.clear() @@ -388,10 +411,10 @@ try: float(self.get_widget('txt_conf_time').get_text()) except: - self.get_widget('txt_conf_time').set_text('1.0') + self.get_widget('txt_conf_time').set_text('0.1') - if float(self.get_widget('txt_conf_time').get_text()) < 1.0: - self.get_widget('txt_conf_time').set_text('1.0') + if float(self.get_widget('txt_conf_time').get_text()) < self.measure.rate: + self.get_widget('txt_conf_time').set_text(str(self.measure.rate)) if float(self.get_widget('txt_conf_time').get_text()) > self.measure.rate * self.measure.sample: self.get_widget('txt_conf_time').set_text(str(self.measure.rate * self.measure.sample)) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade =================================================================== (Binary files differ) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-10 15:04:47 UTC (rev 600) @@ -16,70 +16,36 @@ # ########################################################### def new(self): - #Fill the text box with the previous values - self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) - self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) - self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) - self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) - self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) - self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) - self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) - self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) - self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) - self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) - self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) - - #Restore the previous radio button status - self.get_widget('radDrop').set_active(_me.get_param('drop_rad')) - self.get_widget('radRaise').set_active(_me.get_param('raise_rad')) - self.get_widget('radChangeD').set_active(_me.get_param('changeD_rad')) - self.get_widget('radChangeU').set_active(_me.get_param('changeU_rad')) - self.get_widget('radIncrease').set_active(_me.get_param('increase_rad')) - self.get_widget('radDecrease').set_active(_me.get_param('decrease_rad')) - self.get_widget('radBoth').set_active(_me.get_param('both_rad')) - - #Restore the check boxes - self.get_widget('chkThreshold').set_active(_me.get_param('threshold_chk')) - self.get_widget('chk_ThresholdBehavior').set_active(_me.get_param('chk_ThresholdBehavior')) - self.get_widget('chk_ChangeBehavior').set_active(_me.get_param('chk_ChangeBehavior')) self.get_widget("window1").set_title(_me.string('name_to_read')) + self.get_widget("lblThreshold").set_text(_me.string('widget_lblTest')) - #Set the labels - self.get_widget("radBoth").set_label(_me.string('widget_lblBoth')) - self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) - self.get_widget("lblChange").set_text(_me.string('widget_lblChange')) - self.get_widget("radChangeD").set_label(_me.string('widget_lblChangeD')) - self.get_widget("radChangeU").set_label(_me.string('widget_lblChangeU')) - self.get_widget("radDecrease").set_label(_me.string('widget_lblDecrease')) - self.get_widget("radDrop").set_label(_me.string('widget_lblDrop')) - self.get_widget("lblEventChange").set_text(_me.string('widget_lblEvent')) - self.get_widget("lblEventThreshold").set_text(_me.string('widget_lblEvent')) - self.get_widget("radIncrease").set_label(_me.string('widget_lblIncrease')) - self.get_widget("radRaise").set_label(_me.string('widget_lblRaise')) - self.get_widget("lblThreshold").set_text(_me.string('widget_lblThreshold')) - self.get_widget("lblValue").set_text(_me.string('widget_lblValue')) - self.get_widget("lblControl").set_text(_me.string('widget_lblControl')) - self.get_widget("chkThreshold").set_label(_me.string('widget_lblDisplayThreshold')) - self.get_widget('chk_ThresholdBehavior').set_label(_me.string('widget_lblBehavior')) - self.get_widget('chk_ChangeBehavior').set_label(_me.string('widget_lblBehavior')) - self.get_widget('chkChangeNotified').set_label(_me.string('widget_lblNotified')) - self.get_widget('chkThresholdNotified').set_label(_me.string('widget_lblNotified')) - self.get_widget("lblRate").set_text(_me.string('gui_conf_rate_lb')) - self.get_widget("lblSample").set_text(_me.string('gui_conf_sample_lb')) self.get_widget("lblBtnDark").set_label(_me.string('widget_lblDark')) self.get_widget("lblBtnLight").set_label(_me.string('widget_lblLight')) - self.get_widget("btnSet").set_label(_me.string('widget_lblSet')) + self.get_widget("btnAdd").set_label(_me.string('widget_lblSet')) - for i in range (7): - self.get_widget('cbbConfig').remove_text(0) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblDrop')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblRaise')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblChangeD')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblChangeU')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblIncrease')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblDecrease')) - self.get_widget('cbbConfig').append_text(_me.string('conf_lblBoth')) - self.get_widget('cbbConfig').set_active(0) + self.get_widget('txtValue').set_text('1.0') + self.get_widget('txtTime').set_text('0.1') + + self.get_widget('cbbEvent').append_text(_me.string('conf_lblChange')) + self.get_widget('cbbEvent').append_text(_me.string('conf_lblThreshold')) + self.get_widget('cbbEvent').set_active(0) + + self.get_widget("lblEvent").set_text(_me.string('conf_lblEvent')) + self.get_widget("lblType").set_text(_me.string('conf_lblType')) + self.get_widget("lblValue").set_text(_me.string('conf_lblValue')) + self.get_widget("lblTime").set_text(_me.string('conf_lblTime')) + self.get_widget("lblNotify").set_text(_me.string('conf_lblNotified')) + self.get_widget("lblScript").set_text(_me.string('conf_lblBehavior')) + self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) + + tab = _me.get_param('test_tab') + self.get_widget('cbbEvent').set_active(tab[0][1]) + self.get_widget('cbbType').set_active(tab[0][2]) + self.get_widget('txtValue').set_text(str(tab[0][3])) + self.get_widget('txtTime').set_text(str(tab[0][4])) + self.get_widget('chkNotify').set_active(tab[0][5]) + self.get_widget('Behavior').set_filename(tab[0][6]) + thread.start_new_thread(self.update, ()) ########################################################### @@ -88,66 +54,10 @@ # ########################################################### def update_value(self): - #Rate - _me.set_param('Rate', self.measure.rate) - self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) - - #Sample - _me.set_param('Sample', self.measure.sample) - self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) - - #Drop - _me.set_param('drop', self.measure.val_drop) - self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) - _me.set_param('drop_time', self.measure.val_drop_time) - self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) - - #Raise - _me.set_param('raise', self.measure.val_raise) - self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) - _me.set_param('raise_time', self.measure.val_raise_time) - self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) - - #Drop and raise - _me.set_param('changeD', self.measure.val_changeD) - self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) - _me.set_param('changeD_time', self.measure.val_changeD_time) - self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) - - #Raise and drop - _me.set_param('changeU', self.measure.val_changeU) - self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) - _me.set_param('changeU_time', self.measure.val_changeU_time) - self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) - - #Threshold - _me.set_param('threshold', self.measure.val_threshold) - self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) - - self.measure.change_control() - - #update the radio button status - self.measure.drop = _me.get_param('drop_rad') - self.measure.raising = _me.get_param('raise_rad') - self.measure.changeD = _me.get_param('changeD_rad') - self.measure.changeU = _me.get_param('changeU_rad') - self.measure.increase = _me.get_param('increase_rad') - self.measure.decrease = _me.get_param('decrease_rad') - self.measure.both = _me.get_param('both_rad') self.measure.changetext = _me.string('conf_lblChange') self.measure.thresholdtext = _me.string('conf_lblThreshold') - # '' the check boxes - self.measure.change_notified = _me.get_param('change_notified') - self.measure.threshold_notified = _me.get_param('threshold_notified') - self.measure.threshold_chk = _me.get_param('threshold_chk') - self.measure.threshold_behavior_chk = _me.get_param('chk_ThresholdBehavior') - self.measure.change_behavior_chk = _me.get_param('chk_ChangeBehavior') - - - - ########################################################### # # Event functions @@ -156,133 +66,72 @@ def on_window1_destroy(self, widget, *args): _me.get_param('measure').GUI_on = False self.measure.GUI_on = False - + def on_btnAdd_clicked(self, widget, *args): + length = len(_me.get_param('config')) + self.verify_value() + value = [] + value = [(length + 1), + self.get_widget('cbbEvent').get_active(), + self.get_widget('cbbType').get_active(), + float(self.get_widget('txtValue').get_text()), + float(self.get_widget('txtTime').get_text()), + self.get_widget('chkNotify').get_active(), + str(self.get_widget('Behavior').get_filename()), + False, + 0] + self.measure.event_tab = _me.get_param('config') + verify_tab = _me.get_funct('verify_tab') + if verify_tab(value): + self.measure.event_tab.append(value) + refresh_tree = _me.get_funct('refresh_tree') + refresh_tree() + + def on_btnApply_clicked(self, widget, *args): + length = len(_me.get_param('config')) + self.verify_value() + value = [] + value = [(length + 1), + self.get_widget('cbbEvent').get_active(), + self.get_widget('cbbType').get_active(), + float(self.get_widget('txtValue').get_text()), + float(self.get_widget('txtTime').get_text()), + self.get_widget('chkNotify').get_active(), + str(self.get_widget('Behavior').get_filename()), + False, + 0] + self.measure.test_tab[0] = value + _me.set_param('test_tab', value) - def on_btnSet_clicked(self, widget, *args): - - if self.measure.threshold_behavior_chk: - threshold_script = self.measure.threshold_behavior - else: - threshold_script = None + - if self.measure.change_behavior_chk: - change_script = self.measure.change_behavior + def on_expander_activate(self, widget, *args): + self.get_widget('txtValue').set_text(str(self.measure.test_tab[0][3])) + self.get_widget('txtTime').set_text(str(self.measure.test_tab[0][4])) + + ########################################################### + # + # On combo box event + # + ########################################################### + def on_cbb_conf_event_changed(self, widget, *args): + if self.get_widget('cbbEvent').get_active() == 0: + for i in range (4): + self.get_widget('cbbType').remove_text(0) + 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')) + self.get_widget('cbbType').append_text(_me.string('conf_lblChangeU')) + self.get_widget('cbbType').set_active(0) else: - change_script = None + for i in range (4): + self.get_widget('cbbType').remove_text(0) + self.get_widget('cbbType').append_text(_me.string('conf_lblIncrease')) + self.get_widget('cbbType').append_text(_me.string('conf_lblDecrease')) + self.get_widget('cbbType').append_text(_me.string('conf_lblBoth')) + self.get_widget('cbbType').set_active(0) - if self.get_widget('cbbConfig').get_active() == 0: - val = [len(self.measure.event_tab)+1, 0, 0, - self.measure.val_drop, - self.measure.val_drop_time, - self.measure.change_notified, - change_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 1: - val = [len(self.measure.event_tab)+1, 0, 1, - self.measure.val_raise, - self.measure.val_raise_time, - self.measure.change_notified, - change_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 2: - val = [len(self.measure.event_tab)+1, 0, 2, - self.measure.val_changeD, - self.measure.val_changeD_time, - self.measure.change_notified, - change_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 3: - val = [len(self.measure.event_tab)+1, 0, 3, - self.measure.val_changeU, - self.measure.val_changeU_time, - self.measure.change_notified, - change_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 4: - val = [len(self.measure.event_tab)+1, 1, 0, - self.measure.val_threshold, - 0, - self.measure.threshold_notified, - threshold_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 5: - val = [len(self.measure.event_tab)+1, 1, 1, - self.measure.val_threshold, - 0, - self.measure.threshold_notified, - threshold_script, - False, - 0] - elif self.get_widget('cbbConfig').get_active() == 6: - val = [len(self.measure.event_tab)+1, 1, 2, - self.measure.val_threshold, - 0, - self.measure.threshold_notified, - threshold_script, - False, - 0] - self.measure.event_tab.append(val) - refresh_tree = _me.get_funct('refresh_tree') - - refresh_tree() - - def on_btnApply_clicked(self, widget, *args): - #Store the new radio buttons status - _me.set_param('drop_rad', self.get_widget('radDrop').get_active()) - _me.set_param('raise_rad', self.get_widget('radRaise').get_active()) - _me.set_param('changeD_rad', self.get_widget('radChangeD').get_active()) - _me.set_param('changeU_rad', self.get_widget('radChangeU').get_active()) - _me.set_param('increase_rad', self.get_widget('radIncrease').get_active()) - _me.set_param('decrease_rad', self.get_widget('radDecrease').get_active()) - _me.set_param('both_rad', self.get_widget('radBoth').get_active()) - _me.set_param('threshold_chk', self.get_widget('chkThreshold').get_active()) - _me.set_param('chk_ThresholdBehavior', self.get_widget('chk_ThresholdBehavior').get_active()) - _me.set_param('threshold_notified', self.get_widget('chkThresholdNotified').get_active()) - _me.set_param('change_notified', self.get_widget('chkChangeNotified').get_active()) - _me.set_param('chk_ChangeBehavior', self.get_widget('chk_ChangeBehavior').get_active()) - temp_rate = self.check_float_value(self.get_widget('txtRate').get_text(), 1, 3600) - temp_sample = self.check_float_value(self.get_widget('txtSample').get_text(), 1, 100000) - #sample and rate param - if temp_rate != self.measure.rate or temp_sample != self.measure.sample: - self.measure.rate = temp_rate - self.measure.sample = temp_sample - self.measure.val_table = [0] * (int(self.measure.sample)+1) - - - max_time = self.measure.rate * self.measure.sample - - self.measure.val_drop = self.check_float_value(self.get_widget('valDrop_percent').get_text(), 1, 100) - self.measure.val_drop_time = self.check_float_value(self.get_widget('valDrop_time').get_text(), self.measure.rate, max_time) - self.measure.val_raise = self.check_float_value(self.get_widget('valRaise_percent').get_text(), 1, 100) - self.measure.val_raise_time = self.check_float_value(self.get_widget('valRaise_time').get_text(), self.measure.rate, max_time) - self.measure.val_changeD = self.check_float_value(self.get_widget('valChangeD_percent').get_text(), 1, 100) - self.measure.val_changeD_time = self.check_float_value(self.get_widget('valChangeD_time').get_text(), self.measure.rate, max_time) - self.measure.val_changeU = self.check_float_value(self.get_widget('valChangeU_percent').get_text(), 1, 100) - self.measure.val_changeU_time = self.check_float_value(self.get_widget('valChangeU_time').get_text(), self.measure.rate, max_time) - self.measure.val_threshold = self.check_float_value(self.get_widget('valThreshold').get_text(), 0, 100) - - #Update values - self.update_value() - - def on_threshold_selection_changed(self, widget, *args): - filename = widget.get_filename() - filename = filename.replace('%20', ' ') - _me.set_param('behavior_file_threshold', filename) - _me.get_param('measure').threshold_behavior = _me.get_param('behavior_file_threshold') - - def on_change_selection_changed(self, widget, *args): - filename = widget.get_filename() - filename = filename.replace('%20', ' ') - _me.set_param('behavior_file_change', filename) - _me.get_param('measure').change_behavior = _me.get_param('behavior_file_change') - ########################################################### # # Value integrity control @@ -300,19 +149,44 @@ value = float(maximum) return value + + def update(self): self.graph = Graph() _me.set_param('graph', self.graph) - _me.update_informations() + #_me.update_informations() self.measure = _me.get_param('measure') _me.get_param('measure').graph_measure = self.graph _me.get_param('graph').measure_graph = self.measure _me.get_param('measure').GUI_on = True self.update_value() - self.graph.set_size_request(600, 300) + self.graph.set_size_request(400, 200) gtk.gdk.threads_enter() layout = self.get_widget('vbox2') layout.add(self.graph) layout.show_all() gtk.gdk.threads_leave() + + def verify_value(self): + try: + float(self.get_widget('txtTime').get_text()) + except: + self.get_widget('txtTime').set_text('1.0') + + if float(self.get_widget('txtTime').get_text()) < 1.0: + self.get_widget('txtTime').set_text('1.0') + if float(self.get_widget('txtTime').get_text()) > self.measure.rate * self.measure.sample: + self.get_widget('txtTime').set_text(str(self.measure.rate * self.measure.sample)) + + try: + float(self.get_widget('txtValue').get_text()) + except: + self.get_widget('txtValue').set_text('1') + + if float(self.get_widget('txtValue').get_text()) < 1: + self.get_widget('txtValue').set_text('1') + if float(self.get_widget('txtValue').get_text()) > 100: + self.get_widget('txtValue').set_text('100') + + Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp 2007-10-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp 2007-10-10 15:04:47 UTC (rev 600) @@ -1,9 +1,5 @@ sys.path.append(_me.get_path('root') + '/Scripts/Python') -try: - from Battery_class import Measure -except: - print sys.exc_info() - +from Battery_class import Measure measure = Measure() _me.set_param('measure', measure) @@ -18,6 +14,8 @@ measure.val_changeD_time = float(_me.get_param('changeD_time')) 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') + #update the radio button status measure.drop = _me.get_param('drop_rad') @@ -30,10 +28,11 @@ # '' the check boxes measure.threshold_chk = _me.get_param('threshold_chk') -measure.change_control() +#measure.change_control() # update the sample and rate values if _me.get_param('Rate') != (0 or None or '') and float(_me.get_param('Rate')) != measure.rate: + measure.tick = 1 measure.rate = float(_me.get_param('Rate')) if _me.get_param('Sample') != (0 or None or '' or '1') and float(_me.get_param('Sample')) != measure.sample: measure.val_table = [0] * int(_me.get_param('Sample')) @@ -46,8 +45,8 @@ monitor_id = tux.monitoring.insert(0x25, measure.on_battery_level) _me.set_param('monitor_id', monitor_id) + def destroy(): - print ' Remove' tux.monitoring.remove(_me.get_param('monitor_id')) _me.insert_funct('destroy', destroy) Modified: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/main.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/main.pyp 2007-10-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/main.pyp 2007-10-10 15:04:47 UTC (rev 600) @@ -1,2 +1,3 @@ def update_informations(): pass + 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-10 13:52:16 UTC (rev 599) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/fr_ALL.xml 2007-10-10 15:04:47 UTC (rev 600) @@ -4,6 +4,7 @@ <conf_lblThreshold type='str'>Seuil</conf_lblThreshold> <gui_conf_remote_title type='str'>Contrôle</gui_conf_remote_title> <conf_lblRaise type='str'>Accroissement</conf_lblRaise> + <widget_lblTest type='str'>Notifications</widget_lblTest> <gui_conf_description_lb type='str'>Description</gui_conf_description_lb> <conf_lblEvent type='str'>Evènement</conf_lblEvent> <widget_lblControl type='str'>Contrôle</widget_lblControl> @@ -20,6 +21,7 @@ <conf_lblChangeU type='str'>Augmente et chute</conf_lblChangeU> <gui_conf_cancel_bt type='str'>Annuler</gui_conf_cancel_bt> <gui_conf_rate_lb type='str'>Taux de rafraichissement :</gui_conf_rate_lb> + <mainscript type='str'>J'ai trouvé la lumière !</mainscript> <conf_btnRemove t... [truncated message content] |
From: Paul_R <c2m...@c2...> - 2007-10-10 13:52:16
|
Author: Paul_R Date: 2007-10-10 15:52:16 +0200 (Wed, 10 Oct 2007) New Revision: 599 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.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: * Minor changes in the labels text. Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) 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 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:52:16 UTC (rev 599) @@ -141,8 +141,9 @@ ########################################################### def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) + self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) - self.get_widget("lbclient_conf_value").set_text(_me.string('conf_lblValue')) + self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) self.get_widget("lbl_conf_notified").set_text(_me.string('conf_lblNotified')) self.get_widget("lbl_conf_behavior").set_text(_me.string('conf_lblBehavior')) @@ -153,6 +154,7 @@ self.get_widget("lbl_conf_sample").set_text(_me.string('conf_lblSample')) self.get_widget("lbl_conf_rate").set_text(_me.string('conf_lblRate')) self.get_widget("lblControlFrame").set_text(_me.string('conf_lblControl')) + self.get_widget("lblScript").set_text(_me.string('MainBehavior')) ########################################################### 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 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:52:16 UTC (rev 599) @@ -36,6 +36,7 @@ self.get_widget("lblTime").set_text(_me.string('conf_lblTime')) self.get_widget("lblNotify").set_text(_me.string('conf_lblNotified')) self.get_widget("lblScript").set_text(_me.string('conf_lblBehavior')) + self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) tab = _me.get_param('test_tab') self.get_widget('cbbEvent').set_active(tab[0][1]) 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-10 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/Strings/fr_ALL.xml 2007-10-10 13:52:16 UTC (rev 599) @@ -44,6 +44,7 @@ <conf_lblNotifiedBehavior type='str'>Notifié</conf_lblNotifiedBehavior> <gui_conf_author_lb type='str'>Auteur</gui_conf_author_lb> <widget_lblDrop type='str'>Chute</widget_lblDrop> + <MainBehavior type='str'>Comportement principal</MainBehavior> <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> Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-10 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-10 13:52:16 UTC (rev 599) @@ -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'>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> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-10 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-10 13:52:16 UTC (rev 599) @@ -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-10 13:50:45 UTC (rev 598) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-10 13:52:16 UTC (rev 599) @@ -4,14 +4,12 @@ <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> @@ -21,16 +19,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> + <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> @@ -43,10 +44,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> @@ -54,7 +55,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> - <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> @@ -62,6 +63,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> - <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) |
From: Paul_R <c2m...@c2...> - 2007-10-10 13:50:47
|
Author: Paul_R Date: 2007-10-10 15:50:45 +0200 (Wed, 10 Oct 2007) New Revision: 598 Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor.tgf software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.glade software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml software/gadgets/light_monitor/tags/0.0.1/Light_monitor/about.xml software/gadgets/light_monitor/tags/0.0.1/Light_monitor/settings.xml software/gadgets/light_monitor/tags/0.0.1/Light_monitor/strings.xml Log: * Woops, I don't have tagged the correct version in my last commit... Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:50:45 UTC (rev 598) @@ -141,8 +141,9 @@ ########################################################### def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) + self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) - self.get_widget("lbclient_conf_value").set_text(_me.string('conf_lblValue')) + self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) self.get_widget("lbl_conf_notified").set_text(_me.string('conf_lblNotified')) self.get_widget("lbl_conf_behavior").set_text(_me.string('conf_lblBehavior')) @@ -153,6 +154,7 @@ self.get_widget("lbl_conf_sample").set_text(_me.string('conf_lblSample')) self.get_widget("lbl_conf_rate").set_text(_me.string('conf_lblRate')) self.get_widget("lblControlFrame").set_text(_me.string('conf_lblControl')) + self.get_widget("lblScript").set_text(_me.string('MainBehavior')) ########################################################### Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:50:45 UTC (rev 598) @@ -36,6 +36,7 @@ self.get_widget("lblTime").set_text(_me.string('conf_lblTime')) self.get_widget("lblNotify").set_text(_me.string('conf_lblNotified')) self.get_widget("lblScript").set_text(_me.string('conf_lblBehavior')) + self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) tab = _me.get_param('test_tab') self.get_widget('cbbEvent').set_active(tab[0][1]) Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml 2007-10-10 13:50:45 UTC (rev 598) @@ -44,6 +44,7 @@ <conf_lblNotifiedBehavior type='str'>Notifié</conf_lblNotifiedBehavior> <gui_conf_author_lb type='str'>Auteur</gui_conf_author_lb> <widget_lblDrop type='str'>Chute</widget_lblDrop> + <MainBehavior type='str'>Comportement principal</MainBehavior> <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> Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/about.xml 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/about.xml 2007-10-10 13:50:45 UTC (rev 598) @@ -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'>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> </about> Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/settings.xml 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/settings.xml 2007-10-10 13:50:45 UTC (rev 598) @@ -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/tags/0.0.1/Light_monitor/strings.xml =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/strings.xml 2007-10-10 13:35:10 UTC (rev 597) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/strings.xml 2007-10-10 13:50:45 UTC (rev 598) @@ -4,14 +4,12 @@ <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> @@ -21,16 +19,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> + <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> @@ -43,10 +44,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> @@ -54,7 +55,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> - <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> @@ -62,6 +63,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> - <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/tags/0.0.1/Light_monitor.tgf =================================================================== (Binary files differ) |
Author: Paul_R Date: 2007-10-10 15:35:10 +0200 (Wed, 10 Oct 2007) New Revision: 597 Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor.tgf software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.glade software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.glade software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/init.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/main.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/notify.pyp software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml software/gadgets/light_monitor/tags/0.0.1/Light_monitor/settings.xml software/gadgets/light_monitor/tags/0.0.1/Light_monitor/strings.xml Log: * Create the 0.0.1 tag with all changes wanted by Se. Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) Property changes on: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 13:35:10 UTC (rev 597) @@ -1,18 +1,23 @@ bindtextdomain("params", "") class Window(SimpleGladeApp): - def __init__(self, path=_me.get_path('root') + '/Scripts/Python/GUI/conf/other.glade', root="window1", domain="params", **kwargs): SimpleGladeApp.__init__(self, path, root, domain, **kwargs) + def new(self): self.measure = _me.get_param('measure') + _me.insert_funct('refresh_tree', self.refresh_tree) + _me.insert_funct('verify_tab', self.verify_tab) self.updates_commons() self.make_viewtree() self.update_labels() + + + def updates_commons(self): # Window title @@ -119,7 +124,8 @@ self.get_widget('cbb_conf_event').set_active(0) self.get_widget('txt_conf_value').set_text('1.0') self.get_widget('txt_conf_time').set_text('0.1') - self.gadget_viewer.connect("row_activated", self.on_row_selected) + self.gadget_viewer.get_selection().connect("changed",self.on_row_selected) + #self.gadget_viewer.connect("row_activated", self.on_row_selected) self.measure.event_tab = _me.get_param('config') self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblChange')) self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblThreshold')) @@ -128,7 +134,6 @@ for i in range(len(self.measure.event_tab)): self.add_row(i) - ########################################################### # # Update the labels @@ -137,7 +142,7 @@ def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) - self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) + self.get_widget("lbclient_conf_value").set_text(_me.string('conf_lblValue')) self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) self.get_widget("lbl_conf_notified").set_text(_me.string('conf_lblNotified')) self.get_widget("lbl_conf_behavior").set_text(_me.string('conf_lblBehavior')) @@ -155,15 +160,16 @@ # On row selected # ########################################################### - def on_row_selected(self, treeview, path, view_column): - self.iter = self.value_list.get_iter(path) - index = self.value_list.get_value(self.iter, 0) - event = self.value_list.get_value(self.iter, 1) - typet = self.value_list.get_value(self.iter, 2) - value = self.value_list.get_value(self.iter, 3) - time = self.value_list.get_value(self.iter, 4) - notify = self.value_list.get_value(self.iter, 5) - behavior = self.value_list.get_value(self.iter, 6) + def on_row_selected(self, obj): + path = obj.get_selected_rows() + self.__iter = self.value_list.get_iter(path[1][0]) + index = self.value_list.get_value(self.__iter, 0) + event = self.value_list.get_value(self.__iter, 1) + typet = self.value_list.get_value(self.__iter, 2) + value = self.value_list.get_value(self.__iter, 3) + time = self.value_list.get_value(self.__iter, 4) + notify = self.value_list.get_value(self.__iter, 5) + behavior = self.value_list.get_value(self.__iter, 6) if event == _me.string('conf_lblChange'): self.get_widget('cbb_conf_event').set_active(0) @@ -199,15 +205,15 @@ self.get_widget('conf_behavior').set_filename(behavior) else: self.get_widget('conf_behavior').set_filename('None') + - ########################################################### # # On row modified # ########################################################### def on_btn_conf_modify_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab = _me.get_param('config') length = len(_me.get_param('config')) @@ -224,11 +230,13 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab[(index-1)] = value - _me.set_param('config', self.measure.event_tab) - self.value_list.clear() - for i in range(len(self.measure.event_tab)): - self.add_row(i) + + if self.verify_tab(value): + self.measure.event_tab[(index-1)] = value + _me.set_param('config', self.measure.event_tab) + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) ########################################################### # @@ -236,11 +244,11 @@ # ########################################################### def on_btn_conf_remove_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab =_me.get_param('config') self.measure.event_tab.pop(index - 1) _me.set_param('config', self.measure.event_tab) - self.iter = 0 + self.__iter = 0 self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) @@ -264,12 +272,27 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab.append(value) - + if self.verify_tab(value): + self.measure.event_tab.append(value) + self.refresh_tree() + + def refresh_tree(self): _me.set_param('config', self.measure.event_tab) self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) + + + def verify_tab(self, tab): + for i in range(len(self.measure.event_tab)): + if self.measure.event_tab[i][1] == tab[1]: + if self.measure.event_tab[i][2] == tab[2]: + if self.measure.event_tab[i][3] == tab[3]: + if self.measure.event_tab[i][4] == tab[4]: + if self.measure.event_tab[i][5] == tab[5]: + if self.measure.event_tab[i][6] == tab[6]: + return False + return True ########################################################### # @@ -305,7 +328,7 @@ if self.measure.event_tab[i][5]: Notify = _me.string('conf_lblNotifiedBehavior') - if self.measure.event_tab[i][6] == None: + if self.measure.event_tab[i][6] ==None: Behavior = _me.string('conf_lblDefaultBehavior') else: Behavior = str(self.measure.event_tab[i][6]) @@ -346,8 +369,9 @@ def on_accept_clicked(self, widget, *args): _me.set_param('Rate', float(self.get_widget('txt_conf_rate').get_text())) _me.set_param('Sample',float(self.get_widget('txt_conf_sample').get_text())) - self.measure.rate = _me.get_param('Rate') - self.measure.sample = _me.get_param('Sample') + _me.set_param(('MainScript'), str(self.get_widget('mainScript').get_filename())) + self.measure.rate_backup = _me.get_param('Rate') + self.measure.sample_backup = _me.get_param('Sample') _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) @@ -369,10 +393,8 @@ ########################################################### 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][6] + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab[index-1][6] = None - print self.measure.event_tab[index][6] self.value_list.clear() for i in range(len(self.measure.event_tab)): @@ -389,8 +411,8 @@ except: self.get_widget('txt_conf_time').set_text('0.1') - if float(self.get_widget('txt_conf_time').get_text()) < 0.1: - self.get_widget('txt_conf_time').set_text('0.1') + if float(self.get_widget('txt_conf_time').get_text()) < self.measure.rate: + self.get_widget('txt_conf_time').set_text(str(self.measure.rate)) if float(self.get_widget('txt_conf_time').get_text()) > self.measure.rate * self.measure.sample: self.get_widget('txt_conf_time').set_text(str(self.measure.rate * self.measure.sample)) @@ -403,3 +425,4 @@ self.get_widget('txt_conf_value').set_text('1') if float(self.get_widget('txt_conf_value').get_text()) > 100: self.get_widget('txt_conf_value').set_text('100') + Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.glade =================================================================== (Binary files differ) Property changes on: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 13:35:10 UTC (rev 597) @@ -16,56 +16,35 @@ # ########################################################### def new(self): - #Fill the text box with the previous values - self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) - self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) - self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) - self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) - self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) - self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) - self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) - self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) - self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) - self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) - self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) + self.get_widget("window1").set_title(_me.string('name_to_read')) + self.get_widget("lblThreshold").set_text(_me.string('widget_lblTest')) - #Restore the previous radio button status - self.get_widget('radDrop').set_active(_me.get_param('drop_rad')) - self.get_widget('radRaise').set_active(_me.get_param('raise_rad')) - self.get_widget('radChangeD').set_active(_me.get_param('changeD_rad')) - self.get_widget('radChangeU').set_active(_me.get_param('changeU_rad')) - self.get_widget('radIncrease').set_active(_me.get_param('increase_rad')) - self.get_widget('radDecrease').set_active(_me.get_param('decrease_rad')) - self.get_widget('radBoth').set_active(_me.get_param('both_rad')) + self.get_widget("lblBtnDark").set_label(_me.string('widget_lblDark')) + self.get_widget("lblBtnLight").set_label(_me.string('widget_lblLight')) + self.get_widget("btnAdd").set_label(_me.string('widget_lblSet')) - #Restore the check boxes - self.get_widget('chkThreshold').set_active(_me.get_param('threshold_chk')) - self.get_widget('chk_ThresholdBehavior').set_active(_me.get_param('chk_ThresholdBehavior')) - self.get_widget('chk_ChangeBehavior').set_active(_me.get_param('chk_ChangeBehavior')) - self.get_widget("window1").set_title(_me.string('name_to_read')) + self.get_widget('txtValue').set_text('1.0') + self.get_widget('txtTime').set_text('0.1') + + self.get_widget('cbbEvent').append_text(_me.string('conf_lblChange')) + self.get_widget('cbbEvent').append_text(_me.string('conf_lblThreshold')) + self.get_widget('cbbEvent').set_active(0) - #Set the labels - print 'tick' - self.get_widget("radBoth").set_label(_me.string('widget_lblBoth')) - self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) - self.get_widget("lblChange").set_text(_me.string('widget_lblChange')) - self.get_widget("radChangeD").set_label(_me.string('widget_lblChangeD')) - self.get_widget("radChangeU").set_label(_me.string('widget_lblChangeU')) - self.get_widget("radDecrease").set_label(_me.string('widget_lblDecrease')) - self.get_widget("radDrop").set_label(_me.string('widget_lblDrop')) - self.get_widget("lblEventChange").set_text(_me.string('widget_lblEvent')) - self.get_widget("lblEventThreshold").set_text(_me.string('widget_lblEvent')) - self.get_widget("radIncrease").set_label(_me.string('widget_lblIncrease')) - self.get_widget("radRaise").set_label(_me.string('widget_lblRaise')) - self.get_widget("lblThreshold").set_text(_me.string('widget_lblThreshold')) - self.get_widget("lblValue").set_text(_me.string('widget_lblValue')) - self.get_widget("lblControl").set_text(_me.string('widget_lblControl')) - self.get_widget("chkThreshold").set_label(_me.string('widget_lblDisplayThreshold')) - self.get_widget('chk_ThresholdBehavior').set_label(_me.string('widget_lblBehavior')) - self.get_widget('chk_ChangeBehavior').set_label(_me.string('widget_lblBehavior')) - self.get_widget("lblRate").set_text(_me.string('gui_conf_rate_lb')) - self.get_widget("lblSample").set_text(_me.string('gui_conf_sample_lb')) + self.get_widget("lblEvent").set_text(_me.string('conf_lblEvent')) + self.get_widget("lblType").set_text(_me.string('conf_lblType')) + self.get_widget("lblValue").set_text(_me.string('conf_lblValue')) + self.get_widget("lblTime").set_text(_me.string('conf_lblTime')) + self.get_widget("lblNotify").set_text(_me.string('conf_lblNotified')) + self.get_widget("lblScript").set_text(_me.string('conf_lblBehavior')) + tab = _me.get_param('test_tab') + self.get_widget('cbbEvent').set_active(tab[0][1]) + self.get_widget('cbbType').set_active(tab[0][2]) + self.get_widget('txtValue').set_text(str(tab[0][3])) + self.get_widget('txtTime').set_text(str(tab[0][4])) + self.get_widget('chkNotify').set_active(tab[0][5]) + self.get_widget('Behavior').set_filename(tab[0][6]) + thread.start_new_thread(self.update, ()) ########################################################### @@ -74,66 +53,10 @@ # ########################################################### def update_value(self): - #Rate - _me.set_param('Rate', self.light_measure.rate) - self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) - - #Sample - _me.set_param('Sample', self.light_measure.sample) - self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) - - #Drop - _me.set_param('drop', self.light_measure.val_drop) - self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) - print self.light_measure.val_drop_time - _me.set_param('drop_time', self.light_measure.val_drop_time) - self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) - - #Raise - _me.set_param('raise', self.light_measure.val_raise) - self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) - _me.set_param('raise_time', self.light_measure.val_raise_time) - self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) - - #Drop and raise - _me.set_param('changeD', self.light_measure.val_changeD) - self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) - _me.set_param('changeD_time', self.light_measure.val_changeD_time) - self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) - - #Raise and drop - _me.set_param('changeU', self.light_measure.val_changeU) - self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) - _me.set_param('changeU_time', self.light_measure.val_changeU_time) - self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) - - #Threshold - _me.set_param('threshold', self.light_measure.val_threshold) - self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) - - - - #update the radio button status - self.light_measure.drop = _me.get_param('drop_rad') - self.light_measure.raising = _me.get_param('raise_rad') - self.light_measure.changeD = _me.get_param('changeD_rad') - self.light_measure.changeU = _me.get_param('changeU_rad') - self.light_measure.increase = _me.get_param('increase_rad') - self.light_measure.decrease = _me.get_param('decrease_rad') - self.light_measure.both = _me.get_param('both_rad') self.light_measure.changetext = _me.string('conf_lblChange') self.light_measure.thresholdtext = _me.string('conf_lblThreshold') - # '' the check boxes - self.light_measure.threshold_chk = _me.get_param('threshold_chk') - print _me.get_param('chk_ThresholdBehavior') - self.light_measure.threshold_behavior_chk = _me.get_param('chk_ThresholdBehavior') - self.light_measure.change_behavior_chk = _me.get_param('chk_ChangeBehavior') - self.light_measure.change_control() - - - ########################################################### # # Event functions @@ -143,59 +66,92 @@ _me.get_param('measure').GUI_on = False self.light_measure.GUI_on = False + def on_btnAdd_clicked(self, widget, *args): + length = len(_me.get_param('config')) + self.verify_value() + value = [] + value = [(length + 1), + self.get_widget('cbbEvent').get_active(), + self.get_widget('cbbType').get_active(), + float(self.get_widget('txtValue').get_text()), + float(self.get_widget('txtTime').get_text()), + self.get_widget('chkNotify').get_active(), + str(self.get_widget('Behavior').get_filename()), + False, + 0] + self.light_measure.event_tab = _me.get_param('config') + verify_tab = _me.get_funct('verify_tab') + if verify_tab(value): + self.light_measure.event_tab.append(value) + refresh_tree = _me.get_funct('refresh_tree') + refresh_tree() + def on_btnApply_clicked(self, widget, *args): - #Store the new radio buttons status - _me.set_param('drop_rad', self.get_widget('radDrop').get_active()) - _me.set_param('raise_rad', self.get_widget('radRaise').get_active()) - _me.set_param('changeD_rad', self.get_widget('radChangeD').get_active()) - _me.set_param('changeU_rad', self.get_widget('radChangeU').get_active()) - _me.set_param('increase_rad', self.get_widget('radIncrease').get_active()) - _me.set_param('decrease_rad', self.get_widget('radDecrease').get_active()) - _me.set_param('both_rad', self.get_widget('radBoth').get_active()) - _me.set_param('threshold_chk', self.get_widget('chkThreshold').get_active()) - _me.set_param('chk_ThresholdBehavior', self.get_widget('chk_ThresholdBehavior').get_active()) - _me.set_param('chk_ChangeBehavior', self.get_widget('chk_ChangeBehavior').get_active()) - print _me.get_param('chk_ChangeBehavior') - - temp_rate = self.check_float_value(self.get_widget('txtRate').get_text(), 0.1, 36000) - temp_sample = self.check_float_value(self.get_widget('txtSample').get_text(), 1, 100000) - #sample and rate param - if temp_rate != self.light_measure.rate or temp_sample != self.light_measure.sample: - self.light_measure.tick = 1 - self.light_measure.rate = temp_rate - self.light_measure.sample = temp_sample - self.light_measure.val_table = [0] * (int(self.light_measure.sample)+1) - + length = len(_me.get_param('config')) + self.verify_value() + value = [] + value = [(length + 1), + self.get_widget('cbbEvent').get_active(), + self.get_widget('cbbType').get_active(), + float(self.get_widget('txtValue').get_text()), + float(self.get_widget('txtTime').get_text()), + self.get_widget('chkNotify').get_active(), + str(self.get_widget('Behavior').get_filename()), + False, + 0] + self.light_measure.test_tab[0] = value + _me.set_param('test_tab', value) - max_time = self.light_measure.rate * self.light_measure.sample + 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 + 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 + self.config_light_search() - self.light_measure.val_drop = self.check_float_value(self.get_widget('valDrop_percent').get_text(), 1, 100) - self.light_measure.val_drop_time = self.check_float_value(self.get_widget('valDrop_time').get_text(), self.light_measure.rate, max_time) - self.light_measure.val_raise = self.check_float_value(self.get_widget('valRaise_percent').get_text(), 1, 100) - self.light_measure.val_raise_time = self.check_float_value(self.get_widget('valRaise_time').get_text(), self.light_measure.rate, max_time) - self.light_measure.val_changeD = self.check_float_value(self.get_widget('valChangeD_percent').get_text(), 1, 100) - self.light_measure.val_changeD_time = self.check_float_value(self.get_widget('valChangeD_time').get_text(), self.light_measure.rate, max_time) - self.light_measure.val_changeU = self.check_float_value(self.get_widget('valChangeU_percent').get_text(), 1, 100) - self.light_measure.val_changeU_time = self.check_float_value(self.get_widget('valChangeU_time').get_text(), self.light_measure.rate, max_time) - self.light_measure.val_threshold = self.check_float_value(self.get_widget('valThreshold').get_text(), 0, 100) - print self.light_measure.val_changeD_time + 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) - #Update values - self.update_value() - - def on_threshold_selection_changed(self, widget, *args): - filename = widget.get_filename() - _me.set_param('behavior_file_threshold', filename) - _me.get_param('measure').threshold_behavior = _me.get_param('behavior_file_threshold') - - def on_change_selection_changed(self, widget, *args): - filename = widget.get_filename() - _me.set_param('behavior_file_change', filename) - _me.get_param('measure').change_behavior = _me.get_param('behavior_file_change') + def on_expander_activate(self, widget, *args): + self.get_widget('txtValue').set_text(str(self.light_measure.test_tab[0][3])) + self.get_widget('txtTime').set_text(str(self.light_measure.test_tab[0][4])) - ########################################################### # + # On combo box event + # + ########################################################### + def on_cbb_conf_event_changed(self, widget, *args): + if self.get_widget('cbbEvent').get_active() == 0: + for i in range (4): + self.get_widget('cbbType').remove_text(0) + 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')) + self.get_widget('cbbType').append_text(_me.string('conf_lblChangeU')) + self.get_widget('cbbType').set_active(0) + else: + for i in range (4): + self.get_widget('cbbType').remove_text(0) + self.get_widget('cbbType').append_text(_me.string('conf_lblIncrease')) + self.get_widget('cbbType').append_text(_me.string('conf_lblDecrease')) + self.get_widget('cbbType').append_text(_me.string('conf_lblBoth')) + self.get_widget('cbbType').set_active(0) + + + ########################################################### + # # Value integrity control # ########################################################### @@ -203,30 +159,52 @@ try: value = float(value) except: - print '0' value = float(minimum) if value < float(minimum): - print '1' value = float(minimum) elif value > float(maximum): - print '2' value = float(maximum) return value + + def update(self): self.light_graph = lightGraph() _me.set_param('graph', self.light_graph) - _me.update_informations() + #_me.update_informations() self.light_measure = _me.get_param('measure') _me.get_param('measure').light_graph_measure = self.light_graph _me.get_param('graph').light_measure_graph = self.light_measure _me.get_param('measure').GUI_on = True self.update_value() - self.light_graph.set_size_request(600, 300) + self.light_graph.set_size_request(400, 200) gtk.gdk.threads_enter() layout = self.get_widget('vbox2') layout.add(self.light_graph) layout.show_all() gtk.gdk.threads_leave() + + def verify_value(self): + try: + float(self.get_widget('txtTime').get_text()) + except: + self.get_widget('txtTime').set_text('0.1') + + if float(self.get_widget('txtTime').get_text()) < 0.1: + self.get_widget('txtTime').set_text('0.1') + if float(self.get_widget('txtTime').get_text()) > self.light_measure.rate * self.light_measure.sample: + self.get_widget('txtTime').set_text(str(self.light_measure.rate * self.light_measure.sample)) + + try: + float(self.get_widget('txtValue').get_text()) + except: + self.get_widget('txtValue').set_text('1') + + if float(self.get_widget('txtValue').get_text()) < 1: + self.get_widget('txtValue').set_text('1') + if float(self.get_widget('txtValue').get_text()) > 100: + self.get_widget('txtValue').set_text('100') + + Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/init.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/init.pyp 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/init.pyp 2007-10-10 13:35:10 UTC (rev 597) @@ -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() @@ -18,6 +16,8 @@ measure.val_changeD_time = float(_me.get_param('changeD_time')) 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') + #update the radio button status measure.drop = _me.get_param('drop_rad') @@ -30,7 +30,7 @@ # '' the check boxes measure.threshold_chk = _me.get_param('threshold_chk') -measure.change_control() +#measure.change_control() # update the sample and rate values if _me.get_param('Rate') != (0 or None or '') and float(_me.get_param('Rate')) != measure.rate: @@ -44,5 +44,15 @@ measure.change_behavior = _me.get_param('behavior_file_change') measure.event_tab = _me.get_param('config') -tux.monitoring.insert(0x1B, measure.on_light_level) +monitor_id = tux.monitoring.insert(0x1B, measure.on_light_level) +_me.set_param('monitor_id', monitor_id) + +def destroy(): + tux.monitoring.remove(_me.get_param('monitor_id')) + +_me.insert_funct('destroy', destroy) + + + + Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/lightGraph_class.py =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-10 13:35:10 UTC (rev 597) @@ -2,6 +2,8 @@ import sys import time import os +import threading +import thread sys.path.append('/opt/tuxdroid/api/python') from tux import * @@ -32,7 +34,7 @@ context.rectangle(rect.x, rect.y, rect.width, rect.height) #set a white background context.set_source_rgb(1, 1, 1) - context.fill_preserve() + context.fill() #draw a black border context.set_source_rgb(0, 0, 0) context.set_line_width(1) @@ -53,16 +55,10 @@ context.set_source_rgb(0, 0, 0) context.set_line_width(0.6) context.line_to(0, y) - context.show_text(str((10-(i/2))*10)+"%") + context.set_source_rgb(0.2, 0.2, 0.2) + 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 @@ -83,10 +79,10 @@ #display sample and rate #move the vector in the bottom - context.move_to(10, rect.height - 10) + context.move_to(5, rect.height - 10) #display the rate context.show_text("rate = "+str(self.light_measure_graph.rate)+" sec.") - context.move_to(10, rect.height - 20) + context.move_to(5, rect.height - 20) #and the samples context.show_text("samples = "+str(self.light_measure_graph.sample)) context.stroke() @@ -94,87 +90,90 @@ #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)) - - #trace the curve - context.move_to(rect.x, rect.height) - context.set_source_rgb(1.0, 0, 0) + + #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)) 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.close_path() + context.set_source_rgba(1.0, 0, 0, 0.2) + context.fill() + + #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)) + 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.stroke() class lightMeasure(): def __init__(self): #Initial value self.sample = 500.0 - self.val_table = [0] * int(self.sample + 1) - self.rate = 1.0 - self.tick = self.rate * 10 - self.threshold_chk = False + self.sample_backup = self.sample + self.val_table = [-2] * int(self.sample + 1) + self.test_tab = [0] + self.rate = 0.1 + self.rate_backup = self.rate + self.tick = time.time() + - self.increase = False - self.decrease = False - self.both = False - self.drop = False - self.raising = False - self.changeD = False - self.changeU = False + self.GUI_on = False + self.start_flag = True + self.wait = time.time() + 2.0 + self.light_search = True - #Events flags - self.threshold_event = False - self.change_event = False + self.search_light_flag = False - self.GUI_on = False - self.notify = True + self.__on_light_mutex = threading.Lock() + self.__timeout_mutex = threading.Lock() - self.timeout = 0 - self.start_flag = True - self.wait = 0 - ########################################################### # # Events control # ########################################################### def event_control(self): - for i in range (len(self.event_tab)): - self.Threshold_control(i) - self.Change_control(i) + if self.GUI_on: + 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) - #Gadget or test notifications - if self.GUI_on: - self.test_func() - #disable gadget notifications - self.notify = False - + 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 == 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: - self.change_event = False - self.threshold_event = False + self.test_tab[0][7] = False self.start_flag = False - - + for i in range (len(self.event_tab)): + self.event_tab[i][7] = False + - def change_control(self): - # Determine how many point must be checked for changes events - pts_per_sec = self.sample / (self.rate * self.sample) - self.timeout = 0 - if self.val_drop_time >= 0.1 and self.val_drop > 0: - self.val_drop_time = int(self.val_drop_time * pts_per_sec) - if self.val_raise_time >= 0.1 and self.val_raise > 0: - self.val_raise_time = int(self.val_raise_time * pts_per_sec) - if self.val_changeD_time >= 0.1 and self.val_changeD > 0: - self.val_changeD_time = int(self.val_changeD_time * pts_per_sec) - if self.val_changeU_time >= 0.1 and self.val_changeU > 0: - self.val_changeU_time = int(self.val_changeU_time * pts_per_sec) - ########################################################### # @@ -182,20 +181,20 @@ # ########################################################### def Threshold_control(self, index): - if self.event_tab[index][1] == 1: - if self.event_tab[index][7] != True: - if self.event_tab[index][2] == 0: + if self.__tab[index][1] == 1: + if self.__tab[index][7] != True: + if self.__tab[index][2] == 0: #Increasing threshold control - if self.Increase_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True - elif self.event_tab[index][2] == 1: + if self.Increase_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True + elif self.__tab[index][2] == 1: #Decreasing threshold control - if self.Decrease_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True - elif self.event_tab[index][2] == 2: + if self.Decrease_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True + elif self.__tab[index][2] == 2: #Both direction theshold control - if self.Both_control(self.event_tab[index][3]) == True: - self.event_tab[index][7] = True + if self.Both_control(self.__tab[index][3]) == True: + self.__tab[index][7] = True def Increase_control(self, value): val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 @@ -224,166 +223,198 @@ ########################################################### def Change_control(self, i): #Changements control - if self.event_tab[i][1] == 0: + if self.__tab[i][1] == 0: pts_per_sec = self.sample / (self.rate * self.sample) - time = float(self.event_tab[i][4] * pts_per_sec) - if self.event_tab[i][7] != True: + time = int(self.__tab[i][4] * pts_per_sec) + if self.__tab[i][7] != True: # Drop change part : - if self.event_tab[i][2] == 0: - if self.Drop_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 0: + if self.Drop_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Raise change part - if self.event_tab[i][2] == 1: - if self.Raise_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 1: + if self.Raise_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Drop and Raise change - if self.event_tab[i][2] == 2: - if self.ChangeD_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True + if self.__tab[i][2] == 2: + if self.ChangeD_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True # Raise and Drop change - if self.event_tab[i][2] == 3: - if self.ChangeU_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: - self.event_tab[i][7] = True - + if self.__tab[i][2] == 3: + if self.ChangeU_control(time, self.__tab[i][3], self.__tab[i][8], i) == True: + self.__tab[i][7] = True + + def Drop_control(self, time, val, timeout, index): #timeout control : to prevent multiple notifications with the same event 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]) + if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*1124): - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.timeout = int(time) + self.__tab[index][8] = int(time) return True - elif self.GUI_on: - self.timeout = timeout + else: + self.__tab[index][8] = timeout def Raise_control(self, time, val, timeout, index): if timeout != 0: timeout -= 1 - init_val = len(self.val_table) - 1 - int(time) + timeout + 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): - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.timeout = int(time) + self.__tab[index][8] = int(time) return True - elif self.GUI_on: - self.timeout = timeout + else: + 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 + 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]) if maximum >= self.val_table[len(self.val_table) - 1 - i] + val: - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.timeout = int(time) + self.__tab[index][8] = int(time) return True - if self.GUI_on: - self.timeout = timeout - else: - self.event_tab[index][8] = timeout + self.__tab[index][8] = timeout return False + def ChangeU_control(self, time, val, timeout, index): 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]) 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]) if minimum <= self.val_table[len(self.val_table) - 1 - i] - val: - if self.GUI_on == False: - self.event_tab[index][8] = int(time) - else: - self.timeout = int(time) + self.__tab[index][8] = int(time) return True - if self.GUI_on: - self.timeout = timeout - else: - self.event_tab[index][8] = timeout + self.__tab[index][8] = timeout return False + ########################################################### # # Test functions # ########################################################### - def test_func(self): - if self.threshold_event != True: - #Decrease threshold control - if self.decrease: - self.threshold_event = self.Decrease_control(self.val_threshold) - #Increasing threshold control - if self.increase: - self.threshold_event = self.Increase_control(self.val_threshold) - #Both direction theshold control - if self.both: - self.threshold_event = self.Both_control(self.val_threshold) - - #Changements control - if self.change_event != True: - # Drop change part : - if self.drop == True and self.val_drop_time > 0.0: - self.change_event = self.Drop_control(self.val_drop_time, self.val_drop, self.timeout, 0) - # Raise change part - if self.raising == True and self.val_raise_time > 0.0: - self.change_event = self.Raise_control(self.val_raise_time, self.val_raise, self.timeout, 0) - # Drop and Raise change - if self.changeD == True and self.val_changeD_time > 0.0: - self.change_event = self.ChangeD_control(self.val_changeD_time, self.val_changeD, self.timeout, 0) - # Raise and Drop change - if self.changeU == True and self.val_changeU_time > 0.0: - self.change_event = self.ChangeU_control(self.val_changeU_time, self.val_changeU, self.timeout, 0) - - def test_notification(self): - if self.threshold_event == True: - if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior): - self.threshold_event = False - tux.sys.shell_free(self.threshold_behavior) - else: - self.threshold_event = False - tux.cmd.mouth_open() - tux.tts.speak(self.thresholdtext) - tux.cmd.mouth_close() - - elif self.change_event == True: - print self.change_behavior - print os.path.isfile(self.change_behavior) - if self.change_behavior_chk: - if os.path.isfile(self.change_behavior): - print 'test' - self.change_event = False - tux.sys.shell_free(self.change_behavior) - else: - self.change_event = False - tux.cmd.mouth_open() - tux.tts.speak(self.changetext) - tux.cmd.mouth_close() + if self.test_tab[0][7] == True: + self.test_tab[0][7] = False + if self.test_tab[0][5] == True: + path = self.test_tab[0][6] + path = path.replace('%20', ' ') + if os.path.isfile(path) and os.path.exists(path): + path = self.test_tab[0][6] + path = "'%s'" % path + tux.sys.shell_free(path) + elif self.test_tab[0][1] == 0: + thread.start_new_thread(self.test_default_behavior, (self.changetext,)) + elif self.test_tab[0][1] == 1: + thread.start_new_thread(self.test_default_behavior, (self.thresholdtext,)) + def test_default_behavior(self, txt): + tux.cmd.mouth_open() + tux.tts.speak(txt) + tux.cmd.mouth_close() + ########################################################### # # Acquire # ########################################################### def on_light_level(self, args): - self.tick -= 1 - if self.tick == 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.tick = int(self.rate * 10) - self.event_control() + 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) + + 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() + + def rate_has_changed(self): + self.rate = self.rate_backup + pts_per_sec = self.sample / (self.rate * self.sample) + for i in range(len(self.event_tab)): + if self.event_tab[i][1] == 0: + if self.event_tab[i][4] <= self.rate: + self.event_tab[i][4] = self.rate + elif self.event_tab[i][4] >= self.rate * self.sample: + self.event_tab[i][4] = self.rate * self.sample + + self.event_tab[i][8] = int(self.event_tab[i][4] * pts_per_sec) + if self.test_tab[0][1] == 0: + if self.test_tab[0][4] <= self.rate: + self.test_tab[0][4] = self.rate + elif self.test_tab[0][4] >= self.rate * self.sample: + self.test_tab[0][4] = self.rate * self.sample + + self.test_tab[0][8] = int(self.test_tab[0][4] * pts_per_sec) + + + self.test_tab[0][8] = int(self.test_tab[0][4] * pts_per_sec) + ########################################################### + # + # Search functions + # + ########################################################### + def search_light(self, light): + self.count += 1 + detect = False + if self.light_search_state == 0 and tux.status.spin_counter() == 0 and self.count > 2: + self.light_search_state = 1 + if light == True: + self.light_value = max(self.val_table[len(self.val_table) - self.count: len(self.val_table)]) + self.light_value -= 10 + else: + self.light_value = min(self.val_table[len(self.val_table) - self.count: len(self.val_table)]) + self.light_value += 10 + self.timer = 10 + elif self.light_search_state == 1: + 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 + else: + if self.val_table[len(self.val_table)-1] <= (self.light_value): + thread.start_new_thread(tux.cmd.spinl_off, ()) + detect = True + + if detect: + self.search_light_flag = False + self.light_search_state = 0 + + def timer_control(self): + self.timer -= 1 + if self.timer > 2: + return True + + elif self.timer == 2: + tux.cmd.spinl_on_free(1, 1) + + elif self.timer == 0: + thread.start_new_thread(tux.cmd.spinl_off, ()) + self.timer = 7 + Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/main.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/main.pyp 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/main.pyp 2007-10-10 13:35:10 UTC (rev 597) @@ -1,2 +1,33 @@ def update_informations(): pass + +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: + tux.cmd.mouth_open() + txt = _me.string('mainscript') + tux.tts.speak(str(txt)) + tux.cmd.mouth_close() + + + +run_function() Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/notify.pyp =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/notify.pyp 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Scripts/Python/notify.pyp 2007-10-10 13:35:10 UTC (rev 597) @@ -34,8 +34,11 @@ if event[i][7]: if event[i][5]: - if os.path.isfile(str(event[i][6])): - tux.sys.shell_free(event[i][6]) + 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() @@ -44,6 +47,5 @@ event[i][7] = False else: event[i][7] = False - print 'notification done' break Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml =================================================================== --- software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml 2007-10-10 13:30:13 UTC (rev 596) +++ software/gadgets/light_monitor/tags/0.0.1/Light_monitor/Strings/fr_ALL.xml 2007-10-10 13:35:10 UTC (rev 597) @@ -4,6 +4,7 @@ <conf_lblThreshold type='str'>Seuil</conf_lblThreshold> <gui_conf_remote_title type='str'>Contrôle</gui_conf_remote_title> <conf_lblRaise type='str'>Accroissement</conf_lblRaise> + <widget_lblTest type='str'>Notifications</widget_lblTest> <gui_conf_description_lb type='str'>Description</gui_conf_description_lb> <conf_lblEvent type='str'>Evènement</conf_lblEvent> <widget_lblControl type='str'>Contrôle</widget_lblControl> @@ -20,6 +21,7 @@ <conf_lblChangeU type='str'>Augmente et chute</conf_lblChangeU> <gui_conf_cancel_bt type='str'>Annuler</gui_conf_cancel_bt> <gui_conf_rate_lb type='str'>Taux de rafraichissement :</gui_conf_rate_lb> + <mainscript type='str'>J'ai trouvé la lumière !</mainscript> <conf_btnRemove type='str'>Enlever</conf_btnRemove> <gui_conf_delay_lb type='str'>Délai (sec)</gui_conf_delay_lb> <conf_btnBehavior type='str'>Supprimer</conf_btnBehavior> @@ -32,6 +34,7 @@ <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> + <widget_lblNotified type='str'>Notifé</widget_lblNotified> <widget_lblIncrease type='str'>Accroissement</widget_lblIncrease> <widget_lblRaise type='str'>Augmentation</widget_lblRaise> <conf_btnAdd type='str'>Ajouter</conf_btnAdd> @@ -46,16 +49,19 @@ <conf_lblBehavior type='str'>Comportement</conf_lblBehavior> <gui_conf_remote_set_bt type='str'>Set</gui_conf_remote_set_bt> <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> <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> - <widget_lblThreshold type='str'>Seuil</widget_lblThreshold> + <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> + <widget_lblSet type='str'>Ajouter a la config.</widget_lblSet> <conf_lblValue type='str'>Valeur (%)</conf_lblValue> <conf_lblRate type='str'>Taux de rafraichissement</conf_lblRate> <widget_lblBehavior type='str'>Activer le script</widget_lblBehavior> <widget_lblChangeD type='str'>Changement inf.</widget_lblChangeD> <conf_lblTime type='str'>Temps (sec.)</conf_lblTime> <conf_lblControl type='str'>Contrôle</conf_lblControl> - <conf_lblNotified type='str'>Notifié ?</conf_lblNotified> + <widget_lblDark type='str'>Trouver ombre</widget_lblDark> + <widget_lblThreshold type='str'>Seuil</widget_lblThreshold> </strings> Modified: software/gadgets/light_monitor/tags/0.0.1/Light_monitor/sett... [truncated message content] |
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) |
Author: Paul_R Date: 2007-10-10 14:48:07 +0200 (Wed, 10 Oct 2007) New Revision: 595 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/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: * Big changes in the widget GUI. * Minor changes in the search light function * Added a behavior when the 'run' button is activate in the manager. A new filechooser button have been added in the conf GUI to execute a script when light has been found. * Rate and sample value is buffered, and refreshed always on the same place. This prevent bug in the change control functions. Modified: 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.glade 2007-10-09 15:32:49 UTC (rev 594) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.glade 2007-10-10 12:48:07 UTC (rev 595) @@ -362,32 +362,6 @@ </child> <child> - <widget class="GtkLabel" id="lbl_conf_behavior"> - <property name="width_request">144</property> - <property name="height_request">16</property> - <property name="visible">True</property> - <property name="label" translatable="yes">Behavior script</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="x">480</property> - <property name="y">8</property> - </packing> - </child> - - <child> <widget class="GtkLabel" id="lbl_conf_notified"> <property name="width_request">96</property> <property name="height_request">16</property> @@ -468,6 +442,32 @@ <property name="y">32</property> </packing> </child> + + <child> + <widget class="GtkLabel" id="lbl_conf_behavior"> + <property name="width_request">144</property> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="label" translatable="yes">Behavior script</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="x">480</property> + <property name="y">8</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> @@ -656,6 +656,50 @@ <property name="y">24</property> </packing> </child> + + <child> + <widget class="GtkLabel" id="lblScript"> + <property name="width_request">144</property> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="label" translatable="yes">Behavior script</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="x">480</property> + <property name="y">0</property> + </packing> + </child> + + <child> + <widget class="GtkFileChooserButton" id="mainScript"> + <property name="width_request">144</property> + <property name="height_request">30</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Select A File</property> + <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> + <property name="local_only">True</property> + <property name="show_hidden">False</property> + <property name="do_overwrite_confirmation">False</property> + <property name="width_chars">-1</property> + </widget> + <packing> + <property name="x">480</property> + <property name="y">24</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> 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-09 15:32:49 UTC (rev 594) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-10 12:48:07 UTC (rev 595) @@ -10,10 +10,14 @@ def new(self): self.measure = _me.get_param('measure') - _me.insert_funct('refresh_tree', self.refresh_tree) + _me.insert_funct('refresh_tree', self.refresh_tree) + _me.insert_funct('verify_tab', self.verify_tab) self.updates_commons() self.make_viewtree() self.update_labels() + + + def updates_commons(self): # Window title @@ -365,8 +369,9 @@ def on_accept_clicked(self, widget, *args): _me.set_param('Rate', float(self.get_widget('txt_conf_rate').get_text())) _me.set_param('Sample',float(self.get_widget('txt_conf_sample').get_text())) - self.measure.rate = _me.get_param('Rate') - self.measure.sample = _me.get_param('Sample') + _me.set_param(('MainScript'), str(self.get_widget('mainScript').get_filename())) + self.measure.rate_backup = _me.get_param('Rate') + self.measure.sample_backup = _me.get_param('Sample') _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) @@ -408,8 +413,8 @@ except: self.get_widget('txt_conf_time').set_text('0.1') - if float(self.get_widget('txt_conf_time').get_text()) < 0.1: - self.get_widget('txt_conf_time').set_text('0.1') + if float(self.get_widget('txt_conf_time').get_text()) < self.measure.rate: + self.get_widget('txt_conf_time').set_text(str(self.measure.rate)) if float(self.get_widget('txt_conf_time').get_text()) > self.measure.rate * self.measure.sample: self.get_widget('txt_conf_time').set_text(str(self.measure.rate * self.measure.sample)) @@ -422,9 +427,4 @@ self.get_widget('txt_conf_value').set_text('1') if float(self.get_widget('txt_conf_value').get_text()) > 100: self.get_widget('txt_conf_value').set_text('100') -''' - try: - _me.insert_funct('refresh_tree', refresh_tree) - except: - print sys.exc_info() -''' + Modified: 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.glade 2007-10-09 15:32:49 UTC (rev 594) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.glade 2007-10-10 12:48:07 UTC (rev 595) @@ -46,23 +46,24 @@ </child> <child> - <widget class="GtkExpander" id="expander1"> + <widget class="GtkExpander" id="expander2"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="expanded">False</property> <property name="spacing">0</property> + <signal name="activate" handler="on_expander_activate" last_modification_time="Wed, 10 Oct 2007 09:25:14 GMT"/> <child> - <widget class="GtkFrame" id="frame1"> + <widget class="GtkFrame" id="frame2"> <property name="border_width">5</property> + <property name="width_request">400</property> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="label_yalign">0.5</property> <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> <child> - <widget class="GtkAlignment" id="alignment2"> - <property name="border_width">1</property> + <widget class="GtkAlignment" id="alignment3"> <property name="visible">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> @@ -74,12 +75,14 @@ <property name="right_padding">0</property> <child> - <widget class="GtkFixed" id="fixed1"> + <widget class="GtkFixed" id="fixed10"> + <property name="width_request">373</property> + <property name="height_request">227</property> <property name="visible">True</property> <child> - <widget class="GtkEntry" id="valDrop_percent"> - <property name="width_request">48</property> + <widget class="GtkEntry" id="txtValue"> + <property name="width_request">80</property> <property name="height_request">24</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -92,14 +95,14 @@ <property name="activates_default">False</property> </widget> <packing> - <property name="x">176</property> - <property name="y">32</property> + <property name="x">200</property> + <property name="y">35</property> </packing> </child> <child> - <widget class="GtkEntry" id="valRaise_percent"> - <property name="width_request">48</property> + <widget class="GtkEntry" id="txtTime"> + <property name="width_request">80</property> <property name="height_request">24</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -112,53 +115,36 @@ <property name="activates_default">False</property> </widget> <packing> - <property name="x">176</property> - <property name="y">56</property> + <property name="x">284</property> + <property name="y">35</property> </packing> </child> <child> - <widget class="GtkEntry" id="valChangeD_percent"> - <property name="width_request">48</property> - <property name="height_request">24</property> + <widget class="GtkComboBox" id="cbbType"> + <property name="width_request">88</property> + <property name="height_request">30</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> + <property name="items" translatable="yes"></property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> </widget> <packing> - <property name="x">176</property> - <property name="y">80</property> + <property name="x">104</property> + <property name="y">32</property> </packing> </child> <child> - <widget class="GtkFixed" id="fixed4"> - <property name="width_request">0</property> - <property name="height_request">0</property> + <widget class="GtkLabel" id="lblType"> + <property name="width_request">88</property> + <property name="height_request">16</property> <property name="visible">True</property> - </widget> - <packing> - <property name="x">0</property> - <property name="y">0</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label10"> - <property name="width_request">46</property> - <property name="height_request">17</property> - <property name="visible">True</property> - <property name="label" translatable="yes">%</property> + <property name="label" translatable="yes">Type</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> + <property name="wrap">True</property> <property name="selectable">False</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> @@ -170,81 +156,21 @@ <property name="angle">0</property> </widget> <packing> - <property name="x">176</property> + <property name="x">104</property> <property name="y">8</property> </packing> </child> <child> - <widget class="GtkEntry" id="valDrop_time"> - <property name="width_request">48</property> - <property name="height_request">24</property> + <widget class="GtkLabel" id="lblValue"> + <property name="width_request">80</property> + <property name="height_request">16</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">232</property> - <property name="y">32</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="valRaise_time"> - <property name="width_request">48</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">232</property> - <property name="y">56</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="valChangeD_time"> - <property name="width_request">48</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">232</property> - <property name="y">80</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label11"> - <property name="width_request">46</property> - <property name="height_request">17</property> - <property name="visible">True</property> - <property name="label" translatable="yes">sec.</property> + <property name="label" translatable="yes">Value</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> + <property name="wrap">True</property> <property name="selectable">False</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> @@ -256,144 +182,17 @@ <property name="angle">0</property> </widget> <packing> - <property name="x">232</property> + <property name="x">200</property> <property name="y">8</property> </packing> </child> <child> - <widget class="GtkEntry" id="valChangeU_percent"> - <property name="width_request">48</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">176</property> - <property name="y">104</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="valChangeU_time"> - <property name="width_request">48</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">232</property> - <property name="y">104</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="radDrop"> - <property name="width_request">140</property> - <property name="height_request">22</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">32</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="radRaise"> - <property name="width_request">140</property> - <property name="height_request">22</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">radDrop</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">56</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="radChangeD"> - <property name="width_request">140</property> - <property name="height_request">22</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">radDrop</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">80</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="radChangeU"> - <property name="width_request">140</property> - <property name="height_request">22</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">radDrop</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">104</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="lblEventChange"> - <property name="width_request">128</property> + <widget class="GtkLabel" id="lblTime"> + <property name="width_request">80</property> <property name="height_request">16</property> <property name="visible">True</property> - <property name="label" translatable="yes">Event</property> + <property name="label" translatable="yes">Time</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -409,186 +208,43 @@ <property name="angle">0</property> </widget> <packing> - <property name="x">32</property> + <property name="x">284</property> <property name="y">8</property> </packing> </child> <child> - <widget class="GtkFileChooserButton" id="filechooserbuttonchange"> - <property name="width_request">168</property> - <property name="height_request">32</property> + <widget class="GtkLabel" id="lblNotify"> + <property name="width_request">96</property> + <property name="height_request">16</property> <property name="visible">True</property> - <property name="title" translatable="yes">Select A File</property> - <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> - <property name="local_only">True</property> - <property name="show_hidden">False</property> - <property name="do_overwrite_confirmation">False</property> + <property name="label" translatable="yes">Notified?</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="width_chars">-1</property> - <signal name="selection_changed" handler="on_change_selection_changed" last_modification_time="Tue, 25 Sep 2007 14:38:19 GMT"/> + <property name="single_line_mode">False</property> + <property name="angle">0</property> </widget> <packing> - <property name="x">328</property> + <property name="x">0</property> <property name="y">72</property> </packing> </child> <child> - <widget class="GtkCheckButton" id="chk_ChangeBehavior"> - <property name="width_request">168</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">checkbutton1</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x">328</property> - <property name="y">48</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="chkChangeNotified"> - <property name="width_request">168</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">checkbutton1</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x">328</property> - <property name="y">24</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label7"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="lblChange"> - <property name="visible">True</property> - <property name="label" translatable="yes">Changes</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.519999980927</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkExpander" id="expander2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="expanded">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkFrame" id="frame2"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkAlignment" id="alignment3"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">12</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkFixed" id="fixed2"> - <property name="visible">True</property> - - <child> - <widget class="GtkEntry" id="valThreshold"> - <property name="width_request">112</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">176</property> - <property name="y">64</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="lblValue"> - <property name="width_request">72</property> + <widget class="GtkLabel" id="lblScript"> + <property name="width_request">144</property> <property name="height_request">16</property> <property name="visible">True</property> - <property name="label" translatable="yes">Value (%)</property> + <property name="label" translatable="yes">Behavior script</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -604,55 +260,70 @@ <property name="angle">0</property> </widget> <packing> - <property name="x">176</property> - <property name="y">16</property> + <property name="x">120</property> + <property name="y">72</property> </packing> </child> <child> - <widget class="GtkRadioButton" id="radDecrease"> - <property name="width_request">140</property> - <property name="height_request">22</property> + <widget class="GtkFileChooserButton" id="Behavior"> + <property name="width_request">144</property> + <property name="height_request">30</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> + <property name="title" translatable="yes">Select A File</property> + <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> + <property name="local_only">True</property> + <property name="show_hidden">False</property> + <property name="do_overwrite_confirmation">False</property> + <property name="width_chars">-1</property> </widget> <packing> - <property name="x">32</property> - <property name="y">64</property> + <property name="x">120</property> + <property name="y">96</property> </packing> </child> <child> - <widget class="GtkRadioButton" id="radBoth"> - <property name="width_request">140</property> + <widget class="GtkCheckButton" id="chkNotify"> + <property name="width_request">24</property> <property name="height_request">24</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">False</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> - <property name="group">radDecrease</property> + + <child> + <placeholder/> + </child> </widget> <packing> <property name="x">32</property> - <property name="y">88</property> + <property name="y">96</property> </packing> </child> <child> - <widget class="GtkLabel" id="lblEventThreshold"> - <property name="width_request">136</property> + <widget class="GtkComboBox" id="cbbEvent"> + <property name="width_request">88</property> + <property name="height_request">30</property> + <property name="visible">True</property> + <property name="items" translatable="yes"></property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + <signal name="changed" handler="on_cbb_conf_event_changed"/> + </widget> + <packing> + <property name="x">8</property> + <property name="y">32</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="lblEvent"> + <property name="width_request">88</property> <property name="height_request">16</property> <property name="visible">True</property> <property name="label" translatable="yes">Event</property> @@ -671,108 +342,106 @@ <property name="angle">0</property> </widget> <packing> - <property name="x">32</property> - <property name="y">16</property> + <property name="x">8</property> + <property name="y">8</property> </packing> </child> <child> - <widget class="GtkRadioButton" id="radIncrease"> - <property name="width_request">140</property> - <property name="height_request">22</property> + <widget class="GtkButton" id="btnApply"> + <property name="width_request">144</property> + <property name="height_request">29</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">False</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">radDecrease</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">40</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="chkThreshold"> - <property name="width_request">264</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x">32</property> - <property name="y">120</property> - </packing> - </child> + <signal name="clicked" handler="on_btnApply_clicked"/> - <child> - <widget class="GtkCheckButton" id="chk_ThresholdBehavior"> - <property name="width_request">168</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">checkbutton2</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x">328</property> - <property name="y">40</property> - </packing> - </child> + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> - <child> - <widget class="GtkFileChooserButton" id="threshold_behavior_path"> - <property name="width_request">168</property> - <property name="height_request">32</property> - <property name="visible">True</property> - <property name="title" translatable="yes">Select A File</property> - <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> - <property name="local_only">True</property> - <property name="show_hidden">False</property> - <property name="do_overwrite_confirmation">False</property> - <property name="width_chars">-1</property> - <signal name="selection_changed" handler="on_threshold_selection_changed" last_modification_time="Tue, 25 Sep 2007 14:36:58 GMT"/> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-yes</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="lblBtnApply"> + <property name="visible">True</property> + <property name="label" translatable="yes">Apply changes</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> </widget> <packing> - <property name="x">328</property> - <property name="y">64</property> + <property name="x">8</property> + <property name="y">160</property> </packing> </child> <child> - <widget class="GtkCheckButton" id="chkThresholdNotified"> - <property name="width_request">168</property> - <property name="height_request">24</property> + <widget class="GtkButton" id="btnAdd"> + <property name="width_request">144</property> + <property name="height_request">29</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">checkbutton2</property> + <property name="label" translatable="yes">button1</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> + <signal name="clicked" handler="on_btnAdd_clicked" last_modification_time="Tue, 09 Oct 2007 18:34:49 GMT"/> </widget> <packing> - <property name="x">328</property> - <property name="y">16</property> + <property name="x">176</property> + <property name="y">160</property> </packing> </child> </widget> @@ -808,12 +477,13 @@ <child> <widget class="GtkLabel" id="lblThreshold"> <property name="visible">True</property> - <property name="label" translatable="yes">Threshold</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Test notifications</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> <property name="wrap">False</property> - <property name="selectable">False</property> + <property name="selectable">True</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">0</property> @@ -868,37 +538,41 @@ <property name="visible">True</property> <child> - <widget class="GtkButton" id="lblBtnDark"> + <widget class="GtkButton" id="lblBtnLight"> <property name="width_request">130</property> - <property name="height_request">29</property> + <property name="height_request">30</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_btnDark_clicked" last_modification_time="Wed, 03 Oct 2007 09:23:25 GMT"/> + <signal name="clicked" handler="on_btnLight_clicked"/> + + <child> + <placeholder/> + </child> </widget> <packing> - <property name="x">208</property> + <property name="x">16</property> <property name="y">0</property> </packing> </child> <child> - <widget class="GtkButton" id="lblBtnLight"> + <widget class="GtkButton" id="lblBtnDark"> <property name="width_request">130</property> - <property name="height_request">30</property> + <property name="height_request">29</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_btnLight_clicked" last_modification_time="Wed, 03 Oct 2007 09:23:19 GMT"/> + <signal name="clicked" handler="on_btnDark_clicked"/> + + <child> + <placeholder/> + </child> </widget> <packing> - <property name="x">48</property> + <property name="x">160</property> <property name="y">0</property> </packing> </child> @@ -961,276 +635,6 @@ <property name="fill">True</property> </packing> </child> - - <child> - <widget class="GtkFrame" id="frame3"> - <property name="border_width">5</property> - <property name="height_request">136</property> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkAlignment" id="alignment4"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">12</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkFixed" id="fixed3"> - <property name="visible">True</property> - - <child> - <widget class="GtkEntry" id="txtRate"> - <property name="width_request">104</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">168</property> - <property name="y">8</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="txtSample"> - <property name="width_request">104</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="x">168</property> - <property name="y">40</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="lblRate"> - <property name="width_request">224</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="label" translatable="yes">Rate :</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="x">0</property> - <property name="y">8</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="btnApply"> - <property name="width_request">144</property> - <property name="height_request">30</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_btnApply_clicked"/> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-yes</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="lblBtnApply"> - <property name="visible">True</property> - <property name="label" translatable="yes">Apply changes</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="x">0</property> - <property name="y">72</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="lblSample"> - <property name="width_request">240</property> - <property name="height_request">24</property> - <property name="visible">True</property> - <property name="label" translatable="yes">Sample :</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="x">0</property> - <property name="y">40</property> - </packing> - </child> - - <child> - <widget class="GtkComboBox" id="cbbConfig"> - <property name="width_request">150</property> - <property name="height_request">30</property> - <property name="visible">True</property> - <property name="items" translatable="yes">1 -2 -3 -4 -5 -6 -7</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="x">320</property> - <property name="y">0</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="btnSet"> - <property name="width_request">149</property> - <property name="height_request">30</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">button1</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <signal name="clicked" handler="on_btnSet_clicked" last_modification_time="Thu, 04 Oct 2007 15:53:35 GMT"/> - </widget> - <packing> - <property name="x">320</property> - <property name="y">40</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="lblControl"> - <property name="visible">True</property> - <property name="label" translatable="yes">Control</property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> </widget> </child> </widget> 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-09 15:32:49 UTC (rev 594) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-10 12:48:07 UTC (rev 595) @@ -16,70 +16,35 @@ # ########################################################### def new(self): - #Fill the text box with the previous values - self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) - self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) - self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) - self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) - self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) - self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) - self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) - self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) - self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) - self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) - self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) - - #Restore the previous radio button status - self.get_widget('radDrop').set_active(_me.get_param('drop_rad')) - self.get_widget('radRaise').set_active(_me.get_param('raise_rad')) - self.get_widget('radChangeD').set_active(_me.get_param('changeD_rad')) - self.get_widget('radChangeU').set_active(_me.get_param('changeU_rad')) - self.get_widget('radIncrease').set_active(_me.get_param('increase_rad')) - self.get_widget('radDecrease').set_active(_me.get_param('decrease_rad')) - self.get_widget('radBoth').set_active(_me.get_param('both_rad')) - - #Restore the check boxes - self.get_widget('chkThreshold').set_active(_me.get_param('threshold_chk')) - self.get_widget('chk_ThresholdBehavior').set_active(_me.get_param('chk_ThresholdBehavior')) - self.get_widget('chk_ChangeBehavior').set_active(_me.get_param('chk_ChangeBehavior')) self.get_widget("window1").set_title(_me.string('name_to_read')) + self.get_widget("lblThreshold").set_text(_me.string('widget_lblTest')) - #Set the labels - self.get_widget("radBoth").set_label(_me.string('widget_lblBoth')) - self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) - self.get_widget("lblChange").set_text(_me.string('widget_lblChange')) - self.get_widget("radChangeD").set_label(_me.string('widget_lblChangeD')) - self.get_widget("radChangeU").set_label(_me.string('widget_lblChangeU')) - self.get_widget("radDecrease").set_label(_me.string('widget_lblDecrease')) - self.get_widget("radDrop").set_label(_me.string('widget_lblDrop')) - self.get_widget("lblEventChange").set_text(_me.string('widget_lblEvent')) - self.get_widget("lblEventThreshold").set_text(_me.string('widget_lblEvent')) - self.get_widget("radIncrease").set_label(_me.string('widget_lblIncrease')) - self.get_widget("radRaise").set_label(_me.string('widget_lblRaise')) - self.get_widget("lblThreshold").set_text(_me.string('widget_lblThreshold')) - self.get_widget("lblValue").set_text(_me.string('widget_lblValue')) - self.get_widget("lblControl").set_text(_me.string('widget_lblControl')) - self.get_widget("chkThreshold").set_label(_me.string('w... [truncated message content] |
From: Paul_R <c2m...@c2...> - 2007-10-09 15:33:28
|
Author: Paul_R Date: 2007-10-09 17:32:49 +0200 (Tue, 09 Oct 2007) New Revision: 594 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/trunk/Light_monitor/about.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Changed the treeview config to enable to select a row with only one click. 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-09 14:34:47 UTC (rev 593) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-09 15:32:49 UTC (rev 594) @@ -120,7 +120,8 @@ self.get_widget('cbb_conf_event').set_active(0) self.get_widget('txt_conf_value').set_text('1.0') self.get_widget('txt_conf_time').set_text('0.1') - self.gadget_viewer.connect("row_activated", self.on_row_selected) + self.gadget_viewer.get_selection().connect("changed",self.on_row_selected) + #self.gadget_viewer.connect("row_activated", self.on_row_selected) self.measure.event_tab = _me.get_param('config') self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblChange')) self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblThreshold')) @@ -137,7 +138,7 @@ def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) - self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) + self.get_widget("lbclient_conf_value").set_text(_me.string('conf_lblValue')) self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) self.get_widget("lbl_conf_notified").set_text(_me.string('conf_lblNotified')) self.get_widget("lbl_conf_behavior").set_text(_me.string('conf_lblBehavior')) @@ -155,15 +156,16 @@ # On row selected # ########################################################### - def on_row_selected(self, treeview, path, view_column): - self.iter = self.value_list.get_iter(path) - index = self.value_list.get_value(self.iter, 0) - event = self.value_list.get_value(self.iter, 1) - typet = self.value_list.get_value(self.iter, 2) - value = self.value_list.get_value(self.iter, 3) - time = self.value_list.get_value(self.iter, 4) - notify = self.value_list.get_value(self.iter, 5) - behavior = self.value_list.get_value(self.iter, 6) + def on_row_selected(self, obj): + path = obj.get_selected_rows() + self.__iter = self.value_list.get_iter(path[1][0]) + index = self.value_list.get_value(self.__iter, 0) + event = self.value_list.get_value(self.__iter, 1) + typet = self.value_list.get_value(self.__iter, 2) + value = self.value_list.get_value(self.__iter, 3) + time = self.value_list.get_value(self.__iter, 4) + notify = self.value_list.get_value(self.__iter, 5) + behavior = self.value_list.get_value(self.__iter, 6) if event == _me.string('conf_lblChange'): self.get_widget('cbb_conf_event').set_active(0) @@ -199,15 +201,15 @@ self.get_widget('conf_behavior').set_filename(behavior) else: self.get_widget('conf_behavior').set_filename('None') + - ########################################################### # # On row modified # ########################################################### def on_btn_conf_modify_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab = _me.get_param('config') length = len(_me.get_param('config')) @@ -238,11 +240,11 @@ # ########################################################### def on_btn_conf_remove_clicked(self, widget, *args): - index = self.value_list.get_value(self.iter, 0) + index = self.value_list.get_value(self.__iter, 0) self.measure.event_tab =_me.get_param('config') self.measure.event_tab.pop(index - 1) _me.set_param('config', self.measure.event_tab) - self.iter = 0 + self.__iter = 0 self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) @@ -280,14 +282,12 @@ def verify_tab(self, tab): for i in range(len(self.measure.event_tab)): if self.measure.event_tab[i][1] == tab[1]: - print '1' if self.measure.event_tab[i][2] == tab[2]: - print '2' if self.measure.event_tab[i][3] == tab[3]: - print '3' if self.measure.event_tab[i][4] == tab[4]: - print '4' - return False + if self.measure.event_tab[i][5] == tab[5]: + if self.measure.event_tab[i][6] == tab[6]: + return False return True ########################################################### @@ -388,7 +388,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) + 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] 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-09 14:34:47 UTC (rev 593) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-09 15:32:49 UTC (rev 594) @@ -97,7 +97,7 @@ #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)) - + #Fill... context.set_line_width(2.0) context.set_source_rgb(0, 0, 1) context.move_to(rect.x - 2, rect.height + 2) @@ -107,9 +107,8 @@ context.line_to(rect.x + ((i) * coeff_x), rect.height + 5) context.close_path() context.set_source_rgba(1.0, 0, 0, 0.2) - context.fill() - + #and trace the curce context.set_line_width(1.0) context.set_source_rgb(1, 0, 0) context.move_to(rect.x - 2, rect.height + 2) Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 14:34:47 UTC (rev 593) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 15:32:49 UTC (rev 594) @@ -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_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/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-09 14:34:47 UTC (rev 593) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-09 15:32:49 UTC (rev 594) @@ -10,6 +10,7 @@ <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,13 +20,11 @@ <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> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <widget_lblBoth type='str'>Both direction</widget_lblBoth> <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> @@ -42,9 +41,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> @@ -60,6 +60,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> - <conf_lblNotified type='str'>Notified ?</conf_lblNotified> + <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) |
From: Paul_R <c2m...@c2...> - 2007-10-09 14:35:24
|
Author: Paul_R Date: 2007-10-09 16:34:47 +0200 (Tue, 09 Oct 2007) New Revision: 593 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/trunk/Light_monitor/about.xml Log: * Fill the graph 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-09 12:46:31 UTC (rev 592) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-09 14:34:47 UTC (rev 593) @@ -34,7 +34,7 @@ context.rectangle(rect.x, rect.y, rect.width, rect.height) #set a white background context.set_source_rgb(1, 1, 1) - context.fill_preserve() + context.fill() #draw a black border context.set_source_rgb(0, 0, 0) context.set_line_width(1) @@ -98,11 +98,25 @@ coeff_y = float(rect.height / 1124.00) coeff_x = float(rect.width / (self.light_measure_graph.sample - 1)) - #trace the curve - context.move_to(rect.x, rect.height) - context.set_source_rgb(1.0, 0, 0) + context.set_line_width(2.0) + 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)) 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.close_path() + context.set_source_rgba(1.0, 0, 0, 0.2) + + context.fill() + + context.set_line_width(1.0) + 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)) + 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.stroke() class lightMeasure(): Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 12:46:31 UTC (rev 592) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 14:34:47 UTC (rev 593) @@ -2,6 +2,6 @@ <about> <gadget_author type='str'>Paul Rathgeb</gadget_author> <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> - <gadget_name type='str'>light_monitor</gadget_name> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |
From: Paul_R <c2m...@c2...> - 2007-10-09 12:46:43
|
Author: Paul_R Date: 2007-10-09 14:46:31 +0200 (Tue, 09 Oct 2007) New Revision: 592 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/trunk/Light_monitor/about.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Added a protection to not add a config already in the setting table. 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-09 09:30:03 UTC (rev 591) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-09 12:46:31 UTC (rev 592) @@ -129,7 +129,6 @@ for i in range(len(self.measure.event_tab)): self.add_row(i) - ########################################################### # # Update the labels @@ -225,11 +224,13 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab[(index-1)] = value - _me.set_param('config', self.measure.event_tab) - self.value_list.clear() - for i in range(len(self.measure.event_tab)): - self.add_row(i) + if self.verify_tab(value): + + self.measure.event_tab[(index-1)] = value + _me.set_param('config', self.measure.event_tab) + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) ########################################################### # @@ -265,15 +266,29 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab.append(value) - self.refresh_tree() + if self.verify_tab(value): + self.measure.event_tab.append(value) + self.refresh_tree() def refresh_tree(self): - print 'refresh tree =========================================================' _me.set_param('config', self.measure.event_tab) self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) + + + def verify_tab(self, tab): + for i in range(len(self.measure.event_tab)): + if self.measure.event_tab[i][1] == tab[1]: + print '1' + if self.measure.event_tab[i][2] == tab[2]: + print '2' + if self.measure.event_tab[i][3] == tab[3]: + print '3' + if self.measure.event_tab[i][4] == tab[4]: + print '4' + return False + return True ########################################################### # 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-09 09:30:03 UTC (rev 591) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-09 12:46:31 UTC (rev 592) @@ -150,19 +150,14 @@ def event_control(self): if self.GUI_on == False: for i in range (len(self.event_tab)): - print 'goto threshold control' self.Threshold_control(i) - print 'goto change control' self.Change_control(i) #Gadget or test notifications else: - print 'GUI on' if self.search_light_flag: - print 'search light' self.search_light(self.light_search) else: - print 'goto test function' self.test_func() #disable gadget notifications self.notify = False @@ -170,14 +165,12 @@ #goto test notification every sec. if self.wait == 0: self.wait = 10 - print 'goto notifications' self.test_notification() else: self.wait -= 1 # To prevent notifications at startup if self.start_flag == True: - print 'start flag' self.change_event = False self.threshold_event = False self.start_flag = False @@ -187,7 +180,6 @@ def change_control(self): # Determine how many point must be checked for changes events - print 'Enter change control' pts_per_sec = self.sample / (self.rate * self.sample) if self.val_drop_time >= 0.1 and self.val_drop > 0: @@ -202,7 +194,6 @@ if self.val_changeU_time >= 0.1 and self.val_changeU > 0: self.changeU_point = int(self.val_changeU_time * pts_per_sec) self.set_timeout(self.changeU_point) - print 'exiting change control' ########################################################### @@ -214,45 +205,36 @@ if self.event_tab[index][1] == 1: if self.event_tab[index][7] != True: if self.event_tab[index][2] == 0: - print 'increase detected' #Increasing threshold control if self.Increase_control(self.event_tab[index][3]) == True: self.event_tab[index][7] = True elif self.event_tab[index][2] == 1: - print 'decrease detected' #Decreasing threshold control if self.Decrease_control(self.event_tab[index][3]) == True: self.event_tab[index][7] = True elif self.event_tab[index][2] == 2: - print 'both detected' #Both direction theshold control if self.Both_control(self.event_tab[index][3]) == True: self.event_tab[index][7] = True def Increase_control(self, value): - print 'enter increase control' val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 if val_prev <= value and val_act > value: return True - print 'leave increase control' def Decrease_control(self, val): - print 'enter decrease control' val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 val_prev = (self.val_table[len(self.val_table)-2]*100) / 1124.0 if val_prev >= val and val_act < val: return True - print 'leave decrease control' def Both_control(self, val): - print 'enter both control' val_act = (self.val_table[int(len(self.val_table)-1)]*100) / 1124.0 val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / 1124.0 if val_prev <= val and val_act > val or val_prev >= val and val_act < val: return True - print 'leave both control' ########################################################### @@ -263,37 +245,27 @@ def Change_control(self, i): #Changements control if self.event_tab[i][1] == 0: - print 'change detected' pts_per_sec = self.sample / (self.rate * self.sample) time = int(self.event_tab[i][4] * pts_per_sec) if self.event_tab[i][7] != True: # Drop change part : if self.event_tab[i][2] == 0: - print 'drop detected' if self.Drop_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: self.event_tab[i][7] = True - print 'dropped' # Raise change part if self.event_tab[i][2] == 1: - print 'raise detected' if self.Raise_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: self.event_tab[i][7] = True - print 'raised' # Drop and Raise change if self.event_tab[i][2] == 2: - print 'drop and raise detected' if self.ChangeD_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: self.event_tab[i][7] = True - print 'drop and raise event !' # Raise and Drop change if self.event_tab[i][2] == 3: - print 'raise and drop detected' if self.ChangeU_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: self.event_tab[i][7] = True - print 'raise and drop event !' def Drop_control(self, time, val, timeout, index): - print 'enter drop control' #timeout control : to prevent multiple notifications with the same event if timeout != 0: timeout -= 1 @@ -315,10 +287,8 @@ self.set_timeout(timeout) else: self.event_tab[index][8] = timeout - print 'leave drop control' def Raise_control(self, time, val, timeout, index): - print 'enter raise control' if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout @@ -340,10 +310,8 @@ self.set_timeout(timeout) else: self.event_tab[index][8] = timeout - print 'leave raise control' def ChangeD_control(self, time, val, timeout, index): - print 'enter drop and raise control' if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout @@ -366,12 +334,10 @@ self.set_timeout(timeout) else: self.event_tab[index][8] = timeout - print 'leave drop and raise control' return False def ChangeU_control(self, time, val, timeout, index): - print 'enter raise and drop control' if timeout != 0: timeout -= 1 init_val = len(self.val_table) - 1 - int(time) + timeout @@ -394,7 +360,6 @@ self.set_timeout(timeout) else: self.event_tab[index][8] = timeout - print 'leave raise and drop control' return False @@ -405,68 +370,50 @@ ########################################################### def test_func(self): if self.threshold_event != True: - print 'test threshold control' #Decrease threshold control if self.decrease: - print 'test decrease' if self.Decrease_control(self.val_threshold) == True: self.threshold_event = True - print 'test decrease event' #Increasing threshold control if self.increase: - print 'test increase' if self.Increase_control(self.val_threshold) == True: self.threshold_event = True - print 'test increase event' #Both direction theshold control if self.both: - print 'test both' if self.Both_control(self.val_threshold) == True: self.threshold_event = True - print 'test both event' #Changements control if self.change_event != True: timeout = self.get_timeout() - print 'test change control' # Drop change part : if self.drop == True and self.val_drop_time > 0.0: - print 'test drop detected' if self.Drop_control(self.drop_point, self.val_drop, timeout, 0) == True: self.change_event = True - print 'test drop event' # Raise change part if self.raising == True and self.val_raise_time > 0.0: - print 'test raise detected' if self.Raise_control(self.raise_point, self.val_raise, timeout, 0) == True: self.change_event = True - print 'test raise event' # Drop and Raise change if self.changeD == True and self.val_changeD_time > 0.0: - print 'test drop and raise detected' if self.ChangeD_control(self.changeD_point, self.val_changeD, timeout, 0) == True: self.change_event = True - print 'test drop and raise event' # Raise and Drop change if self.changeU == True and self.val_changeU_time > 0.0: - print 'test raise and drop detected' if self.ChangeU_control(self.changeU_point, self.val_changeU, timeout, 0) == True: self.change_event = True - print 'test raise and drop event' + def test_notification(self): - print 'enter test notifications' if self.threshold_event == True: if self.threshold_notified: path = self.change_behavior path = "'%s'" % path if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior) and os.path.exists(self.threshold_behavior): - print 'threshold behavior script' self.threshold_event = False tux.sys.shell_free(path) else: - print 'threshold default behavior' self.threshold_event = False thread.start_new_thread(self.test_default_behavior, (self.thresholdtext,)) else: @@ -477,11 +424,9 @@ path = self.change_behavior path = "'%s'" % path if self.change_behavior_chk and os.path.isfile(self.change_behavior) and os.path.exists(self.change_behavior): - print 'change behavior script' self.change_event = False tux.sys.shell_free(path) else: - print 'change default behavior' self.change_event = False thread.start_new_thread(self.test_default_behavior, (self.changetext,)) else: Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 09:30:03 UTC (rev 591) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 12:46:31 UTC (rev 592) @@ -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'>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> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-09 09:30:03 UTC (rev 591) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-09 12:46:31 UTC (rev 592) @@ -10,7 +10,6 @@ <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> @@ -20,11 +19,13 @@ <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> + <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> @@ -41,10 +42,9 @@ <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> + <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> @@ -60,6 +60,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> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <conf_lblNotified type='str'>Notified ?</conf_lblNotified> <widget_lblThreshold type='str'>Threshold</widget_lblThreshold> </strings> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |
From: Paul_R <c2m...@c2...> - 2007-10-09 09:30:06
|
Author: Paul_R Date: 2007-10-09 11:30:03 +0200 (Tue, 09 Oct 2007) New Revision: 591 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/about.xml software/gadgets/light_monitor/trunk/Light_monitor/settings.xml Log: * Minor changes to differentiate it compared to the battery monitor gadget Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 09:02:10 UTC (rev 590) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-09 09:30:03 UTC (rev 591) @@ -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_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> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-09 09:02:10 UTC (rev 590) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-09 09:30:03 UTC (rev 591) @@ -31,9 +31,9 @@ <general> <gui_state> <widget> - <y type='int'>73</y> + <y type='int'>317</y> <visible type='bool'>True</visible> - <x type='int'>10</x> + <x type='int'>0</x> </widget> <conf> <y type='int'>131</y> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |
Author: Paul_R Date: 2007-10-09 11:02:10 +0200 (Tue, 09 Oct 2007) New Revision: 590 Added: software/gadgets/battery_monitor/ software/gadgets/battery_monitor/branches/ software/gadgets/battery_monitor/tags/ software/gadgets/battery_monitor/trunk/ software/gadgets/battery_monitor/trunk/Battery_monitor.tgf software/gadgets/battery_monitor/trunk/Battery_monitor_svn/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Pictures/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Pictures/Icons/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Pictures/Icons/gadget.png software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.glade software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/main.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/notify.pyp software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Strings/ 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/parts.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/settings.xml software/gadgets/battery_monitor/trunk/Battery_monitor_svn/strings.xml Log: * Added the battery_monitor gadget. Only the function's names and the monitoring signal has been changed from the light_monitor gadget. Added: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf =================================================================== (Binary files differ) Property changes on: software/gadgets/battery_monitor/trunk/Battery_monitor.tgf ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Pictures/Icons/gadget.png =================================================================== (Binary files differ) Property changes on: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Pictures/Icons/gadget.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: 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 (rev 0) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/Battery_class.py 2007-10-09 09:02:10 UTC (rev 590) @@ -0,0 +1,468 @@ +import gtk +import sys +import time +import os +import threading +import thread +sys.path.append('/opt/tuxdroid/api/python') +from tux import * + +class Graph(gtk.DrawingArea): + def __init__(self): + super(Graph, self).__init__() + self.connect("expose_event", self.expose) + self.context = None + + def expose(self, widget, event): + #when an event occur, update the context + self.context = widget.window.cairo_create() + self.context.rectangle(event.area.x, event.area.y, + event.area.width, event.area.height) + self.context.clip() + self.draw(self.context) + return False + + def refresh(self): + if self.window: + width,height = self.window.get_size() + self.window.invalidate_rect(gtk.gdk.Rectangle(0,0,width,height),False) + + def draw(self, context): + rect = self.get_allocation() + #draw axes + #draw a rectangle in the window area + context.rectangle(rect.x, rect.y, rect.width, rect.height) + #set a white background + context.set_source_rgb(1, 1, 1) + context.fill_preserve() + #draw a black border + context.set_source_rgb(0, 0, 0) + context.set_line_width(1) + context.stroke() + + #draw horizontal grid with 10 div. and 10 sub-div + for i in range(20): + y = (rect.height / 20.0) * float(i) + #place correctly the vector + context.move_to(rect.width, y) + if i % 2 == 1: + #Minor div: no text + context.set_source_rgb(0.2, 0.2, 0.2) + context.set_line_width(0.4) + context.line_to(0, y) + else: + #Major div: place text + context.set_source_rgb(0, 0, 0) + context.set_line_width(0.6) + context.line_to(0, y) + context.set_source_rgb(0.2, 0.2, 0.2) + context.show_text(str((10-(i/2))*10)+"%") + context.stroke() + + #draw the threshold line + if self.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.measure_graph.val_threshold / 100.0))) + context.line_to(rect.width, rect.height - (rect.height * (self.measure_graph.val_threshold / 100.0))) + context.stroke() + + #draw vertical division + #create a tab with the wanted divisions + temp_tab = [0.25, 0.5, 0.75] + for i in range(3): + 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) + #trace a line + context.line_to(rect.width * temp_tab[i], rect.height) + #replace the vector to draw text + context.move_to(rect.width * temp_tab[i], rect.height - 5) + #determine the time labels + context.show_text(str((self.measure_graph.rate * self.measure_graph.sample) - ((self.measure_graph.rate) * + self.measure_graph.sample * temp_tab[i])) + " sec.") + context.stroke() + + #display sample and rate + #move the vector in the bottom + context.move_to(10, rect.height - 10) + #display the rate + context.show_text("rate = "+str(self.measure_graph.rate)+" sec.") + context.move_to(10, rect.height - 20) + #and the samples + context.show_text("samples = "+str(self.measure_graph.sample)) + context.stroke() + + #determine the coefficients to adjust the curve in the window space + coeff_y = float(rect.height / 1024.00) + coeff_x = float(rect.width / (self.measure_graph.sample - 1)) + + #trace the curve + context.move_to(rect.x, rect.height) + context.set_source_rgb(1.0, 0, 0) + for i, val in enumerate(self.measure_graph.val_table): + context.line_to(rect.x + ((i) * coeff_x), rect.height - (val * coeff_y)) + context.stroke() + +class Measure(): + def __init__(self): + #Initial value + self.sample = 500.0 + self.val_table = [0] * int(self.sample + 1) + self.value = 0 + self.timecontrol = time.time() + self.rate = 1.0 + self.threshold_chk = False + + self.increase = False + self.decrease = False + self.both = False + self.drop = False + self.raising = False + self.changeD = False + self.changeU = False + + #Events flags + self.threshold_event = False + self.change_event = False + + self.GUI_on = False + self.notify = True + + self.timeout = 0 + self.start_flag = True + self.wait = 0 + #self.temp = 1124 + self.ok_flag = False + self.__on_battery_mutex = threading.Lock() + self.__timeout_mutex = threading.Lock() + + + ########################################################### + # + # Events control + # + ########################################################### + def event_control(self): + if self.GUI_on == False: + for i in range (len(self.event_tab)): + self.Threshold_control(i) + self.Change_control(i) + + #Gadget or test notifications + else: + self.test_func() + #disable gadget notifications + self.notify = False + + #goto test notification every sec. + if self.wait == 0: + self.wait = 10 + self.test_notification() + else: + self.wait -= 1 + + # To prevent notifications at startup + if self.start_flag == True: + self.change_event = False + self.threshold_event = False + self.start_flag = False + for i in range (len(self.event_tab)): + self.event_tab[i][7] = False + + + def change_control(self): + # Determine how many point must be checked for changes events + pts_per_sec = self.sample / (self.rate * self.sample) + + if self.val_drop_time >= 0.1 and self.val_drop > 0: + self.drop_point = int(self.val_drop_time * pts_per_sec) + self.set_timeout(self.drop_point) + if self.val_raise_time >= 0.1 and self.val_raise > 0: + self.raise_point = int(self.val_raise_time * pts_per_sec) + self.set_timeout(self.raise_point) + if self.val_changeD_time >= 0.1 and self.val_changeD > 0: + self.changeD_point = int(self.val_changeD_time * pts_per_sec) + self.set_timeout(self.changeD_point) + if self.val_changeU_time >= 0.1 and self.val_changeU > 0: + self.changeU_point = int(self.val_changeU_time * pts_per_sec) + self.set_timeout(self.changeU_point) + + + ########################################################### + # + # Threshold control + # + ########################################################### + def Threshold_control(self, index): + if self.event_tab[index][1] == 1: + if self.event_tab[index][7] != True: + if self.event_tab[index][2] == 0: + #Increasing threshold control + if self.Increase_control(self.event_tab[index][3]) == True: + self.event_tab[index][7] = True + elif self.event_tab[index][2] == 1: + #Decreasing threshold control + if self.Decrease_control(self.event_tab[index][3]) == True: + self.event_tab[index][7] = True + elif self.event_tab[index][2] == 2: + #Both direction theshold control + if self.Both_control(self.event_tab[index][3]) == True: + self.event_tab[index][7] = True + + def Increase_control(self, value): + val_act = (self.val_table[len(self.val_table)-1]*100) / 1024.0 + val_prev = (self.val_table[len(self.val_table)-2]*100) / 1024.0 + if val_prev <= value and val_act > value: + return True + + + def Decrease_control(self, val): + val_act = (self.val_table[len(self.val_table)-1]*100) / 1024.0 + val_prev = (self.val_table[len(self.val_table)-2]*100) / 1024.0 + if val_prev >= val and val_act < val: + return True + + def Both_control(self, val): + val_act = (self.val_table[int(len(self.val_table)-1)]*100) / 1024.0 + val_prev = (self.val_table[int(len(self.val_table)-2)]*100) / 1024.0 + if val_prev <= val and val_act > val or val_prev >= val and val_act < val: + return True + + + ########################################################### + # + # Changes control + # + ########################################################### + def Change_control(self, i): + #Changements control + if self.event_tab[i][1] == 0: + pts_per_sec = self.sample / (self.rate * self.sample) + time = int(self.event_tab[i][4] * pts_per_sec) + if self.event_tab[i][7] != True: + # Drop change part : + if self.event_tab[i][2] == 0: + if self.Drop_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + self.event_tab[i][7] = True + # Raise change part + if self.event_tab[i][2] == 1: + if self.Raise_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + self.event_tab[i][7] = True + # Drop and Raise change + if self.event_tab[i][2] == 2: + if self.ChangeD_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + self.event_tab[i][7] = True + # Raise and Drop change + if self.event_tab[i][2] == 3: + if self.ChangeU_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + self.event_tab[i][7] = True + + def Drop_control(self, time, val, timeout, index): + #timeout control : to prevent multiple notifications with the same event + 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]) + + if maximum >= self.val_table[len(self.val_table)-1] + ((val/100)*1024): + if self.GUI_on == False: + self.event_tab[index][8] = int(time) + else: + self.set_timeout(int(time)) + return True + else: + if self.GUI_on: + self.set_timeout(timeout) + else: + self.event_tab[index][8] = timeout + + 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]) + + minimum = min(self.val_table[init_val:(len(self.val_table)-1)]) + if minimum <= self.val_table[len(self.val_table)-1] - ((val/100)*1024): + if self.GUI_on == False: + self.event_tab[index][8] = int(time) + else: + self.set_timeout(int(time)) + return True + else: + if self.GUI_on: + self.set_timeout(timeout) + else: + self.event_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]) + + 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)*1024): + maximum = max(self.val_table[init_val:len(self.val_table) - i]) + if maximum >= self.val_table[len(self.val_table) - 1 - i] + val: + if self.GUI_on == False: + self.event_tab[index][8] = int(time) + else: + self.set_timeout(int(time)) + return True + if self.GUI_on: + self.set_timeout(timeout) + else: + self.event_tab[index][8] = timeout + return False + + + def ChangeU_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]) + + 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)*1024): + minimum = min(self.val_table[init_val:len(self.val_table)-i]) + if minimum <= self.val_table[len(self.val_table) - 1 - i] - val: + if self.GUI_on == False: + self.event_tab[index][8] = int(time) + else: + self.set_timeout(int(time)) + return True + if self.GUI_on: + self.set_timeout(timeout) + else: + self.event_tab[index][8] = timeout + return False + + + ########################################################### + # + # Test functions + # + ########################################################### + def test_func(self): + if self.threshold_event != True: + #Decrease threshold control + if self.decrease: + if self.Decrease_control(self.val_threshold) == True: + self.threshold_event = True + #Increasing threshold control + if self.increase: + if self.Increase_control(self.val_threshold) == True: + self.threshold_event = True + #Both direction theshold control + if self.both: + if self.Both_control(self.val_threshold) == True: + self.threshold_event = True + + #Changements control + if self.change_event != True: + timeout = self.get_timeout() + # Drop change part : + if self.drop == True and self.val_drop_time > 0.0: + if self.Drop_control(self.drop_point, self.val_drop, timeout, 0) == True: + self.change_event = True + # Raise change part + if self.raising == True and self.val_raise_time > 0.0: + if self.Raise_control(self.raise_point, self.val_raise, timeout, 0) == True: + self.change_event = True + # Drop and Raise change + if self.changeD == True and self.val_changeD_time > 0.0: + if self.ChangeD_control(self.changeD_point, self.val_changeD, timeout, 0) == True: + self.change_event = True + # Raise and Drop change + if self.changeU == True and self.val_changeU_time > 0.0: + if self.ChangeU_control(self.changeU_point, self.val_changeU, timeout, 0) == True: + self.change_event = True + + + def test_notification(self): + if self.threshold_event == True: + if self.threshold_notified: + path = self.change_behavior + path = "'%s'" % path + if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior) and os.path.exists(self.threshold_behavior): + self.threshold_event = False + tux.sys.shell_free(path) + else: + self.threshold_event = False + thread.start_new_thread(self.test_default_behavior, (self.thresholdtext,)) + else: + self.threshold_event = False + + elif self.change_event == True: + if self.change_notified: + path = self.change_behavior + path = "'%s'" % path + if self.change_behavior_chk and os.path.isfile(self.change_behavior) and os.path.exists(self.change_behavior): + self.change_event = False + tux.sys.shell_free(path) + else: + self.change_event = False + thread.start_new_thread(self.test_default_behavior, (self.changetext,)) + else: + self.change_event = False + + def test_default_behavior(self, txt): + tux.cmd.mouth_open() + tux.tts.speak(txt) + tux.cmd.mouth_close() + + + ########################################################### + # + # Acquire + # + ########################################################### + def on_battery_level(self, args): + self.__on_battery_mutex.acquire() + if self.timecontrol <= time.time(): + self.timecontrol = 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.graph_measure.refresh() + self.event_control() + self.__on_battery_mutex.release() + + + ########################################################### + # + # Timeout management + # + ########################################################### + def set_timeout(self, val): + self.__timeout_mutex.acquire() + self.timeout = val + self.__timeout_mutex.release() + + def get_timeout(self): + self.__timeout_mutex.acquire() + val = self.timeout + self.__timeout_mutex.release() + return val + + Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) Property changes on: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp (rev 0) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/conf/other.pyp 2007-10-09 09:02:10 UTC (rev 590) @@ -0,0 +1,407 @@ +bindtextdomain("params", "") + +class Window(SimpleGladeApp): + def __init__(self, + path=_me.get_path('root') + '/Scripts/Python/GUI/conf/other.glade', + root="window1", + domain="params", **kwargs): + SimpleGladeApp.__init__(self, path, root, domain, **kwargs) + + + def new(self): + self.measure = _me.get_param('measure') + _me.insert_funct('refresh_tree', self.refresh_tree) + self.updates_commons() + self.make_viewtree() + self.update_labels() + + def updates_commons(self): + # Window title + txt = "%s : %s" % (_me.string('name_to_read'), + _me.string('gui_conf_window_title')) + self.get_widget("window1").set_title(txt) + + # About labels + txt = _me.string('gui_conf_about_title') + self.get_widget("label7").set_text(txt) + + txt = "%s : %s" % (_me.string('gui_conf_description_lb'), + _me.get_description()) + self.get_widget("label_description").set_text(txt) + + txt = "%s : %s" % (_me.string('gui_conf_author_lb'), + _me.get_author()) + self.get_widget("label_author").set_text(txt) + + txt = "%s : %s" % (_me.string('gui_conf_version_lb'), + _me.get_version()) + self.get_widget("label_version").set_text(txt) + + # Update Frame + txt = _me.string('gui_conf_update_title') + self.get_widget("label12").set_text(txt) + + txt = "%s : " % _me.string('gui_conf_delay_lb') + self.get_widget("label13").set_text(txt) + + value = _me.get_var('notify_delay') + self.get_widget("delay_spinbutton").set_value(value) + + # Bottom buttons + txt = _me.string('gui_conf_cancel_bt') + self.get_widget("label6").set_text(txt) + + txt = _me.string('gui_conf_accept_bt') + self.get_widget("label5").set_text(txt) + + self.get_widget('txt_conf_rate').set_text(str(_me.get_param('Rate'))) + self.get_widget('txt_conf_sample').set_text(str(_me.get_param('Sample'))) + + + ########################################################### + # + # Light configuration control + # + ########################################################### + def make_viewtree(self): + self.index_column = gtk.TreeViewColumn('Index') + self.index_column.set_min_width(50) + self.index_cell = gtk.CellRendererText() + self.index_column.pack_start(self.index_cell, True) + self.index_column.add_attribute(self.index_cell, 'text', 0) + + self.event_column = gtk.TreeViewColumn(_me.string('conf_lblEvent')) + self.event_column.set_min_width(100) + self.event_cell = gtk.CellRendererText() + self.event_column.pack_start(self.event_cell, True) + self.event_column.add_attribute(self.event_cell, 'text', 1) + + self.type_column = gtk.TreeViewColumn(_me.string('conf_lblType')) + self.type_column.set_min_width(100) + self.type_cell = gtk.CellRendererText() + self.type_column.pack_start(self.type_cell, True) + self.type_column.add_attribute(self.type_cell, 'text', 2) + + self.value_column = gtk.TreeViewColumn(_me.string('conf_lblValue')) + self.value_column.set_min_width(100) + self.value_cell = gtk.CellRendererText() + self.value_column.pack_start(self.value_cell, True) + self.value_column.add_attribute(self.value_cell, 'text', 3) + + self.time_column = gtk.TreeViewColumn(_me.string('conf_lblTime')) + self.time_column.set_min_width(100) + self.time_cell = gtk.CellRendererText() + self.time_column.pack_start(self.time_cell, True) + self.time_column.add_attribute(self.time_cell, 'text', 4) + + self.notified_column = gtk.TreeViewColumn(_me.string('conf_lblNotified')) + self.notified_column.set_min_width(100) + self.notified_cell = gtk.CellRendererText() + self.notified_column.pack_start(self.notified_cell, True) + self.notified_column.add_attribute(self.notified_cell, 'text', 5) + + self.behavior_column = gtk.TreeViewColumn(_me.string('conf_lblBehavior')) + self.behavior_cell = gtk.CellRendererText() + self.behavior_column.pack_start(self.behavior_cell, True) + self.behavior_column.add_attribute(self.behavior_cell, 'text', 6) + + self.value_list = gtk.TreeStore(int, str, str, str, str, str, str) + self.gadget_viewer = gtk.TreeView(self.value_list) + self.gadget_viewer.append_column(self.index_column) + self.gadget_viewer.append_column(self.event_column) + self.gadget_viewer.append_column(self.type_column) + self.gadget_viewer.append_column(self.value_column) + self.gadget_viewer.append_column(self.time_column) + self.gadget_viewer.append_column(self.notified_column) + self.gadget_viewer.append_column(self.behavior_column) + self.get_widget("scrolledwindow1").add(self.gadget_viewer) + self.get_widget("scrolledwindow1").set_size_request(0, 150) + self.get_widget("scrolledwindow1").show_all() + self.get_widget('cbb_conf_event').set_active(0) + self.get_widget('txt_conf_value').set_text('1.0') + self.get_widget('txt_conf_time').set_text('0.1') + self.gadget_viewer.connect("row_activated", self.on_row_selected) + self.measure.event_tab = _me.get_param('config') + self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblChange')) + self.get_widget('cbb_conf_event').append_text(_me.string('conf_lblThreshold')) + self.get_widget('cbb_conf_event').set_active(0) + + for i in range(len(self.measure.event_tab)): + self.add_row(i) + + + ########################################################### + # + # Update the labels + # + ########################################################### + def update_labels(self): + self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) + self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) + self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) + self.get_widget("lbl_conf_time").set_text(_me.string('conf_lblTime')) + self.get_widget("lbl_conf_notified").set_text(_me.string('conf_lblNotified')) + self.get_widget("lbl_conf_behavior").set_text(_me.string('conf_lblBehavior')) + self.get_widget("btn_conf_add").set_label(_me.string('conf_btnAdd')) + self.get_widget("btn_conf_remove").set_label(_me.string('conf_btnRemove')) + self.get_widget("btn_conf_modify").set_label(_me.string('conf_btnModify')) + self.get_widget("btnBehavior").set_label(_me.string('conf_btnBehavior')) + self.get_widget("lbl_conf_sample").set_text(_me.string('conf_lblSample')) + self.get_widget("lbl_conf_rate").set_text(_me.string('conf_lblRate')) + self.get_widget("lblControlFrame").set_text(_me.string('conf_lblControl')) + + + ########################################################### + # + # On row selected + # + ########################################################### + def on_row_selected(self, treeview, path, view_column): + self.iter = self.value_list.get_iter(path) + index = self.value_list.get_value(self.iter, 0) + event = self.value_list.get_value(self.iter, 1) + typet = self.value_list.get_value(self.iter, 2) + value = self.value_list.get_value(self.iter, 3) + time = self.value_list.get_value(self.iter, 4) + notify = self.value_list.get_value(self.iter, 5) + behavior = self.value_list.get_value(self.iter, 6) + + if event == _me.string('conf_lblChange'): + self.get_widget('cbb_conf_event').set_active(0) + if typet == _me.string('conf_lblDrop'): + self.get_widget('cbb_conf_type').set_active(0) + if typet == _me.string('conf_lblRaise'): + self.get_widget('cbb_conf_type').set_active(1) + if typet == _me.string('conf_lblChangeD'): + self.get_widget('cbb_conf_type').set_active(2) + if typet == _me.string('conf_lblChangeU'): + self.get_widget('cbb_conf_type').set_active(3) + self.get_widget('txt_conf_value').set_text(value) + self.get_widget('txt_conf_time').set_text(time) + + else: + self.get_widget('cbb_conf_event').set_active(1) + if typet == _me.string('conf_lblIncrease'): + self.get_widget('cbb_conf_type').set_active(0) + if typet == _me.string('conf_lblDecrease'): + self.get_widget('cbb_conf_type').set_active(1) + if typet == _me.string('conf_lblBoth'): + self.get_widget('cbb_conf_type').set_active(2) + + self.get_widget('txt_conf_value').set_text(value) + self.get_widget('txt_conf_time').set_text('') + + if notify == _me.string('conf_lblNotifiedBehavior'): + self.get_widget('chk_conf_notified').set_active(True) + else: + self.get_widget('chk_conf_notified').set_active(False) + + if behavior != 'N.A.': + self.get_widget('conf_behavior').set_filename(behavior) + else: + self.get_widget('conf_behavior').set_filename('None') + + + ########################################################### + # + # On row modified + # + ########################################################### + def on_btn_conf_modify_clicked(self, widget, *args): + index = self.value_list.get_value(self.iter, 0) + + self.measure.event_tab = _me.get_param('config') + length = len(_me.get_param('config')) + self.verify_value() + + value = [] + value = [index, + self.get_widget('cbb_conf_event').get_active(), + self.get_widget('cbb_conf_type').get_active(), + float(self.get_widget('txt_conf_value').get_text()), + float(self.get_widget('txt_conf_time').get_text()), + self.get_widget('chk_conf_notified').get_active(), + str(self.get_widget('conf_behavior').get_filename()), + False, + 0] + self.measure.event_tab = _me.get_param('config') + self.measure.event_tab[(index-1)] = value + _me.set_param('config', self.measure.event_tab) + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) + + ########################################################### + # + # On row deleted + # + ########################################################### + def on_btn_conf_remove_clicked(self, widget, *args): + index = self.value_list.get_value(self.iter, 0) + self.measure.event_tab =_me.get_param('config') + self.measure.event_tab.pop(index - 1) + _me.set_param('config', self.measure.event_tab) + self.iter = 0 + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) + + ########################################################### + # + # On row added + # + ########################################################### + def on_btn_conf_add_clicked(self, widget, *args): + length = len(_me.get_param('config')) + self.verify_value() + value = [] + value = [(length + 1), + self.get_widget('cbb_conf_event').get_active(), + self.get_widget('cbb_conf_type').get_active(), + float(self.get_widget('txt_conf_value').get_text()), + float(self.get_widget('txt_conf_time').get_text()), + self.get_widget('chk_conf_notified').get_active(), + str(self.get_widget('conf_behavior').get_filename()), + False, + 0] + self.measure.event_tab = _me.get_param('config') + self.measure.event_tab.append(value) + self.refresh_tree() + + def refresh_tree(self): + _me.set_param('config', self.measure.event_tab) + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) + + ########################################################### + # + # Add row function + # + ########################################################### + def add_row(self, tab_index): + self.measure.event_tab = _me.get_param('config') + i = tab_index + + if self.measure.event_tab[i][1] == 0: + Event = _me.string('conf_lblChange') + if self.measure.event_tab[i][2] == 0: + Type = _me.string('conf_lblDrop') + elif self.measure.event_tab[i][2] == 1: + Type = _me.string('conf_lblRaise') + elif self.measure.event_tab[i][2] == 2: + Type = _me.string('conf_lblChangeD') + elif self.measure.event_tab[i][2] == 3: + Type = _me.string('conf_lblChangeU') + Value = str(self.measure.event_tab[i][3]) + Time = str(self.measure.event_tab[i][4]) + else: + Event = _me.string('conf_lblThreshold') + if self.measure.event_tab[i][2] == 0: + Type = _me.string('conf_lblIncrease') + elif self.measure.event_tab[i][2] == 1: + Type = _me.string('conf_lblDecrease') + elif self.measure.event_tab[i][2] == 2: + Type = _me.string('conf_lblBoth') + Value = str(self.measure.event_tab[i][3]) + Time = 'N.A.' + + if self.measure.event_tab[i][5]: + Notify = _me.string('conf_lblNotifiedBehavior') + if self.measure.event_tab[i][6] ==None: + Behavior = _me.string('conf_lblDefaultBehavior') + else: + Behavior = str(self.measure.event_tab[i][6]) + else: + Notify = _me.string('conf_lblNotNotified') + Behavior = 'N.A.' + + self.value_list.append(None,[(i+1), Event, Type, Value, Time, Notify, Behavior]) + + ########################################################### + # + # On combo box event + # + ########################################################### + def on_cbb_conf_event_changed(self, widget, *args): + if self.get_widget('cbb_conf_event').get_active() == 0: + for i in range (4): + self.get_widget('cbb_conf_type').remove_text(0) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblDrop')) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblRaise')) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblChangeD')) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblChangeU')) + self.get_widget('cbb_conf_type').set_active(0) + else: + for i in range (4): + self.get_widget('cbb_conf_type').remove_text(0) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblIncrease')) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblDecrease')) + self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblBoth')) + self.get_widget('cbb_conf_type').set_active(0) + + + ########################################################### + # + # On accept button clicked + # + ########################################################### + def on_accept_clicked(self, widget, *args): + _me.set_param('Rate', float(self.get_widget('txt_conf_rate').get_text())) + _me.set_param('Sample',float(self.get_widget('txt_conf_sample').get_text())) + self.measure.rate = _me.get_param('Rate') + self.measure.sample = _me.get_param('Sample') + + _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) + + self.get_widget("window1").destroy() + + + ########################################################### + # + # On cancel button clicked + # + ########################################################### + def on_cancel_clicked(self, widget, *args): + self.get_widget("window1").destroy() + + ########################################################### + # + # On Clear path button clicked + # + ########################################################### + def on_btnBehavior_clicked(self, widget, *args): + self.get_widget('conf_behavior').set_filename('None') + index = self.value_list.get_value(self.iter, 0) + self.measure.event_tab[index-1][6] = None + + self.value_list.clear() + for i in range(len(self.measure.event_tab)): + self.add_row(i) + + ########################################################### + # + # Verify the value + # + ########################################################### + def verify_value(self): + try: + float(self.get_widget('txt_conf_time').get_text()) + except: + self.get_widget('txt_conf_time').set_text('1.0') + + if float(self.get_widget('txt_conf_time').get_text()) < 1.0: + self.get_widget('txt_conf_time').set_text('1.0') + if float(self.get_widget('txt_conf_time').get_text()) > self.measure.rate * self.measure.sample: + self.get_widget('txt_conf_time').set_text(str(self.measure.rate * self.measure.sample)) + + try: + float(self.get_widget('txt_conf_value').get_text()) + except: + self.get_widget('txt_conf_value').set_text('1') + + if float(self.get_widget('txt_conf_value').get_text()) < 1: + self.get_widget('txt_conf_value').set_text('1') + if float(self.get_widget('txt_conf_value').get_text()) > 100: + self.get_widget('txt_conf_value').set_text('100') + Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade =================================================================== (Binary files differ) Property changes on: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.glade ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp (rev 0) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/GUI/widget/other.pyp 2007-10-09 09:02:10 UTC (rev 590) @@ -0,0 +1,318 @@ +bindtextdomain("params", "") +sys.path.append(_me.get_path('root') + '/Scripts/Python') +from Battery_class import Graph + +class Window(SimpleGladeApp): + + def __init__(self, + path=_me.get_path('root') + '/Scripts/Python/GUI/widget/other.glade', + root="window1", + domain="params", **kwargs): + SimpleGladeApp.__init__(self, path, root, domain, **kwargs) + + ########################################################### + # + # Display the new window + # + ########################################################### + def new(self): + #Fill the text box with the previous values + self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) + self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) + self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) + self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) + self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) + self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) + self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) + self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) + self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) + self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) + self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) + + #Restore the previous radio button status + self.get_widget('radDrop').set_active(_me.get_param('drop_rad')) + self.get_widget('radRaise').set_active(_me.get_param('raise_rad')) + self.get_widget('radChangeD').set_active(_me.get_param('changeD_rad')) + self.get_widget('radChangeU').set_active(_me.get_param('changeU_rad')) + self.get_widget('radIncrease').set_active(_me.get_param('increase_rad')) + self.get_widget('radDecrease').set_active(_me.get_param('decrease_rad')) + self.get_widget('radBoth').set_active(_me.get_param('both_rad')) + + #Restore the check boxes + self.get_widget('chkThreshold').set_active(_me.get_param('threshold_chk')) + self.get_widget('chk_ThresholdBehavior').set_active(_me.get_param('chk_ThresholdBehavior')) + self.get_widget('chk_ChangeBehavior').set_active(_me.get_param('chk_ChangeBehavior')) + self.get_widget("window1").set_title(_me.string('name_to_read')) + + #Set the labels + self.get_widget("radBoth").set_label(_me.string('widget_lblBoth')) + self.get_widget("lblBtnApply").set_text(_me.string('widget_lblBtnApply')) + self.get_widget("lblChange").set_text(_me.string('widget_lblChange')) + self.get_widget("radChangeD").set_label(_me.string('widget_lblChangeD')) + self.get_widget("radChangeU").set_label(_me.string('widget_lblChangeU')) + self.get_widget("radDecrease").set_label(_me.string('widget_lblDecrease')) + self.get_widget("radDrop").set_label(_me.string('widget_lblDrop')) + self.get_widget("lblEventChange").set_text(_me.string('widget_lblEvent')) + self.get_widget("lblEventThreshold").set_text(_me.string('widget_lblEvent')) + self.get_widget("radIncrease").set_label(_me.string('widget_lblIncrease')) + self.get_widget("radRaise").set_label(_me.string('widget_lblRaise')) + self.get_widget("lblThreshold").set_text(_me.string('widget_lblThreshold')) + self.get_widget("lblValue").set_text(_me.string('widget_lblValue')) + self.get_widget("lblControl").set_text(_me.string('widget_lblControl')) + self.get_widget("chkThreshold").set_label(_me.string('widget_lblDisplayThreshold')) + self.get_widget('chk_ThresholdBehavior').set_label(_me.string('widget_lblBehavior')) + self.get_widget('chk_ChangeBehavior').set_label(_me.string('widget_lblBehavior')) + self.get_widget('chkChangeNotified').set_label(_me.string('widget_lblNotified')) + self.get_widget('chkThresholdNotified').set_label(_me.string('widget_lblNotified')) + self.get_widget("lblRate").set_text(_me.string('gui_conf_rate_lb')) + self.get_widget("lblSample").set_text(_me.string('gui_conf_sample_lb')) + self.get_widget("lblBtnDark").set_label(_me.string('widget_lblDark')) + self.get_widget("lblBtnLight").set_label(_me.string('widget_lblLight')) + self.get_widget("btnSet").set_label(_me.string('widget_lblSet')) + + for i in range (7): + self.get_widget('cbbConfig').remove_text(0) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblDrop')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblRaise')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblChangeD')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblChangeU')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblIncrease')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblDecrease')) + self.get_widget('cbbConfig').append_text(_me.string('conf_lblBoth')) + self.get_widget('cbbConfig').set_active(0) + thread.start_new_thread(self.update, ()) + + ########################################################### + # + # Update the values + # + ########################################################### + def update_value(self): + #Rate + _me.set_param('Rate', self.measure.rate) + self.get_widget("txtRate").set_text(str(_me.get_param('Rate'))) + + #Sample + _me.set_param('Sample', self.measure.sample) + self.get_widget("txtSample").set_text(str(_me.get_param('Sample'))) + + #Drop + _me.set_param('drop', self.measure.val_drop) + self.get_widget("valDrop_percent").set_text(str(_me.get_param('drop'))) + _me.set_param('drop_time', self.measure.val_drop_time) + self.get_widget("valDrop_time").set_text(str(_me.get_param('drop_time'))) + + #Raise + _me.set_param('raise', self.measure.val_raise) + self.get_widget("valRaise_percent").set_text(str(_me.get_param('raise'))) + _me.set_param('raise_time', self.measure.val_raise_time) + self.get_widget("valRaise_time").set_text(str(_me.get_param('raise_time'))) + + #Drop and raise + _me.set_param('changeD', self.measure.val_changeD) + self.get_widget("valChangeD_percent").set_text(str(_me.get_param('changeD'))) + _me.set_param('changeD_time', self.measure.val_changeD_time) + self.get_widget("valChangeD_time").set_text(str(_me.get_param('changeD_time'))) + + #Raise and drop + _me.set_param('changeU', self.measure.val_changeU) + self.get_widget("valChangeU_percent").set_text(str(_me.get_param('changeU'))) + _me.set_param('changeU_time', self.measure.val_changeU_time) + self.get_widget("valChangeU_time").set_text(str(_me.get_param('changeU_time'))) + + #Threshold + _me.set_param('threshold', self.measure.val_threshold) + self.get_widget("valThreshold").set_text(str(_me.get_param('threshold'))) + + self.measure.change_control() + + #update the radio button status + self.measure.drop = _me.get_param('drop_rad') + self.measure.raising = _me.get_param('raise_rad') + self.measure.changeD = _me.get_param('changeD_rad') + self.measure.changeU = _me.get_param('changeU_rad') + self.measure.increase = _me.get_param('increase_rad') + self.measure.decrease = _me.get_param('decrease_rad') + self.measure.both = _me.get_param('both_rad') + + self.measure.changetext = _me.string('conf_lblChange') + self.measure.thresholdtext = _me.string('conf_lblThreshold') + # '' the check boxes + self.measure.change_notified = _me.get_param('change_notified') + self.measure.threshold_notified = _me.get_param('threshold_notified') + self.measure.threshold_chk = _me.get_param('threshold_chk') + self.measure.threshold_behavior_chk = _me.get_param('chk_ThresholdBehavior') + self.measure.change_behavior_chk = _me.get_param('chk_ChangeBehavior') + + + + + + ########################################################### + # + # Event functions + # + ########################################################### + def on_window1_destroy(self, widget, *args): + _me.get_param('measure').GUI_on = False + self.measure.GUI_on = False + + + + def on_btnSet_clicked(self, widget, *args): + + if self.measure.threshold_behavior_chk: + threshold_script = self.measure.threshold_behavior + else: + threshold_script = None + + if self.measure.change_behavior_chk: + change_script = self.measure.change_behavior + else: + change_script = None + + if self.get_widget('cbbConfig').get_active() == 0: + val = [len(self.measure.event_tab)+1, 0, 0, + self.measure.val_drop, + self.measure.val_drop_time, + self.measure.change_notified, + change_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 1: + val = [len(self.measure.event_tab)+1, 0, 1, + self.measure.val_raise, + self.measure.val_raise_time, + self.measure.change_notified, + change_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 2: + val = [len(self.measure.event_tab)+1, 0, 2, + self.measure.val_changeD, + self.measure.val_changeD_time, + self.measure.change_notified, + change_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 3: + val = [len(self.measure.event_tab)+1, 0, 3, + self.measure.val_changeU, + self.measure.val_changeU_time, + self.measure.change_notified, + change_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 4: + val = [len(self.measure.event_tab)+1, 1, 0, + self.measure.val_threshold, + 0, + self.measure.threshold_notified, + threshold_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 5: + val = [len(self.measure.event_tab)+1, 1, 1, + self.measure.val_threshold, + 0, + self.measure.threshold_notified, + threshold_script, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 6: + val = [len(self.measure.event_tab)+1, 1, 2, + self.measure.val_threshold, + 0, + self.measure.threshold_notified, + threshold_script, + False, + 0] + self.measure.event_tab.append(val) + refresh_tree = _me.get_funct('refresh_tree') + + refresh_tree() + + def on_btnApply_clicked(self, widget, *args): + #Store the new radio buttons status + _me.set_param('drop_rad', self.get_widget('radDrop').get_active()) + _me.set_param('raise_rad', self.get_widget('radRaise').get_active()) + _me.set_param('changeD_rad', self.get_widget('radChangeD').get_active()) + _me.set_param('changeU_rad', self.get_widget('radChangeU').get_active()) + _me.set_param('increase_rad', self.get_widget('radIncrease').get_active()) + _me.set_param('decrease_rad', self.get_widget('radDecrease').get_active()) + _me.set_param('both_rad', self.get_widget('radBoth').get_active()) + _me.set_param('threshold_chk', self.get_widget('chkThreshold').get_active()) + _me.set_param('chk_ThresholdBehavior', self.get_widget('chk_ThresholdBehavior').get_active()) + _me.set_param('threshold_notified', self.get_widget('chkThresholdNotified').get_active()) + _me.set_param('change_notified', self.get_widget('chkChangeNotified').get_active()) + _me.set_param('chk_ChangeBehavior', self.get_widget('chk_ChangeBehavior').get_active()) + + temp_rate = self.check_float_value(self.get_widget('txtRate').get_text(), 1, 3600) + temp_sample = self.check_float_value(self.get_widget('txtSample').get_text(), 1, 100000) + #sample and rate param + if temp_rate != self.measure.rate or temp_sample != self.measure.sample: + self.measure.rate = temp_rate + self.measure.sample = temp_sample + self.measure.val_table = [0] * (int(self.measure.sample)+1) + + + max_time = self.measure.rate * self.measure.sample + + self.measure.val_drop = self.check_float_value(self.get_widget('valDrop_percent').get_text(), 1, 100) + self.measure.val_drop_time = self.check_float_value(self.get_widget('valDrop_time').get_text(), self.measure.rate, max_time) + self.measure.val_raise = self.check_float_value(self.get_widget('valRaise_percent').get_text(), 1, 100) + self.measure.val_raise_time = self.check_float_value(self.get_widget('valRaise_time').get_text(), self.measure.rate, max_time) + self.measure.val_changeD = self.check_float_value(self.get_widget('valChangeD_percent').get_text(), 1, 100) + self.measure.val_changeD_time = self.check_float_value(self.get_widget('valChangeD_time').get_text(), self.measure.rate, max_time) + self.measure.val_changeU = self.check_float_value(self.get_widget('valChangeU_percent').get_text(), 1, 100) + self.measure.val_changeU_time = self.check_float_value(self.get_widget('valChangeU_time').get_text(), self.measure.rate, max_time) + self.measure.val_threshold = self.check_float_value(self.get_widget('valThreshold').get_text(), 0, 100) + + #Update values + self.update_value() + + def on_threshold_selection_changed(self, widget, *args): + filename = widget.get_filename() + filename = filename.replace('%20', ' ') + _me.set_param('behavior_file_threshold', filename) + _me.get_param('measure').threshold_behavior = _me.get_param('behavior_file_threshold') + + def on_change_selection_changed(self, widget, *args): + filename = widget.get_filename() + filename = filename.replace('%20', ' ') + _me.set_param('behavior_file_change', filename) + _me.get_param('measure').change_behavior = _me.get_param('behavior_file_change') + + ########################################################### + # + # Value integrity control + # + ########################################################### + def check_float_value(self, value, minimum, maximum): + try: + value = float(value) + except: + value = float(minimum) + + if value < float(minimum): + value = float(minimum) + elif value > float(maximum): + value = float(maximum) + return value + + def update(self): + self.graph = Graph() + _me.set_param('graph', self.graph) + _me.update_informations() + self.measure = _me.get_param('measure') + _me.get_param('measure').graph_measure = self.graph + _me.get_param('graph').measure_graph = self.measure + _me.get_param('measure').GUI_on = True + self.update_value() + self.graph.set_size_request(600, 300) + gtk.gdk.threads_enter() + layout = self.get_widget('vbox2') + layout.add(self.graph) + layout.show_all() + gtk.gdk.threads_leave() + Added: software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp =================================================================== --- software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp (rev 0) +++ software/gadgets/battery_monitor/trunk/Battery_monitor_svn/Scripts/Python/init.pyp 2007-10-09 09:02:10 UTC (rev 590) @@ -0,0 +1,57 @@ +sys.path.append(_me.get_path('root') + '/Scripts/Python') +try: + from Battery_class import Measure +except: + print sys.exc_info() + + +measure = Measure() +_me.set_param('measure', measure) + +#update the values +measure.val_drop = float(_me.get_param('drop')) +measure.val_raise = float(_me.get_param('raise')) +measure.val_changeD = float(_me.get_param('changeD')) +measure.val_changeU = float(_me.get_param('changeU')) +measure.val_drop_time = float(_me.get_param('drop_time')) +measure.val_raise_time = float(_me.get_param('raise_time')) +measure.val_changeD_time = float(_me.get_param('changeD_time')) +measure.val_changeU_time = float(_me.get_param('changeU_time')) +measure.val_threshold = float(_me.get_param('... [truncated message content] |
From: jaguarondi <c2m...@c2...> - 2007-10-08 16:12:10
|
Author: jaguarondi Date: 2007-10-08 18:12:07 +0200 (Mon, 08 Oct 2007) New Revision: 589 Modified: firmware/tuxcore/trunk/main.c Log: * The ir signals of the greeting function were detected by the light measurement, so I disabled the greeting function for now as it's not working correctly anyway. Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-10-08 14:56:27 UTC (rev 588) +++ firmware/tuxcore/trunk/main.c 2007-10-08 16:12:07 UTC (rev 589) @@ -196,7 +196,10 @@ if (t1s_flag) { t1s_flag = FALSE; - ir_send_flg = 1; + /* XXX disabled ir signals for tux greeting as this function needs + * to be refactored and was conflicting to the new light + * measurement method. */ + /*ir_send_flg = 1;*/ } /* * Communication: updating status, receiving and sending commands |
From: jaguarondi <c2m...@c2...> - 2007-10-08 14:56:26
|
Author: jaguarondi Date: 2007-10-08 16:56:27 +0200 (Mon, 08 Oct 2007) New Revision: 588 Modified: api/python/trunk/tuxapi_class.py api/python/trunk/tuxapi_const.py Log: * Added battery level status in the api. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-10-08 14:54:27 UTC (rev 587) +++ api/python/trunk/tuxapi_class.py 2007-10-08 14:56:27 UTC (rev 588) @@ -2479,6 +2479,7 @@ tux.status.ir_led tux.status.ir_signal tux.status.light_level + tux.status.battery_level tux.status.lled tux.status.lwing_bt tux.status.mouth_closed @@ -2606,6 +2607,9 @@ if status[4]==DATAS_STATUS_LIGHT_LEVEL: line=line+"Light level->" value_type=value_16b + if status[4]==DATAS_STATUS_BATTERY: + line=line+"Battery level->" + value_type=value_16b if status[4]==DATAS_STATUS_EYES_POSITION_COUNTER: line=line+"Eyes position counter->" value_type=value_8b @@ -3175,7 +3179,7 @@ """ Get the last light level - Return an integer (0..1024, max light=0) + Return an integer (0..1024) Example: >>> var = tux.status.light_level() @@ -3192,6 +3196,34 @@ return 0 #-------------------------------------------------------------------------- + # Get the last state of battery level status + #-------------------------------------------------------------------------- + def battery_level(self): + """ + Get the last battery level + + Return a tupple with the battery level and the status: + (level, status) + level: 0..1024 + status: True (valid battery level) or False (i.e. a motor was + running during the measurement so it's not accurate) + + Example: + >>> (level, valid) = tux.status.battery_level() + """ + if not self.parent.daemon.connected: + return 0 + frame = self.get(DATAS_STATUS_BATTERY) + try: + if len(frame) > 0: + return ((ord(frame[5])*256)+ord(frame[6]), + bool(not ord(frame[7]))) + else: + return 0 + except: + return 0 + + #-------------------------------------------------------------------------- # Get the last state of eyes position counter status #-------------------------------------------------------------------------- def get_eyes_position_counter(self): Modified: api/python/trunk/tuxapi_const.py =================================================================== --- api/python/trunk/tuxapi_const.py 2007-10-08 14:54:27 UTC (rev 587) +++ api/python/trunk/tuxapi_const.py 2007-10-08 14:56:27 UTC (rev 588) @@ -156,6 +156,7 @@ DATAS_STATUS_IR_CODE = 0x22 DATAS_STATUS_SOUND_COUNT = 0x23 DATAS_STATUS_PONG = 0x24 +DATAS_STATUS_BATTERY = 0x25 # Tux connection commands TUX_CONNECTION_DISCONNECT = 1 |
From: Paul_R <c2m...@c2...> - 2007-10-08 14:54:27
|
Author: Paul_R Date: 2007-10-08 16:54:27 +0200 (Mon, 08 Oct 2007) New Revision: 587 Modified: firmware/tuxcore/trunk/main.c Log: * Added a test to be sure that the fifo is empty before sending the status Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-10-08 14:53:59 UTC (rev 586) +++ firmware/tuxcore/trunk/main.c 2007-10-08 14:54:27 UTC (rev 587) @@ -263,6 +263,8 @@ static void updateStatus(void) { + if (FifoLength(statusFifo) != 0) + return; statusFifoFlag = 1; FifoPut(statusFifo, STATUS_SENSORS1_CMD); FifoPut(statusFifo, gStatus.sw); |
From: jaguarondi <c2m...@c2...> - 2007-10-08 14:53:59
|
Author: jaguarondi Date: 2007-10-08 16:53:59 +0200 (Mon, 08 Oct 2007) New Revision: 586 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/libs/USBDaemon_status_table.h Log: * Added battery level status. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-10-08 14:53:59 UTC (rev 586) @@ -611,6 +611,11 @@ result[1] = sensors2.light_level / 256; result[2] = sensors2.light_level % 256; break; + case DATA_STATUS_BATTERY: + result[1] = battery.level / 256; + result[2] = battery.level % 256; + result[3] = battery.status; + break; case DATA_STATUS_EYES_POSITION_COUNTER: result[1] = position1.eyes_position.Byte; break; Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-10-08 14:53:59 UTC (rev 586) @@ -225,12 +225,34 @@ tcp_frame[4] = DATA_STATUS_LIGHT_LEVEL; sensors2.light_level = light_level; - + tcp_frame[5] = light_level / 256; tcp_frame[6] = light_level % 256; tcp_server_send_raw(tcp_frame); } +static void battery_changed(int level, int status) +{ + tcp_frame_t tcp_frame; + + tcp_frame_zero(&tcp_frame); + + tcp_frame[0] = SOURCE_TUX; + tcp_frame[1] = SS_DEFAULT; + tcp_frame[2] = DATA_TP_RSP; + tcp_frame[3] = SUBDATA_TP_STATUS; + + tcp_frame[4] = DATA_STATUS_BATTERY; + + battery.level = level; + battery.status = status; + + tcp_frame[5] = level / 256; + tcp_frame[6] = level % 256; + tcp_frame[7] = status; + tcp_server_send_raw(tcp_frame); +} + static void pong_event(unsigned char pong_number, unsigned char pong_received) { tcp_frame_t tcp_frame; @@ -532,7 +554,7 @@ /* The answer from the usb_tux_connection command has been received */ connection_status.usb_request_f = false; connection_status.tux_id = (new_status[1] << 8) + new_status[2]; - log_debug("id retunred by tux: %i (0x%.2x%.2x)", + log_debug("id returned by tux: %i (0x%.2x%.2x)", connection_status.tux_id, new_status[1], new_status[2]); break; case STATUS_PORTS_CMD: @@ -563,6 +585,16 @@ } break; + case STATUS_BATTERY_CMD: + { + int level; + int status; + level = (new_status[1] << 8) + new_status[2]; + status = new_status[3]; + battery_changed(level, status); + } + break; + case STATUS_POSITION1_CMD: if (position1.eyes_position.Byte != new_status[1] || position1.mouth_position.Byte != new_status[2] Modified: daemon/trunk/libs/USBDaemon_status_table.h =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.h 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_status_table.h 2007-10-08 14:53:59 UTC (rev 586) @@ -175,6 +175,7 @@ #define DATA_STATUS_IR_CODE 0x22 #define DATA_STATUS_SOUND_COUNT 0x23 #define DATA_STATUS_PONG 0x24 +#define DATA_STATUS_BATTERY 0x25 /* tux connection commands available on the usb dongle */ typedef enum @@ -242,6 +243,13 @@ } sensors2; struct { + _PORT_BYTE_ level_high; + _PORT_BYTE_ level_low; + int status; + int level; +} battery; +struct +{ _PORT_BYTE_ eyes_position; _PORT_BYTE_ mouth_position; _PORT_BYTE_ wings_position; |
From: Paul_R <c2m...@c2...> - 2007-10-08 13:47:47
|
Author: Paul_R Date: 2007-10-08 15:47:19 +0200 (Mon, 08 Oct 2007) New Revision: 585 Modified: firmware/tuxcore/trunk/global.h firmware/tuxcore/trunk/main.c firmware/tuxcore/trunk/motors.c firmware/tuxcore/trunk/sensors.c firmware/tuxcore/trunk/sensors.h firmware/tuxdefs/commands.h Log: * Changed sensors.[ch] to include the battery level. The new status command for battery level is 0xC7 - STATUS_BATTERY_CMD The third status byte is to indicate if motors are running : 0 - All the motors are off 1 - One or more motor(s) is (are) on. * Changed motors.c and gStatus to include the motors status. Modified: firmware/tuxcore/trunk/global.h =================================================================== --- firmware/tuxcore/trunk/global.h 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxcore/trunk/global.h 2007-10-08 13:47:19 UTC (rev 585) @@ -99,27 +99,19 @@ * gStatus.mot: Motors Status */ -/* gStatus.mot:[1-0] Spin motor - * xxxxxxx0 === Spin right - * xxxxxxx1 === Spin left */ -#define GSTATUS_MOT_SR 0x01 -#define GSTATUS_MOT_SL 0x02 -/* gStatus.mot:[3-2] Eyes/Mouth motor - * xxxxxxx0 === Eyes - * xxxxxxx1 === Mouth - * xxxxxx0x === Motor stopped - * xxxxxx1x === Motor running */ -#define GSTATUS_MOT_E 0x04 -#define GSTATUS_MOT_M 0x08 -/* gStatus.mot:[5-4] Wings motor - * xxxxxx00 === Wings forward - * xxxxxx01 === Wings backward - * xxxxxx0x === Motor stopped - * xxxxxx1x === Motor running */ -#define GSTATUS_MOT_W0 0x10 -#define GSTATUS_MOT_W1 0x20 -//#define GSTATUS_SW__6 0x40 -//#define GSTATUS_SW__7 0x80 +/* gStatus.mot:[0] Spin motor + * xxxxxxx0 === Spin off + * xxxxxxx1 === Spin on */ +#define GSTATUS_MOT_SPIN 0x01 +/* gStatus.mot:[1] Eyes/Mouth motor + * xxxxxx0x === motor off + * xxxxxx1x === motor on */ +#define GSTATUS_MOT_EYES 0x02 +#define GSTATUS_MOT_MOUTH 0x02 +/* gStatus.mot:[2] Wings motor + * xxxxx0xx === Wings off + * xxxxx1xx === Wings on */ +#define GSTATUS_MOT_WINGS 0x04 /* * gStatus.ir: IR Status @@ -165,8 +157,12 @@ uint8_t lightL; /* Light level low byte */ uint8_t lightH; /* Light level high byte */ uint8_t lightM; /* Light mode */ + uint8_t batteryL; /* Battery level low byte */ + uint8_t batteryH; /* Battery level high byte */ + uint8_t batteryS; /* Battery level status */ uint8_t ir; /* IR RC5 code received from tux's remote */ uint8_t pos; /* Poitionning */ + uint8_t mot; } GSTATUS; Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxcore/trunk/main.c 2007-10-08 13:47:19 UTC (rev 585) @@ -162,6 +162,8 @@ { t4ms_flag = FALSE; motor_control(); + if (sensorsUpdate) + sensors_control(); if (i2c_pause) i2c_pause--; /* delay after a nack */ @@ -204,8 +206,6 @@ { updateStatusFlag = 0; updateStatus(); /* add sensors states to the status queue */ - - getLight(); /* light measurement */ } //if (commandProcessFlag) /* XXX check if it's quick enough with the if //*/ @@ -261,11 +261,8 @@ turnIrOff(); } -#define STATUS_BYTE_SIZE 20 static void updateStatus(void) { - if (FifoLength(statusFifo) >= (STATUS_BUF_SIZE - STATUS_BYTE_SIZE)) - return; /* if there's not enough place, we dont save. */ statusFifoFlag = 1; FifoPut(statusFifo, STATUS_SENSORS1_CMD); FifoPut(statusFifo, gStatus.sw); @@ -283,14 +280,22 @@ FifoPut(statusFifo, spin_move_counter); FifoPut(statusFifo, gStatus.pos); FifoPut(statusFifo, 0); - if (light_f) /* send light measurement */ + if (sensorsStatus & LIGHT_FLAG) /* send light measurement */ { - light_f = 0; + sensorsStatus &= ~LIGHT_FLAG; FifoPut(statusFifo, STATUS_LIGHT_CMD); FifoPut(statusFifo, gStatus.lightH); FifoPut(statusFifo, gStatus.lightL); FifoPut(statusFifo, gStatus.lightM); } + if (sensorsStatus & BATTERY_FLAG) /* send light measurement */ + { + sensorsStatus &= ~BATTERY_FLAG; + FifoPut(statusFifo, STATUS_BATTERY_CMD); + FifoPut(statusFifo, gStatus.batteryH); + FifoPut(statusFifo, gStatus.batteryL); + FifoPut(statusFifo, gStatus.batteryS); + } if (ir_f) /* send received ir signals */ { ir_f--; @@ -307,7 +312,7 @@ FifoPut(statusFifo, 0); FifoPut(statusFifo, 0); } - + sensorsUpdate |= STATUS_SENT; statusFifoFlag = 0; } Modified: firmware/tuxcore/trunk/motors.c =================================================================== --- firmware/tuxcore/trunk/motors.c 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxcore/trunk/motors.c 2007-10-08 13:47:19 UTC (rev 585) @@ -194,6 +194,7 @@ */ void stop_eyes(void) { + gStatus.mot &= ~GSTATUS_MOT_EYES; stop_eyes_motor(); } @@ -210,6 +211,7 @@ */ void blink_eyes(uint8_t const cnt) { + gStatus.mot |= GSTATUS_MOT_EYES; eyes_move_counter = cnt; eyes_stop_delay = 0; run_eyes_motor(); @@ -352,6 +354,7 @@ */ void stop_mouth(void) { + gStatus.mot &= ~GSTATUS_MOT_MOUTH; stop_mouth_motor(); } @@ -367,6 +370,7 @@ */ void move_mouth(uint8_t const cnt) { + gStatus.mot |= GSTATUS_MOT_MOUTH; mouth_move_counter = cnt; mouth_stop_delay = 0; run_mouth_motor(); @@ -469,6 +473,7 @@ */ void stop_flippers(void) { + gStatus.mot &= ~GSTATUS_MOT_WINGS; stop_flippers_motor(); } @@ -487,6 +492,7 @@ */ void wave_flippers(uint8_t const cnt, uint8_t const pwm) { + gStatus.mot |= GSTATUS_MOT_WINGS; flippers_move_counter = cnt; flippers_PWM = pwm; flippers_stop_delay = 0; @@ -636,6 +642,7 @@ */ void stop_spinning(void) { + gStatus.mot &= ~GSTATUS_MOT_SPIN; stop_spin_motor(); } @@ -647,6 +654,7 @@ */ void spin_left(uint8_t const angle, uint8_t const pwm) { + gStatus.mot |= GSTATUS_MOT_SPIN; spin_direction = LEFT; spin_move_counter = angle; /* If the rotation direction is changing and we are not stopped exactly on @@ -668,6 +676,7 @@ */ void spin_right(uint8_t const angle, uint8_t const pwm) { + gStatus.mot |= GSTATUS_MOT_SPIN; spin_direction = RIGHT; spin_move_counter = angle; /* If the rotation direction is changing and we are not stopped exactly on @@ -762,7 +771,7 @@ flippers_stop_delay--; if (!flippers_stop_delay) { - stop_flippers_motor(); + stop_flippers(); flippers_PWM = 0; } } @@ -773,7 +782,7 @@ eyes_stop_delay--; if (!eyes_stop_delay) { - stop_eyes_motor(); + stop_eyes(); } } @@ -783,17 +792,17 @@ mouth_stop_delay--; if (!mouth_stop_delay) { - stop_mouth_motor(); + stop_mouth(); } } /* spin braking (motor reversed) delay */ if (spin_stop_delay) { - spin_stop_delay--; - if (!spin_stop_delay) - { - stop_spin_motor(); - } + spin_stop_delay--; + if (!spin_stop_delay) + { + stop_spinning(); + } } } Modified: firmware/tuxcore/trunk/sensors.c =================================================================== --- firmware/tuxcore/trunk/sensors.c 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxcore/trunk/sensors.c 2007-10-08 13:47:19 UTC (rev 585) @@ -29,38 +29,55 @@ #include "sensors.h" #include "adc.h" #include "global.h" +#include "sensors.h" #include "hardware.h" +#include "adc.h" +void static light_control(uint16_t light_val); +void static battery_control(uint16_t battery_val); +void static read_flag(void); + +uint8_t static sensorsControlState; +uint8_t static motorsStatus; +uint8_t sensorsStatus; +uint8_t sensorsUpdate; + /** - * \name Light level - * @{ */ -/** \ingroup sensors */ + \brief This function manage the acquisition of all sensors. -void save_light(void) + Two sensors are treaties for now : A light sensor and the battery. + This function is based on a state machine. + + To execute this function, the STATUS_SENT flag OR the ADC_READY flag must be set. The STATUS_SEND flag is set when the status are send to the PC. The ADC_READY flag is set when an interrupt on the ADC module occurs. + + When the state machine is in the last state, it will be resetted and wait while the status are sent. If status are sent before the last state, the cycle continue. + */ +void sensors_control(void) { - union16_t adc_value; - adc_value.w = ADC_read(); - /* Save light mode before changing it below. */ - gStatus.lightM = LIGHT_PU_PORT & LIGHT_PU_MK; - /* Check if it's necessary to change the light mode. */ - if ((adc_value.b[0] <= 0x28) && (adc_value.b[1] == 0x00) && - !(LIGHT_PU_PORT & LIGHT_PU_MK)) + if (sensorsControlState == 0) { - LIGHT_PU_PORT |= LIGHT_PU_MK; - LIGHT_PU_DDR |= LIGHT_PU_MK; + // New cycle started - clear the status_sent flag + sensorsUpdate &= ~STATUS_SENT; + + ADC_start(LIGHT_ADMUX); // XXX Arg : ADMUX + sensorsControlState ++; } - else if ((adc_value.b[0] >= 0xE8) && (adc_value.b[1] == 0x03) && - (LIGHT_PU_PORT & LIGHT_PU_MK)) + else if (sensorsControlState == 1) { - LIGHT_PU_PORT &= ~LIGHT_PU_MK; - LIGHT_PU_DDR &= ~LIGHT_PU_MK; + light_control(ADC_read()); + if (gStatus.mot != 0) + motorsStatus = 1; + + ADC_start(BATTERY_ADMUX); // XXX arg : ADMUX + sensorsControlState ++; } - /* adc_value.b[1] should be read after adc_value.b[0] otherwise - * adc_value.b[0] stays wite protected (c.f. datasheet). */ - gStatus.lightL = adc_value.b[0]; - gStatus.lightH = adc_value.b[1]; - /* There's a new light value. */ - light_f = 1; + else if (sensorsControlState == 2) + { + if (gStatus.mot != 0) + motorsStatus = 1; + battery_control(ADC_read()); + sensorsControlState = 0; + } } /** @@ -68,22 +85,11 @@ */ void sensors_init(void) { - ADC_set_ISR_callback(save_light); + ADC_set_ISR_callback(read_flag); ADC_init(); } /** - \brief Start a light level measurement. - - Start a light level conversion. The result will be saved by the ADC - interrupt. - */ -void getLight(void) -{ - ADC_start(LIGHT_ADMUX); -} - -/** \brief Disable all sensors. This function should minimize power consumption. */ @@ -91,4 +97,73 @@ { ADC_disable(); } + +/** + \brief Callback function of the ADC ISR. + + When an ADC conversion cycle is finished, the ADC_READY flag is set. + */ + +void static read_flag(void) +{ + sensorsUpdate |= ADC_READY; +} + +/** + \brief Light control function. + \param light_val The light level + + This function control the light level. + The light sensor has 2 different values of pull-up resistors (1M and 10k) to increase the range. It's necessary to switch from one to the other resistor depending on the light level. This is done here. + */ + +void static light_control(uint16_t light_val) +{ + union16_t light_value; + light_value.w = light_val; + + /* Save light mode before changing it below. */ + gStatus.lightM = LIGHT_PU_PORT & LIGHT_PU_MK; + + /* Check if it's necessary to change the light mode. */ + if ((light_value.w <= 0x0028) && !(LIGHT_PU_PORT & LIGHT_PU_MK)) + { + LIGHT_PU_PORT |= LIGHT_PU_MK; + LIGHT_PU_DDR |= LIGHT_PU_MK; + } + else if ((light_value.w >= 0x03E8) && (LIGHT_PU_PORT & LIGHT_PU_MK)) + { + LIGHT_PU_PORT &= ~LIGHT_PU_MK; + LIGHT_PU_DDR &= ~LIGHT_PU_MK; + } + + gStatus.lightL = light_value.b[0]; + gStatus.lightH = light_value.b[1]; + /* There's a new light value. */ + sensorsStatus |= LIGHT_FLAG; + sensorsUpdate &= ~ ADC_READY; +} + +/** + \brief Battery control function. + \param battery_val The battery level + + The battery level is just store in gStatus, to be sent to the PC + */ + +void static battery_control(uint16_t battery_val) +{ + union16_t battery_value; + battery_value.w = battery_val; + + gStatus.batteryL = battery_value.b[0]; + gStatus.batteryH = battery_value.b[1]; + if (motorsStatus) + gStatus.batteryS = 1; + else + gStatus.batteryS = 0; + motorsStatus = 0; + sensorsStatus |= BATTERY_FLAG; + sensorsUpdate &= ~ ADC_READY; +} /*! @} */ Modified: firmware/tuxcore/trunk/sensors.h =================================================================== --- firmware/tuxcore/trunk/sensors.h 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxcore/trunk/sensors.h 2007-10-08 13:47:19 UTC (rev 585) @@ -34,8 +34,16 @@ #ifndef _SENSORS_H_ #define _SENSORS_H_ +#define LIGHT_FLAG 1 +#define BATTERY_FLAG 2 +#define STATUS_SENT 1 +#define ADC_READY 2 + +uint8_t extern sensorsStatus; +uint8_t extern sensorsUpdate; + void sensors_init(void); void sensors_disable(void); -void getLight(void); +void sensors_control(void); #endif /* _SENSORS_H_ */ Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-10-08 11:48:05 UTC (rev 584) +++ firmware/tuxdefs/commands.h 2007-10-08 13:47:19 UTC (rev 585) @@ -324,6 +324,10 @@ /* 1st parameter: Tux ID number (MSB) */ /* 2nd parameter: Tux ID number (LSB) */ +#define STATUS_BATTERY_CMD 0xC7 +/* 1st parameter: battery level high byte */ +/* 2nd parameter: battery level low byte */ +/* 3rd parameter: battery measure status : 0 - motors off; 1 - motors on*/ /* * Special commands */ |
From: jaguarondi <c2m...@c2...> - 2007-10-08 11:48:04
|
Author: jaguarondi Date: 2007-10-08 13:48:05 +0200 (Mon, 08 Oct 2007) New Revision: 584 Added: firmware/tuxcore/trunk/adc.c firmware/tuxcore/trunk/adc.h Log: * Forgot to include the adc module. Added: firmware/tuxcore/trunk/adc.c =================================================================== --- firmware/tuxcore/trunk/adc.c (rev 0) +++ firmware/tuxcore/trunk/adc.c 2007-10-08 11:48:05 UTC (rev 584) @@ -0,0 +1,135 @@ +/* + * TUXCORE - Firmware for the 'core' CPU of tuxdroid + * Copyright (C) 2007 C2ME S.A. <tux...@c2...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id$ */ + +/** \file adc.c + \brief ADC module + \ingroup adc +*/ + +#include <avr/interrupt.h> +#include <avr/io.h> + +#include "adc.h" + +/** Union between 16 bits variables and the two 8 bits registers they're made + * of. */ +typedef union +{ + uint16_t w; + uint8_t b[2]; +} union16_t; + +/** Function pointer to the ADC ISR user function. */ +static void (*ADC_ISR_callback)(void); + +/** + \brief Set the user function which handles the ADC ISR + \param ADC_ISR_user_callback Function pointer to the user callback function. + \ingroup adc + + This sets the user function which is called when the conversion completes. + */ +void ADC_set_ISR_callback(void (*ADC_ISR_user_callback)(void)) +{ + ADC_ISR_callback = ADC_ISR_user_callback; +} + +/** + \brief Initialize and enable the ADC module. + \ingroup adc + */ +void ADC_init() +{ + /* Enable ADC in single conversion mode. */ + ADCSRA = _BV(ADEN) | + /* Enable ADC interrupt. */ + _BV(ADIE) | + /* Set ADC prescaler to 128. + * Clock = F_CPU / 128 = 62.5kHz + * Sample rate = clock / 13 cycles = 4.8kHz (around 2ms). */ + _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); +} + +/** + \brief Disable the ADC. + The ADC should be re-enabled with ADC_init(), which restores the prescaler. + \ingroup adc + */ +void ADC_disable() +{ + ADCSRA = 0; +} + +/** + \brief Start a conversion on the selected channel. + \param ad_mux (ADMUX) Reference, format and channel selection. + \ingroup adc + + ADC Multiplexer Selection Register - ADMUX + Bit 7:6 - REFS1:0: Reference Selection Bits + 0 0 AREF, Internal Vref turned off + 0 1 AVCC with external capacitor at AREF pin + 1 0 Reserved + 1 1 Internal 1.1V Voltage Reference with external capacitor at AREF pin + Bit 5 - ADLAR: ADC Left Adjust Result + Bit 4 - Res: Reserved Bit + Bits 3:0 - MUX3:0: Analog Channel Selection Bits + 0000 ADC0 + 0001 ADC1 + 0010 ADC2 + 0011 ADC3 + 0100 ADC4 + 0101 ADC5 + 0110 ADC6 + 0111 ADC7 + 1110 1.1V (VBG) + 1111 0V (GND) +*/ +void ADC_start(const uint8_t ad_mux) +{ + ADMUX = ad_mux; + ADCSRA |= _BV(ADSC); +} + +/** + \brief Read the value of the last conversion. + \return Conversion result (10 bits). + \ingroup adc + You should ensure that the conversion is completed before reading the value. + */ +uint16_t ADC_read() +{ + union16_t adc_value; + /* ADCH should be read after ADCL otherwise ADCL stays wite protected + * (c.f. datasheet). */ + adc_value.b[0] = ADCL; + adc_value.b[1] = ADCH; + return adc_value.w; +} + +/** + \brief ADC conversion interrupt + The callback function is called when the interrupt occurs. + */ +ISR(SIG_ADC) +{ + ADC_ISR_callback(); +} Property changes on: firmware/tuxcore/trunk/adc.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: firmware/tuxcore/trunk/adc.h =================================================================== --- firmware/tuxcore/trunk/adc.h (rev 0) +++ firmware/tuxcore/trunk/adc.h 2007-10-08 11:48:05 UTC (rev 584) @@ -0,0 +1,43 @@ +/* + * TUXCORE - Firmware for the 'core' CPU of tuxdroid + * Copyright (C) 2007 C2ME S.A. <tux...@c2...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id$ */ + +/** \file adc.h + \brief ADC module interface + \ingroup adc +*/ + +/** \defgroup adc ADC + The ADC module is the driver for the internal ADC of the AVR. +*/ + +#ifndef _ADC_H_ +#define _ADC_H_ + +/* + * Interface + */ +void ADC_set_ISR_callback(void (*ADC_ISR_user_callback)(void)); +void ADC_init(void); +void ADC_disable(void); +void ADC_start(const uint8_t ad_mux); +uint16_t ADC_read(void); + +#endif /* _ADC_H_ */ Property changes on: firmware/tuxcore/trunk/adc.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native |
From: jaguarondi <c2m...@c2...> - 2007-10-08 11:43:53
|
Author: jaguarondi Date: 2007-10-08 13:43:17 +0200 (Mon, 08 Oct 2007) New Revision: 583 Modified: firmware/tuxcore/trunk/Makefile firmware/tuxcore/trunk/global.h firmware/tuxcore/trunk/hardware.h firmware/tuxcore/trunk/main.c firmware/tuxcore/trunk/sensors.c firmware/tuxcore/trunk/sensors.h firmware/tuxcore/trunk/standalone.c Log: * Added a new ADC module in order to do battery and light measurements with the same ADC. The functionality doesn't change in this commit but functions and files have been reorganised. Modified: firmware/tuxcore/trunk/Makefile =================================================================== --- firmware/tuxcore/trunk/Makefile 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/Makefile 2007-10-08 11:43:17 UTC (rev 583) @@ -90,8 +90,8 @@ HEADERS = $(wildcards *.h) ## Objects that must be built in order to link -OBJECTS = main.o sensors.o motors.o global.o led.o communication.o i2c.o \ - fifo.o ir.o parser.o config.o standalone.o +OBJECTS = main.o adc.o sensors.o motors.o global.o led.o communication.o \ + i2c.o fifo.o ir.o parser.o config.o standalone.o ## Build all: svnrev.h $(TARGET) tuxcore.hex tuxcore.eep tuxcore.lss size @@ -101,6 +101,9 @@ main.o: main.c $(CC) $(INCLUDES) $(CFLAGS) -c $< +adc.o: adc.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + sensors.o: sensors.c $(CC) $(INCLUDES) $(CFLAGS) -c $< @@ -219,5 +222,5 @@ -U eeprom:w:$(PROJECT).eep progstk_bl: $(PROJECT).hex $(PROJECT).eep $(PROJECT)_bl.hex - $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex \ + $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex \ -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex Modified: firmware/tuxcore/trunk/global.h =================================================================== --- firmware/tuxcore/trunk/global.h 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/global.h 2007-10-08 11:43:17 UTC (rev 583) @@ -30,6 +30,17 @@ #include "common/commands.h" /* + * Custom types + */ +/** Union between 16 bits variables and the two 8 bits registers they're made + * of. */ +typedef union +{ + uint16_t w; + uint8_t b[2]; +} union16_t; + +/* * -------------------------------------------------------- * STATUS * -------------------------------------------------------- Modified: firmware/tuxcore/trunk/hardware.h =================================================================== --- firmware/tuxcore/trunk/hardware.h 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/hardware.h 2007-10-08 11:43:17 UTC (rev 583) @@ -140,6 +140,9 @@ #define LIGHT_PU_DDR DDRC /** Phototransistor extra pull-up mask. */ #define LIGHT_PU_MK _BV(PC0) +/** ADMUX settings for light measurement. + * AREF reference, result right adjusted, MUX to ADC6. */ +#define LIGHT_ADMUX 0x06 /*! @} */ /** @@ -257,6 +260,15 @@ #define MOT_SPIN_MK (MOT_SPIN_L_MK | MOT_SPIN_R_MK) /*! @} */ +/** + * \name Battery + * The battery voltage can be measured on the pin ADC7 through a resistive + * divider. + * @{ */ +/** ADMUX settings for battery measurement. + * AREF reference, result right adjusted, MUX to ADC7. */ +#define BATTERY_ADMUX 0x07 /*! @} */ +/*! @} */ #endif /* _HARDWARE_H_ */ Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/main.c 2007-10-08 11:43:17 UTC (rev 583) @@ -144,6 +144,7 @@ initIR(); main_tick_init(); initIO(); + sensors_init(); config_init(); /* I2C communication initialization */ @@ -239,13 +240,6 @@ /* Set output for Led's */ LED_DDR |= LED_MK; - /* Enable ADC, select ADC clock = F_CPU / 128 (i.e. 16 Hz) - * Single conversion mode - */ - ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); - ADMUX = 0x06; /* ADC6 selected XXX change this when adding ADC7 too */ - ADCSRA |= _BV(ADIE) | _BV(ADSC); /* set ADC interrupt and start it */ - /* set external I/O as pull-up */ EXIO_PT |= EXIO_MK; @@ -332,6 +326,7 @@ /* Set power savings configuration. */ cli(); closeIO(); + sensors_disable(); powersave_movements(); stop_spinning(); stop_mouth(); @@ -356,6 +351,7 @@ i2cCommunicationInit(); init_movements(); initIO(); + sensors_init(); /* Trigger the post-sleep event */ cond_flags.sleep = COND_POST_SLEEP; Modified: firmware/tuxcore/trunk/sensors.c =================================================================== --- firmware/tuxcore/trunk/sensors.c 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/sensors.c 2007-10-08 11:43:17 UTC (rev 583) @@ -26,52 +26,69 @@ #include <avr/interrupt.h> +#include "sensors.h" +#include "adc.h" #include "global.h" #include "hardware.h" /** - \brief ADC conversion interrupt handling light and battery level + * \name Light level + * @{ */ +/** \ingroup sensors */ - The light sensor has 2 different values of pull-up resistors (1M and 10k) to - increase the range. It's necessary to switch from one to the other resistor - depending on the light level. This is done here. - - \todo TODO add battery level measurement - */ -ISR(SIG_ADC) +void save_light(void) { + union16_t adc_value; + adc_value.w = ADC_read(); /* Save light mode before changing it below. */ gStatus.lightM = LIGHT_PU_PORT & LIGHT_PU_MK; /* Check if it's necessary to change the light mode. */ - if ((ADCL <= 0x28) && (ADCH == 0x00) && !(LIGHT_PU_PORT & LIGHT_PU_MK)) + if ((adc_value.b[0] <= 0x28) && (adc_value.b[1] == 0x00) && + !(LIGHT_PU_PORT & LIGHT_PU_MK)) { LIGHT_PU_PORT |= LIGHT_PU_MK; LIGHT_PU_DDR |= LIGHT_PU_MK; } - else if ((ADCL >= 0xE8) && (ADCH == 0x03) && (LIGHT_PU_PORT & LIGHT_PU_MK)) + else if ((adc_value.b[0] >= 0xE8) && (adc_value.b[1] == 0x03) && + (LIGHT_PU_PORT & LIGHT_PU_MK)) { LIGHT_PU_PORT &= ~LIGHT_PU_MK; LIGHT_PU_DDR &= ~LIGHT_PU_MK; } - /* ADCH should be read after ADCL otherwise ADCL stays wite protected (c.f. - * datasheet). */ - gStatus.lightL = ADCL; - gStatus.lightH = ADCH; + /* adc_value.b[1] should be read after adc_value.b[0] otherwise + * adc_value.b[0] stays wite protected (c.f. datasheet). */ + gStatus.lightL = adc_value.b[0]; + gStatus.lightH = adc_value.b[1]; /* There's a new light value. */ light_f = 1; } /** - * \name Light level - * @{ */ -/** \ingroup sensors */ + \brief Initialize the sensors for normal operation. + */ +void sensors_init(void) +{ + ADC_set_ISR_callback(save_light); + ADC_init(); +} + /** \brief Start a light level measurement. - Start a light level conversion. The result will be saved by the ADC interrupt. + Start a light level conversion. The result will be saved by the ADC + interrupt. */ void getLight(void) { - ADCSRA |= _BV(ADSC); + ADC_start(LIGHT_ADMUX); } + +/** + \brief Disable all sensors. + This function should minimize power consumption. + */ +void sensors_disable(void) +{ + ADC_disable(); +} /*! @} */ Modified: firmware/tuxcore/trunk/sensors.h =================================================================== --- firmware/tuxcore/trunk/sensors.h 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/sensors.h 2007-10-08 11:43:17 UTC (rev 583) @@ -34,6 +34,8 @@ #ifndef _SENSORS_H_ #define _SENSORS_H_ +void sensors_init(void); +void sensors_disable(void); void getLight(void); #endif /* _SENSORS_H_ */ Modified: firmware/tuxcore/trunk/standalone.c =================================================================== --- firmware/tuxcore/trunk/standalone.c 2007-10-05 08:27:46 UTC (rev 582) +++ firmware/tuxcore/trunk/standalone.c 2007-10-08 11:43:17 UTC (rev 583) @@ -86,11 +86,10 @@ /* Startup */ if (cond_flags.startup) { - if (gStatus.lightL == 0) - return; /* wait for a random value at startup */ cond_flags.startup = 0; launchActions((const uint8_t *)&startup_e); - tux_ir_id = gStatus.lightL; /* get some value for the id */ + tux_ir_id = gStatus.lightL; /* XXX remove this when fixing the greeting + function */ } /* Head button */ |
From: Paul_R <c2m...@c2...> - 2007-10-05 08:27:47
|
Author: Paul_R Date: 2007-10-05 10:27:46 +0200 (Fri, 05 Oct 2007) New Revision: 582 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf 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/about.xml software/gadgets/light_monitor/trunk/Light_monitor/settings.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Set the test expander of the test window not expanded by default * Change the param of test behavior and test change scripts * Add a new function to refresh the treeview 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-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-05 08:27:46 UTC (rev 582) @@ -1,15 +1,16 @@ bindtextdomain("params", "") class Window(SimpleGladeApp): - def __init__(self, path=_me.get_path('root') + '/Scripts/Python/GUI/conf/other.glade', root="window1", domain="params", **kwargs): SimpleGladeApp.__init__(self, path, root, domain, **kwargs) + def new(self): self.measure = _me.get_param('measure') + _me.insert_funct('refresh_tree', self.refresh_tree) self.updates_commons() self.make_viewtree() self.update_labels() @@ -265,7 +266,10 @@ 0] self.measure.event_tab = _me.get_param('config') self.measure.event_tab.append(value) - + self.refresh_tree() + + def refresh_tree(self): + print 'refresh tree =========================================================' _me.set_param('config', self.measure.event_tab) self.value_list.clear() for i in range(len(self.measure.event_tab)): @@ -305,7 +309,7 @@ if self.measure.event_tab[i][5]: Notify = _me.string('conf_lblNotifiedBehavior') - if self.measure.event_tab[i][6] == None: + if self.measure.event_tab[i][6] ==None: Behavior = _me.string('conf_lblDefaultBehavior') else: Behavior = str(self.measure.event_tab[i][6]) @@ -403,3 +407,9 @@ self.get_widget('txt_conf_value').set_text('1') if float(self.get_widget('txt_conf_value').get_text()) > 100: self.get_widget('txt_conf_value').set_text('100') +''' + try: + _me.insert_funct('refresh_tree', refresh_tree) + except: + print sys.exc_info() +''' Modified: 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.glade 2007-10-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.glade 2007-10-05 08:27:46 UTC (rev 582) @@ -839,7 +839,7 @@ <widget class="GtkExpander" id="expander3"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="expanded">True</property> + <property name="expanded">False</property> <property name="spacing">0</property> <child> 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-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-05 08:27:46 UTC (rev 582) @@ -157,14 +157,26 @@ _me.get_param('measure').GUI_on = False self.light_measure.GUI_on = False + def on_btnSet_clicked(self, widget, *args): + + if self.light_measure.threshold_behavior_chk: + threshold_script = self.light_measure.threshold_behavior + else: + threshold_script = None + + if self.light_measure.change_behavior_chk: + change_script = self.light_measure.change_behavior + else: + change_script = None + if self.get_widget('cbbConfig').get_active() == 0: val = [len(self.light_measure.event_tab)+1, 0, 0, self.light_measure.val_drop, self.light_measure.val_drop_time, self.light_measure.change_notified, - self.light_measure.change_behavior, + change_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 1: @@ -172,7 +184,7 @@ self.light_measure.val_raise, self.light_measure.val_raise_time, self.light_measure.change_notified, - self.light_measure.change_behavior, + change_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 2: @@ -180,7 +192,7 @@ self.light_measure.val_changeD, self.light_measure.val_changeD_time, self.light_measure.change_notified, - self.light_measure.change_behavior, + change_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 3: @@ -188,39 +200,41 @@ self.light_measure.val_changeU, self.light_measure.val_changeU_time, self.light_measure.change_notified, - self.light_measure.change_behavior, + change_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 4: val = [len(self.light_measure.event_tab)+1, 1, 0, - self.light_measure.val_increase, + self.light_measure.val_threshold, 0, self.light_measure.threshold_notified, - self.light_measure.threshold_behavior, + threshold_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 5: val = [len(self.light_measure.event_tab)+1, 1, 1, - self.light_measure.val_decrease, + self.light_measure.val_threshold, 0, self.light_measure.threshold_notified, - self.light_measure.threshold_behavior, + threshold_script, False, 0] elif self.get_widget('cbbConfig').get_active() == 6: val = [len(self.light_measure.event_tab)+1, 1, 2, - self.light_measure.val_both, + self.light_measure.val_threshold, 0, self.light_measure.threshold_notified, - self.light_measure.threshold_behavior, + threshold_script, False, 0] self.light_measure.event_tab.append(val) - print self.light_measure.event_tab - #_me.gui('conf').hide() + #_me.gui('conf').hide_from_main() #_me.gui('conf').show() + print ' '+str(_me.get_funct('refresh_tree')) + refresh_tree = _me.get_funct('refresh_tree') + + refresh_tree() - def on_btnApply_clicked(self, widget, *args): #Store the new radio buttons status _me.set_param('drop_rad', self.get_widget('radDrop').get_active()) Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-05 08:27:46 UTC (rev 582) @@ -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-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-05 08:27:46 UTC (rev 582) @@ -9,12 +9,12 @@ <changeD_rad type='bool'>False</changeD_rad> <threshold type='float'>50.0</threshold> <decrease_rad type='bool'>False</decrease_rad> - <behavior_file_threshold type='str'>/home/</behavior_file_threshold> + <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='str'>/home/</behavior_file_change> + <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> Modified: software/gadgets/light_monitor/trunk/Light_monitor/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-04 16:23:15 UTC (rev 581) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-05 08:27:46 UTC (rev 582) @@ -10,6 +10,7 @@ <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,13 +20,11 @@ <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> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <widget_lblBoth type='str'>Both direction</widget_lblBoth> <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> @@ -42,9 +41,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> @@ -60,6 +60,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> - <conf_lblNotified type='str'>Notified ?</conf_lblNotified> + <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) |
From: Paul_R <c2m...@c2...> - 2007-10-04 16:23:43
|
Author: Paul_R Date: 2007-10-04 18:23:15 +0200 (Thu, 04 Oct 2007) New Revision: 581 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf 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/about.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Added a new function in the test window to add the selected config in the settings window I can't yet refresh the config window when the button is pressed, because the manager freeze. I have to find a solution to this problem... Modified: 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.glade 2007-10-04 15:08:19 UTC (rev 580) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.glade 2007-10-04 16:23:15 UTC (rev 581) @@ -1190,7 +1190,7 @@ <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="pressed" handler="on_btnSet_pressed" last_modification_time="Thu, 04 Oct 2007 14:52:44 GMT"/> + <signal name="clicked" handler="on_btnSet_clicked" last_modification_time="Thu, 04 Oct 2007 15:53:35 GMT"/> </widget> <packing> <property name="x">320</property> 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-04 15:08:19 UTC (rev 580) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/widget/other.pyp 2007-10-04 16:23:15 UTC (rev 581) @@ -159,9 +159,67 @@ def on_btnSet_clicked(self, widget, *args): - pass + if self.get_widget('cbbConfig').get_active() == 0: + val = [len(self.light_measure.event_tab)+1, 0, 0, + self.light_measure.val_drop, + self.light_measure.val_drop_time, + self.light_measure.change_notified, + self.light_measure.change_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 1: + val = [len(self.light_measure.event_tab)+1, 0, 1, + self.light_measure.val_raise, + self.light_measure.val_raise_time, + self.light_measure.change_notified, + self.light_measure.change_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 2: + val = [len(self.light_measure.event_tab)+1, 0, 2, + self.light_measure.val_changeD, + self.light_measure.val_changeD_time, + self.light_measure.change_notified, + self.light_measure.change_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 3: + val = [len(self.light_measure.event_tab)+1, 0, 3, + self.light_measure.val_changeU, + self.light_measure.val_changeU_time, + self.light_measure.change_notified, + self.light_measure.change_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 4: + val = [len(self.light_measure.event_tab)+1, 1, 0, + self.light_measure.val_increase, + 0, + self.light_measure.threshold_notified, + self.light_measure.threshold_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 5: + val = [len(self.light_measure.event_tab)+1, 1, 1, + self.light_measure.val_decrease, + 0, + self.light_measure.threshold_notified, + self.light_measure.threshold_behavior, + False, + 0] + elif self.get_widget('cbbConfig').get_active() == 6: + val = [len(self.light_measure.event_tab)+1, 1, 2, + self.light_measure.val_both, + 0, + self.light_measure.threshold_notified, + self.light_measure.threshold_behavior, + False, + 0] + self.light_measure.event_tab.append(val) + print self.light_measure.event_tab + #_me.gui('conf').hide() + #_me.gui('conf').show() - def on_btnApply_clicked(self, widget, *args): #Store the new radio buttons status Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-04 15:08:19 UTC (rev 580) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-04 16:23:15 UTC (rev 581) @@ -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/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-04 15:08:19 UTC (rev 580) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-04 16:23:15 UTC (rev 581) @@ -10,7 +10,6 @@ <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> @@ -20,11 +19,13 @@ <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> + <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> @@ -41,10 +42,9 @@ <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> + <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> @@ -60,6 +60,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> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <conf_lblNotified type='str'>Notified ?</conf_lblNotified> <widget_lblThreshold type='str'>Threshold</widget_lblThreshold> </strings> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |