diff --git a/pythonAPI/ExampleSystem.json b/pythonAPI/ExampleSystem.json index bda380026b3d3872d851aa6c0c28408f6f246292..caa26adc56a69e90ff663b9fe7516791df1f4393 100644 --- a/pythonAPI/ExampleSystem.json +++ b/pythonAPI/ExampleSystem.json @@ -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" } ] } diff --git a/pythonAPI/checkUpToDateJson.py b/pythonAPI/checkUpToDateJson.py index ae0143240d4e9d675f9e5fa2f5fd744bc07d20dd..939ccb74c6ed53f83ea94f40db30672663310953 100644 --- a/pythonAPI/checkUpToDateJson.py +++ b/pythonAPI/checkUpToDateJson.py @@ -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() + + """