|
@@ -31,22 +31,7 @@ namespace mdd {
|
|
|
{
|
|
|
|
|
|
}
|
|
|
- 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;
|
|
@@ -76,7 +61,7 @@ namespace mdd {
|
|
|
for (size_t i = 0; i < module_in_ptr->getNumInputs(); i++)
|
|
|
{
|
|
|
auto in = module_in_ptr->getInput(i);
|
|
|
- auto id = obj["input"]["name"].get<std::string>() + std::to_string(obj["input"]["id"].get<int>());
|
|
|
+ auto id = obj["input"]["name"].get<std::string>() + std::to_string(obj["input"]["appendix"].get<int>());
|
|
|
if (in->getID() == id)
|
|
|
{
|
|
|
in_ptr = in;
|
|
@@ -88,7 +73,7 @@ namespace mdd {
|
|
|
for (size_t i = 0; i < module_in_ptr->getNumOutputs(); i++)
|
|
|
{
|
|
|
auto out = module_out_ptr->getOutput(i);
|
|
|
- auto id = obj["output"]["name"].get<std::string>() + std::to_string(obj["output"]["id"].get<int>());
|
|
|
+ auto id = obj["output"]["name"].get<std::string>() + std::to_string(obj["output"]["appendix"].get<int>());
|
|
|
if (out->getID() == id)
|
|
|
{
|
|
|
out_ptr = out;
|
|
@@ -156,34 +141,65 @@ namespace mdd {
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["id"].get<int>()));
|
|
|
+ IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
|
|
|
if (module_ptr == nullptr) {
|
|
|
std::cout << "[Connector]: change: Was not able to find module." << std::endl;
|
|
|
return ret;
|
|
|
}
|
|
|
jargs["subject"] = module_ptr->getIdentifier();
|
|
|
- if (module_ptr->configure(obj.dump()))
|
|
|
+ module_ptr->configure(obj.dump());
|
|
|
+ if (obj.contains("configure"))
|
|
|
{
|
|
|
+ jargs["object"]["configure"] = module_ptr->dump();
|
|
|
+ }
|
|
|
+ else {
|
|
|
jargs["object"] = obj;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else if (sub["type"] == "module")
|
|
|
{
|
|
|
- IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["id"].get<int>()));
|
|
|
+ IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
|
|
|
if (module_ptr == nullptr) {
|
|
|
std::cout << "[Connector]: change: Was not able to find module." << std::endl;
|
|
|
return ret;
|
|
|
}
|
|
|
jargs["subject"] = module_ptr->getIdentifier();
|
|
|
- if (module_ptr->configure(obj.dump()))
|
|
|
+ module_ptr->configure(obj.dump());
|
|
|
+ if (obj.contains("configure"))
|
|
|
{
|
|
|
+ jargs["object"]["configure"] = module_ptr->dump();
|
|
|
+ }
|
|
|
+ else {
|
|
|
jargs["object"] = obj;
|
|
|
}
|
|
|
}
|
|
|
else if (sub["type"] == "input")
|
|
|
{
|
|
|
-
|
|
|
+ IModule::Ptr module_ptr = _root->getModule(sub["prefix"].back().get<std::string>());
|
|
|
+ if (module_ptr == nullptr) {
|
|
|
+ std::cout << "[Connector]: change: Was not able to find module." << std::endl;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ IInput::Ptr in_ptr = module_ptr->getInput(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
|
|
|
+ if (in_ptr == nullptr) {
|
|
|
+ std::cout << "[Connector]: change: Was not able to find input." << std::endl;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ if (obj.contains("value"))
|
|
|
+ {
|
|
|
+ json jval = json::parse(obj["value"].get<std::string>());
|
|
|
+ if (!jval.is_array())
|
|
|
+ {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ jval.get<std::vector<double>>();
|
|
|
+ std::vector<double> new_val = jval.get<std::vector<double>>();
|
|
|
+ in_ptr->setValue(new_val);
|
|
|
+ jargs["subject"] = in_ptr->getIdentifier();
|
|
|
+ jargs["object"] = obj;
|
|
|
+ }
|
|
|
}
|
|
|
else if (sub["type"] == "output")
|
|
|
{
|