/[ascend]/trunk/pygtk/interface/solverreporter.py
ViewVC logotype

Diff of /trunk/pygtk/interface/solverreporter.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 318 by johnpye, Thu Feb 23 10:29:29 2006 UTC revision 319 by johnpye, Thu Feb 23 12:30:40 2006 UTC
# Line 22  class PythonSolverReporter(ascend.Solver Line 22  class PythonSolverReporter(ascend.Solver
22            
23          self.progressbar = _xml.get_widget("progressbar")          self.progressbar = _xml.get_widget("progressbar")
24          self.closebutton = _xml.get_widget("closebutton")          self.closebutton = _xml.get_widget("closebutton")
25          self.cancelbutton = _xml.get_widget("cancelbutton")          self.stopbutton = _xml.get_widget("stopbutton")
26                            
27          print "SOLVER REPORTER ---- PYTHON"          print "SOLVER REPORTER ---- PYTHON"
28    
# Line 49  class PythonSolverReporter(ascend.Solver Line 49  class PythonSolverReporter(ascend.Solver
49      def run(self):      def run(self):
50          self.window.run()          self.window.run()
51    
52      def on_cancelbutton_clicked(self,*args):      def on_stopbutton_clicked(self,*args):
53          print "STOPPING..."          print "STOPPING..."
54          self.guiinterrupt = True;          self.guiinterrupt = True;
55    
56      def on_solverstatusdialog_close(self):      def on_solverstatusdialog_close(self,*args):
57          self.window.response(gtk.RESPONSE_CLOSE)          self.window.response(gtk.RESPONSE_CLOSE)
58    
59      def on_solverstatusdialog_response(self,response,*args):      def on_solverstatusdialog_response(self,response,*args):
# Line 78  class PythonSolverReporter(ascend.Solver Line 78  class PythonSolverReporter(ascend.Solver
78  #           print "TRYING..."  #           print "TRYING..."
79  #       except RuntimeError,e:  #       except RuntimeError,e:
80  #           print "ERROR OF SOME SORT"  #           print "ERROR OF SOME SORT"
81          if status.isConverged():          _frac = float(status.getNumConverged()) / self.nv
82              self.progressbar.set_fraction(1.0)          print "FRACTION = ",_frac
83              self.progressbar.set_text("Converged");          self.progressbar.set_text("%d vars converged..." % status.getNumConverged());
84              self.closebutton.set_sensitive(True)          self.progressbar.set_fraction(_frac)
             self.cancelbutton.set_sensitive(False)  
         else:  
             _frac = float(status.getNumConverged()) / self.nv  
             print "FRACTION = ",_frac  
             self.progressbar.set_text("%d vars converged..." % status.getNumConverged());  
             self.progressbar.set_fraction(_frac)  
   
         while gtk.events_pending():  
             gtk.main_iteration()          
85    
86      def report(self,status):      def report(self,status):
87          _time = time.clock();          _time = time.clock();
# Line 103  class PythonSolverReporter(ascend.Solver Line 94  class PythonSolverReporter(ascend.Solver
94              self.elapsed = _time - self.starttime              self.elapsed = _time - self.starttime
95              print "UPDATING!"              print "UPDATING!"
96              self.fill_values(status)              self.fill_values(status)
97    
98            while gtk.events_pending():
99                gtk.main_iteration()        
100    
101          if status.isConverged() or status.isDiverged() or status.isInterrupted():          if status.isConverged() or status.isDiverged() or status.isInterrupted():
102              return 1              return 1
103          if self.guiinterrupt:          if self.guiinterrupt:
104              return 2              return 2
105          return 0          return 0
106    
107        def finalise(self,status):
108            _p = self.browser.prefs;
109            _close_on_converged = _p.getBoolPref("SolverReporter","close_on_converged");
110    
111            if status.isConverged() and _close_on_converged:
112                self.window.response(gtk.RESPONSE_CLOSE)
113                return      
114    
115            self.fill_values(status)
116    
117            if status.isConverged():
118                self.progressbar.set_fraction(1.0)
119                self.progressbar.set_text("Converged")
120            elif status.hasExceededTimeLimit():
121                self.progressbar.set_text("Exceeded time limit")
122            elif status.hasExceededIterationLimit():
123                self.progressbar.set_text("Exceeded iteration limit")
124            elif status.isDiverged():
125                self.progressbar.set_text("Diverged")
126                    
127            self.closebutton.set_sensitive(True)
128            self.stopbutton.set_sensitive(False)
129            
130                

Legend:
Removed from v.318  
changed lines
  Added in v.319

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22