Package PyFoam :: Package LogAnalysis :: Module LogLineAnalyzer
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.LogAnalysis.LogLineAnalyzer

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/LogAnalysis/LogLineAnalyzer.py 2494 2007-12-14T14:37:46.025021Z bgschaid  $  
 2  """Base class for analyzing lines""" 
 3   
 4  from PyFoam.Error import error 
 5   
6 -class LogLineAnalyzer(object):
7 """Base class for the analysis of all lines from a OpenFOAM-log 8 9 Lines are available one at a time""" 10
11 - def __init__(self):
12 self.parent=None 13 self.eventListeners=[]
14
15 - def doAnalysis(self,line):
16 """Analyze a line 17 18 line - the line to be analyzed 19 20 This method carries the main functionality in the sub-classes""" 21 pass
22
23 - def timeChanged(self):
24 """The value of the time has changed in the Log-file 25 26 For subclasses that need to know the current time""" 27 pass
28
29 - def setParent(self,parent):
30 """Introduces the LineAnalyzer to its supervisor 31 32 @param parent: The Analyzer class of which this is a part""" 33 self.parent=parent
34
35 - def setDirectory(self,oDir):
36 """Set the directory to which output is to be written (if any 37 output is written)""" 38 pass
39
40 - def goOn(self):
41 """If the analyzer thinks the simulation should be stopped 42 (for instance because of convergence) it returns false""" 43 return True
44
45 - def getTime(self):
46 """@returns: current time""" 47 return self.parent.getTime()
48
49 - def addListener(self,func):
50 """@param func: a new listener-function that gets notified every time 51 the line-analyzer encounters something interesting""" 52 53 self.eventListeners.append(func)
54
55 - def notify(self,*data):
56 """Notifys the event listeners of an event 57 @param data: The data of the event. Everything is possible""" 58 59 for f in self.eventListeners: 60 f(*data)
61
62 - def tearDown(self):
63 """Hook to let every analyzer give its stuff back when the analysis has ended""" 64 pass
65