From e63c7dee2ab05e9a08f9827ec11b7dad1b866a54 Mon Sep 17 00:00:00 2001 From: Rahul Date: Sun, 19 Feb 2023 22:35:10 +0530 Subject: [PATCH 1/3] CORS enabled --- fri/server/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fri/server/main.py b/fri/server/main.py index e546761..203a94d 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -5,6 +5,7 @@ from pathlib import Path import json import subprocess +from flask_cors import CORS, cross_origin cur_path = os.path.dirname(os.path.abspath(__file__)) concore_path = os.path.abspath(os.path.join(cur_path, '../../')) @@ -13,6 +14,9 @@ app = Flask(__name__) app.secret_key = "secret key" +cors = CORS(app) +app.config['CORS_HEADERS'] = 'Content-Type' + # To upload multiple file. For example, /upload/test?apikey=xyz @app.route('/upload/', methods=['POST']) def upload(dir): From 8fa6bb3162051ba7329a4b91f8f0461cf5bceca8 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 22 Feb 2023 03:50:33 +0530 Subject: [PATCH 2/3] Windows for concore configured --- fri/server/main.py | 74 ++-- fri/test.py | 49 ++- fri/u | 1 + sample/CZ/__pycache__/concore.cpython-311.pyc | Bin 0 -> 5655 bytes sample/CZ/concore.iport | 1 + sample/CZ/concore.oport | 1 + sample/CZ/concore.py | 113 ++++++ sample/CZ/controller.py | 32 ++ sample/PZ/__pycache__/concore.cpython-311.pyc | Bin 0 -> 5655 bytes sample/PZ/concore.iport | 1 + sample/PZ/concore.oport | 1 + sample/PZ/concore.py | 113 ++++++ sample/PZ/pm.py | 27 ++ sample/build.bat | 24 ++ sample/clear.bat | 2 + sample/debug.bat | 2 + sample/maxtime.bat | 2 + sample/params.bat | 2 + sample/run.bat | 2 + sample/src/concore.hpp | 228 ++++++++++++ sample/src/concore.py | 113 ++++++ sample/src/concore.v | 351 ++++++++++++++++++ sample/src/concore_default_maxtime.m | 12 + sample/src/concore_initval.m | 6 + sample/src/concore_iport.m | 17 + sample/src/concore_oport.m | 17 + sample/src/concore_read.m | 22 ++ sample/src/concore_unchanged.m | 16 + sample/src/concore_write.m | 11 + sample/src/controller.iport | 1 + sample/src/controller.oport | 1 + sample/src/controller.py | 32 ++ sample/src/import_concore.m | 42 +++ sample/src/mkcompile | 7 + sample/src/pm.iport | 1 + sample/src/pm.oport | 1 + sample/src/pm.py | 27 ++ sample/stop.bat | 4 + sample/unlock.bat | 2 + test_xyz/controller.py | 32 ++ test_xyz/pm.py | 27 ++ test_xyz/sample.graphml | 137 +++++++ 42 files changed, 1500 insertions(+), 54 deletions(-) create mode 100644 fri/u create mode 100644 sample/CZ/__pycache__/concore.cpython-311.pyc create mode 100644 sample/CZ/concore.iport create mode 100644 sample/CZ/concore.oport create mode 100644 sample/CZ/concore.py create mode 100644 sample/CZ/controller.py create mode 100644 sample/PZ/__pycache__/concore.cpython-311.pyc create mode 100644 sample/PZ/concore.iport create mode 100644 sample/PZ/concore.oport create mode 100644 sample/PZ/concore.py create mode 100644 sample/PZ/pm.py create mode 100644 sample/build.bat create mode 100644 sample/clear.bat create mode 100644 sample/debug.bat create mode 100644 sample/maxtime.bat create mode 100644 sample/params.bat create mode 100644 sample/run.bat create mode 100644 sample/src/concore.hpp create mode 100644 sample/src/concore.py create mode 100644 sample/src/concore.v create mode 100644 sample/src/concore_default_maxtime.m create mode 100644 sample/src/concore_initval.m create mode 100644 sample/src/concore_iport.m create mode 100644 sample/src/concore_oport.m create mode 100644 sample/src/concore_read.m create mode 100644 sample/src/concore_unchanged.m create mode 100644 sample/src/concore_write.m create mode 100644 sample/src/controller.iport create mode 100644 sample/src/controller.oport create mode 100644 sample/src/controller.py create mode 100644 sample/src/import_concore.m create mode 100644 sample/src/mkcompile create mode 100644 sample/src/pm.iport create mode 100644 sample/src/pm.oport create mode 100644 sample/src/pm.py create mode 100644 sample/stop.bat create mode 100644 sample/unlock.bat create mode 100644 test_xyz/controller.py create mode 100644 test_xyz/pm.py create mode 100644 test_xyz/sample.graphml diff --git a/fri/server/main.py b/fri/server/main.py index 51f8f97..a548d34 100644 --- a/fri/server/main.py +++ b/fri/server/main.py @@ -1,10 +1,11 @@ from flask import Flask, request, jsonify, send_file, send_from_directory from werkzeug.utils import secure_filename import os +import subprocess from subprocess import call from pathlib import Path import json -import subprocess +import platform from flask_cors import CORS, cross_origin cur_path = os.path.dirname(os.path.abspath(__file__)) @@ -21,8 +22,10 @@ @app.route('/upload/', methods=['POST']) def upload(dir): apikey = request.args.get('apikey') - dirname = secure_filename(dir) + "_" + apikey - + if(apikey == None): + dirname = secure_filename(dir) + else: + dirname = secure_filename(dir) + "_" + apikey if 'files[]' not in request.files: resp = jsonify({'message': 'No file in the request'}) resp.status_code = 400 @@ -38,7 +41,6 @@ def upload(dir): if not os.path.isdir(directory_name): os.mkdir(directory_name) - for file in files: if file: filename = secure_filename(file.filename) @@ -60,32 +62,42 @@ def upload(dir): return resp - # to download /build/?fetch=. For example, /build/test?fetch=sample1&apikey=xyz @app.route('/build/', methods=['POST']) def build(dir): graphml_file = request.args.get('fetch') apikey = request.args.get('apikey') - dirname = secure_filename(dir) + "_" + apikey + if(apikey == None): + dirname = secure_filename(dir) + else: + dirname = secure_filename(dir) + "_" + apikey makestudy_dir = dirname + "/" + graphml_file #for makestudy dir_path = os.path.abspath(os.path.join(concore_path, graphml_file)) #path for ./build if not os.path.exists(dir_path): - proc = call(["./makestudy", makestudy_dir], cwd=concore_path) + if(platform.uname()[0]=='Windows'): + proc= call(["makestudy", makestudy_dir], shell=True, cwd=concore_path) + else: + proc = call(["./makestudy", makestudy_dir], cwd=concore_path) if(proc == 0): resp = jsonify({'message': 'Directory successfully created'}) resp.status_code = 201 else: resp = jsonify({'message': 'There is an Error'}) - resp.status_code = 500 - call(["./build"], cwd=dir_path) + resp.status_code = 500 + if(platform.uname()[0]=='Windows'): + call(["build"], cwd=dir_path, shell=True) + else: + call(["./build"], cwd=dir_path) return resp - @app.route('/debug/', methods=['POST']) def debug(dir): - dir = secure_filename(dir) - dir_path = os.path.abspath(os.path.join(concore_path, dir)) - proc = call(["./debug"], cwd=dir_path) + dir_name = secure_filename(dir) + dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) + if(platform.uname()[0]=='Windows'): + proc=call(["debug"],shell=True, cwd=dir_path) + else: + proc = call(["./debug"], cwd=dir_path) if(proc == 0): resp = jsonify({'message': 'Close the pop window after obtaining result'}) resp.status_code = 201 @@ -95,12 +107,14 @@ def debug(dir): resp.status_code = 500 return resp - @app.route('/run/', methods=['POST']) def run(dir): - dir = secure_filename(dir) - dir_path = os.path.abspath(os.path.join(concore_path, dir)) - proc = call(["./run"], cwd=dir_path) + dir_name = secure_filename(dir) + dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) + if(platform.uname()[0]=='Windows'): + proc=call(["run"],shell=True, cwd=dir_path) + else: + proc = call(["./run"], cwd=dir_path) if(proc == 0): resp = jsonify({'message': 'result prepared'}) resp.status_code = 201 @@ -112,9 +126,12 @@ def run(dir): @app.route('/stop/', methods=['POST']) def stop(dir): - dir = secure_filename(dir) - dir_path = os.path.abspath(os.path.join(concore_path, dir)) - proc = call(["./stop"], cwd=dir_path) + dir_name = secure_filename(dir) + dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) + if(platform.uname()[0]=='Windows'): + proc=call(["stop"],shell=True, cwd=dir_path) + else: + proc = call(["./stop"], cwd=dir_path) if(proc == 0): resp = jsonify({'message': 'resources cleaned'}) resp.status_code = 201 @@ -127,9 +144,12 @@ def stop(dir): @app.route('/clear/', methods=['POST']) def clear(dir): - dir = secure_filename(dir) - dir_path = os.path.abspath(os.path.join(concore_path, dir)) - proc = call(["./clear"], cwd=dir_path) + dir_name = secure_filename(dir) + dir_path = os.path.abspath(os.path.join(concore_path, dir_name)) + if(platform.uname()[0]=='Windows'): + proc=call(["clear"],shell=True, cwd=dir_path) + else: + proc = call(["./clear"], cwd=dir_path) if(proc == 0): resp = jsonify({'message': 'result deleted'}) resp.status_code = 201 @@ -157,11 +177,13 @@ def download(dir): resp.status_code = 400 return resp - @app.route('/destroy/', methods=['DELETE']) def destroy(dir): dir = secure_filename(dir) - proc = call(["./destroy", dir], cwd=concore_path) + if(platform.uname()[0]=='Windows'): + proc=call(["destroy"],shell=True, cwd=concore_path) + else: + proc = call(["./destroy"], cwd=concore_path) if(proc == 0): resp = jsonify({'message': 'Successfuly deleted Dirctory'}) resp.status_code = 201 @@ -181,7 +203,6 @@ def getFilesList(dir): res = json.dumps(res) return res - @app.route('/openJupyter/', methods=['POST']) def openJupyter(): proc = subprocess.Popen(['jupyter', 'lab'], shell=False, stdout=subprocess.PIPE, cwd=concore_path) @@ -195,6 +216,5 @@ def openJupyter(): return resp - if __name__ == "__main__": app.run(host="0.0.0.0", port=5000) diff --git a/fri/test.py b/fri/test.py index 684c6ef..8204c68 100644 --- a/fri/test.py +++ b/fri/test.py @@ -13,7 +13,6 @@ def upload(files): response = requests.request("POST", url, headers=headers, data=payload, files=files) print(response.text) - # # ******* # function to check build @@ -23,37 +22,36 @@ def build(dir, graphml, apikey): print(response.text) # function to debug -def debug(graphml): - url = "http://127.0.0.1:5000/debug/"+graphml +def debug(graphml, apikey): + url = "http://127.0.0.1:5000/debug/"+graphml+"?"+"apikey="+apikey response = requests.request("POST", url) print(response.text) # function to test run() method. -def run(graphml): - url = "http://127.0.0.1:5000/run/"+graphml +def run(graphml, apikey): + url = "http://127.0.0.1:5000/run/"+graphml+"?"+"apikey="+apikey response = requests.request("POST", url) print(response.text) -def clear(graphml): - url = "http://127.0.0.1:5000/clear/"+graphml +def clear(graphml, apikey): + url = "http://127.0.0.1:5000/clear/"+graphml+"?"+"apikey="+apikey response = requests.request("POST", url) print(response.text) -def stop(graphml): - url = "http://127.0.0.1:5000/stop/"+graphml +def stop(graphml, apikey): + url = "http://127.0.0.1:5000/stop/"+graphml+"?"+"apikey="+apikey response = requests.request("POST", url) print(response.text) - #function to destroy dir. -def destroy(dir): - url = "http://127.0.0.1:5000/destroy/" + dir +def destroy(dir, apikey): + url = "http://127.0.0.1:5000/destroy/" + dir+"?"+"apikey="+apikey response = requests.request("DELETE", url) print(response.text) -def getFilesList(dir, sub_dir = ""): - url = "http://127.0.0.1:5000/getFilesList/" + dir + "?"+"fetch="+sub_dir +def getFilesList(apikey, dir, sub_dir = ""): + url = "http://127.0.0.1:5000/getFilesList/" + dir + "?"+"fetch="+sub_dir+"&"+"apikey="+apikey response = requests.request("POST", url) print(response.text) @@ -63,8 +61,8 @@ def openJupyter(): print(response.text) # function to test download() method. -def download(dir, subDir, fileName ): - url = "http://127.0.0.1:5000/download/"+dir+"?"+"fetchDir="+subDir+"&"+"fetch="+ fileName +def download(dir, subDir, fileName , apikey ): + url = "http://127.0.0.1:5000/download/"+dir+"?"+"fetchDir="+subDir+"&"+"fetch="+ fileName+"&"+"apikey="+apikey urllib.request.urlretrieve(url, fileName) # file list to be uploaded @@ -83,25 +81,22 @@ def download(dir, subDir, fileName ): ('files[]',(file_name3,open(path_file3,'rb'),'application/octet-stream')), ] - upload(files) time.sleep(2) build("test", "sample", "xyz") time.sleep(6) method = input("methods - 1 for debug, 0 for run :") if method == "1": - debug("sample") + debug("sample", "xyz") else: - run("sample") + run("sample", "xyz") time.sleep(2) -stop("sample") +stop("sample", "xyz") time.sleep(2) -getFilesList("sample", "cu") -getFilesList("sample", "pym") +getFilesList("xyz", "sample", "CU") +getFilesList("xyz","sample", "PYM") time.sleep(5) -download("sample", "cu", "u") -clear("sample") -destroy("sample") +download("sample", "CU", "u", "xyz") +clear("sample", "xyz") +destroy("sample", "xyz") openJupyter() - - diff --git a/fri/u b/fri/u new file mode 100644 index 0000000..d7c144c --- /dev/null +++ b/fri/u @@ -0,0 +1 @@ +[44.0, 0.5548107472306294] \ No newline at end of file diff --git a/sample/CZ/__pycache__/concore.cpython-311.pyc b/sample/CZ/__pycache__/concore.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a191b6d28ab4ed248c038b96e9d2fe9e22430dd8 GIT binary patch literal 5655 zcmb^#TWk|o_TG7T#*RIHCvhOe#33O-62c={pird=$u4R`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!;*fBtECupP zVWiZt#|Z8*qybYJ_*U9?Pugcl2TbVzD5wAmdM#U+xhJ#}|272oq?PR}-7DSi?#>I< z#?)V)|I_oUL1XKHxpkn_F<=G;VMve)v8%r&3Dr;;yaHd6dWx?a(jG$`FvWqAI8Y9> z78VQYyNfG{Vo!0gsD8M(nz++*XYr2u_r=c=pLc)$sxkV4Ir@UpH*NM!8*L}ewv$HS zWa-5jBQOILs;kC|=Ya8s!zI_}-m<^5uyy5};qNv5y?OAyH0|r9GxC`gV57$ncbMXi zQvC-)Ct}AS5|2NB>iR3oujD4lL%KN*`@jj;fse-!85+QiurKE=um%d5C{#kB3Mb%j z1vNmxOPUSP?ZqRcX$RdL4iX9*fi?}s^S6Ct1MJ-aZfsb%djJ!7sQ0-j`XcInZjk+A uU+;JXeHn3&_px7&J~uEWps#ndOb(;3_hM2X_D!+uH<*X|H-dXA%>EYvrKDs4 literal 0 HcmV?d00001 diff --git a/sample/CZ/concore.iport b/sample/CZ/concore.iport new file mode 100644 index 0000000..dcee8c5 --- /dev/null +++ b/sample/CZ/concore.iport @@ -0,0 +1 @@ +{'PYM': 1} \ No newline at end of file diff --git a/sample/CZ/concore.oport b/sample/CZ/concore.oport new file mode 100644 index 0000000..f6d3892 --- /dev/null +++ b/sample/CZ/concore.oport @@ -0,0 +1 @@ +{'CU': 1} \ No newline at end of file diff --git a/sample/CZ/concore.py b/sample/CZ/concore.py new file mode 100644 index 0000000..9375b9c --- /dev/null +++ b/sample/CZ/concore.py @@ -0,0 +1,113 @@ +import time +import os +from ast import literal_eval +import sys +import re + +#if windows, create script to kill this process +# because batch files don't provide easy way to know pid of last command +# ignored for posix!=windows, because "concorepid" is handled by script +# ignored for docker (linux!=windows), because handled by docker stop +if hasattr(sys, 'getwindowsversion'): + with open("concorekill.bat","w") as fpid: + fpid.write("taskkill /F /PID "+str(os.getpid())+"\n") + +try: + iport = literal_eval(open("concore.iport").read()) +except: + iport = dict() +try: + oport = literal_eval(open("concore.oport").read()) +except: + oport = dict() + + +s = '' +olds = '' +delay = 1 +retrycount = 0 +inpath = "./in" #must be rel path for local +outpath = "./out" + +#9/21/22 +try: + sparams = open(inpath+"1/concore.params").read() + if sparams[0] == '"': #windows keeps "" need to remove + sparams = sparams[1:] + sparams = sparams[0:sparams.find('"')] + if sparams != '{': + print("converting sparams: "+sparams) + sparams = "{'"+re.sub(';',",'",re.sub('=',"':",re.sub(' ','',sparams)))+"}" + print("converted sparams: " + sparams) + try: + params = literal_eval(sparams) + except: + print("bad params: "+sparams) +except: + params = dict() +#9/30/22 +def tryparam(n,i): + try: + return params[n] + except: + return i + + +#9/12/21 +def default_maxtime(default): + global maxtime + try: + maxtime = literal_eval(open(inpath+"1/concore.maxtime").read()) + except: + maxtime = default +default_maxtime(100) + +def unchanged(): + global olds,s + if olds==s: + s = '' + return True + else: + olds = s + return False + +def read(port, name, initstr): + global s,simtime,retrycount + time.sleep(delay) + try: + infile = open(inpath+str(port)+"/"+name); + ins = infile.read() + except: + ins = initstr + while len(ins)==0: + time.sleep(delay) + ins = infile.read() + retrycount += 1 + s += ins + inval = literal_eval(ins) + simtime = max(simtime,inval[0]) + return inval[1:] + +def write(port, name, val, delta=0): + global outpath,simtime + if isinstance(val,str): + time.sleep(2*delay) + elif isinstance(val,list)==False: + print("mywrite must have list or str") + quit() + try: + with open(outpath+str(port)+"/"+name,"w") as outfile: + if isinstance(val,list): + outfile.write(str([simtime+delta]+val)) + simtime += delta + else: + outfile.write(val) + except: + print("skipping"+outpath+str(port)+"/"+name); + +def initval(simtime_val): + global simtime + val = literal_eval(simtime_val) + simtime = val[0] + return val[1:] + diff --git a/sample/CZ/controller.py b/sample/CZ/controller.py new file mode 100644 index 0000000..945748e --- /dev/null +++ b/sample/CZ/controller.py @@ -0,0 +1,32 @@ +import numpy as np +import concore + +ysp = 3.0 + +# controller function +def controller(ym): + if ym[0] < ysp: + return 1.01 * ym + else: + return 0.9 * ym + +# main +concore.default_maxtime(150) +concore.delay = 0.02 + +# initial values -- transforms to string including the simtime as the 0th entry in the list +init_simtime_u = "[0.0, 0.0]" +init_simtime_ym = "[0.0, 0.0]" + +u = np.array([concore.initval(init_simtime_u)]).T +while(concore.simtime iport; + map oport; + + //Constructor to put in iport and oport values in map + Concore(){ + iport = mapParser("concore.iport"); + oport = mapParser("concore.oport"); + } + + map mapParser(string filename){ + map ans; + + ifstream portfile; + string portstr; + portfile.open(filename); + if(portfile){ + ostringstream ss; + ss << portfile.rdbuf(); + portstr = ss.str(); + portfile.close(); + } + + portstr[portstr.size()-1]=','; + portstr+='}'; + int i=0; + string portname=""; + string portnum=""; + + while(portstr[i]!='}'){ + if(portstr[i]=='\''){ + i++; + while(portstr[i]!='\''){ + portname+=portstr[i]; + i++; + } + ans.insert({portname,0}); + } + + if(portstr[i]==':'){ + i++; + while(portstr[i]!=','){ + portnum+=portstr[i]; + i++; + } + ans[portname]=stoi(portnum); + portnum=""; + portname=""; + } + i++; + } + return ans; + } + + //function to compare and determine whether file content has been changed + bool unchanged(){ + if(olds.compare(s)==0){ + s = ""; + return true; + } + else{ + olds = s; + return false; + } + } + + vector parser(string f){ + vector temp; + string value = ""; + + //Changing last bracket to comma to use comma as a delimiter + f[f.length()-1]=','; + + for(int i=1;i read(int port, string name, string initstr){ + chrono::milliseconds timespan((int)(1000*delay)); + this_thread::sleep_for(timespan); + string ins; + try { + ifstream infile; + infile.open(inpath+to_string(port)+"/"+name, ios::in); + if(infile) { + ostringstream ss; + ss << infile.rdbuf(); // reading data + ins = ss.str(); //saving data as string + infile.close(); + } + else { + throw 505;} + } + catch (...) { + ins = initstr; + } + + while ((int)ins.length()==0){ + this_thread::sleep_for(timespan); + try{ + ifstream infile; + infile.open(inpath+to_string(port)+"/"+name, ios::in); + if(infile) { + ostringstream ss; + ss << infile.rdbuf(); // reading data + ins = ss.str(); + retrycount++; + infile.close(); + } + else{ + retrycount++; + throw 505; + } + } + //observed retry count in C++ from various tests is approx 80. + catch(...){ + cout<<"Read error"; + } + + + } + s += ins; + + + vector inval = parser(ins); + simtime = simtime > inval[0] ? simtime : inval[0]; + + //returning a string with data excluding simtime + inval.erase(inval.begin()); + return inval; + + } + + //write method, accepts a vector double and writes it to the file + void write(int port, string name, vector val, int delta=0){ + + try { + ofstream outfile; + outfile.open(outpath+to_string(port)+"/"+name, ios::out); + if(outfile){ + val.insert(val.begin(),simtime+delta); + outfile<<'['; + for(int i=0;i initval(string f){ + //parsing + vector val = parser(f); + + //determining simtime + simtime = val[0]; + + //returning the rest of the values(except simtime) in val + val.erase(val.begin()); + return val; + } + +}; diff --git a/sample/src/concore.py b/sample/src/concore.py new file mode 100644 index 0000000..9375b9c --- /dev/null +++ b/sample/src/concore.py @@ -0,0 +1,113 @@ +import time +import os +from ast import literal_eval +import sys +import re + +#if windows, create script to kill this process +# because batch files don't provide easy way to know pid of last command +# ignored for posix!=windows, because "concorepid" is handled by script +# ignored for docker (linux!=windows), because handled by docker stop +if hasattr(sys, 'getwindowsversion'): + with open("concorekill.bat","w") as fpid: + fpid.write("taskkill /F /PID "+str(os.getpid())+"\n") + +try: + iport = literal_eval(open("concore.iport").read()) +except: + iport = dict() +try: + oport = literal_eval(open("concore.oport").read()) +except: + oport = dict() + + +s = '' +olds = '' +delay = 1 +retrycount = 0 +inpath = "./in" #must be rel path for local +outpath = "./out" + +#9/21/22 +try: + sparams = open(inpath+"1/concore.params").read() + if sparams[0] == '"': #windows keeps "" need to remove + sparams = sparams[1:] + sparams = sparams[0:sparams.find('"')] + if sparams != '{': + print("converting sparams: "+sparams) + sparams = "{'"+re.sub(';',",'",re.sub('=',"':",re.sub(' ','',sparams)))+"}" + print("converted sparams: " + sparams) + try: + params = literal_eval(sparams) + except: + print("bad params: "+sparams) +except: + params = dict() +#9/30/22 +def tryparam(n,i): + try: + return params[n] + except: + return i + + +#9/12/21 +def default_maxtime(default): + global maxtime + try: + maxtime = literal_eval(open(inpath+"1/concore.maxtime").read()) + except: + maxtime = default +default_maxtime(100) + +def unchanged(): + global olds,s + if olds==s: + s = '' + return True + else: + olds = s + return False + +def read(port, name, initstr): + global s,simtime,retrycount + time.sleep(delay) + try: + infile = open(inpath+str(port)+"/"+name); + ins = infile.read() + except: + ins = initstr + while len(ins)==0: + time.sleep(delay) + ins = infile.read() + retrycount += 1 + s += ins + inval = literal_eval(ins) + simtime = max(simtime,inval[0]) + return inval[1:] + +def write(port, name, val, delta=0): + global outpath,simtime + if isinstance(val,str): + time.sleep(2*delay) + elif isinstance(val,list)==False: + print("mywrite must have list or str") + quit() + try: + with open(outpath+str(port)+"/"+name,"w") as outfile: + if isinstance(val,list): + outfile.write(str([simtime+delta]+val)) + simtime += delta + else: + outfile.write(val) + except: + print("skipping"+outpath+str(port)+"/"+name); + +def initval(simtime_val): + global simtime + val = literal_eval(simtime_val) + simtime = val[0] + return val[1:] + diff --git a/sample/src/concore.v b/sample/src/concore.v new file mode 100644 index 0000000..4c1ab08 --- /dev/null +++ b/sample/src/concore.v @@ -0,0 +1,351 @@ +`define CONCORE_MAXLEN 150 +`define INPATHLEN 6 //includes trailing portdigit and "/" +`define OUTPATHLEN 7 //modify these to match inpath and outpath +`define MAXFILES 9 +module concore; + integer datasize; + real data[9:0]; + integer filenum=-1; + reg[`CONCORE_MAXLEN*8-1:0] curs; + reg[`CONCORE_MAXLEN*8-1:0] s[`MAXFILES-1:0]; + reg[`CONCORE_MAXLEN*8-1:0] olds[`MAXFILES-1:0]; + integer lens[`MAXFILES-1:0]; + integer oldlens[`MAXFILES-1:0]; + reg[(`INPATHLEN-2)*8-1:0] inpath = "./in"; //omits trailing portdigit and "/" + reg[(`OUTPATHLEN-2)*8-1:0] outpath = "./out"; + real simtime; + integer retrycount = 0; + + integer fin,fout; + integer i; + real dummy; + + integer iii; + initial + begin + for(iii=0; iii<`MAXFILES; iii = iii+1) + begin + s[iii] = 0; + olds[iii] = 0; + lens[iii] = 0; + oldlens[iii] = 0; + end + end + + function [0:0] unchanged; + input [0:0] dummy_arg; + reg nochange; + begin + nochange = 1; + for (i=0; i<=filenum; i=i+1) + begin +//$display("1oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); + if (!((oldlens[i] == lens[i])&&(olds[i] == s[i]))) + nochange = 0; + end + if (nochange) + begin + for (i=0; i<=filenum; i=i+1) + s[i] = 0; + for (i=0; i<=filenum; i=i+1) + lens[i] = 0; + unchanged = 1; + filenum = -1; +//$display("unchanged"); + end + else + begin +// for (i=0; i<=filenum; i=i+1) +//$display("2oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); + for (i=0; i<=filenum; i=i+1) + olds[i] = s[i]; + for (i=0; i<=filenum; i=i+1) + oldlens[i] = lens[i]; + unchanged = 0; +//$display("changed"); + end +// for (i=0; i<=filenum; i=i+1) +//$display("3oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); +//$stop; +// filenum = -1; + end + endfunction + + function integer msbhelper; + input [`CONCORE_MAXLEN*8-1:0] s; + integer i,msb; + begin + //$display("help %s",s); + msb = 7; + for (i=8; i<`CONCORE_MAXLEN*8; i=i+1) + begin + if (s[i]) msb = i; + end + msbhelper = msb; + end + endfunction + + function integer lsbhelper; + input [`CONCORE_MAXLEN*8-1:0] s; + integer i,lsb; + begin + //$display("help %s",s); + lsb = 7; + for (i=`CONCORE_MAXLEN*8; i>=8; i=i-1) + begin + if (s[i]) lsb = i; + end + lsbhelper = lsb; + end + endfunction + + function [`CONCORE_MAXLEN*8-1:0] trim; + input [`CONCORE_MAXLEN*8-1:0] s; + integer msb; + begin + msb = msbhelper(s); + //$display("%s",s); + //$display(msb); + //$display(msb/8); + //$display(`CONCORE_MAXLEN - msb/8 -1); + trim = s << (8*(`CONCORE_MAXLEN - msb/8 -1)); + end + endfunction + + function integer len; + input [`CONCORE_MAXLEN*8-1:0] s; + integer msb; + begin + msb = msbhelper(s); + len = (msb/8)+1; + end + endfunction + + task readdata; //passed via global data and datasize (from literal_eval) + input integer port; + input [`CONCORE_MAXLEN*8-1:0] name; + input [`CONCORE_MAXLEN*8-1:0] initstr; + reg datavalid; + reg [(`CONCORE_MAXLEN+`INPATHLEN)*8-1:0] fname; //room for 6 extra chars + reg [7:0] asciiport; + integer i; + begin + filenum = filenum + 1; + if (filenum > `MAXFILES) + begin + $display("too many reads in loop"); + $finish; + end + s[filenum] = 0; + //olds[filenum] = 0; + lens[filenum] = 0; + //oldlens[filenum] = 0; + asciiport = "0"; + asciiport = asciiport + port; + fname = {inpath,asciiport,"/",trim(name)}; + datavalid = 0; + while(datavalid == 0) + begin + delayhelper; + //fin = $fopen(fname,"r"); + //fin = $fopen("./in1/ym","r"); + case (len(name)) + 1: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"r"); + 2: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"r"); + 3: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"r"); + 4: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"r"); + 5: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"r"); + 6: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"r"); + 7: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"r"); + 8: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"r"); + 9: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"r"); + 10: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"r"); + 11: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"r"); + 12: fin = $fopen( + fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"r"); + default: begin $display("filename too long:%s",name);$finish; end + endcase + datavalid = 0; + if (fin==0) + begin + lens[filenum] = 7;//actual len? + s[filenum] = trim(initstr); //"[0,0,0]"; + end + else + begin + lens[filenum] = $fgets(curs,fin); + s[filenum] = curs; + $fclose(fin); + end + //parse + literal_eval(datavalid,simtime); + if (datavalid == 0) + begin + retrycount = retrycount + 1; + end + //time + end //datavalid + end + endtask + + task write; //string argument only + input integer port; + input [`CONCORE_MAXLEN*8-1:0] name; + input [`CONCORE_MAXLEN*8-1:0] val; + reg [(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:0] fname; + reg [7:0] asciiport; + begin + asciiport = "0"; + asciiport = asciiport + port; + fname = {outpath,asciiport,"/",trim(name)}; + //$display("outfile=%s",fname); + delayhelper; + //fout = $fopen("./out1/u","w"); + //fout = $fopen(fname,"w"); + case (len(name)) + 1: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"w"); + 2: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"w"); + 3: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"w"); + 4: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"w"); + 5: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"w"); + 6: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"w"); + 7: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"w"); + 8: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"w"); + 9: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"w"); + 10: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"w"); + 11: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"w"); + 12: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"w"); + default: begin $display("filename too long:%s",name);$finish; end + endcase + $fdisplay(fout,"%s",trim(val)); + $fclose(fout); + end + endtask + + task writedata; //passed via global data and datasize + input integer port; + input [`CONCORE_MAXLEN*8-1:0] name; + input real delta; + reg [(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:0] fname; //room for 7 extra chars + reg [7:0] asciiport; + integer i; + real realdata; + begin + asciiport = "0"; + asciiport = asciiport + port; + fname = {outpath,asciiport,"/",trim(name)}; + //$display("outfile=%s",fname); + delayhelper; + //fout = $fopen("./out1/u","w"); + //fout = $fopen(fname,"w"); + case (len(name)) + 1: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"w"); + 2: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"w"); + 3: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"w"); + 4: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"w"); + 5: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"w"); + 6: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"w"); + 7: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"w"); + 8: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"w"); + 9: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"w"); + 10: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"w"); + 11: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"w"); + 12: fout = $fopen( + fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"w"); + default: begin $display("filename too long:%s",name);$finish; end + endcase + $fwrite(fout,"[%g",simtime+delta); + for (i=0; i + + + + + + + + + + + CZ:controller.py + + + + + + + + + + + PZ:pm.py + + + + + + + + + + CU + + + + + + + + + + + + PYM + + + + + + + + 1638390071794 + Pradeeban + + DEL_NODE + WyIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiXQ== + + + ADD_NODE + WyJDWjpjb250cm9sbGVyLnB5Iix7IndpZHRoIjoxMzIsImhlaWdodCI6NTAsInNoYXBlIjoicmVjdGFuZ2xlIiwib3BhY2l0eSI6MSwiYmFja2dyb3VuZENvbG9yIjoiI2ZmY2MwMCIsImJvcmRlckNvbG9yIjoiIzAwMCIsImJvcmRlcldpZHRoIjoxfSwib3JkaW4iLHsieCI6MTAwLCJ5IjoxMDB9LHt9LCIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiXQ== + + + + 1638390078744 + Pradeeban + + DEL_NODE + WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiXQ== + + + ADD_NODE + WyJQWjpwbS5weSIseyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjUwLCJzaGFwZSI6InJlY3RhbmdsZSIsIm9wYWNpdHkiOjEsImJhY2tncm91bmRDb2xvciI6IiNmZmNjMDAiLCJib3JkZXJDb2xvciI6IiMwMDAiLCJib3JkZXJXaWR0aCI6MX0sIm9yZGluIix7IngiOjk5LCJ5IjoyNjJ9LHt9LCI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiXQ== + + + + 1638390083602 + Pradeeban + + SET_POS + WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiLHsieCI6MTEwLCJ5IjoxMTB9LHsieCI6OTksInkiOjI2Mn1d + + + SET_POS + WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiLHsieCI6OTksInkiOjI2Mn0seyJ4IjoxMTAsInkiOjExMH1d + + + + 1638390087263 + Pradeeban + + DEL_EDGE + WyI0ZTY3NzY3Ny1jYmI5LTRlMGUtOGUwYS0zNDUxMDJkODIzYWYiXQ== + + + ADD_EDGE + W3sic291cmNlSUQiOiIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiLCJ0YXJnZXRJRCI6IjljNWUxNGM4LTFmNWMtNDIwZS1hNzJkLTQ2YjJlZmEyNDRhNiIsImxhYmVsIjoiQyIsInN0eWxlIjp7InRoaWNrbmVzcyI6MSwiYmFja2dyb3VuZENvbG9yIjoiI2Y0NDMzNiIsInNoYXBlIjoic29saWQifSwiaWQiOiI0ZTY3NzY3Ny1jYmI5LTRlMGUtOGUwYS0zNDUxMDJkODIzYWYifV0= + + + + 1638390162285 + Pradeeban + + DEL_EDGE + WyI4NzRiYmZiNi02NTM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WVd + + + + \ No newline at end of file From 74f9640d12995765c2ecf853c0091e5df7d6f64d Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 22 Feb 2023 03:51:09 +0530 Subject: [PATCH 3/3] unnecessary files removed --- fri/u | 1 - sample/CZ/__pycache__/concore.cpython-311.pyc | Bin 5655 -> 0 bytes sample/CZ/concore.iport | 1 - sample/CZ/concore.oport | 1 - sample/CZ/concore.py | 113 ------ sample/CZ/controller.py | 32 -- sample/PZ/__pycache__/concore.cpython-311.pyc | Bin 5655 -> 0 bytes sample/PZ/concore.iport | 1 - sample/PZ/concore.oport | 1 - sample/PZ/concore.py | 113 ------ sample/PZ/pm.py | 27 -- sample/build.bat | 24 -- sample/clear.bat | 2 - sample/debug.bat | 2 - sample/maxtime.bat | 2 - sample/params.bat | 2 - sample/run.bat | 2 - sample/src/concore.hpp | 228 ------------ sample/src/concore.py | 113 ------ sample/src/concore.v | 351 ------------------ sample/src/concore_default_maxtime.m | 12 - sample/src/concore_initval.m | 6 - sample/src/concore_iport.m | 17 - sample/src/concore_oport.m | 17 - sample/src/concore_read.m | 22 -- sample/src/concore_unchanged.m | 16 - sample/src/concore_write.m | 11 - sample/src/controller.iport | 1 - sample/src/controller.oport | 1 - sample/src/controller.py | 32 -- sample/src/import_concore.m | 42 --- sample/src/mkcompile | 7 - sample/src/pm.iport | 1 - sample/src/pm.oport | 1 - sample/src/pm.py | 27 -- sample/stop.bat | 4 - sample/unlock.bat | 2 - test_xyz/controller.py | 32 -- test_xyz/pm.py | 27 -- test_xyz/sample.graphml | 137 ------- 40 files changed, 1431 deletions(-) delete mode 100644 fri/u delete mode 100644 sample/CZ/__pycache__/concore.cpython-311.pyc delete mode 100644 sample/CZ/concore.iport delete mode 100644 sample/CZ/concore.oport delete mode 100644 sample/CZ/concore.py delete mode 100644 sample/CZ/controller.py delete mode 100644 sample/PZ/__pycache__/concore.cpython-311.pyc delete mode 100644 sample/PZ/concore.iport delete mode 100644 sample/PZ/concore.oport delete mode 100644 sample/PZ/concore.py delete mode 100644 sample/PZ/pm.py delete mode 100644 sample/build.bat delete mode 100644 sample/clear.bat delete mode 100644 sample/debug.bat delete mode 100644 sample/maxtime.bat delete mode 100644 sample/params.bat delete mode 100644 sample/run.bat delete mode 100644 sample/src/concore.hpp delete mode 100644 sample/src/concore.py delete mode 100644 sample/src/concore.v delete mode 100644 sample/src/concore_default_maxtime.m delete mode 100644 sample/src/concore_initval.m delete mode 100644 sample/src/concore_iport.m delete mode 100644 sample/src/concore_oport.m delete mode 100644 sample/src/concore_read.m delete mode 100644 sample/src/concore_unchanged.m delete mode 100644 sample/src/concore_write.m delete mode 100644 sample/src/controller.iport delete mode 100644 sample/src/controller.oport delete mode 100644 sample/src/controller.py delete mode 100644 sample/src/import_concore.m delete mode 100644 sample/src/mkcompile delete mode 100644 sample/src/pm.iport delete mode 100644 sample/src/pm.oport delete mode 100644 sample/src/pm.py delete mode 100644 sample/stop.bat delete mode 100644 sample/unlock.bat delete mode 100644 test_xyz/controller.py delete mode 100644 test_xyz/pm.py delete mode 100644 test_xyz/sample.graphml diff --git a/fri/u b/fri/u deleted file mode 100644 index d7c144c..0000000 --- a/fri/u +++ /dev/null @@ -1 +0,0 @@ -[44.0, 0.5548107472306294] \ No newline at end of file diff --git a/sample/CZ/__pycache__/concore.cpython-311.pyc b/sample/CZ/__pycache__/concore.cpython-311.pyc deleted file mode 100644 index a191b6d28ab4ed248c038b96e9d2fe9e22430dd8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5655 zcmb^#TWk|o_TG7T#*RIHCvhOe#33O-62c={pird=$u4R`tI$?>k*cZ3fWdLHGm}u< zu<{~SGF7U2S4E_|Me9l}o2r$TkNv3jtF%@7>p>&c8Y$Y9R{h}56|IEOe(br|kBk$j zsCMso&fLej_ndp~d0qe2<8dJ<2gZL)q*@UAH)+(1RI5Cwun65m3Q}+y#j9T&$Ixcd z%q$ycakY<&a}J4-oLkr$&$-+kw2yE^L9x-{EDPxpriJ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M!8*L}ewv$HS zWa-5jBQOILs;kC|=Ya8s!zI_}-m<^5uyy5};qNv5y?OAyH0|r9GxC`gV57$ncbMXi zQvC-)Ct}AS5|2NB>iR3oujD4lL%KN*`@jj;fse-!85+QiurKE=um%d5C{#kB3Mb%j z1vNmxOPUSP?ZqRcX$RdL4iX9*fi?}s^S6Ct1MJ-aZfsb%djJ!7sQ0-j`XcInZjk+A uU+;JXeHn3&_px7&J~uEWps#ndOb(;3_hM2X_D!+uH<*X|H-dXA%>EYvrKDs4 diff --git a/sample/CZ/concore.iport b/sample/CZ/concore.iport deleted file mode 100644 index dcee8c5..0000000 --- a/sample/CZ/concore.iport +++ /dev/null @@ -1 +0,0 @@ -{'PYM': 1} \ No newline at end of file diff --git a/sample/CZ/concore.oport b/sample/CZ/concore.oport deleted file mode 100644 index f6d3892..0000000 --- a/sample/CZ/concore.oport +++ /dev/null @@ -1 +0,0 @@ -{'CU': 1} \ No newline at end of file diff --git a/sample/CZ/concore.py b/sample/CZ/concore.py deleted file mode 100644 index 9375b9c..0000000 --- a/sample/CZ/concore.py +++ /dev/null @@ -1,113 +0,0 @@ -import time -import os -from ast import literal_eval -import sys -import re - -#if windows, create script to kill this process -# because batch files don't provide easy way to know pid of last command -# ignored for posix!=windows, because "concorepid" is handled by script -# ignored for docker (linux!=windows), because handled by docker stop -if hasattr(sys, 'getwindowsversion'): - with open("concorekill.bat","w") as fpid: - fpid.write("taskkill /F /PID "+str(os.getpid())+"\n") - -try: - iport = literal_eval(open("concore.iport").read()) -except: - iport = dict() -try: - oport = literal_eval(open("concore.oport").read()) -except: - oport = dict() - - -s = '' -olds = '' -delay = 1 -retrycount = 0 -inpath = "./in" #must be rel path for local -outpath = "./out" - -#9/21/22 -try: - sparams = open(inpath+"1/concore.params").read() - if sparams[0] == '"': #windows keeps "" need to remove - sparams = sparams[1:] - sparams = sparams[0:sparams.find('"')] - if sparams != '{': - print("converting sparams: "+sparams) - sparams = "{'"+re.sub(';',",'",re.sub('=',"':",re.sub(' ','',sparams)))+"}" - print("converted sparams: " + sparams) - try: - params = literal_eval(sparams) - except: - print("bad params: "+sparams) -except: - params = dict() -#9/30/22 -def tryparam(n,i): - try: - return params[n] - except: - return i - - -#9/12/21 -def default_maxtime(default): - global maxtime - try: - maxtime = literal_eval(open(inpath+"1/concore.maxtime").read()) - except: - maxtime = default -default_maxtime(100) - -def unchanged(): - global olds,s - if olds==s: - s = '' - return True - else: - olds = s - return False - -def read(port, name, initstr): - global s,simtime,retrycount - time.sleep(delay) - try: - infile = open(inpath+str(port)+"/"+name); - ins = infile.read() - except: - ins = initstr - while len(ins)==0: - time.sleep(delay) - ins = infile.read() - retrycount += 1 - s += ins - inval = literal_eval(ins) - simtime = max(simtime,inval[0]) - return inval[1:] - -def write(port, name, val, delta=0): - global outpath,simtime - if isinstance(val,str): - time.sleep(2*delay) - elif isinstance(val,list)==False: - print("mywrite must have list or str") - quit() - try: - with open(outpath+str(port)+"/"+name,"w") as outfile: - if isinstance(val,list): - outfile.write(str([simtime+delta]+val)) - simtime += delta - else: - outfile.write(val) - except: - print("skipping"+outpath+str(port)+"/"+name); - -def initval(simtime_val): - global simtime - val = literal_eval(simtime_val) - simtime = val[0] - return val[1:] - diff --git a/sample/CZ/controller.py b/sample/CZ/controller.py deleted file mode 100644 index 945748e..0000000 --- a/sample/CZ/controller.py +++ /dev/null @@ -1,32 +0,0 @@ -import numpy as np -import concore - -ysp = 3.0 - -# controller function -def controller(ym): - if ym[0] < ysp: - return 1.01 * ym - else: - return 0.9 * ym - -# main -concore.default_maxtime(150) -concore.delay = 0.02 - -# initial values -- transforms to string including the simtime as the 0th entry in the list -init_simtime_u = "[0.0, 0.0]" -init_simtime_ym = "[0.0, 0.0]" - -u = np.array([concore.initval(init_simtime_u)]).T -while(concore.simtime iport; - map oport; - - //Constructor to put in iport and oport values in map - Concore(){ - iport = mapParser("concore.iport"); - oport = mapParser("concore.oport"); - } - - map mapParser(string filename){ - map ans; - - ifstream portfile; - string portstr; - portfile.open(filename); - if(portfile){ - ostringstream ss; - ss << portfile.rdbuf(); - portstr = ss.str(); - portfile.close(); - } - - portstr[portstr.size()-1]=','; - portstr+='}'; - int i=0; - string portname=""; - string portnum=""; - - while(portstr[i]!='}'){ - if(portstr[i]=='\''){ - i++; - while(portstr[i]!='\''){ - portname+=portstr[i]; - i++; - } - ans.insert({portname,0}); - } - - if(portstr[i]==':'){ - i++; - while(portstr[i]!=','){ - portnum+=portstr[i]; - i++; - } - ans[portname]=stoi(portnum); - portnum=""; - portname=""; - } - i++; - } - return ans; - } - - //function to compare and determine whether file content has been changed - bool unchanged(){ - if(olds.compare(s)==0){ - s = ""; - return true; - } - else{ - olds = s; - return false; - } - } - - vector parser(string f){ - vector temp; - string value = ""; - - //Changing last bracket to comma to use comma as a delimiter - f[f.length()-1]=','; - - for(int i=1;i read(int port, string name, string initstr){ - chrono::milliseconds timespan((int)(1000*delay)); - this_thread::sleep_for(timespan); - string ins; - try { - ifstream infile; - infile.open(inpath+to_string(port)+"/"+name, ios::in); - if(infile) { - ostringstream ss; - ss << infile.rdbuf(); // reading data - ins = ss.str(); //saving data as string - infile.close(); - } - else { - throw 505;} - } - catch (...) { - ins = initstr; - } - - while ((int)ins.length()==0){ - this_thread::sleep_for(timespan); - try{ - ifstream infile; - infile.open(inpath+to_string(port)+"/"+name, ios::in); - if(infile) { - ostringstream ss; - ss << infile.rdbuf(); // reading data - ins = ss.str(); - retrycount++; - infile.close(); - } - else{ - retrycount++; - throw 505; - } - } - //observed retry count in C++ from various tests is approx 80. - catch(...){ - cout<<"Read error"; - } - - - } - s += ins; - - - vector inval = parser(ins); - simtime = simtime > inval[0] ? simtime : inval[0]; - - //returning a string with data excluding simtime - inval.erase(inval.begin()); - return inval; - - } - - //write method, accepts a vector double and writes it to the file - void write(int port, string name, vector val, int delta=0){ - - try { - ofstream outfile; - outfile.open(outpath+to_string(port)+"/"+name, ios::out); - if(outfile){ - val.insert(val.begin(),simtime+delta); - outfile<<'['; - for(int i=0;i initval(string f){ - //parsing - vector val = parser(f); - - //determining simtime - simtime = val[0]; - - //returning the rest of the values(except simtime) in val - val.erase(val.begin()); - return val; - } - -}; diff --git a/sample/src/concore.py b/sample/src/concore.py deleted file mode 100644 index 9375b9c..0000000 --- a/sample/src/concore.py +++ /dev/null @@ -1,113 +0,0 @@ -import time -import os -from ast import literal_eval -import sys -import re - -#if windows, create script to kill this process -# because batch files don't provide easy way to know pid of last command -# ignored for posix!=windows, because "concorepid" is handled by script -# ignored for docker (linux!=windows), because handled by docker stop -if hasattr(sys, 'getwindowsversion'): - with open("concorekill.bat","w") as fpid: - fpid.write("taskkill /F /PID "+str(os.getpid())+"\n") - -try: - iport = literal_eval(open("concore.iport").read()) -except: - iport = dict() -try: - oport = literal_eval(open("concore.oport").read()) -except: - oport = dict() - - -s = '' -olds = '' -delay = 1 -retrycount = 0 -inpath = "./in" #must be rel path for local -outpath = "./out" - -#9/21/22 -try: - sparams = open(inpath+"1/concore.params").read() - if sparams[0] == '"': #windows keeps "" need to remove - sparams = sparams[1:] - sparams = sparams[0:sparams.find('"')] - if sparams != '{': - print("converting sparams: "+sparams) - sparams = "{'"+re.sub(';',",'",re.sub('=',"':",re.sub(' ','',sparams)))+"}" - print("converted sparams: " + sparams) - try: - params = literal_eval(sparams) - except: - print("bad params: "+sparams) -except: - params = dict() -#9/30/22 -def tryparam(n,i): - try: - return params[n] - except: - return i - - -#9/12/21 -def default_maxtime(default): - global maxtime - try: - maxtime = literal_eval(open(inpath+"1/concore.maxtime").read()) - except: - maxtime = default -default_maxtime(100) - -def unchanged(): - global olds,s - if olds==s: - s = '' - return True - else: - olds = s - return False - -def read(port, name, initstr): - global s,simtime,retrycount - time.sleep(delay) - try: - infile = open(inpath+str(port)+"/"+name); - ins = infile.read() - except: - ins = initstr - while len(ins)==0: - time.sleep(delay) - ins = infile.read() - retrycount += 1 - s += ins - inval = literal_eval(ins) - simtime = max(simtime,inval[0]) - return inval[1:] - -def write(port, name, val, delta=0): - global outpath,simtime - if isinstance(val,str): - time.sleep(2*delay) - elif isinstance(val,list)==False: - print("mywrite must have list or str") - quit() - try: - with open(outpath+str(port)+"/"+name,"w") as outfile: - if isinstance(val,list): - outfile.write(str([simtime+delta]+val)) - simtime += delta - else: - outfile.write(val) - except: - print("skipping"+outpath+str(port)+"/"+name); - -def initval(simtime_val): - global simtime - val = literal_eval(simtime_val) - simtime = val[0] - return val[1:] - diff --git a/sample/src/concore.v b/sample/src/concore.v deleted file mode 100644 index 4c1ab08..0000000 --- a/sample/src/concore.v +++ /dev/null @@ -1,351 +0,0 @@ -`define CONCORE_MAXLEN 150 -`define INPATHLEN 6 //includes trailing portdigit and "/" -`define OUTPATHLEN 7 //modify these to match inpath and outpath -`define MAXFILES 9 -module concore; - integer datasize; - real data[9:0]; - integer filenum=-1; - reg[`CONCORE_MAXLEN*8-1:0] curs; - reg[`CONCORE_MAXLEN*8-1:0] s[`MAXFILES-1:0]; - reg[`CONCORE_MAXLEN*8-1:0] olds[`MAXFILES-1:0]; - integer lens[`MAXFILES-1:0]; - integer oldlens[`MAXFILES-1:0]; - reg[(`INPATHLEN-2)*8-1:0] inpath = "./in"; //omits trailing portdigit and "/" - reg[(`OUTPATHLEN-2)*8-1:0] outpath = "./out"; - real simtime; - integer retrycount = 0; - - integer fin,fout; - integer i; - real dummy; - - integer iii; - initial - begin - for(iii=0; iii<`MAXFILES; iii = iii+1) - begin - s[iii] = 0; - olds[iii] = 0; - lens[iii] = 0; - oldlens[iii] = 0; - end - end - - function [0:0] unchanged; - input [0:0] dummy_arg; - reg nochange; - begin - nochange = 1; - for (i=0; i<=filenum; i=i+1) - begin -//$display("1oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); - if (!((oldlens[i] == lens[i])&&(olds[i] == s[i]))) - nochange = 0; - end - if (nochange) - begin - for (i=0; i<=filenum; i=i+1) - s[i] = 0; - for (i=0; i<=filenum; i=i+1) - lens[i] = 0; - unchanged = 1; - filenum = -1; -//$display("unchanged"); - end - else - begin -// for (i=0; i<=filenum; i=i+1) -//$display("2oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); - for (i=0; i<=filenum; i=i+1) - olds[i] = s[i]; - for (i=0; i<=filenum; i=i+1) - oldlens[i] = lens[i]; - unchanged = 0; -//$display("changed"); - end -// for (i=0; i<=filenum; i=i+1) -//$display("3oldl=%d l=%d olds=%s s=%s",oldlens[i],lens[i],olds[i],s[i]); -//$stop; -// filenum = -1; - end - endfunction - - function integer msbhelper; - input [`CONCORE_MAXLEN*8-1:0] s; - integer i,msb; - begin - //$display("help %s",s); - msb = 7; - for (i=8; i<`CONCORE_MAXLEN*8; i=i+1) - begin - if (s[i]) msb = i; - end - msbhelper = msb; - end - endfunction - - function integer lsbhelper; - input [`CONCORE_MAXLEN*8-1:0] s; - integer i,lsb; - begin - //$display("help %s",s); - lsb = 7; - for (i=`CONCORE_MAXLEN*8; i>=8; i=i-1) - begin - if (s[i]) lsb = i; - end - lsbhelper = lsb; - end - endfunction - - function [`CONCORE_MAXLEN*8-1:0] trim; - input [`CONCORE_MAXLEN*8-1:0] s; - integer msb; - begin - msb = msbhelper(s); - //$display("%s",s); - //$display(msb); - //$display(msb/8); - //$display(`CONCORE_MAXLEN - msb/8 -1); - trim = s << (8*(`CONCORE_MAXLEN - msb/8 -1)); - end - endfunction - - function integer len; - input [`CONCORE_MAXLEN*8-1:0] s; - integer msb; - begin - msb = msbhelper(s); - len = (msb/8)+1; - end - endfunction - - task readdata; //passed via global data and datasize (from literal_eval) - input integer port; - input [`CONCORE_MAXLEN*8-1:0] name; - input [`CONCORE_MAXLEN*8-1:0] initstr; - reg datavalid; - reg [(`CONCORE_MAXLEN+`INPATHLEN)*8-1:0] fname; //room for 6 extra chars - reg [7:0] asciiport; - integer i; - begin - filenum = filenum + 1; - if (filenum > `MAXFILES) - begin - $display("too many reads in loop"); - $finish; - end - s[filenum] = 0; - //olds[filenum] = 0; - lens[filenum] = 0; - //oldlens[filenum] = 0; - asciiport = "0"; - asciiport = asciiport + port; - fname = {inpath,asciiport,"/",trim(name)}; - datavalid = 0; - while(datavalid == 0) - begin - delayhelper; - //fin = $fopen(fname,"r"); - //fin = $fopen("./in1/ym","r"); - case (len(name)) - 1: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"r"); - 2: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"r"); - 3: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"r"); - 4: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"r"); - 5: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"r"); - 6: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"r"); - 7: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"r"); - 8: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"r"); - 9: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"r"); - 10: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"r"); - 11: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"r"); - 12: fin = $fopen( - fname[(`CONCORE_MAXLEN+`INPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"r"); - default: begin $display("filename too long:%s",name);$finish; end - endcase - datavalid = 0; - if (fin==0) - begin - lens[filenum] = 7;//actual len? - s[filenum] = trim(initstr); //"[0,0,0]"; - end - else - begin - lens[filenum] = $fgets(curs,fin); - s[filenum] = curs; - $fclose(fin); - end - //parse - literal_eval(datavalid,simtime); - if (datavalid == 0) - begin - retrycount = retrycount + 1; - end - //time - end //datavalid - end - endtask - - task write; //string argument only - input integer port; - input [`CONCORE_MAXLEN*8-1:0] name; - input [`CONCORE_MAXLEN*8-1:0] val; - reg [(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:0] fname; - reg [7:0] asciiport; - begin - asciiport = "0"; - asciiport = asciiport + port; - fname = {outpath,asciiport,"/",trim(name)}; - //$display("outfile=%s",fname); - delayhelper; - //fout = $fopen("./out1/u","w"); - //fout = $fopen(fname,"w"); - case (len(name)) - 1: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"w"); - 2: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"w"); - 3: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"w"); - 4: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"w"); - 5: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"w"); - 6: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"w"); - 7: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"w"); - 8: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"w"); - 9: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"w"); - 10: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"w"); - 11: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"w"); - 12: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"w"); - default: begin $display("filename too long:%s",name);$finish; end - endcase - $fdisplay(fout,"%s",trim(val)); - $fclose(fout); - end - endtask - - task writedata; //passed via global data and datasize - input integer port; - input [`CONCORE_MAXLEN*8-1:0] name; - input real delta; - reg [(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:0] fname; //room for 7 extra chars - reg [7:0] asciiport; - integer i; - real realdata; - begin - asciiport = "0"; - asciiport = asciiport + port; - fname = {outpath,asciiport,"/",trim(name)}; - //$display("outfile=%s",fname); - delayhelper; - //fout = $fopen("./out1/u","w"); - //fout = $fopen(fname,"w"); - case (len(name)) - 1: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-1)*8],"w"); - 2: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-2)*8],"w"); - 3: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-3)*8],"w"); - 4: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-4)*8],"w"); - 5: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-5)*8],"w"); - 6: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-6)*8],"w"); - 7: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-7)*8],"w"); - 8: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-8)*8],"w"); - 9: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-9)*8],"w"); - 10: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-10)*8],"w"); - 11: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-11)*8],"w"); - 12: fout = $fopen( - fname[(`CONCORE_MAXLEN+`OUTPATHLEN)*8-1:(`CONCORE_MAXLEN-12)*8],"w"); - default: begin $display("filename too long:%s",name);$finish; end - endcase - $fwrite(fout,"[%g",simtime+delta); - for (i=0; i - - - - - - - - - - - CZ:controller.py - - - - - - - - - - - PZ:pm.py - - - - - - - - - - CU - - - - - - - - - - - - PYM - - - - - - - - 1638390071794 - Pradeeban - - DEL_NODE - WyIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiXQ== - - - ADD_NODE - WyJDWjpjb250cm9sbGVyLnB5Iix7IndpZHRoIjoxMzIsImhlaWdodCI6NTAsInNoYXBlIjoicmVjdGFuZ2xlIiwib3BhY2l0eSI6MSwiYmFja2dyb3VuZENvbG9yIjoiI2ZmY2MwMCIsImJvcmRlckNvbG9yIjoiIzAwMCIsImJvcmRlcldpZHRoIjoxfSwib3JkaW4iLHsieCI6MTAwLCJ5IjoxMDB9LHt9LCIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiXQ== - - - - 1638390078744 - Pradeeban - - DEL_NODE - WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiXQ== - - - ADD_NODE - WyJQWjpwbS5weSIseyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjUwLCJzaGFwZSI6InJlY3RhbmdsZSIsIm9wYWNpdHkiOjEsImJhY2tncm91bmRDb2xvciI6IiNmZmNjMDAiLCJib3JkZXJDb2xvciI6IiMwMDAiLCJib3JkZXJXaWR0aCI6MX0sIm9yZGluIix7IngiOjk5LCJ5IjoyNjJ9LHt9LCI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiXQ== - - - - 1638390083602 - Pradeeban - - SET_POS - WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiLHsieCI6MTEwLCJ5IjoxMTB9LHsieCI6OTksInkiOjI2Mn1d - - - SET_POS - WyI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiLHsieCI6OTksInkiOjI2Mn0seyJ4IjoxMTAsInkiOjExMH1d - - - - 1638390087263 - Pradeeban - - DEL_EDGE - WyI0ZTY3NzY3Ny1jYmI5LTRlMGUtOGUwYS0zNDUxMDJkODIzYWYiXQ== - - - ADD_EDGE - W3sic291cmNlSUQiOiIyM2ZlODE5Yi1hMTZjLTQzY2ItOWQ5NC1mM2I1M2QwNjk4NWYiLCJ0YXJnZXRJRCI6IjljNWUxNGM4LTFmNWMtNDIwZS1hNzJkLTQ2YjJlZmEyNDRhNiIsImxhYmVsIjoiQyIsInN0eWxlIjp7InRoaWNrbmVzcyI6MSwiYmFja2dyb3VuZENvbG9yIjoiI2Y0NDMzNiIsInNoYXBlIjoic29saWQifSwiaWQiOiI0ZTY3NzY3Ny1jYmI5LTRlMGUtOGUwYS0zNDUxMDJkODIzYWYifV0= - - - - 1638390162285 - Pradeeban - - DEL_EDGE - WyI4NzRiYmZiNi02NTMwLTQxMzgtOTI4Zi1kMDI5NDEyZGQwN2UiXQ== - - - ADD_EDGE - W3sic291cmNlSUQiOiI5YzVlMTRjOC0xZjVjLTQyMGUtYTcyZC00NmIyZWZhMjQ0YTYiLCJ0YXJnZXRJRCI6IjIzZmU4MTliLWExNmMtNDNjYi05ZDk0LWYzYjUzZDA2OTg1ZiIsImxhYmVsIjoiUCI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