Skip to content

Commit

Permalink
Added django-mongo integration dependencies, minor config changes (#14)
Browse files Browse the repository at this point in the history
* Add simulationAPI app boilerplate

* add parser to parse data from output of ngspice and return data as json

* modify parser to take filepath as commandline argument

* Merge Develop branch changes (#11)

* EDA React application starter pack

* Hotfix: Docker command

* Included Arduino Frontend

* Configured For github actions

* Optimize build caching , add mysql , celery deps

* Configure Containers

* Add dev environment documentation

* Added docker config for eda-frontend

* Added Layout and Grid for simulator interface

* Added docker config for eda-frontend

* Docker config for angular-frontend

Co-authored-by: dssudake <darshansudake555@gmail.com>
Co-authored-by: Navonil Das <navneeladas@gmail.com>
Co-authored-by: Meet10 <61341284+meet-10@users.noreply.github.com>
Co-authored-by: felixfaisal <faisalahmedfarooq46@gmail.com>

* Revert "Merge Develop branch changes (#11)"

This reverts commit 719ec10.

* Added django-mongo integration dependencies and config

* Remove redundant env variables

* removed main

* add general parser but requirerefactoring

* add parser to parse output generated by ngspice for any type of analysis. needs refactoring!
  • Loading branch information
darshkpatel authored Apr 27, 2020
1 parent 8f5ae81 commit 782fb73
Show file tree
Hide file tree
Showing 15 changed files with 476 additions and 12 deletions.
5 changes: 1 addition & 4 deletions .env.public
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ MYSQL_DATABASE=esimcloud_db
MYSQL_USER=user
MYSQL_PASSWORD=password

SQL_DATABASE=esimcloud_db
SQL_USER=user
SQL_PASSWORD=password

MONGO_INITDB_ROOT_USERNAME=user
MONGO_INITDB_ROOT_PASSWORD=password
MONGO_INITDB_DATABASE=esimcloud_db
3 changes: 3 additions & 0 deletions esim-cloud-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.sqlite3
__pycache__
venv/
19 changes: 15 additions & 4 deletions esim-cloud-backend/esimCloud/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = bool(os.environ.get("DJANGO_DEBUG", default=True))

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['0.0.0.0']


# Application definition
Expand Down Expand Up @@ -77,11 +77,22 @@
DATABASES = {
"default": {
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
"NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
"USER": os.environ.get("SQL_USER", "user"),
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
"NAME": os.environ.get("MYSQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
"USER": os.environ.get("MYSQL_USER", "user"),
"PASSWORD": os.environ.get("MYSQL_PASSWORD", "password"),
"HOST": os.environ.get("SQL_HOST", "localhost"),
"PORT": os.environ.get("SQL_PORT", "5432"),
},
"mongodb":{
"ENGINE": 'djongo',
"NAME": os.environ.get("MONGO_INITDB_DATABASE", "esimcloud_db"),
"USER": os.environ.get("MONGO_INITDB_ROOT_USERNAME", "user"),
"PASSWORD": os.environ.get("MONGO_INITDB_ROOT_PASSWORD", "password"),
"HOST": "mongodb",
"PORT": 27017,
'AUTH_SOURCE': 'admin',
'AUTH_MECHANISM': 'SCRAM-SHA-1',

}
}

Expand Down
12 changes: 8 additions & 4 deletions esim-cloud-backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
amqp==2.5.2
asgiref==3.2.7
billiard==3.6.3.0
bson==0.5.8
celery==4.4.2
configparse==0.1.5
configparser==5.0.0
Django==3.0.5
dataclasses==0.6
Django==2.2.12
django-cors-headers==3.2.1
django-mysql==3.4.0
djangorestframework==3.11.0
djongo==1.3.2
gunicorn==20.0.4
kombu==4.6.8
mysqlclient==1.4.6
pymongo==3.10.1
python-dateutil==2.8.1
pytz==2019.3
redis==3.4.1
sqlparse==0.3.1
six==1.14.0
sqlparse==0.2.4
vine==1.3.0
whitenoise==5.0.1
Empty file.
3 changes: 3 additions & 0 deletions esim-cloud-backend/simulationAPI/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions esim-cloud-backend/simulationAPI/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class SimulationapiConfig(AppConfig):
name = 'simulationAPI'
67 changes: 67 additions & 0 deletions esim-cloud-backend/simulationAPI/helpers/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import re
import json
import sys


def extract_data_from_ngspice_output(pathToFile):

""" Parses the output file generated by ngspice and
returns a json containing points to plot graph.
"""

try:
with open(pathToFile,'r') as f:
f_contents = f.readlines()
json_data = {"total_number_of_tables":0,"data":[]}
curernt_headers = []
total_number_of_tables = 0

for line in f_contents:
contents_of_line = line.split()

if('Index' in contents_of_line):
line_set = remove_duplicate_items_from_list(contents_of_line)

if(line_set != curernt_headers):
curernt_headers = line_set
json_data["data"].append({"labels":[],"x":[],"y":[]})
index = len(json_data["data"]) - 1
for x in range(2,len(curernt_headers)):
json_data["data"][index]["y"].append([])

for x in range(1,len(curernt_headers)):
json_data["data"][index]["labels"].append(curernt_headers[x])
total_number_of_tables += 1

else:
m = re.match('[0-9]+',line)
if(m):
d = (contents_of_line)
index = len(json_data["data"]) - 1
data = json_data["data"][index]
data["x"].append(contents_of_line[1])

for x in range(len(data["y"])):
data["y"][x].append(contents_of_line[x+2])


json_data["total_number_of_tables"] = total_number_of_tables - len(json_data["data"])
return json.dumps(json_data)

except IOError as e:
return "Cannot open file."


def remove_duplicate_items_from_list(line_list):
res = []
for i in line_list:
if i not in res:
res.append(i)
return res


#for testing provide the filepath as command line argument
if __name__ == "__main__":

filePath = sys.argv[1]
print(extract_data_from_ngspice_output(filePath))
155 changes: 155 additions & 0 deletions esim-cloud-backend/simulationAPI/helpers/sample_files/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

Transient Analysis Sun Apr 26 18:25:24 2020
--------------------------------------------------------------------------------
Index time in out time
--------------------------------------------------------------------------------
0 0.000000e+00 0.000000e+00 -1.21023e-22 0.000000e+00
1 1.000000e-05 1.570794e-02 1.570075e-02 1.000000e-05
2 2.000000e-05 3.141572e-02 3.140645e-02 2.000000e-05
3 4.000000e-05 6.283020e-02 6.281484e-02 4.000000e-05
4 8.000000e-05 1.256505e-01 1.256003e-01 8.000000e-05
5 1.600000e-04 2.512216e-01 2.504194e-01 1.600000e-04
6 3.200000e-04 5.018086e-01 4.396405e-01 3.200000e-04
7 5.343163e-04 8.353661e-01 5.117272e-01 5.343163e-04
8 7.511639e-04 1.169004e+00 5.404550e-01 7.511639e-04
9 1.014269e-03 1.566385e+00 5.610074e-01 1.014269e-03
10 1.540478e-03 2.326420e+00 5.852507e-01 1.540478e-03
11 2.592896e-03 3.637196e+00 6.101154e-01 2.592896e-03
12 4.592896e-03 4.959163e+00 6.259915e-01 4.592896e-03
13 6.592896e-03 4.386898e+00 6.198553e-01 6.592896e-03
14 8.592896e-03 2.138988e+00 5.802750e-01 8.592896e-03
15 1.059290e-02 -9.25943e-01 -5.21192e-01 1.059290e-02
16 1.168731e-02 -2.52802e+00 -5.90034e-01 1.168731e-02
17 1.260627e-02 -3.65157e+00 -6.10029e-01 1.260627e-02
18 1.351234e-02 -4.46380e+00 -6.20549e-01 1.351234e-02
19 1.532450e-02 -4.97404e+00 -6.26197e-01 1.532450e-02
20 1.732450e-02 -3.72500e+00 -6.11244e-01 1.732450e-02
21 1.932450e-02 -1.05313e+00 -5.32182e-01 1.932450e-02
22 2.109176e-02 1.681502e+00 5.658107e-01 2.109176e-02
23 2.284255e-02 3.894825e+00 6.136953e-01 2.284255e-02
24 2.446551e-02 4.929676e+00 6.256863e-01 2.446551e-02
25 2.603276e-02 4.739130e+00 6.236773e-01 2.603276e-02
26 2.803276e-02 2.897143e+00 5.977803e-01 2.803276e-02
27 3.003276e-02 -5.14551e-02 -5.14419e-02 3.003276e-02
28 3.181211e-02 -2.69517e+00 -5.93524e-01 3.181211e-02
29 3.353100e-02 -4.47693e+00 -6.20747e-01 3.353100e-02
30 3.548425e-02 -4.94225e+00 -6.26203e-01 3.548425e-02
31 3.748425e-02 -3.55298e+00 -6.08802e-01 3.748425e-02
32 3.948425e-02 -8.06597e-01 -5.07973e-01 3.948425e-02
33 4.084025e-02 1.304594e+00 5.485420e-01 4.084025e-02
34 4.232563e-02 3.336652e+00 6.053367e-01 4.232563e-02
35 4.432563e-02 4.888208e+00 6.256007e-01 4.432563e-02
36 4.614809e-02 4.678280e+00 6.231567e-01 4.614809e-02
37 4.814809e-02 2.747621e+00 5.949600e-01 4.814809e-02
38 5.014809e-02 -2.32536e-01 -2.32009e-01 5.014809e-02
39 5.106495e-02 -1.64179e+00 -5.64133e-01 5.106495e-02
40 5.192012e-02 -2.83650e+00 -5.96466e-01 5.192012e-02
41 5.288026e-02 -3.93170e+00 -6.14042e-01 5.288026e-02
42 5.433190e-02 -4.89027e+00 -6.25323e-01 5.433190e-02
43 5.633190e-02 -4.56865e+00 -6.21871e-01 5.633190e-02
44 5.833190e-02 -2.50196e+00 -5.89905e-01 5.833190e-02
45 6.033190e-02 5.203956e-01 4.469106e-01 6.033190e-02
46 6.201058e-02 2.952352e+00 5.985459e-01 6.201058e-02
47 6.359054e-02 4.517790e+00 6.212035e-01 6.359054e-02
48 6.524527e-02 4.985165e+00 6.263736e-01 6.524527e-02
49 6.724527e-02 3.806855e+00 6.123643e-01 6.724527e-02
50 6.924527e-02 1.174457e+00 5.410754e-01 6.924527e-02
51 7.069407e-02 -1.08163e+00 -5.34385e-01 7.069407e-02
52 7.237416e-02 -3.39303e+00 -6.06125e-01 7.237416e-02
53 7.412120e-02 -4.81065e+00 -6.24769e-01 7.412120e-02
54 7.582571e-02 -4.83272e+00 -6.24761e-01 7.582571e-02

Index time in out time
--------------------------------------------------------------------------------
55 7.782571e-02 -3.15590e+00 -6.02409e-01 7.782571e-02
56 7.982571e-02 -2.73641e-01 -2.72327e-01 7.982571e-02
57 8.082874e-02 1.287122e+00 5.479313e-01 8.082874e-02
58 8.192022e-02 2.836635e+00 5.964361e-01 8.192022e-02
59 8.332868e-02 4.326466e+00 6.189574e-01 8.332868e-02
60 8.468753e-02 4.975928e+00 6.262056e-01 8.468753e-02
61 8.668753e-02 4.313647e+00 6.188623e-01 8.668753e-02
62 8.868753e-02 2.003700e+00 5.763923e-01 8.868753e-02
63 9.068753e-02 -1.07159e+00 -5.33642e-01 9.068753e-02
64 9.256918e-02 -3.61153e+00 -6.09422e-01 9.256918e-02
65 9.445688e-02 -4.92739e+00 -6.26152e-01 9.445688e-02
66 9.621191e-02 -4.64196e+00 -6.22698e-01 9.621191e-02
67 9.821191e-02 -2.66332e+00 -5.93225e-01 9.821191e-02
68 1.000000e-01 -6.12323e-15 -5.42079e-06 1.000000e-01


Transient Analysis Sun Apr 26 18:25:24 2020
--------------------------------------------------------------------------------
Index time v1#branch
--------------------------------------------------------------------------------
0 0.000000e+00 -1.21023e-25
1 1.000000e-05 -7.18261e-09
2 2.000000e-05 -9.27278e-09
3 4.000000e-05 -1.53546e-08
4 8.000000e-05 -5.02056e-08
5 1.600000e-04 -8.02233e-07
6 3.200000e-04 -6.21680e-05
7 5.343163e-04 -3.23639e-04
8 7.511639e-04 -6.28549e-04
9 1.014269e-03 -1.00538e-03
10 1.540478e-03 -1.74117e-03
11 2.592896e-03 -3.02708e-03
12 4.592896e-03 -4.33317e-03
13 6.592896e-03 -3.76704e-03
14 8.592896e-03 -1.55871e-03
15 1.059290e-02 4.047519e-04
16 1.168731e-02 1.937990e-03
17 1.260627e-02 3.041544e-03
18 1.351234e-02 3.843251e-03
19 1.532450e-02 4.347845e-03
20 1.732450e-02 3.113754e-03
21 1.932450e-02 5.209497e-04
22 2.109176e-02 -1.11569e-03
23 2.284255e-02 -3.28113e-03
24 2.446551e-02 -4.30399e-03
25 2.603276e-02 -4.11545e-03
26 2.803276e-02 -2.29936e-03
27 3.003276e-02 1.323245e-08
28 3.181211e-02 2.101648e-03
29 3.353100e-02 3.856183e-03
30 3.548425e-02 4.316048e-03
31 3.748425e-02 2.944182e-03
32 3.948425e-02 2.986236e-04
33 4.084025e-02 -7.56052e-04
34 4.232563e-02 -2.73131e-03
35 4.432563e-02 -4.26261e-03
36 4.614809e-02 -4.05512e-03
37 4.814809e-02 -2.15266e-03
38 5.014809e-02 5.269492e-07
39 5.106495e-02 1.077659e-03
40 5.192012e-02 2.240032e-03
41 5.288026e-02 3.317656e-03
42 5.433190e-02 4.264945e-03
43 5.633190e-02 3.946775e-03
44 5.833190e-02 1.912051e-03
45 6.033190e-02 -7.34851e-05
46 6.201058e-02 -2.35381e-03
47 6.359054e-02 -3.89659e-03
48 6.524527e-02 -4.35879e-03
49 6.724527e-02 -3.19449e-03
50 6.924527e-02 -6.33382e-04
51 7.069407e-02 5.472455e-04
52 7.237416e-02 2.786905e-03
53 7.412120e-02 4.185885e-03
54 7.582571e-02 4.207954e-03

Index time v1#branch
--------------------------------------------------------------------------------
55 7.782571e-02 2.553494e-03
56 7.982571e-02 1.314865e-06
57 8.082874e-02 -7.39190e-04
58 8.192022e-02 -2.24020e-03
59 8.332868e-02 -3.70751e-03
60 8.468753e-02 -4.34972e-03
61 8.668753e-02 -3.69479e-03
62 8.868753e-02 -1.42731e-03
63 9.068753e-02 5.379516e-04
64 9.256918e-02 3.002108e-03
65 9.445688e-02 4.301241e-03
66 9.621191e-02 4.019265e-03
67 9.821191e-02 2.070094e-03
68 1.000000e-01 -5.42079e-09
Loading

0 comments on commit 782fb73

Please sign in to comment.