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

[dev] simple example working

parent ac24c326
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"softwares":[ "softwares":[
{"powerTwo":"s1", {"powerTwo":"s1",
"in":[], "in":[],
"out":[], "out":[]
} }
], ],
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
{ {
"name":"c1", "name":"c1",
"id": 2053, "id": 2053,
"value":"var(B)<10" "value":"B<10"
} }
] ]
} }
...@@ -39,9 +39,10 @@ class Var: ...@@ -39,9 +39,10 @@ class Var:
self.id = nanospace_id self.id = nanospace_id
self.name = nanospace_name self.name = nanospace_name
self.val = '?' self.val = '?'
self.check = False
def __repr__(self): 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): def getVal(self):
try: try:
...@@ -58,6 +59,7 @@ class Var: ...@@ -58,6 +59,7 @@ class Var:
print ('-'*60) print ('-'*60)
def setVal(self,newVal): def setVal(self,newVal):
nanospace.update_formula_value(self.id, self.name ,str(newVal)) nanospace.update_formula_value(self.id, self.name ,str(newVal))
self.val = newVal
...@@ -108,14 +110,33 @@ var_B = lVar[1] ...@@ -108,14 +110,33 @@ var_B = lVar[1]
def reCompute(): def reCompute():
#get list to run #get list to run
var_B.setVal(s1(float(var_A.val))) var_B.setVal(s1(float(var_A.val)))
print ("done") print ("reCompute done!")
#reCompute() #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() oldVal = var_A.getVal()
...@@ -132,6 +153,9 @@ while (True): ...@@ -132,6 +153,9 @@ while (True):
reCompute() reCompute()
print(var_B) print(var_B)
oldVal = newVal oldVal = newVal
checkRequirements()
""" """
......
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