diff options
Diffstat (limited to 'Monitoring/MonitoringService/Service/WatchdogManager.py')
-rw-r--r-- | Monitoring/MonitoringService/Service/WatchdogManager.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Monitoring/MonitoringService/Service/WatchdogManager.py b/Monitoring/MonitoringService/Service/WatchdogManager.py new file mode 100644 index 0000000..e40f1c3 --- /dev/null +++ b/Monitoring/MonitoringService/Service/WatchdogManager.py @@ -0,0 +1,46 @@ +''' +Created on Dec 10, 2012 + +@author: steger +''' +from DataProcessing.LinearCombination import LinearCombination +from DataProcessing.Bool import IsPositive, IsNotPositive, IsNegative,\ + IsNotNegative + +class WatchdogManager(object): + def __init__(self, am): + self._id = 0; + self._conditionals = {} + self.am = am + self._dep = {} + + def newConditional(self, dataSource, cellrequest, conditiontype, operation): + deps = [] + if conditiontype in [ IsPositive, IsNegative, IsNotNegative, IsNotPositive ]: + lincomb = LinearCombination() + for factor, commandflow in operation: + Aid, A = self.am.newAggregator(dataSource, cellrequest, commandflow) + lincomb.addTerm(factor, A) + deps.append(Aid) + DS = conditiontype(lincomb) + self._id += 1 + self._conditionals[ self._id ] = DS + self._dep[ self._id ] = deps[:] + return self._id, DS + + def __getitem__(self, watchdogid): + try: + return self._conditionals[ watchdogid ] + except: + raise Exception("Watchdog with id %s not found" % watchdogid) + + def pop(self, watchdogid): + try: + self._conditionals.pop( watchdogid ) + deps = self._dep.pop(watchdogid) + while len(deps): + Aid = deps.pop() + self.am.pop(Aid) + except KeyError: + print "WW: Watchdog with id %s not found" % watchdogid +
\ No newline at end of file |