[tuxdroid-svn] r578 - in software/gadgets/light_monitor/trunk: . Light_monitor Light_monitor/Script
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-03 08:29:10
|
Author: Paul_R Date: 2007-10-03 10:28:04 +0200 (Wed, 03 Oct 2007) New Revision: 578 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/Scripts/Python/notify.pyp software/gadgets/light_monitor/trunk/Light_monitor/about.xml Log: * Fix some bug when the widget window was displayed 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-02 21:18:59 UTC (rev 577) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-03 08:28:04 UTC (rev 578) @@ -370,9 +370,9 @@ 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] + print self.measure.event_tab[index-1][6] self.measure.event_tab[index-1][6] = None - print self.measure.event_tab[index][6] + print self.measure.event_tab[index-1][6] self.value_list.clear() for i in range(len(self.measure.event_tab)): 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-02 21:18:59 UTC (rev 577) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-03 08:28:04 UTC (rev 578) @@ -53,6 +53,7 @@ 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() @@ -137,12 +138,16 @@ # ########################################################### def event_control(self): - for i in range (len(self.event_tab)): - self.Threshold_control(i) - self.Change_control(i) + 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 - if self.GUI_on: + else: + print 'Goto test functions' self.test_func() #disable gadget notifications self.notify = False @@ -159,9 +164,8 @@ 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) @@ -183,19 +187,28 @@ ########################################################### def Threshold_control(self, index): if self.event_tab[index][1] == 1: + print 'Threshold found' if self.event_tab[index][7] != True: + print 'No event detected' if self.event_tab[index][2] == 0: + print 'Increase' #Increasing threshold control if self.Increase_control(self.event_tab[index][3]) == True: + print 'Increase detected' self.event_tab[index][7] = True elif self.event_tab[index][2] == 1: + print 'Decrease' #Decreasing threshold control if self.Decrease_control(self.event_tab[index][3]) == True: + print 'Decrease detected' self.event_tab[index][7] = True elif self.event_tab[index][2] == 2: + print 'Both direction' #Both direction theshold control if self.Both_control(self.event_tab[index][3]) == True: + print 'Both detected' self.event_tab[index][7] = True + print 'Threshold control done ...' def Increase_control(self, value): val_act = (self.val_table[len(self.val_table)-1]*100) / 1124.0 @@ -224,27 +237,38 @@ ########################################################### def Change_control(self, i): #Changements control - if self.event_tab[i][1] == 0: + if self.event_tab[i][1] == 0: + print 'Change found' 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: + print 'no event detected' # Drop change part : if self.event_tab[i][2] == 0: + print 'Drop' if self.Drop_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + print 'Drop detected' self.event_tab[i][7] = True # Raise change part if self.event_tab[i][2] == 1: + print 'Raise' if self.Raise_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + print 'Raise detected' self.event_tab[i][7] = True # Drop and Raise change if self.event_tab[i][2] == 2: + print 'Drop and raise' if self.ChangeD_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + print 'Drop and raise detected' self.event_tab[i][7] = True # Raise and Drop change if self.event_tab[i][2] == 3: + print 'Raise and drop' if self.ChangeU_control(time, self.event_tab[i][3], self.event_tab[i][8], i) == True: + print 'Raise and drop detected' self.event_tab[i][7] = True - + print 'Change control done ...' + def Drop_control(self, time, val, timeout, index): #timeout control : to prevent multiple notifications with the same event if timeout != 0: @@ -257,8 +281,11 @@ else: self.timeout = int(time) return True - elif self.GUI_on: - self.timeout = timeout + else: + if self.GUI_on: + self.timeout = timeout + else: + self.event_tab[index][8] = timeout def Raise_control(self, time, val, timeout, index): if timeout != 0: @@ -271,8 +298,11 @@ else: self.timeout = int(time) return True - elif self.GUI_on: - self.timeout = timeout + else: + if self.GUI_on: + self.timeout = timeout + else: + self.event_tab[index][8] = timeout def ChangeD_control(self, time, val, timeout, index): if timeout != 0: @@ -319,57 +349,82 @@ ########################################################### def test_func(self): if self.threshold_event != True: + print 'Threshold event found' #Decrease threshold control if self.decrease: - self.threshold_event = self.Decrease_control(self.val_threshold) + print 'Goto decrease control' + if self.Decrease_control(self.val_threshold) == True: + self.threshold_event = True + print 'done ...' #Increasing threshold control if self.increase: - self.threshold_event = self.Increase_control(self.val_threshold) + print 'Goto Increase control' + if self.Increase_control(self.val_threshold) == True: + self.threshold_event = True + print 'done ...' #Both direction theshold control if self.both: - self.threshold_event = self.Both_control(self.val_threshold) + print 'Goto Both control' + if self.Both_control(self.val_threshold) == True: + self.threshold_event = True + print 'done ...' #Changements control if self.change_event != True: + print 'Change event found' # 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) + print 'Goto drop control' + if self.Drop_control(self.val_drop_time, self.val_drop, self.timeout, 0) == True: + self.change_event = True + print 'done ...' # 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) + print 'Goto raise control' + if self.Raise_control(self.val_raise_time, self.val_raise, self.timeout, 0) == True: + self.change_event = True + print 'done ...' # 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) + print 'Goto drop and raise control' + if self.ChangeD_control(self.val_changeD_time, self.val_changeD, self.timeout, 0) == True: + self.change_event = True + print 'done ...' # 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) + print 'Goto raise and drop control' + if self.ChangeU_control(self.val_changeU_time, self.val_changeU, self.timeout, 0) == True: + self.change_event = True + print 'Done' def test_notification(self): if self.threshold_event == True: - if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior): + print 'Theshold event occur' + if self.threshold_behavior_chk and os.path.isfile(self.threshold_behavior) and os.path.exists(self.threshold_behavior) : + print 'Execute behavior script' self.threshold_event = False tux.sys.shell_free(self.threshold_behavior) else: + print 'execute deflaut behavior' 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) + print 'Change event occur' + if self.change_behavior_chk and os.path.isfile(self.change_behavior) and os.path.exists(self.change_behavior): + print 'Execute behavior script' + self.change_event = False + tux.sys.shell_free(self.change_behavior) else: + print 'Default behavior' self.change_event = False tux.cmd.mouth_open() tux.tts.speak(self.changetext) tux.cmd.mouth_close() - + print 'End of test notifications' ########################################################### # # Acquire 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-02 21:18:59 UTC (rev 577) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/notify.pyp 2007-10-03 08:28:04 UTC (rev 578) @@ -26,23 +26,32 @@ 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]: - if os.path.isfile(str(event[i][6])): + print 'notification enable' + if os.path.isfile(event[i][6]) and os.path.exists(event[i][6]): + print 'script found and valid' tux.sys.shell_free(event[i][6]) 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-02 21:18:59 UTC (rev 577) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-03 08:28:04 UTC (rev 578) @@ -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_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.tgf =================================================================== (Binary files differ) |