diff --git a/pythonAPI/checkUpToDate.py b/pythonAPI/checkUpToDate.py index 9377214ac79b0a1421e40b034d635f4cfb8dd113..b75ffd43f7597eafdf2f856f9761976526bb41da 100644 --- a/pythonAPI/checkUpToDate.py +++ b/pythonAPI/checkUpToDate.py @@ -34,8 +34,9 @@ nanospace = Nanospace(options.server,options.user, options.pwd) class Var: - def __init__(self,nanospace_id): + def __init__(self,nanospace_id,nanospace_name): self.id = nanospace_id + self.name = nanospace_name self.val = '?' def __repr__(self): return "<"+str(self.id)+":"+self.val+">" @@ -44,7 +45,8 @@ class Var: try: #be carefull between string and formulas !! Check Python API... self.val = nanospace.get_formula_value(self.id) - print(self) + return self.val + #print(self) except ValueError: print ("Are you sure that you're using the right ID ("+str(self.idA)+")?") @@ -52,31 +54,52 @@ class Var: print ('-'*60) traceback.print_exc(file=sys.stdout) print ('-'*60) - def setVal(self): - nanospace.update_formula_value(84, 'multiplication','5*20') + def setVal(self,newVal): + nanospace.update_formula_value(self.id, self.name ,str(newVal)) idA = 2120 -var_A = Var(idA) +var_A = Var(idA,"A") var_A.getVal() idB = 2123 -var_B = Var(idB) +var_B = Var(idB,"B") var_B.getVal() dicoRelation = {var_A:var_B} -def compute(): - #get list to run - var_B.setVal(s1(var_A.val)) - - def s1(val): return val*val - +def reCompute(): + #get list to run + var_B.setVal(s1(float(var_A.val))) + print ("done") +reCompute() + + +oldVal = var_A.getVal() +print("waiting")# , end="", flush=False) + + + while (True): + #print(". ", end="", flush=True) time.sleep(1) + newVal = var_A.getVal() + if not (oldVal == newVal): + print ("Value changed") + print(var_A) + reCompute() + print(var_B) + oldVal = newVal + + +""" +while (True): + print(". ", end="", flush=False) + time.sleep(1) +"""