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 7656 2012-01-06T14:43:20.069830Z 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 writeProgress(self,msg):
36 """Let the parent write an additional progress message""" 37 if self.parent: 38 self.parent.writeProgress(msg)
39
40 - def setDirectory(self,oDir):
41 """Set the directory to which output is to be written (if any 42 output is written)""" 43 pass
44
45 - def goOn(self):
46 """If the analyzer thinks the simulation should be stopped 47 (for instance because of convergence) it returns false""" 48 return True
49
50 - def getTime(self):
51 """@returns: current time""" 52 return self.parent.getTime()
53
54 - def addListener(self,func):
55 """@param func: a new listener-function that gets notified every time 56 the line-analyzer encounters something interesting""" 57 58 self.eventListeners.append(func)
59
60 - def notify(self,*data):
61 """Notifys the event listeners of an event 62 @param data: The data of the event. Everything is possible""" 63 64 for f in self.eventListeners: 65 f(*data)
66
67 - def tearDown(self):
68 """Hook to let every analyzer give its stuff back when the analysis has ended""" 69 pass
70
71 - def getCurrentData(self):
72 """Give back the current analyzed data in a dictionary 73 74 To be overwritten by subclasses""" 75 76 return {}
77