Skip to content
Snippets Groups Projects
Commit a404a862 authored by GATEAU Thibault's avatar GATEAU Thibault
Browse files

[dev] example checking val change done

parent ea9c2e10
No related branches found
No related tags found
No related merge requests found
......@@ -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)
"""
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment