/[ascend]/trunk/models/johnpye/listnotes.py
ViewVC logotype

Diff of /trunk/models/johnpye/listnotes.py

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

revision 899 by johnpye, Tue Oct 24 13:34:13 2006 UTC revision 900 by johnpye, Wed Oct 25 06:03:04 2006 UTC
# Line 20  def listnotes(self): Line 20  def listnotes(self):
20    
21  def setup_solver(self):  def setup_solver(self):
22      """ use the NOTES DB to configure solver parameters for the current model """      """ use the NOTES DB to configure solver parameters for the current model """
23        print "SETUP_SOLVER..."
24      self = ascpy.Registry().getInstance('context')      self = ascpy.Registry().getInstance('context')
25      sim = browser.sim      sim = ascpy.Registry().getSimulation('sim')
     reporter = browser.reporter  
26    
27      # at present this code is pretty clunky because of the bare-bone code in the wrapper API.      reporter = browser.reporter
     # this could be improved a lot with some python wizardry for iterators, __getitem__ etc.  
28    
29      db = browser.library.getAnnotationDatabase()      db = browser.library.getAnnotationDatabase()
30    
31      solvernotes = db.getNotes(self.getType(),ascpy.SymChar("solver"),ascpy.SymChar("name"))      print "GOT SIM..."
32      if len(solvernotes) > 1:      
33          reporter.reportNote("Multiple solvers specified in NOTES for model '%s'", sim.getType())      if not sim:
34      elif len(solvernotes) == 1:          reporter.reportError("No simulation present yet")
35          solver = ascpy.Solver(solvernotes[0].getText())          return
36          reporter.reportNote("Setting solver to '%s'" % solver.getName())  
37          sim.setSolver(solver)      if not browser.solver:
38      else:          reporter.reportError("No solver yet")
39          reporter.reportNote("No solver specified in NOTES , using current")          return
40    
41      solvername = sim.getSolver().getName()      solvername = browser.solver.getName()
42      #reporter.reportNote("Parameters for solver '%s'" % solvername)      reporter.reportNote("Active solver is '%s'" % solvername)
43    
44      notes = db.getNotes(self.getType(),ascpy.SymChar(solvername))      notes = db.getNotes(self.getType(),ascpy.SymChar(solvername))
45    
46        print "GETTINGS SOLVER PARAMS..."
47    
48      params = sim.getSolverParameters()      params = sim.getSolverParameters()
49    
50        print "DONE SOLVER PARAMS"
51    
52        print params
53    
54      paramnames = [p.getName() for p in params]      paramnames = [p.getName() for p in params]
55    
56        print "DONE PARAMS"
57    
58      for i in range(0,len(notes)):      for i in range(0,len(notes)):
59          note = notes[i]          note = notes[i]
60    

Legend:
Removed from v.899  
changed lines
  Added in v.900

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