Willi Zschiebsch 4 سال پیش
والد
کامیت
b429fe66e8

+ 1 - 0
CMakeLists.txt

@@ -26,6 +26,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libzmq/include)
 set(BUILD_SHARED OFF)
 set(BUILD_STATIC ON)
 set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
+set(ZMQ_BUILD_TESTS OFF CACHE BOOL "" FORCE)
 set(ENABLE_PRECOMPILED OFF CACHE BOOL "" FORCE)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libzmq)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cppzmq)

+ 27 - 23
lib/CMakeLists.txt

@@ -3,47 +3,51 @@ project(mdd_lib)
 
 add_library(${PROJECT_NAME} STATIC
 	include/Connector.h
-	include/Generator.h
+	include/ModuleGenerator.h
 	include/IConnection.h
-	include/IGenerator.h
-        include/IInput.h
-        include/IInteractive.h
-        include/IManager.h
-        include/IModule.h
-        include/Input.h
+	include/IModuleGenerator.h
+    include/IInput.h
+    include/IInteractive.h
+    include/IManager.h
+    include/IModule.h
+    include/Input.h
 	include/IOptimizable.h
 	include/IOptimizer.h
-        include/IOutput.h
-        include/IProcessor.h
+	include/IOptimizerGenerator.h
+    include/IOutput.h
+    include/IProcessor.h
+	include/IProcessorGenerator.h
 	include/IState.h
-        include/IUnique.h
-        include/ModuleBase.h
+    include/IUnique.h
+    include/ModuleBase.h
 	include/OptimizerBase.h
 	include/OptimizerEvolutionary.h
-        include/Output.h
+	include/OptimizerGenerator.h
+    include/Output.h
 	include/Parameter.h
-        include/ProcessorBase.h
+    include/ProcessorBase.h
+	include/ProcessorGenerator.h
 	include/ProcessorStandard.h
 	include/Registration.h
 	include/state.h
 
 	src/Connector.cpp
-        src/Input.cpp
-        src/ModuleBase.cpp
-        src/ModuleHTTP.cpp
-        src/ModuleMath.cpp
+    src/Input.cpp
+    src/ModuleBase.cpp
+    src/ModuleHTTP.cpp
+    src/ModuleMath.cpp
 	src/ModuleMerge.cpp
 	src/ModuleSplitt.cpp
-        src/ModuleSQL.cpp
-        src/ModuleSwitch.cpp
+    src/ModuleSQL.cpp
+    src/ModuleSwitch.cpp
 	src/OptimizerBase.cpp
 	src/OptimizerEvolutionary.cpp
-        src/Output.cpp
+    src/Output.cpp
 	src/Parameter.cpp
-        src/ProcessorBase.cpp
-        src/ProcessorStandard.cpp
+    src/ProcessorBase.cpp
+    src/ProcessorStandard.cpp
 	src/Registration.cpp
-        )
+)
 
 target_include_directories(${PROJECT_NAME} PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

+ 42 - 24
lib/include/Connector.h

@@ -1,5 +1,5 @@
-#ifndef CONNECTOR_H
-#define CONNECTOR_H
+#pragma once
+
 #include "memory"
 #include "json.hpp"
 
@@ -8,30 +8,48 @@
 
 #include <Registration.h>
 
+#include <ProcessorStandard.h>
+
 namespace mdd {
 	class Connector {
 
+	private:
+		Registration regi = Registration();
+		IProcessor::Ptr _root;
+		const std::map<const std::string, std::function<json(const json&)>> _ops = {//const std::map<const std::string, const json& (Connector::*)(const json&)> _ops = {
+			{"add", std::bind(&Connector::add,this,std::placeholders::_1) },/*
+			{"remove", std::bind(&Connector::remove,this,std::placeholders::_1)},
+			{"change", std::bind(&Connector::change,this,std::placeholders::_1)},*/
+			{"state", std::bind(&Connector::state,this,std::placeholders::_1)}
+        };
+
+		bool contains_subj_obj_structure(const json& args);
+
+		/**
+		*subject
+		*object
+		**/
+		//refernece funktioniert nicht!????
+		json add(const json& args);
+		/**
+		*subject
+		*object
+		**/
+		json remove(const json& args);
+		/**
+		*subject
+		*object
+		**/
+		json change(const json& args);
+		/**
+		*subject
+		*object
+		**/
+		json state(const json& args);
+
 	public:
-		/*
-		json{
-		"type": "StandardProcessor",
-		("params": [param1, param2,...])
-		("subs":[
-		{
-		"type": "Math",
-		"params":[param1,param2,...]
-		},
-		{
-		"type": "Math",
-		"params":[param1,param2,...]
-		}
-		],
-		"connections":[[in1,out1],[in2,out2],...]
-		})
-		*/
-		static std::shared_ptr<IModule> decode(const json& structure);
-		static const json& encode(const std::shared_ptr<IModule>& structure);
+		Connector();
+		json decode(const json& request);
+		json encode();
 	};
-}
-
-#endif
+}

+ 2 - 0
lib/include/IInteractive.h

@@ -5,6 +5,7 @@
 #include "IState.h"
 #include "IConnection.h"
 #include "IOptimizable.h"
+#include "IManager.h"
 
 namespace mdd {
     template <class T>
@@ -12,6 +13,7 @@ namespace mdd {
         : public IState
         , public IConnection<T>
         , public IOptimizable
+        , public IManager
     {
     public:
         typedef std::shared_ptr<IInteractive> Ptr;

+ 2 - 2
lib/include/IGenerator.h

@@ -6,10 +6,10 @@
 
 namespace mdd
 {
-	class IGenerator
+	class IModuleGenerator
 	{
 	public:
-		virtual ~IGenerator() {}
+		virtual ~IModuleGenerator() {}
 
 		virtual std::shared_ptr<IModule> generate() = 0;
 	};

+ 2 - 0
lib/include/IOptimizer.h

@@ -9,6 +9,8 @@ namespace mdd {
 		: public IManager
 	{
 		public:
+			typedef std::shared_ptr<IOptimizer> Ptr;
+
 			virtual bool connect(std::shared_ptr<IModule> module) = 0;
 			
 			virtual bool setEvaluation(std::string func) = 0;

+ 16 - 0
lib/include/IOptimizerGenerator.h

@@ -0,0 +1,16 @@
+
+#pragma once
+
+#include <memory>
+#include "IOptimizer.h"
+
+namespace mdd
+{
+	class IOptimizerGenerator
+	{
+	public:
+		virtual ~IOptimizerGenerator() {}
+
+		virtual std::shared_ptr<IOptimizer> generate() = 0;
+	};
+}

+ 2 - 0
lib/include/IProcessor.h

@@ -8,6 +8,8 @@ namespace mdd
 {
     class IProcessor: public  IModule{
     public:
+        typedef std::shared_ptr<IProcessor> Ptr;
+
         virtual std::string addModule(std::shared_ptr<IModule> module) = 0;
         virtual void  removeModule(std::shared_ptr<IModule> module) = 0;
 

+ 16 - 0
lib/include/IProcessorGenerator.h

@@ -0,0 +1,16 @@
+
+#pragma once
+
+#include <memory>
+#include "IProcessor.h"
+
+namespace mdd
+{
+	class IProcessorGenerator
+	{
+	public:
+		virtual ~IProcessorGenerator() {}
+
+		virtual std::shared_ptr<IProcessor> generate() = 0;
+	};
+}

+ 4 - 1
lib/include/IUnique.h

@@ -5,8 +5,11 @@
 namespace mdd{
     class IUnique{
     public:
-        virtual std::string setType(const std::string& type) = 0;
         virtual std::string getType() = 0;
+        virtual std::string getGeneratorKey() = 0;
+
+        virtual std::string setName(const std::string& name) = 0;
+        virtual std::string getName() = 0;
         
         virtual std::string setAppendix(int appendix) = 0;
         virtual int getAppendix() = 0;

+ 16 - 4
lib/include/Input.h

@@ -11,7 +11,7 @@
 namespace mdd {
     class Input : public IInput{
     private:
-        std::string _type;
+        std::string _name;
         int _appendix;
         IModule* _parent;
 
@@ -20,14 +20,21 @@ namespace mdd {
         std::shared_ptr <IOutput> _output;
         bool _optimizable;
         limits _limit;//make shared_ptr!!!
+
+    protected:
+        std::string type;
+        std::string key;
+
     public:
-        Input(IModule* parent, const std::string &type, int appendix, const std::vector<double>& default_value);
+        Input(IModule* parent, const std::string &name, int appendix, const std::vector<double>& default_value);
         //const std::function<bool(const json &)> &verification = [](const json&) { return true; }
-        std::string setType(const std::string& type) override;
         std::string getType() override;
-        std::string getID() override;
+        std::string getGeneratorKey() override;
+        std::string setName(const std::string& name) override; 
+        std::string getName() override; 
         std::string setAppendix(int appendix) override;
         int getAppendix() override;
+        std::string getID() override;
 
         std::string getParentID() override;
 
@@ -50,6 +57,11 @@ namespace mdd {
         int removeConnection(std::shared_ptr<IOutput> output) override;
         bool connect(std::shared_ptr<IOutput> output) override;
         void disconnect() override;
+
+        bool configure(const std::string& config) override;
+        std::string getConfiguration() override;
+        void load(const json& j) override;
+        json dump() override;
     };
 }
 

+ 7 - 5
lib/include/ModuleBase.h

@@ -4,20 +4,20 @@
 #include "Input.h"
 #include "Output.h"
 #include "IModule.h"
-#include "Generator.h"
 
 namespace mdd {
 
     class ModuleBase : public  IModule{
     private:
-        std::string _type = "";
+        std::string _name = "";
         int _appendix = 0;
 
         std::string _base_config = "";
 
     protected:
         ModuleBase(const std::string& base_config = "{}"); 
-
+        std::string type = "module";
+        std::string key;
         std::vector<std::shared_ptr<Input>> inputs;
         std::vector<std::shared_ptr<Output>> outputs;
 
@@ -36,11 +36,13 @@ namespace mdd {
         std::vector<std::shared_ptr<IInput>> getOptimizableInputs() override;
         std::vector<std::shared_ptr<IOutput>> getOptimizableOutputs() override;
         
-        std::string setType(const std::string& type) override;
+        std::string getGeneratorKey() override;
         std::string getType() override;
-        std::string getID() override;
+        std::string setName(const std::string& name) override;
+        std::string getName() override;
         std::string setAppendix(int appendix) override;
         int getAppendix() override;
+        std::string getID() override;
     
         void load(const json& j) override;
         json dump() override;

+ 4 - 4
lib/include/Generator.h

@@ -2,16 +2,16 @@
 
 #include <map>
 #include <string>
-#include "IGenerator.h"
+#include "IModuleGenerator.h"
 
 namespace mdd
 {
 	template <class MODULE_CLASS>
-	class Generator
-		: public IGenerator
+	class ModuleGenerator
+		: public IModuleGenerator
 	{
 
-		virtual std::shared_ptr<IModule> generate()
+		std::shared_ptr<IModule> generate() override
 		{
 			return std::make_shared<MODULE_CLASS>();
 		}

+ 21 - 0
lib/include/OptimizerGenerator.h

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <map>
+#include <string>
+#include "IOptimizerGenerator.h"
+
+namespace mdd
+{
+	template <class OPTIMIZER_CLASS>
+	class OptimizerGenerator
+		: public IOptimizerGenerator
+	{
+
+		std::shared_ptr<IOptimizer> generate() override
+		{
+			return std::make_shared<OPTIMIZER_CLASS>();
+		}
+	};
+}
+
+//#define ADD_GENERATOR(CLASS) namespace{mdd::GeneratorRegistration<CLASS> reg_sdewfdsf(#CLASS);}

+ 15 - 4
lib/include/Output.h

@@ -8,14 +8,18 @@ namespace mdd {
     private:
         state _state;
         std::vector<double> _value;
-        std::string _type;
+        std::string _name;
         int _appendix;
         std::vector<std::shared_ptr<IInput>> _connections;
         bool _optimizable;
         IModule* _parent;
 
+    protected:
+        std::string type;
+        std::string key;
+
     public:
-        Output(IModule* parent, const std::string& type, int appendix, const std::vector<double>& initial);
+        Output(IModule* parent, const std::string& name, int appendix, const std::vector<double>& initial);
         const std::vector<double>& getValue() override;
         std::vector<double>& setValue() override;
         state setValue(const std::vector<double>& val) override;
@@ -23,17 +27,24 @@ namespace mdd {
         void setOptimizability(bool state);
         state getState() override;
         void resetState() override;
-        std::string setType(const std::string& type) override;
         std::string getType() override;
-        std::string getID() override;
+        std::string getGeneratorKey() override;
+        std::string setName(const std::string& name) override;
+        std::string getName() override;
         std::string setAppendix(int appendix) override;
         int getAppendix() override;
+        std::string getID() override;
         std::string getParentID() override;
         int addConnection(std::shared_ptr<IInput> input) override;
         int removeConnection(std::shared_ptr<IInput> input) override;
         bool connect(std::shared_ptr<IInput> input) override;
         std::vector<std::shared_ptr<IInput>> getConnections() override;
         void disconnect() override;
+
+        bool configure(const std::string& config) override;
+        std::string getConfiguration() override;
+        void load(const json& j) override;
+        json dump() override;
     };
 }
 #endif

+ 1 - 1
lib/include/Parameter.h

@@ -8,7 +8,7 @@ namespace mdd {
     public:
         Parameter(IModule* parent);
         state update() override;
-        std::string setType(const std::string& type) override;
+        std::string setName(const std::string& type) override;
         std::string setAppendix(int appendix) override;
         bool configure(const std::string& config) override;
         std::string getConfiguration() override;

+ 7 - 5
lib/include/ProcessorBase.h

@@ -11,13 +11,14 @@ namespace mdd {
     class ProcessorBase : public IProcessor{
     private:
 
-        std::string _type = "";
+        std::string _name = "";
         int _appendix = 0;
         std::string _base_config = "";
 
     protected:
         ProcessorBase(const std::string& base_config);
-
+        std::string type = "processor";
+        std::string key;
         std::vector<std::shared_ptr<Input>>processor_inputs;
         std::vector<std::shared_ptr<Output>> processor_outputs;
         std::vector<std::shared_ptr<IModule>> modules;
@@ -28,12 +29,13 @@ namespace mdd {
         bool configure(const std::string& config);
         std::string getConfiguration() override;
 
-        std::string getID() override ;
-        std::string setType(const std::string& type) override;
+        std::string getGeneratorKey() override;
         std::string getType() override;
-        
+        std::string setName(const std::string& name) override;
+        std::string getName() override;
         std::string setAppendix(int appendix) override;
         int getAppendix() override;
+        std::string getID() override;
 
         std::string addModule(std::shared_ptr<IModule> module) override ;
         void removeModule(std::shared_ptr<IModule> module) override;

+ 20 - 0
lib/include/ProcessorGenerator.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include <map>
+#include <string>
+#include "IProcessorGenerator.h"
+
+namespace mdd
+{
+	template <class PROCESSOR_CLASS>
+	class ProcessorGenerator
+		: public IProcessorGenerator
+	{
+		std::shared_ptr<IProcessor> generate() override
+		{
+			return std::make_shared<PROCESSOR_CLASS>();
+		}
+	};
+}
+
+//#define ADD_GENERATOR(CLASS) namespace{mdd::GeneratorRegistration<CLASS> reg_sdewfdsf(#CLASS);}

+ 40 - 6
lib/include/Registration.h

@@ -2,29 +2,63 @@
 #include <mutex>
 #include <map>
 #include <memory>
-#include <IGenerator.h>
+#include <ModuleGenerator.h>
+#include <ProcessorGenerator.h>
+#include <OptimizerGenerator.h>
 
-#define REGISTER(CLASS) registerGenerator<CLASS>(#CLASS);
+#define REGISTER_MODULE(CLASS) registerModuleGenerator<CLASS>(#CLASS);
+#define REGISTER_PROCESSOR(CLASS) registerProcessorGenerator<CLASS>(#CLASS);
+#define REGISTER_OPTIMIZER(CLASS) registerOptimizerGenerator<CLASS>(#CLASS);
 
 namespace mdd {
 	class Registration {
 	private:
-		std::map<std::string, std::shared_ptr<IGenerator>> _gens;
+		std::map<std::string, std::shared_ptr<IModuleGenerator>> _modules;
+		std::map<std::string, std::shared_ptr<IProcessorGenerator>> _processors;
+		std::map<std::string, std::shared_ptr<IOptimizerGenerator>> _optimizers;
 		//std::mutex _mutex;
 	public:
 		template<class MODULE_CLASS>
-		void registerGenerator(const std::string& name) {
-			auto generator = std::make_shared<Generator<MODULE_CLASS>>();
+		void registerModuleGenerator(const std::string& name) {
+			auto generator = std::make_shared<ModuleGenerator<MODULE_CLASS>>();
 			if (generator != nullptr)
 			{
 				//_mutex.lock();
-				_gens[name] = generator;
+				_modules[name] = generator;
+				//_mutex.unlock();
+			}
+		}
+
+		template<class PROCESSOR_CLASS>
+		void registerProcessorGenerator(const std::string& name) {
+			auto generator = std::make_shared<ProcessorGenerator<PROCESSOR_CLASS>>();
+			if (generator != nullptr)
+			{
+				//_mutex.lock();
+				_processors[name] = generator;
+				//_mutex.unlock();
+			}
+		}
+
+		template<class OPTIMIZER_CLASS>
+		void registerOptimizerGenerator(const std::string& name) {
+			auto generator = std::make_shared<OptimizerGenerator<OPTIMIZER_CLASS>>();
+			if (generator != nullptr)
+			{
+				//_mutex.lock();
+				_optimizers[name] = generator;
 				//_mutex.unlock();
 			}
 		}
 		Registration();
 		IModule::Ptr generateModule(const std::string& name);
 		std::vector<std::string> getModules();
+
+		IProcessor::Ptr generateProcessor(const std::string& name);
+		std::vector<std::string> getProcessors();
+
+		IOptimizer::Ptr generateOptimizer(const std::string& name);
+		std::vector<std::string> getOptimizers();
 	};
 }
 

+ 176 - 5
lib/src/Connector.cpp

@@ -1,16 +1,187 @@
 #include "Connector.h"
 namespace mdd {
-	std::shared_ptr<IModule> Connector::decode(const json& structure)
-	{
-		std::shared_ptr<IModule> ret;
 
+	bool Connector::contains_subj_obj_structure(const json& args) {
+		if (args.contains("object") && args.contains("subject"))
+		{
+			return true;
+		}
+
+		return false;
+	}
+
+	json Connector::add(const json& args) {
+		json ret;
+		if (!contains_subj_obj_structure(args))
+		{
+			return ret;
+		}
+		json sub = args["subject"];
+		if (!sub.contains("type"))
+		{
+			return ret;
+		}
+		ret["operation"] = "add";
+		json jargs;
+		if (sub["type"] == "processor")
+		{
+			jargs["subject"] = _root->dump();
+		}
+		else if(sub["type"] == "module")
+		{
+
+		}
+		else if (sub["type"] == "connection")
+		{
+
+		}
+		else if (sub["type"] == "input")
+		{
+
+		}
+		else if (sub["type"] == "output")
+		{
+
+		}
+		else if (sub["type"] == "configuration")
+		{
+
+		}
+		else {
+			json j;
+			return j;
+		}
+
+		json obj = args["object"];
+		if (!obj.contains("type"))
+		{
+			json j;
+			return j;
+		}
+		if (obj["type"] == "processor")
+		{
+
+		}
+		else if (obj["type"] == "module")
+		{
+			_root->addModule(Registration().generateModule(obj["key"].get<std::string>()));
+			jargs["object"] = _root->getModules().back()->dump();
+		}
+		else if (obj["type"] == "connection")
+		{
+
+		}
+		else if (obj["type"] == "input")
+		{
+
+		}
+		else if (obj["type"] == "output")
+		{
+
+		}
+		else if (obj["type"] == "configuration")
+		{
+
+		}
+		else {
+			return ret;
+		}
+		ret["args"] = jargs;
 		return ret;
 	}
-	const json&  Connector::encode(const std::shared_ptr<IModule>& module)
+
+	json Connector::remove(const json& args) {
+
+		return args;
+	}
+
+	json Connector::change(const json& args) {
+
+		return args;
+	}
+
+	json Connector::state(const json& args) {
+		json j;
+		bool found = false;
+		if (args == "all")
+		{
+			j = encode();
+		}
+		if (args.contains("module"))
+		{
+			found = true;
+			if (args["module"] == "all")
+			{
+				
+				auto modules = regi.getModules();
+				for (size_t i = 0; i < modules.size(); i++)
+				{
+					json jmodule;
+					jmodule["key"] = modules[i];
+					jmodule["type"] = "module";
+					j["module"].push_back(jmodule);
+				}
+			}
+		}
+		if (args.contains("processor"))
+		{
+			found = true;
+			if (args["processor"] == "all")
+			{
+				auto processors = regi.getProcessors();
+				for (size_t i = 0; i < processors.size(); i++)
+				{
+					json jprocessor;
+					jprocessor["key"] = processors[i];
+					jprocessor["type"] = "module";
+					j["processor"].push_back(jprocessor);
+				}
+			}
+		}
+		if (!found)
+		{
+			j["error"] = "Reached end of state parser!";
+		}
+		//std::cout << "[Connector]: state: " << j.dump() << std::endl;
+		json ret;
+		ret["operation"] = "state";
+		ret["args"] = j;
+		return ret;
+	}
+
+	Connector::Connector()
+	{
+		_root = regi.generateProcessor("ProcessorStandard");
+		_root->setName("root");
+	}
+
+	json Connector::decode(const json& request)
 	{
 		json ret;
-		ret["test"]= "";
 
+		// check for correct structure
+		if (!request.contains("operation") || !request.contains("args")) {
+			ret["error"] = "Missing json member!";
+			std::cout << "[Connector]: " << "Missing json member!" << std::endl;
+			return ret;
+		}
+		
+		auto it = _ops.find(request["operation"].get<std::string>());
+		if (it != _ops.end())
+		{
+			ret = it->second(request["args"]);
+			//std::cout << "[Connector]: " << ret.dump() << std::endl;
+			return ret;
+		}
+		ret["error"] = "Operation is not supported!";
+		return ret;
+	}
+
+	json  Connector::encode()
+	{
+		json ret;
+		ret = _root->dump();
+		std::cout << "[Connector]: encode: " << ret.dump() << std::endl;
 		return ret;
 	}
 

+ 66 - 9
lib/src/Input.cpp

@@ -11,26 +11,34 @@ namespace mdd{
         _output = nullptr;
         return 0;
     }
-    Input::Input(IModule* parent, const std::string& type, int appendix, const std::vector<double>& default_value) {
+    Input::Input(IModule* parent, const std::string& name, int appendix, const std::vector<double>& default_value) {
         _parent = parent;
-        _type = type;
+        _name = name;
         _value = default_value;
         _appendix = appendix;
         _optimizable = false;
 
+        type = "input";
+        key = "Input";
     }
 
-    std::string Input::setType(const std::string& type){
-        _type = type;
-        return getID();
+    std::string Input::getType() {
+        return  type;
     }
-    std::string Input::getType(){
-        return  _type;
+
+    std::string Input::getGeneratorKey() {
+        return  key;
     }
-    std::string Input::getID(){
-        return _type + std::to_string(_appendix);
+ 
+    std::string Input::setName(const std::string& name){
+        _name = name;
+        return getID();
     }
 
+    std::string Input::getName() {
+        return  _name;
+    }
+    
     std::string Input::setAppendix(int appendix){
         _appendix = appendix;
         return  getID();
@@ -40,6 +48,10 @@ namespace mdd{
         return _appendix;
     }
 
+    std::string Input::getID() {
+        return _name + std::to_string(_appendix);
+    }
+
     std::string Input::getParentID() {
         return _parent->getID();
     }
@@ -110,4 +122,49 @@ namespace mdd{
     {
         return _limit;
     }
+
+    bool Input::configure(const std::string& config) 
+    {
+        json jconfig = json::parse(config);
+        if (jconfig.contains("name"))
+        {
+            _name = jconfig["name"].get < std::string >();
+        }
+        if (jconfig.contains("appendix"))
+        {
+            _appendix = jconfig["appendix"].get < int >();
+        }
+        if (jconfig.contains("optimizable"))
+        {
+            _optimizable = jconfig["optimizable"].get < bool >();
+        }
+        if (jconfig.contains("value"))
+        {
+            _value = jconfig["value"].get <std::vector<double> >();
+        }
+        return true;
+    }
+
+    std::string Input::getConfiguration() 
+    {
+        json jconfig;
+        jconfig["name"] = _name;
+        jconfig["appendix"] = _appendix;
+        jconfig["value"] = _value;
+        jconfig["prefix"].push_back(_parent->getID());
+        jconfig["optimizable"] = _optimizable;
+        return jconfig.dump();
+    }
+
+    void Input::load(const json& j) 
+    {
+        configure(j.dump());
+        return;
+    }
+
+    json Input::dump() 
+    {
+        json jdump = json::parse(getConfiguration());
+        return jdump;
+    }
 }

+ 37 - 13
lib/src/ModuleBase.cpp

@@ -11,14 +11,6 @@ namespace mdd {
         return outputs.size();
     }
 
-    std::string ModuleBase::setType(const std::string& type){
-        _type=type;
-        return getID();
-    }
-    std::string ModuleBase::getType(){
-        return _type;
-    }
-
 
     std::shared_ptr<IInput> ModuleBase::getInput(size_t index) {
         if (index <= inputs.size())
@@ -91,19 +83,36 @@ namespace mdd {
         return _base_config;
     }
 
-    std::string ModuleBase::getID(){
-        return _type + std::to_string(_appendix);
+    std::string ModuleBase::getType() {
+        return  type;
     }
 
-    std::string ModuleBase::setAppendix(int appendix){
-        _appendix = appendix;
+    std::string ModuleBase::getGeneratorKey() {
+        return  key;
+    }
+
+    std::string ModuleBase::setName(const std::string& name) {
+        _name = name;
         return getID();
     }
 
+    std::string ModuleBase::getName() {
+        return  _name;
+    }
+
+    std::string ModuleBase::setAppendix(int appendix) {
+        _appendix = appendix;
+        return  getID();
+    }
+
     int ModuleBase::getAppendix() {
         return _appendix;
     }
 
+    std::string ModuleBase::getID() {
+        return _name + std::to_string(_appendix);
+    }
+
     void ModuleBase::load(const json& j)
     {
         if (j.contains("configure"))
@@ -114,8 +123,23 @@ namespace mdd {
     json ModuleBase::dump()
     {
         json ret;
+        ret["name"] = _name;
+        ret["id"] = getAppendix();
+        ret["type"] = type;
+        ret["key"] = key;
+        ret["prefix"] = std::vector<std::string>();
+        json configure = json::parse(_base_config);
+        ret["configure"] = configure;
+
+        for (auto& in : inputs)
+        {
+            ret["inputs"].push_back(in->dump());
+        }
 
-        ret["configure"] = _base_config;
+        for (auto& out : outputs)
+        {
+            ret["outputs"].push_back(out->dump());
+        }
 
         return ret;
     }

+ 3 - 3
lib/src/ModuleHTTP.cpp

@@ -1,7 +1,6 @@
 #include <httplib.h>
 #include <iostream>
 #include <thread>
-#include <Generator.h>
 #include <boost/process.hpp>
 #include <filesystem>
 
@@ -89,7 +88,7 @@ namespace mdd{
             vec.erase(vec.end() + diff, vec.end());
         }
         for(size_t i=0; i < vec.size(); i++){
-            vec[i]->setType(server[i]["type"].get<std::string>());
+            vec[i]->setName(server[i]["type"].get<std::string>());
             vec[i]->setAppendix(i);
             vec[i]->setValue() = server[i]["value"].get<std::vector<double>>();
         }
@@ -149,7 +148,8 @@ namespace mdd{
         }])JSON")
         ,_port(0)
     {
-        setType("HTTP");
+        key = "ModuleHTTP";
+        setName("HTTP");
     }
 
     bool ModuleHTTP::configure(const std::string& config) {

+ 3 - 1
lib/src/ModuleMath.cpp

@@ -56,7 +56,8 @@ namespace mdd {
         inputs.push_back(std::make_shared<Input>(this, "Value", 0, default_val));
         inputs.push_back(std::make_shared<Input>(this, "Value", 1, default_val));
         outputs.push_back(std::make_shared<Output>(this, "Value", 0, default_val));
-        setType("Math");
+        key = "ModuleMath";
+        setName("Math");
     }
 
     bool ModuleMath::configure(const std::string& config)
@@ -86,6 +87,7 @@ namespace mdd {
         json ret = json::parse(ModuleBase::getConfiguration());
         for (auto it = _ops.begin(); it != _ops.end(); it++)
         {
+            //test by doing the operation with two given values
             if (it->second(256,2) == _operation(256, 2)) {
                 ret[0]["value"] = it->first;
                 break;

+ 6 - 5
lib/src/ModuleMerge.cpp

@@ -9,7 +9,7 @@ namespace mdd {
 		ModuleMerge();
 		int addModuleInput();
 		int removeModuleInput();
-		std::string setInputType(const std::string& input_id, const std::string& new_type);
+		std::string setInputName(const std::string& input_id, const std::string& new_name);
 		bool configure(const std::string& config) override;
 		std::string getConfiguration() override;
 		state update() override;
@@ -25,7 +25,8 @@ namespace mdd {
 		inputs.push_back(std::make_shared<Input>(this, "Value", 0, default_val));
 		inputs.push_back(std::make_shared<Input>(this, "Value", 1, default_val));
 		outputs.push_back(std::make_shared<Output>(this, "Value", 0, default_val));
-		setType("Merge");
+		key = "ModuleMerge";
+		setName("Merge");
 	}
 
 	int ModuleMerge::addModuleInput() {
@@ -39,10 +40,10 @@ namespace mdd {
 		return inputs.size();
 	}
 
-	std::string ModuleMerge::setInputType(const std::string& input_id, const std::string& new_type) {
+	std::string ModuleMerge::setInputName(const std::string& input_id, const std::string& new_name) {
 		for (int id = 0; id < inputs.size(); ++id) {
 			if (getInput(id)->getID() == input_id) {
-				getInput(id)->setType(new_type);
+				getInput(id)->setName(new_name);
 				return getInput(id)->getID();
 			}
 		}
@@ -64,7 +65,7 @@ namespace mdd {
 					}
 					for (size_t j = 0; j < length; j++)
 					{
-						inputs[j]->setType(config_parsed[i]["value"][j]["type"].get<std::string>());
+						inputs[j]->setName(config_parsed[i]["value"][j]["type"].get<std::string>());
 						inputs[j]->setValue(config_parsed[i]["value"][j]["value"].get<std::vector<double>>());
 					}
 				}

+ 2 - 1
lib/src/ModuleSQL.cpp

@@ -44,7 +44,8 @@ namespace mdd {
             "value":""
         }])JSON")
 	{
-		setType("SQL");
+		key = "ModuleSQL";
+		setName("SQL");
 	}
 
 	state ModuleSQL::update() {

+ 4 - 3
lib/src/ModuleSwitch.cpp

@@ -20,7 +20,8 @@ namespace mdd{
         inputs.push_back(std::make_shared<Input>(this, "Switch", 0, default_val));
         inputs.push_back(std::make_shared<Input>(this, "Default", 0, default_val));
         outputs.push_back(std::make_shared<Output>(this, "Value", 0, default_val));
-        setType("Switch");
+        key = "ModuleSwitch";
+        setName("Switch");
     }
     bool ModuleSwitch::configure(const std::string& config) {
         json config_parsed = json::parse(config);
@@ -36,7 +37,7 @@ namespace mdd{
                         size_t length_before = inputs.size();
                         if (length_before != 1)
                         {
-                            inputs.back()->setType("Value");
+                            inputs.back()->setName("Value");
                         }
                         
                         for (size_t j = length_before - 1; j < length; j++)
@@ -49,7 +50,7 @@ namespace mdd{
                         }
                         if (length != 0)
                         {
-                            inputs.back()->setType("Default");
+                            inputs.back()->setName("Default");
                         }
                     }
                     return true;

+ 74 - 11
lib/src/Output.cpp

@@ -15,14 +15,17 @@ namespace mdd {
         }
         return _connections.size();
     }
-    Output::Output(IModule* parent, const std::string& type, int appendix, const std::vector<double>& initial) :
+    Output::Output(IModule* parent, const std::string& name, int appendix, const std::vector<double>& initial) :
             _state(state::UNCHANGED),
             _parent(parent)
     {
         _appendix = appendix;
-        _type = type;
+        _name = name;
         _value = initial;
         _optimizable = false;
+
+        type = "output";
+        key = "Output";
     }
 
     const std::vector<double>& Output::getValue() { return _value; }
@@ -49,30 +52,45 @@ namespace mdd {
     void Output::setOptimizability(bool state) {
         _optimizable = state;
     }
-    std::string Output::getType() { return _type; }
 
-    state Output::getState() { return _state; } 
+    state Output::getState() {
+        return _state;
+    }
+    
+    void Output::resetState() {
+        _state = state::UNCHANGED;
+    }
+
+    std::string Output::getType() {
+        return  type;
+    }
 
-    void Output::resetState() { _state = state::UNCHANGED; }
+    std::string Output::getGeneratorKey() {
+        return  key;
+    }
 
-    std::string Output::setType(const std::string& type){
-        _type = type;
+    std::string Output::setName(const std::string& name) {
+        _name = name;
         return getID();
     }
 
-    std::string Output::getID(){
-        return _type + std::to_string(_appendix);
+    std::string Output::getName() {
+        return  _name;
     }
 
-    std::string Output::setAppendix(int appendix){
+    std::string Output::setAppendix(int appendix) {
         _appendix = appendix;
-        return getID();
+        return  getID();
     }
 
     int Output::getAppendix() {
         return _appendix;
     }
 
+    std::string Output::getID() {
+        return _name + std::to_string(_appendix);
+    }
+
     std::string Output::getParentID() {
         return _parent->getID();
     }
@@ -97,4 +115,49 @@ namespace mdd {
         }
         _connections.clear();
     }
+
+    bool Output::configure(const std::string& config)
+    {
+        json jconfig = json::parse(config);
+        if (jconfig.contains("name"))
+        {
+            _name = jconfig["name"].get < std::string >();
+        }
+        if (jconfig.contains("appendix"))
+        {
+            _appendix = jconfig["appendix"].get < int >();
+        }
+        if (jconfig.contains("optimizable"))
+        {
+            _optimizable = jconfig["optimizable"].get < bool >();
+        }
+        if (jconfig.contains("value"))
+        {
+            _value = jconfig["value"].get <std::vector<double> >();
+        }
+        return true;
+    }
+
+    std::string Output::getConfiguration()
+    {
+        json jconfig;
+        jconfig["name"] = _name;
+        jconfig["appendix"] = _appendix;
+        jconfig["value"] = _value;
+        jconfig["prefix"].push_back(_parent->getID());
+        jconfig["optimizable"] = _optimizable;
+        return jconfig.dump();
+    }
+
+    void Output::load(const json& j)
+    {
+        configure(j.dump());
+        return;
+    }
+
+    json Output::dump()
+    {
+        json jdump = json::parse(getConfiguration());
+        return jdump;
+    }
 }

+ 7 - 5
lib/src/Parameter.cpp

@@ -12,17 +12,19 @@ namespace mdd {
         std::vector<double> default_val = { 1 };
         inputs.push_back(std::make_shared<Input>(parent, "Value", 0, default_val));
         outputs.push_back(std::make_shared<Output>(parent, "Value", 0, default_val));
-        setType("Parameter");
+        
+        key = "Parameter";
+        setName(key);
     }
 
     state Parameter::update() {
         return getOutput(0)->setValue(getInput(0)->getValue());
     }
 
-    std::string Parameter::setType(const std::string& type) {
-        inputs[0]->setType(type);
-        outputs[0]->setType(type);
-        return ModuleBase::setType(type);
+    std::string Parameter::setName(const std::string& name) {
+        inputs[0]->setName(name);
+        outputs[0]->setName(name);
+        return ModuleBase::setName(name);
     }
 
     std::string Parameter::setAppendix(int appendix)

+ 51 - 12
lib/src/ProcessorBase.cpp

@@ -18,7 +18,7 @@ namespace mdd{
                     for (size_t i = 0; i < j["inputs"].size(); i++)
                     {
                         inputs.push_back(std::make_shared<Parameter>(this));
-                        inputs.back()->setType(j["inputs"][i]["type"].get<std::string>());
+                        inputs.back()->setName(j["inputs"][i]["type"].get<std::string>());
                         inputs.back()->setAppendix(j["inputs"][i]["appendix"].get<int>());
                     }
                 }
@@ -27,7 +27,7 @@ namespace mdd{
                     for (size_t i = 0; i < j["outputs"].size(); i++)
                     {
                         outputs.push_back(std::make_shared<Parameter>(this));
-                        outputs.back()->setType(j["outputs"][i]["type"].get<std::string>());
+                        outputs.back()->setName(j["outputs"][i]["type"].get<std::string>());
                         outputs.back()->setAppendix(j["outputs"][i]["appendix"].get<int>());
                     }
                 }
@@ -38,7 +38,7 @@ namespace mdd{
                 for (size_t i = 0; i < j["modules"].size(); i++)
                 {
                     addModule(regi.generateModule(j["modules"][i]["id"].get<std::string>()));
-                    modules.back()->setType(j["modules"][i]["type"].get<std::string>());
+                    modules.back()->setName(j["modules"][i]["type"].get<std::string>());
                     modules.back()->setAppendix(j["modules"][i]["appendix"].get<int>());
                     modules.back()->load(j["modules"][i]["load"]);
                 }
@@ -106,27 +106,36 @@ namespace mdd{
         return ret.dump();
     }
 
-    std::string ProcessorBase::getID() {
-        return _type + std::to_string(_appendix);
+    std::string ProcessorBase::getType() {
+        return  type;
+    }
+
+    std::string ProcessorBase::getGeneratorKey() {
+        return  key;
     }
 
-    std::string ProcessorBase::setType(const std::string& type){
-        _type=type;
+    std::string ProcessorBase::setName(const std::string& name) {
+        _name = name;
         return getID();
     }
-    std::string ProcessorBase::getType(){
-        return _type;
+
+    std::string ProcessorBase::getName() {
+        return  _name;
     }
 
-    std::string ProcessorBase::setAppendix(int appendix){
+    std::string ProcessorBase::setAppendix(int appendix) {
         _appendix = appendix;
-        return getID();
+        return  getID();
     }
 
     int ProcessorBase::getAppendix() {
         return _appendix;
     }
 
+    std::string ProcessorBase::getID() {
+        return _name + std::to_string(_appendix);
+    }
+
 
     std::string ProcessorBase::addModule(std::shared_ptr<IModule> module){
         modules.emplace_back(module);
@@ -247,7 +256,37 @@ namespace mdd{
     }
 
     json ProcessorBase::dump() {
-        return json();
+        json ret;
+        ret["name"] = _name;
+        ret["id"] = getAppendix();
+        ret["type"] = type;
+        ret["key"] = key;
+        ret["prefix"] = std::vector<std::string>();
+        ret["configure"] = json::parse(_base_config);
+        
+
+        for (auto& in : processor_inputs)
+        {
+            ret["inputs"].push_back(in->dump());
+        }
+        for (auto& in : inputs)
+        {
+            ret["inputs"].push_back(in->getInput(0)->dump());
+        }
+
+        for (auto& out : processor_outputs)
+        {
+            ret["outputs"].push_back(out->dump());
+        }
+        for (auto& out : outputs)
+        {
+            ret["outputs"].push_back(out->getInput(0)->dump());
+        }
+        for (auto& mod : modules)
+        {
+            ret["modules"].push_back(mod->dump());
+        }
+        return ret;
     }
 
     std::shared_ptr<IOutput> ProcessorBase::getOutput(size_t index) {

+ 3 - 1
lib/src/ProcessorStandard.cpp

@@ -20,7 +20,9 @@ namespace mdd {
     {
         _priorityEvaluation = MANUAL;
         _maxIterations = -1;
-        setType("StandardProcessor");
+        
+        key = "StandardProcessor";
+        setName(key);
         processor_outputs.push_back(std::make_shared<Output>(this, "Iterator", 0, std::vector<double>{0}));
     }
 

+ 54 - 13
lib/src/Registration.cpp

@@ -2,7 +2,6 @@
 #include "Registration.h"
 #include <map>
 #include <string>
-#include "IGenerator.h"
 
 #include "ModuleHTTP.cpp"
 #include "ModuleMath.cpp"
@@ -17,28 +16,70 @@ namespace mdd
 {
 	Registration::Registration()
 	{
-		REGISTER(ModuleHTTP);
-		REGISTER(ModuleMath);
-		REGISTER(ModuleMerge);
-		//REGISTER(ModuleSplitt);
-		REGISTER(ModuleSQL);
-		REGISTER(ModuleSwitch);
-
-		REGISTER(ProcessorStandard);
+		REGISTER_MODULE(ModuleHTTP);
+		REGISTER_MODULE(ModuleMath);
+		REGISTER_MODULE(ModuleMerge);
+		//REGISTER_MODULE(ModuleSplitt);
+		REGISTER_MODULE(ModuleSQL);
+		REGISTER_MODULE(ModuleSwitch);
+		//REGISTER_MODULE(Parameter);
+
+		REGISTER_MODULE(ProcessorStandard);
+
+		REGISTER_PROCESSOR(ProcessorStandard);
 	}
 	IModule::Ptr Registration::generateModule(const std::string& name)
 	{
-		auto it = _gens.find(name);
-		if (it != _gens.end())
+		auto it = _modules.find(name);
+		if (it != _modules.end())
 		{
 			return it->second->generate();
 		}
 		return nullptr;
 	}
 
-	std::vector<std::string> Registration::getModules() {
+	std::vector<std::string> Registration::getModules() 
+	{
+		std::vector<std::string> ret;
+		for (auto it = _modules.begin(); it != _modules.end(); ++it)
+		{
+			ret.push_back(it->first);
+		}
+		return ret;
+	}
+
+	IProcessor::Ptr Registration::generateProcessor(const std::string& name) 
+	{
+		auto it = _processors.find(name);
+		if (it != _processors.end())
+		{
+			return it->second->generate();
+		}
+		return nullptr;
+	}
+	std::vector<std::string> Registration::getProcessors() 
+	{
+		std::vector<std::string> ret;
+		for (auto it = _processors.begin(); it != _processors.end(); ++it)
+		{
+			ret.push_back(it->first);
+		}
+		return ret;
+	}
+
+	IOptimizer::Ptr Registration::generateOptimizer(const std::string& name)
+	{
+		auto it = _optimizers.find(name);
+		if (it != _optimizers.end())
+		{
+			return it->second->generate();
+		}
+		return nullptr;
+	}
+	std::vector<std::string> Registration::getOptimizers() 
+	{
 		std::vector<std::string> ret;
-		for (auto it = _gens.begin(); it != _gens.end(); ++it)
+		for (auto it = _optimizers.begin(); it != _optimizers.end(); ++it)
 		{
 			ret.push_back(it->first);
 		}

+ 26 - 97
lib/test/server/gfk_plate.py

@@ -4,6 +4,8 @@ import pyansys
 import numpy as np
 import os
 import time
+from scipy import sparse
+from scipy.sparse import linalg
 
 
 def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thickness=0.005, omega=1):
@@ -118,6 +120,7 @@ def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thi
 
     mapdl.esel("ALL")
 
+    # Read Stress
     mapdl.run("/SOLU")
     mapdl.csys(1)
     mapdl.omega("", "", omega)
@@ -134,124 +137,50 @@ def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thi
     mapdl.solve()
     mapdl.finish()
 
-    # """
-    # mapdl.run("/INPUT, C:/Users/Willi/Documents/projects/gfk-plate/script/01_Modell.inp")
-
-    # mapdl.solve()
-    # mapdl.finish()
-
     mapdl.run("/Post1")
 
     result = mapdl.result
-    # mapdl.aplot()
-    # result.plot_principal_nodal_stress(0, '1', show_edges=True, show_axes=True)
-    result.plot_nodal_solution(0, 'z', show_displacement=True)
-    result.plot_principal_nodal_stress(0, 'S1', show_edges=True, show_axes=True)
+    # result.plot_nodal_solution(0, 'z', show_displacement=True)
+    # result.plot_principal_nodal_stress(0, 'S1', show_edges=True, show_axes=True)
 
     # """
     nodenump, stress = result.principal_nodal_stress(0)
-
-    # von first principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
-
-    """
-    mapdl.run('*GET, NODE_COUNT, NODE, ,COUNT')
-    mapdl.run('*GET, ELEM_COUNT, ELEM, ,COUNT')
-    mapdl.load_parameters()
-    print(mapdl.parameters['NODE_COUNT'])
-    print(mapdl.parameters['ELEM_COUNT'])
-
-    s1max = angles
-    s2max = angles
-    srmax = angles
-    stmax = angles
-
-    for i in range(0, len(angles)):
-        mapdl.run("LAYER, " + str(i + 1))  #
-        mapdl.run("*DIM, DIM_TEST, ARRAY, ELEM_COUNT, 2")
-        mapdl.run("ETABLE, TEST, S, 1, MAX")
-        mapdl.run("*VGET, DIM_TEST(1,1), ETAB, TEST")
-
-        mapdl.run("*DIM, OUT_STRESS, ARRAY, NODE_COUNT, 4")
-        mapdl.run("*VGET, OUT_STRESS(1, 1), NODE,, S, 1")
-        mapdl.run("*VGET, OUT_STRESS(1, 2), NODE,, S, 2")
-        mapdl.run("*VGET, OUT_STRESS(1, 3), NODE,, S, X")
-        mapdl.run("*VGET, OUT_STRESS(1, 4), NODE,, S, Y")
-        params, arrays = mapdl.load_parameters()
-        print(arrays['TEST'][0])
-        s1max[i] = np.nanmax(arrays['OUT_STRESS'][:, 0])
-        s2max[i] = np.nanmax(arrays['OUT_STRESS'][:, 1])
-        srmax[i] = np.nanmax(arrays['OUT_STRESS'][:, 2])
-        stmax[i] = np.nanmax(arrays['OUT_STRESS'][:, 3])
-
-        # print(str(element_stress[0]))
-        # s1max = np.nanmax(stresses)
-        # nodenump, stress = result.principal_nodal_stress(0)
-        # s1max[i] = np.nanmax(element_stress[:, -5])
-    
-    s1max = np.nanmax(s1max)
-    s2max = np.nanmax(s2max)
-    srmax = np.nanmax(srmax)
-    stmax = np.nanmax(stmax)
-    # """
-    nodenump, stress = result.principal_nodal_stress(0)
-
-    # von first principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
     s1max = np.nanmax(stress[:, -5])
-
-    # von second principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
     s2max = np.nanmax(stress[:, -4])
 
     nodenum, stress = result.nodal_stress(0)
-    # von Mises stress is the last column
-    # must be nanmax as the shell element stress is not recorded
     srmax = np.nanmax(stress[:, -6])
     stmax = np.nanmax(stress[:, -5])
-    # von second principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
-    #s2max = np.nanmax(stress[:, -4])
-
-    #nodenum, stress = result.nodal_stress(0)
-    # von Mises stress is the last column
-    # must be nanmax as the shell element stress is not recorded
-    #srmax = np.nanmax(stress[:, -6])
-    #stmax = np.nanmax(stress[:, -5])
-
-    print(str(s1max))
 
+    # Modual-Analysis
     # """
+    mapdl.run("/SOLU")
+    mapdl.csys(1)
+    mapdl.omega("", "", omega)
+    mapdl.nsel("S", "LOC", "X", inner_diameter / 2)
+    mapdl.d("ALL", "UX", 0)
+    mapdl.d("ALL", "UY", 0)
+    mapdl.nsel("R", "LOC", "Z", 0)
+    mapdl.d("ALL", "UZ", 0)
+    mapdl.run("ALLS")
+    mapdl.outres("ALL", "ALL")
 
-    """
-    # access results using ANSYS object
-    resultfile = os.getcwd() + '\\ws\\file.rst'
-    result = pyansys.read_binary(resultfile)
-
-    # plot_nodal_solution doesnt work
-    nodenump, stress = result.principal_nodal_stress(0)
-
-    # von first principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
-    s1max = np.nanmax(stress[:, -5])
+    mapdl.antype("MODAL")
+    mapdl.modopt("lanb", 3)
+    mapdl.mxpand("", "", "", "yes")
 
-    # von second principle stress is the first column
-    # must be nanmax as the shell element stress is not recorded
-    s2max = np.nanmax(stress[:, -4])
+    mapdl.solve()
+    mapdl.finish()
+    
+    mapdl.run("/Post1")
 
-    nodenum, stress = result.nodal_stress(0)
-    # von Mises stress is the last column
-    # must be nanmax as the shell element stress is not recorded
-    srmax = np.nanmax(stress[:, -6])
-    stmax = np.nanmax(stress[:, -5])
+    result = mapdl.result
+    f = result.time_values
 
-    print(str(s1max))
-    # result.plot_nodal_solution(0)
-    # """
     mapdl.exit()
     time.sleep(0.5)
 
-    return s1max, s2max, srmax, stmax
+    return s1max, s2max, srmax, stmax, f[0], f[1], f[2]
 
 
 print(sim_rotor(

+ 8 - 5
lib/test/server/server-ansys.py

@@ -47,10 +47,13 @@ inputs = [
 ]
 
 outputs = [
-    {'type': "S1max", 'value': [0]},
-    {'type': "S2max", 'value': [2]},
-    {'type': "Srmax", 'value': [4]},
-    {'type': "Stmax", 'value': [4]}
+    {'type': "S1max", 'value':  [0]},
+    {'type': "S2max", 'value':  [1]},
+    {'type': "Srmax", 'value':  [2]},
+    {'type': "Stmax", 'value':  [3]},
+    {'type': "f1", 'value':     [1]},
+    {'type': "f2", 'value':     [2]},
+    {'type': "f3", 'value':     [3]}
 ]
 
 status = {
@@ -69,7 +72,7 @@ def update():
     while not success:
         try:
             outputs[0]['value'][0], outputs[1]['value'][0], outputs[2]['value'][0], outputs[3]['value'][
-                0] = gfk_plate.sim_rotor(materials, inputs[len(inputs) - 1]['value'])
+                0], outputs[4]['value'][0], outputs[5]['value'][0], outputs[6]['value'][0] = gfk_plate.sim_rotor(materials, inputs[len(inputs) - 1]['value'])
             success = True
         except PermissionError:
             print("Catch Error")

+ 74 - 31
server/src/main.cpp

@@ -7,11 +7,15 @@
 #include <zmq.hpp>
 #include "zhelpers.hpp"
 
+#include "ProcessorStandard.h"
+#include "Connector.h"
+
 using namespace mdd;
 class Server {
 private:
     zmq::context_t context;
     Registration regi = Registration();
+    Connector _connector = Connector();
 
     json msg_header() {
         json jmsg;
@@ -27,46 +31,47 @@ private:
         zmq::message_t reply(msg.size());
         memcpy(reply.data(), msg.c_str(), msg.size());
         reply_socket.send(reply);
+        std::cout << "[alive]: " << msg << std::endl;
     }
 
     void get_request(json request) {
 
-        json jans = msg_header();
-        if (request.contains("state")) {
-            if (request["state"].get<std::string>() == "all")
-            {
-                
-            }
-        }
-        if (request.contains("module")) {
-            if (request["module"].get<std::string>() == "all")
+        json jmsg = msg_header();
+        if (request.is_array())
+        {
+            for (size_t i = 0; i < request.size(); i++)
             {
-                jans["module"] = regi.getModules();
+                jmsg["receive"].push_back(_connector.decode(request[i]));
             }
         }
-        if (request.contains("process")) {
-            if (request["process"].get<std::string>() == "all")
-            {
-                jans["process"] = regi.getModules();
-            }
+        else {
+            //json test;
+            //test = _connector.decode(request);
+            //std::cout << "[Server]: get_request: " << test.dump() << std::endl;
+            jmsg["receive"] = _connector.decode(request);
         }
 
-        std::string msg = jans.dump();
+        std::string msg = jmsg.dump();
 
         //  Send reply back to client
         zmq::message_t reply(msg.size());
         memcpy(reply.data(), msg.c_str(), msg.size());
         reply_socket.send(reply);
+
+        std::cout << "[receive]: " << msg << std::endl;
     }
 
     void try_request(json request) {
-        json jmodule;
-        jmodule["type"] = "module";
         json jmsg = msg_header();
-        if (request.contains("add")) {
-            jmsg["id"] = request["id"];
-            jmodule["id"] = request["add"];
-            jmsg["add"] = jmodule;
+        if (request.is_array())
+        {
+            for (size_t i = 0; i < request.size(); i++)
+            {
+                jmsg["change"].push_back(_connector.decode(request[i]));
+            }
+        }
+        else {
+            jmsg["change"] = _connector.decode(request);
         }
 
         std::string smsg = jmsg.dump();
@@ -78,7 +83,7 @@ private:
 
         Sleep(500);
         try {
-            std::cout << "Send: " << stopic << ": " << smsg << std::endl;
+            std::cout << "[change]: " << stopic << ": " << smsg << std::endl;
             s_sendmore(publisher_socket, stopic);
             s_send(publisher_socket, smsg);
             //publisher_socket.send(topic, ZMQ_SNDMORE);
@@ -121,7 +126,7 @@ public:
         }
         catch (const std::exception&)
         {
-            std::cout << "[Server] recived wrong msg!" << std::endl;
+            std::cout << "[Server] received wrong msg!" << std::endl;
         }
         json msg;
         try
@@ -130,19 +135,57 @@ public:
         }
         catch (const std::exception&)
         {
-            std::cout << "[Server] recived wrong msg: " << request.to_string() << std::endl;
+            std::cout << "[Server] received wrong msg: " << request.to_string() << std::endl;
         }
-        if (msg.contains("try"))
+
+        json ans = msg_header();
+
+        //check for missmatch
+        if (msg.contains("serverID") && msg.contains("msgNr"))
         {
-            try_request(msg["try"]);
-            send_alive();
+            if (msg["serverID"] != ans["serverID"] || msg["msgNr"] != ans["msgNr"])
+            {
+                return send_alive();
+            }
         }
-        if (msg.contains("get"))
+        else {
+            return send_alive();
+        }
+
+
+        if (!msg.contains("context"))
         {
-            get_request(msg["get"]);
+            return send_alive();
         }
-        //
 
+        json jcontext = msg["context"];
+
+        if (jcontext.is_array())
+        {
+            for (size_t i = 0; i < jcontext.size(); i++)
+            {
+                if (jcontext[i].contains("try"))
+                {
+                    try_request(jcontext[i]["try"]);
+                    send_alive();
+                }
+                if (jcontext[i].contains("get"))
+                {
+                    get_request(jcontext[i]["get"]);
+                }
+            }
+        }
+        else {
+            if (jcontext.contains("try"))
+            {
+                try_request(jcontext["try"]);
+                send_alive();
+            }
+            if (jcontext.contains("get"))
+            {
+                get_request(jcontext["get"]);
+            }
+        }
         //  Do some 'work'
         Sleep(1000);