diff --git a/pythonAPI/checkUpToDate.py b/pythonAPI/checkUpToDate.py index 1f284251f3e5f28cde8b1d43cead7a2db1bf7157..9377214ac79b0a1421e40b034d635f4cfb8dd113 100644 --- a/pythonAPI/checkUpToDate.py +++ b/pythonAPI/checkUpToDate.py @@ -8,9 +8,8 @@ Created on Tue Aug 3 12:06:08 2021 from optparse import OptionParser import sys, traceback +import time -defaultAltitudeID = 1295 -defaultAltitudeValue = 424.0370523579581 #defaultServer = 'http://dcas-devel-1/api/' defaultServer = 'https://dcas-nanostar.isae.fr/api/' defaultUser = 'user' @@ -33,46 +32,51 @@ parser.add_option("-p", "--pwd", dest="pwd", from nanospace import Nanospace nanospace = Nanospace(options.server,options.user, options.pwd) -marginDownId = 1734 -try: - #be carefull between string and formulas !! Check Python API... - oldAltitude = nanospace.get_formula_value(options.altitudeID) - #print("Altitude value in Nanospace UI was (formula): "+str(oldAltitude)) - -except ValueError: - print ("Are you sure that you're using the right ID ("+str(options.altitudeID)+")?") - print( "Exception in user code:") - print ('-'*60) - traceback.print_exc(file=sys.stdout) - print ('-'*60) -try: - #be carefull between string and formulas !! Check Python API... - marginDown = nanospace.get_formula_value(marginDownId) - #print("marginDownId value in Nanospace UI was (formula): "+str(marginDown)) - -except ValueError: - print ("Are you sure that you're using the right ID ("+str(marginDownId)+")?") - print( "Exception in user code:") - print ('-'*60) - traceback.print_exc(file=sys.stdout) - print ('-'*60) +class Var: + def __init__(self,nanospace_id): + self.id = nanospace_id + self.val = '?' + def __repr__(self): + return "<"+str(self.id)+":"+self.val+">" + def getVal(self): + try: + #be carefull between string and formulas !! Check Python API... + self.val = nanospace.get_formula_value(self.id) + print(self) + + except ValueError: + print ("Are you sure that you're using the right ID ("+str(self.idA)+")?") + print( "Exception in user code:") + print ('-'*60) + traceback.print_exc(file=sys.stdout) + print ('-'*60) + def setVal(self): + nanospace.update_formula_value(84, 'multiplication','5*20') -oldAltitude = oldAltitude.replace('*', '') -oldAltitude = oldAltitude.replace('[km]', '') +idA = 2120 +var_A = Var(idA) +var_A.getVal() + +idB = 2123 +var_B = Var(idB) +var_B.getVal() -res=True -if (float(oldAltitude) >= 750): - print("Warning: LOS requirements may be violated due to field ID ("+str(options.altitudeID)+"): altitude <"+oldAltitude+">") - res=False - -if (float(marginDown)<10): - print("Warning: margins requirements may be violated due to field ID ("+str(marginDownId)+"): marginDown <"+marginDown+">") - res=False - -if res: - print("All seem OK!") +dicoRelation = {var_A:var_B} +def compute(): + #get list to run + var_B.setVal(s1(var_A.val)) + + +def s1(val): + return val*val + +while (True): + time.sleep(1) + + +