def var(self, var, calc=False): if calc or ((var not in self.data.keys()) and (var in ClutchFunc.clutchfunc.funcs.keys())): print "calc",var, return ClutchFunc.runFunc( var, self.data) elif var in self.data.keys() : print "retr",var, return self.data[var] return None
def __init__(self): observable.Observable.__init__(self) # Current values of all variables self.data = {} # Unique data for each variable from primary source self.data_by_source = {} # All current data submitted from all sources, [variable][key] # Race course data needed for calculation self.course = Course() self.course.subscribe(self.update_course) # Notify me on any changes to the course self.boat = Boat.Boat() self.tl = Tables.TableLibrary() self.tl.addTables("Polars") self.update_tablelibrary( {} ) ClutchFunc.load_and_monitor("Functions") # Short term buffer of data we need on hand self.buffer = collections.deque([],5000) self.buffer_last_found = 0
def update_data( self, newdata ): self.data.update(newdata) calced_data = ClutchFunc.runFuncs(self.data, newdata.keys()) self.data.update( calced_data ) self.notifyObservers(dict(newdata.items() + calced_data.items()))
import ClutchFunc import time ClutchFunc.clutchfunc.loadFuncs('Functions') mon = ClutchFunc.functionMonitor() mon.start() data = {'a':1,'b':2} print data new_data = ClutchFunc.clutchfunc.runFuncs(data,['a','b'],[]) data.update(new_data) print data new_data = ClutchFunc.clutchfunc.runFuncs(data,['a','b'],[]) # for i in range(10): # time.sleep(5) # print "----------------------------------" # ClutchFunc.clutchfunc.runFuncs()