Commit 38f0f172 authored by GATEAU Thibault's avatar GATEAU Thibault
Browse files

[dev] simple example working

parent ac24c326
......@@ -26,7 +26,7 @@
"softwares":[
{"powerTwo":"s1",
"in":[],
"out":[],
"out":[]
}
],
......@@ -37,7 +37,7 @@
{
"name":"c1",
"id": 2053,
"value":"var(B)<10"
"value":"B<10"
}
]
}
......@@ -39,9 +39,10 @@ class Var:
self.id = nanospace_id
self.name = nanospace_name
self.val = '?'
self.check = False
def __repr__(self):
return "<"+str(self.name)+"|"+str(self.id)+":"+self.val+">"
return "<"+str(self.name)+"|"+str(self.id)+":"+str(self.val)+">"
def getVal(self):
try:
......@@ -58,6 +59,7 @@ class Var:
print ('-'*60)
def setVal(self,newVal):
nanospace.update_formula_value(self.id, self.name ,str(newVal))
self.val = newVal
......@@ -108,14 +110,33 @@ var_B = lVar[1]
def reCompute():
#get list to run
var_B.setVal(s1(float(var_A.val)))
print ("done")
print ("reCompute done!")
#reCompute()
lReq = []
for req in dataJson["constraints"]:
myVar_id = req["id"]
myVar_name = req["name"]
myVar = Var(myVar_id,myVar_name)
myVar.getVal()
print(myVar)
lReq.append(myVar)
c1 = lReq[0]
def checkRequirements():
c1.check = (float(var_B.val)<10)
if c1.check:
print("Requirements OK")
else:
print("Warning! - Violation: "+repr(c1))
checkRequirements()
oldVal = var_A.getVal()
......@@ -132,6 +153,9 @@ while (True):
reCompute()
print(var_B)
oldVal = newVal
checkRequirements()
"""
......
Markdown is supported
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