فهرست منبع

add MergeModule update pyansys Script

Willi Zschiebsch 5 سال پیش
والد
کامیت
266a470fa3

+ 6 - 0
lib/CMakeLists.txt

@@ -15,6 +15,9 @@ add_library(${PROJECT_NAME} STATIC
         include/ModuleBase.h
         include/ModuleHTTP.h
         include/ModuleMath.h
+	include/ModuleMerge.h
+	include/ModuleParameter.h
+	include/ModuleSplitt.h
         include/ModuleSQL.h
         include/ModuleSwitch.h
         include/Output.h
@@ -25,6 +28,9 @@ add_library(${PROJECT_NAME} STATIC
         src/ModuleBase.cpp
         src/ModuleHTTP.cpp
         src/ModuleMath.cpp
+	src/ModuleMerge.cpp
+	src/ModuleParameter.cpp
+	src/ModuleSplitt.cpp
         src/ModuleSQL.cpp
         src/ModuleSwitch.cpp
         src/Output.cpp

+ 18 - 0
lib/include/ModuleMerge.h

@@ -0,0 +1,18 @@
+#ifndef MODULEMERGE_H
+#define MODULEMERGE_H
+#include "ModuleBase.h"
+
+namespace mdd {
+	class ModuleMerge : public ModuleBase {
+	private:
+
+	public:
+		ModuleMerge();
+		int addModuleInput();
+		int removeModuleInput();
+		std::string setInputType(const std::string& input_id, const std::string& new_type);
+		bool update() override;
+	};
+}
+
+#endif 

+ 16 - 0
lib/include/ModuleParameter.h

@@ -0,0 +1,16 @@
+#ifndef MODULEPARAMETER_H
+#define MODULEPARAMETER_H
+#include "ModuleBase.h"
+
+namespace mdd {
+
+    class ModuleParameter : public ModuleBase {
+    private:
+       
+    public:
+        ModuleParameter();
+        bool update() override;
+    };
+}
+
+#endif

+ 0 - 0
lib/include/ModuleSplitt.h


+ 49 - 0
lib/src/ModuleMerge.cpp

@@ -0,0 +1,49 @@
+#include "ModuleMerge.h"
+#include <boost/algorithm/string.hpp>
+
+namespace mdd {
+	ModuleMerge::ModuleMerge() {
+		json default_val;
+		default_val["value"] = 1;
+		addInput("Value", default_val);
+		addInput("Value", default_val);
+		addOutput("Value", default_val);
+		setType("Math");
+	}
+
+	int ModuleMerge::addModuleInput() {
+		json default_val;
+		default_val["value"] = 1;
+		return addInput("Value", default_val);
+	}
+
+	int ModuleMerge::removeModuleInput() {
+		return pop_backInput();
+	}
+
+	std::string ModuleMerge::setInputType(const std::string& input_id, const std::string& new_type) {
+		for (int id = 0; id < getInputs().size(); ++id) {
+			if (getInput(id)->getID() == input_id) {
+				getInput(id)->setType(new_type);
+				return getInput(id)->getID();
+			}
+		}
+		return "";
+	}
+	bool ModuleMerge::update() {
+		json ret;
+		for (size_t i = 0; i < getInputs().size(); i++)
+		{
+			std::string key = getInput(i)->getType();
+			boost::algorithm::to_lower(key);
+			ret.emplace(key, getInput(i)->getValue()["value"]);
+		}
+		if (ret.dump() != getOutput(0)->getValue().dump()) {
+			getOutput(0)->getValueInternal() = ret;
+			return true;
+		}
+		else {
+			return false;
+		}
+	}
+}

+ 23 - 0
lib/src/ModuleParameter.cpp

@@ -0,0 +1,23 @@
+#include "ModuleParameter.h"
+
+namespace mdd {
+    ModuleParameter::ModuleParameter() {
+        json default_val;
+        default_val["value"] = 1;
+        addInput("Value", default_val);
+        addOutput("Value", default_val);
+        setType("Parameter");
+    }
+
+    bool ModuleParameter::update() {
+        json ret = getInput(0)->getValue()["value"];
+        
+        if (ret.dump() != getOutput(0)->getValue()["value"].dump()) {
+            getOutput(0)->getValueInternal()["value"] = ret;
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+}

+ 13 - 21
lib/src/ModuleSQL.cpp

@@ -1,4 +1,5 @@
 #include "ModuleSQL.h"
+#include <boost/algorithm/string.hpp>
 
 namespace mdd {
 	void ModuleSQL::erase_keyword(std::string& str, std::string key) {
@@ -118,7 +119,11 @@ namespace mdd {
 		json default_val;
 		default_val["value"] = 1;
 		addInput(_content[0].key, default_val);
-		addOutput(_tbname, default_val);
+		for (auto& cont :_content)
+		{
+			addOutput(cont.key, default_val);
+		}
+		setType("SQL");
 	}
 
 	bool ModuleSQL::update() {
@@ -145,36 +150,23 @@ namespace mdd {
 		}
 
 		step = sqlite3_step(res);
+		bool state = false;
 		json ret;
 		if (step == SQLITE_ROW) {
 			int nCol = sqlite3_column_count(res);
 			std::string parse_str = "{\"" + _tbname + "\" : {";
 			for (size_t i = 0; i < nCol; i++)
 			{
-				  parse_str = parse_str + "\""+_content[i].key+"\" : ";
-				  if(_content[i].type == "TEXT"){
-					  parse_str = parse_str + "\"" + (char*)sqlite3_column_text(res, i) + "\"";
-				  }
-				  else {
-					  parse_str += (char*)sqlite3_column_text(res, i);
-				  }
-				  if (i != nCol - 1) {
-					  parse_str += ",";
-				  }
-				  
+				std::string val = (char*)sqlite3_column_text(res, i);
+				if (getOutput(i)->getValue()["value"].dump() != val) {
+					getOutput(i)->getValueInternal()["value"] = val;
+					state = true;
+				}
 			}
-			parse_str += "}}";
-			ret = json::parse(parse_str);
 		}
 		sqlite3_finalize(res);
 
-		if (ret.dump() != getOutput(0)->getValue().dump()) {
-			getOutput(0)->getValueInternal() = ret;
-			return true;
-		}
-		else {
-			return false;
-		}
+		return state;
 	}
 
 	ModuleSQL::~ModuleSQL() {

+ 0 - 0
lib/src/ModuleSplitt.cpp


+ 1 - 0
lib/test/server/.gitignore

@@ -1,3 +1,4 @@
 .idea
 __pycache__
 venv
+ws

+ 15 - 0
lib/test/server/ansys/00_Model.inp

@@ -0,0 +1,15 @@
+! /INPUT, C:/Users/Willi/Documents/projects/gfk-plate/script/00_Modell.inp
+finish
+/clear
+
+/CONTOUR
+/RGB,INDEX,100,100,100, 0   
+/RGB,INDEX, 80, 80, 80,13   
+/RGB,INDEX, 60, 60, 60,14   
+/RGB,INDEX, 0, 0, 0,15  
+/COLOR,CURVE,4
+/REPLOT 
+
+/filename,GFK_Rotor
+/title,GFK Rotor
+/PLOTPTS,INFO,AUTO

+ 21 - 0
lib/test/server/ansys/01_Parameter.inp

@@ -0,0 +1,21 @@
+! /INPUT, C:/Users/Willi/Documents/projects/gfk-plate/script/00_Modell.inp
+
+
+!**********************************
+!	Variables
+!**********************************
+t_r		=	0.7			![mm]		Schichtdicke
+theta_r	=	0			![°]		Faserorientierung
+
+t_t		=	0.7			![mm]		Schichtdicke
+theta_t	=	90			![°]		Faserorientierung
+
+TH		=	200			![°C]		Herstellungstemperatur
+TN		=	20			![°C]		Nutzungstemperatur
+
+R_out	=	125			![mm]		Aussenradius
+r_in	=	25			![mm]		Innenradius
+D_plate	=	5			![mm]		Plattenhöhe
+d_layer	=	1			![mm]		Schichtdicke
+
+omega_z	=	0.1			![rad/s]	Winkelgeschwindigkeit(+: gegen Uhrzeigersinn)

+ 61 - 0
lib/test/server/ansys/02_Laminate.inp

@@ -0,0 +1,61 @@
+/PREP7
+!**********************************
+!	Materials
+!********************************** 
+!X:	radiale Richtung
+!Y: tangentiale Richtung
+!Z: normale Richtung
+
+!MPTEMP,,,,,,,,  
+!GFK EP-E Glas radial
+MPTEMP,1,TH  
+MPDATA,EX,1,,42.5 			![N/mm^2] 	E-Module in Faserrichtung
+MPDATA,EY,1,,11 			![N/mm^2] 	E-Modul quer zur Faserrichtung
+MPDATA,EZ,1,,11  			![N/mm^2] 	E-Modul quer zur Faserrichtung
+MPDATA,PRXY,1,,0.28
+MPDATA,PRYZ,1,,0.28
+MPDATA,PRXZ,1,,0.28
+MPDATA,GXY,1,,4.2
+MPDATA,GYZ,1,,11/(2*(1+0.28))!
+MPDATA,GXZ,1,,4.2
+MPDATA,DENS,1,,1950E-6		![kg/mm^3]	Dichte
+MPDATA,ALPX,1,,5.7E-6		![1/K]		Waermeausdenungsk
+MPDATA,ALPY,1,,45E-6		![1/K]		Waermeausdenungsk
+MPDATA,ALPZ,1,,45E-6		![1/K]		Waermeausdenungsk
+
+MPDATA,KXX,1,,0.72E3 		![W/K]		Waermeleitfaehigk.
+MPDATA,KYY,1,,0.5E3  		![W/K]		Waermeleitfaehigk.
+MPDATA,KZZ,1,,0.5E3 		![W/K]		Waermeleitfaehigk.
+
+MPDATA,BETX,1,,0E-3			![1/%M]		Quellkoeffizient
+MPDATA,BETY,1,,4E-3			![1/%M]		Quellkoeffizient
+MPDATA,BETZ,1,,4E-3			![1/%M]		Quellkoeffizient
+
+MPDATA,DXX,1,,4.4E3			![mm^2/s]	Diffusionskoeffizient
+MPDATA,DYY,1,,3.1E3			![mm^2/s]	Diffusionskoeffizient
+MPDATA,DZZ,1,,3.1E3			![mm^2/s]	Diffusionskoeffizient
+
+!MPDATA,CTEX,1,,5.7E-6		![]			Schrumpfen
+!MPDATA,CTEY,1,,45E-6		![]			Schrumpfen
+!MPDATA,CTEZ,1,,45E-6		![]			Schrumpfen
+
+!/EOf
+!**********************************
+!	Elements
+!**********************************
+ET,1,SHELL181   
+KEYOPT,1,8,1 ! Enable Laminate
+
+!**********************************
+!	Laminate
+!**********************************
+sect,1,shell,,  
+!secdata, Thickness ,MatId,theta,Number of integration points in layer
+secdata, t_t,1,theta_t,3   
+secdata, t_r,1,theta_r,3
+secdata, t_r,1,theta_r,3
+secdata, t_r,1,theta_r,3
+secdata, t_r,1,theta_r,3
+secdata, t_r,1,thet,0a_r,3
+secoffset,MID   !Shell node will be offset to midplane of the section
+seccontrol,,,, , , ,

+ 53 - 0
lib/test/server/ansys/03_Modell.inp

@@ -0,0 +1,53 @@
+! /INPUT, C:/Users/Willi/Documents/projects/gfk-plate/script/00_Modell.inp
+ 
+!**********************************
+!	Geometry
+!**********************************
+CSYS,1  
+CYL4,0,0,r_in,0,R_out,180
+CYL4,0,0,r_in,180,R_out,360
+
+NSEL,S,LOC,Y,0
+NUMMRG,ALL
+
+NSEL,S,LOC,Y,180
+NUMMRG,ALL
+
+LSEL,S,,,1,7,2
+LESIZE,ALL,,,20
+
+LSEL,S,,,2,4,2
+LESIZE,ALL,,,20
+
+LSEL,ALL
+APLOT,All
+
+MSHAPE,0,2D !quadratic 2D Shapes
+Mshkey,1	!0-free meshing
+AMESH,ALL
+
+EPLOT,ALL
+!**********************************
+!	Load
+!**********************************
+/SOLU
+OMEGA,,,omega_z
+NSEL,S,LOC,X,r_in
+D,ALL,UX,0
+D,ALL,UY,0
+D,ALL,UZ,0
+D,ALL,ROTX,0
+D,ALL,ROTY,0
+D,ALL,ROTZ,0
+ALLS
+
+!Nichtliniearitäten
+!NLGEOM,ON
+	!NSUBST,20
+	!AUTOTS,ON
+outres,ALL,ALL
+!time,1
+solve
+
+finish
+

+ 39 - 0
lib/test/server/ansys/04_Plot.inp

@@ -0,0 +1,39 @@
+!**********************************
+!	Plot
+!**********************************
+/Post1
+ALLS
+
+/erase
+/win,1,ltop $/win,2,rtop
+/win,3,lbot $/win,4,rbot
+
+/win,1,off
+/win,2,off
+/win,3,off
+/win,4,off
+
+/win,1,on
+PLNSOL,S,X !Stress in Radialrichtung
+/noerase
+/win,1,off
+
+/win,2,on
+/view,2,0,0,-1
+PLNSOL,S,X !Stress in Radialrichtung, Sicht von hinten
+/noerase
+/win,2,off
+
+/win,3,on
+PLNSOL,S,Y !Stress in Tangentialrichtung
+/noerase
+/win,3,off
+
+/win,4,on
+!/DSCALE,,1	!Verformung
+!/PLDISP,0
+PLNSOL,U,SUM
+/noerase
+/win,4,off
+
+/EOF

+ 193 - 29
lib/test/server/gfk-plate.py

@@ -1,32 +1,196 @@
 # https://akaszynski.github.io/pyansys/ansys_control.html#initial-setup-and-example
-
+# pip install pyansys --upgrade
 import pyansys
+import numpy as np
+import os
+
+
+def plot_rotor(ansys):
+    ansys.run("/Post1")
+    ansys.run("ALLS")
+    ansys.run("/erase")
+    ansys.run("/win,1,ltop $/win,2,rtop")
+    ansys.run("/win,3,lbot $/win,4,rbot")
+    ansys.run("/win,1,off")
+    ansys.run("/win,2,off")
+    ansys.run("/win,3,off")
+    ansys.run("/win,4,off")
+    ansys.run("/win,1,on")
+    ansys.plnsol("S", "X")  # Stress in Radialrichtung
+    ansys.run("/noerase")
+    ansys.run("/win,1,off")
+    ansys.run("/win,2,on")
+    ansys.run("/view,2,0,0,-1")
+    ansys.plnsol("S", "X")  # Stress in Radialrichtung, Sicht von hinten
+    ansys.run("/noerase")
+    ansys.run("/win,2,off")
+    ansys.run("/win,3,on")
+    ansys.plnsol("S", "Y")  # Stress in Tangentialrichtung
+    ansys.run("/noerase")
+    ansys.run("/win,3,off")
+    ansys.run("/win,4,on")
+    ansys.plnsol("U", "SUM")
+    ansys.run("/noerase")
+    ansys.run("/win,4,off")
+    ansys.run("/EOF")
+
+
+def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thickness=5, omega=0.1):
+    layers = len(angles)
+    layer_thickness = thickness / layers
+
+    path = os.getcwd()+"\\ws"
+    mapdl = pyansys.launch_mapdl(run_location=path, interactive_plotting=True)
+    # clear existing geometry
+    mapdl.finish()
+    mapdl.clear()
+
+    th = 200  # [°C]        Herstellungstemperatur
+    tn = 20  # [°C]        Nutzungstemperatur
+
+    mapdl.prep7()
+    # define Material
+    for i in range(0, len(materials)):
+        mapdl.mptemp(i + 1, th)
+
+        mapdl.mpdata("EX", i + 1, "", materials[i]["e11"])
+        mapdl.mpdata("EY", i + 1, "", materials[i]["e22"])
+        mapdl.mpdata("EZ", i + 1, "", materials[i]["e33"])
+
+        mapdl.mpdata("PRXY", i + 1, "", materials[i]["pr12"])
+        mapdl.mpdata("PRXZ", i + 1, "", materials[i]["pr13"])
+        mapdl.mpdata("PRYZ", i + 1, "", materials[i]["pr23"])
+
+        mapdl.mpdata("DENS", i + 1, "", materials[i]["dens"])
+
+        mapdl.mpdata("GXY", i + 1, "", materials[i]["g12"])
+        mapdl.mpdata("GXZ", i + 1, "", materials[i]["g13"])
+        mapdl.mpdata("GYZ", i + 1, "", materials[i]["g23"])
+
+        # Waermeausdenungsk
+        mapdl.mpdata("ALPX", i + 1, "", materials[i]["alp11"])
+        mapdl.mpdata("ALPY", i + 1, "", materials[i]["alp22"])
+        mapdl.mpdata("ALPZ", i + 1, "", materials[i]["alp33"])
+
+        # Waermeleitfaehigk
+    #    mapdl.mpdata("KXX", i + 1, "", materials[i]["k11"])
+    #    mapdl.mpdata("KYY", i + 1, "", materials[i]["k22"])
+    #    mapdl.mpdata("KZZ", i + 1, "", materials[i]["k33"])
+
+        # Quellkoeffizient
+    #    mapdl.mpdata("BETX", i + 1, "", materials[i]["bet11"])
+    #    mapdl.mpdata("BETY", i + 1, "", materials[i]["bet22"])
+    #    mapdl.mpdata("BETZ", i + 1, "", materials[i]["bet33"])
+
+        # Diffusionskoeffizient
+    #    mapdl.mpdata("DXX", i + 1, "", materials[i]["d11"])
+    #    mapdl.mpdata("DYY", i + 1, "", materials[i]["d22"])
+    #    mapdl.mpdata("DZZ", i + 1, "", materials[i]["d33"])
+
+    # define Element
+    mapdl.et(1, "SHELL181")
+    # enable Laminate
+    mapdl.run("KEYOPT,1,8,1")
+
+    # define Laminate
+    mapdl.run("SECT, 1, SHELL")
+
+    # secdata, Thickness ,MatId,theta,Number of integration points in layer
+    if len(angles) != len(materials):
+        for i in range(0, len(angles)):
+            mapdl.secdata(layer_thickness, 1, angles[i], 3)
+    else:
+        for i in range(0, len(angles)):
+            mapdl.secdata(layer_thickness, i + 1, angles[i], 3)
+
+    # Shell node will be offset to midplane of the section
+    mapdl.secoffset("MID")
+    mapdl.run("seccontrol,,,,,,,")
+
+    mapdl.run("/ESHAPE,1.0")
+    # define Geometry
+    # change global coordinate system to cylindric system
+    mapdl.csys(1)
+    mapdl.cyl4(0, 0, inner_diameter / 2, 0, outer_diameter / 2, 180)
+    mapdl.cyl4(0, 0, inner_diameter / 2, 180, outer_diameter / 2, 360)
+    mapdl.nsel("S", "LOC", "Y", 0)
+    mapdl.nummrg("ALL")
+    mapdl.nsel("S", "LOC", "Y", 180)
+    mapdl.nummrg("ALL")
+    mapdl.lsel("S", "", "", 1, 7, 2)
+    mapdl.lesize("ALL", "", "", 20)
+    mapdl.lsel("S", "", "", 2, 4, 2)
+    mapdl.lesize("ALL", "", "", 20)
+    mapdl.lsel("ALL")
+    # mapdl.aplot()
+    mapdl.mshape(0, "2D")  # quadratic 2D Shapes
+    mapdl.mshkey(1)  # 0-free meshing
+    mapdl.amesh("ALL")
+    # mapdl.eplot()
+
+    mapdl.run("/SOLU")
+    mapdl.omega("", "", omega)  # [rad/s]	Winkelgeschwindigkeit(+: gegen Uhrzeigersinn))
+    mapdl.nsel("S", "LOC", "X", inner_diameter / 2)
+    mapdl.d("ALL", "UX", 0)
+    mapdl.d("ALL", "UY", 0)
+    mapdl.d("ALL", "UZ", 0)
+    mapdl.d("ALL", "ROTX", 0)
+    mapdl.d("ALL", "ROTY", 0)
+    mapdl.d("ALL", "ROTZ", 0)
+    mapdl.run("ALLS")
+
+    mapdl.outres("ALL", "ALL")
+    # mapdl.open_gui()
+    mapdl.solve()
+
+    mapdl.finish()
+    #mapdl.post1()
+    #mapdl.open_gui()
+
+
+    # plot_rotor(mapdl)
+
+    # access results using ANSYS object
+    resultfile = os.getcwd() + '\\ws\\file.rst'
+
+    result = pyansys.read_binary(resultfile)
+    # result = mapdl.result
+    result.plot_principal_nodal_stress(0, 'EQV')
+
+# plot_nodal_solution doesnt work
+    nodenum, stress = result.principal_nodal_stress(0)
+
+    # von Mises stress is the last column
+    # must be nanmax as the shell element stress is not recorded
+    maxstress = np.nanmax(stress[:, -1])
+
+    mapdl.exit()
+
+    return maxstress
+
 
-mapdl = pyansys.launch_mapdl(interactive_plotting=True)
-#, interactive_plotting=True
-
-#os.system('cmd /k "D:\\ANSYS Inc\\v191\\ansys\\bin\\winx64\\ANSYS191.exe" ')
-#mapdl = pyansys.launch_mapdl(interactive_plotting=True)
-# create a square area using keypoints
-mapdl.prep7()
-mapdl.k(1, 0, 0, 0)
-mapdl.k(2, 1, 0, 0)
-mapdl.k(3, 1, 1, 0)
-mapdl.k(4, 0, 1, 0)
-mapdl.l(1, 2)
-mapdl.l(2, 3)
-mapdl.l(3, 4)
-mapdl.l(4, 1)
-mapdl.al(1, 2, 3, 4)
-
-# sets the view to "isometric"
-mapdl.view(1, 1, 1, 1)
-mapdl.pnum('kp', 1)  # enable keypoint numbering
-mapdl.pnum('line', 1)  # enable line numbering
-
-# each of these will create a matplotlib figure and pause execution
-#mapdl.run('/SHOW,PNG')
-mapdl.aplot()
-mapdl.lplot()
-mapdl.kplot()
-mapdl.wait(1)
+print(sim_rotor(
+    [{
+        "e11": 42.5,
+        "e22": 11,
+        "e33": 11,
+        "pr12": 0.28,
+        "pr13": 0.28,
+        "pr23": 0.28,
+        "dens": 1950E-6,
+        "g12": 4.2,
+        "g13": 4.2,
+        "g23": 2.56,
+        "alp11": 5.7E-6,
+        "alp22": 45E-6,
+        "alp33": 45E-6,
+        "k11": 0.72E3,
+        "k22": 0.5E3,
+        "k33": 0.5E3,
+        "bet11": 0E-3,
+        "bet22": 4E-3,
+        "bet33": 4E-3,
+        "d11": 4.4E3,
+        "d22": 3.1E3,
+        "d33": 3.1E3
+    }], [90, 0, 0, 0, 0, 0]))

+ 0 - 2
lib/test/server/links.txt

@@ -1,2 +0,0 @@
-https://www.w3schools.com/python/python_mysql_insert.asp
-https://www.sqlitetutorial.net/sqlite-python/insert/

+ 16 - 0
lib/test/server/monitor.json

@@ -0,0 +1,16 @@
+{
+"aaS.list_monitors_with_persisted_data mntr":
+[
+{
+	"Error": "Opening file 'file.mntr'"
+}
+],
+"aaS.list_monitors_with_persisted_data gst":
+[
+],
+"aaS.list_monitors_with_persisted_data cnd":
+[
+],
+"aaS.list_monitors_with_persisted_data nlh":
+[
+]}

+ 82 - 0
lib/test/server/server-ansys.py

@@ -0,0 +1,82 @@
+from abc import ABC
+
+import tornado.ioloop
+import tornado.web
+import tornado.escape
+import collections
+import json
+
+import sqlite3 as lite
+import sys
+
+import logging
+
+from ini_logger import *
+
+#log_dir = r'/var/log/server'
+#ini_logger(log_dir)
+
+inputs = [
+    {'type': "Material", [{}]},
+    {'type': "Angles", 'value': [0,90]}
+]
+
+outputs = [
+    {'type': "Location", 'value': 0},
+    {'type': "Stress", 'value': 2},
+    {'type': "Temperature", 'value': 4}
+]
+
+def update():
+    do_something = 1
+
+
+class MainHandler(tornado.web.RequestHandler, ABC):
+    def prepare(self):
+        self.set_header("Content-Type", "application/json")
+        if self.request.headers.get('Content-Type') == 'application/json':
+            print(self.request.body)
+            self.json_args = json.loads(self.request.body.decode('utf-8'))
+        else:
+            self.json_args = None
+
+    def get(self, param):
+        print("INFO: GET /" + param)
+        if param == "inputs":
+            self.write(json.dumps(inputs))
+        elif param == "outputs":
+            self.write(json.dumps(outputs))
+        elif param == "status":
+            self.write("{\"status\": \"ready\"}")
+        elif param == "stop":
+            instance = tornado.ioloop.IOLoop.instance()
+            instance.add_callback(instance.stop)
+        else:
+            self.write("Error: GET /" + param)
+            print("Error: GET /" + param)
+
+    def post(self, param):
+        if param == "update":
+            if self.json_args is not None:
+                print("INFO: GET /" + param + "with body: " + self.json_args.dump())
+                counter = 0
+                for entity in self.json_args:
+                    inputs[counter]['value'] = entity['value']
+                    counter = counter + 1
+            update()
+            self.write(json.dumps(outputs))
+        else:
+            self.write("Error: POST /" + param)
+            print("Error: POST /" + param)
+
+
+def make_app():
+    return tornado.web.Application([
+        (r"/(.*)", MainHandler),
+    ])
+
+
+if __name__ == "__main__":
+    app = make_app()
+    app.listen(int(sys.argv[1]))
+    tornado.ioloop.IOLoop.current().start()

+ 0 - 2
lib/test/test_ModuleSQL.cpp

@@ -231,7 +231,5 @@ TEST(ModuleSQL, TestDataExists) {
     }
     sqlite3_close(db);
 
-
-
     EXPECT_TRUE(std::filesystem::exists("../../../lib/test/db/materials.db"));
 }