Commit d7bec0a5 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

WIP

parent 6da3921f
Pipeline #40763 failed with stage
in 1 minute and 12 seconds
......@@ -27,6 +27,7 @@ struct window_logger;
struct plot_output;
struct file_output;
struct file_discrete_output;
struct component_editor;
static inline constexpr int not_found = -1;
......@@ -34,6 +35,7 @@ enum class editor_id : u64;
enum class plot_output_id : u64;
enum class file_output_id : u64;
enum class file_discrete_output_id : u64;
enum class component_editor : u64;
using observation_output = std::variant<std::monostate,
plot_output_id,
......@@ -329,15 +331,35 @@ struct window_logger
const char* log_string(const log_status s) noexcept;
struct component
{};
enum class component_editor_status
{
modeling,
simulating
};
struct component_editor
{
small_string<16> name;
std::filesystem::path path;
modeling mod;
simulation sim;
external_source srcs;
component_editor_status status = component_editor_status::modeling;
ImNodesEditorContext* context = nullptr;
bool show = true;
bool show_minimap = true;
};
struct application
{
data_array<editor, editor_id> editors;
std::filesystem::path home_dir;
std::filesystem::path executable_dir;
std::vector<long long int> simulation_duration;
data_array<editor, editor_id> editors;
data_array<component_editor, component_editor_id> component_editors;
std::filesystem::path home_dir;
std::filesystem::path executable_dir;
std::vector<long long int> simulation_duration;
bool show_log = true;
bool show_simulation = true;
......
// Copyright (c) 2020 INRA Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef ORG_VLEPROJECT_IRRITATOR_APP_APPLICATION_2021
#define ORG_VLEPROJECT_IRRITATOR_APP_APPLICATION_2021
#endif
This diff is collapsed.
......@@ -13,6 +13,7 @@ namespace irt {
enum class component_id : u64;
enum class component_ref_id : u64;
enum class parameter_id : u64;
enum class description_id : u64;
enum class child_type : i8
{
......@@ -34,9 +35,15 @@ struct port;
struct component;
struct component_ref;
struct modeling;
struct description;
status build_simulation(const modeling& mod, simulation& sim);
struct description
{
small_string<1024> data;
};
struct parameter
{
u64 integer[8];
......@@ -97,26 +104,48 @@ struct port
i8 index; // index of the port
};
enum class component_type
{
cpp,
file
};
struct component
{
vector<child> children;
vector<child> models;
vector<connection> connections;
vector<port> x;
vector<port> y;
vector<child> configurables; // configurable model list
vector<child> observables; // observable model list
description_id desc = description_id{ 0 };
small_string<16> name;
component_type type;
};
struct modeling
{
data_array<model, model_id> models;
data_array<component_ref, component_ref_id> component_refs;
data_array<description, description_id> descriptions;
data_array<component, component_id> components;
data_array<parameter, parameter_id> parameters;
data_array<observer, observer_id> observers;
component_ref_id head = component_ref_id{ 0 };
status fill_component() noexcept;
template<typename Dynamics>
Dynamics& alloc() noexcept;
template<typename DynamicsSrc, typename DynamicsDst>
status connect(DynamicsSrc& src,
int port_src,
DynamicsDst& dst,
int port_dst) noexcept;
};
/*
......@@ -145,6 +174,51 @@ inline port::port(component_ref_id component, i8 port_) noexcept
, index{ port_ }
{}
template<typename Dynamics>
Dynamics& modeling::alloc() noexcept;
{
irt_assert(!models.full());
auto& mdl = models.alloc();
mdl.type = dynamics_typeof<Dynamics>();
mdl.handle = nullptr;
new (&mdl.dyn) Dynamics{};
auto& dyn = get_dyn<Dynamics>(mdl);
if constexpr (is_detected_v<has_input_port_t, Dynamics>)
for (int i = 0, e = length(dyn.x); i != e; ++i)
dyn.x[i] = static_cast<u64>(-1);
if constexpr (is_detected_v<has_output_port_t, Dynamics>)
for (int i = 0, e = length(dyn.y); i != e; ++i)
dyn.y[i] = static_cast<u64>(-1);
return dyn;
}
template<typename DynamicsSrc, typename DynamicsDst>
status component::connect(DynamicsSrc& src,
int port_src,
DynamicsDst& dst,
int port_dst) noexcept
{
irt_assert(!connections.full());
model& src_model = get_model(src);
model& dst_model = get_model(dst);
model_id model_src_id = get_id(dst);
model_id model_dst_id = get_id(dst);
irt_return_if_fail(
is_ports_compatible(src_model, port_src, dst_model, port_dst),
status::model_connect_bad_dynamics);
connections.emplace_back(model_src_id, port_src, model_dst_id, port_dst);
return status::success;
}
} // namespace irt
#endif
......@@ -2,6 +2,7 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <irritator/examples.hpp>
#include <irritator/modeling.hpp>
namespace irt {
......@@ -322,6 +323,127 @@ static status build_models(modeling& mod, component_ref& c_ref, simulation& sim)
return status::success;
}
status component::alloc(dynamics_type type) noexcept
{
irt_assert(!models.full());
auto& new_mdl = models.alloc();
new_mdl.type = type;
new_mdl.handle = nullptr;
dispatch(new_mdl, [this, &mdl]<typename Dynamics>(Dynamics& dyn) -> void {
const auto& src_dyn = get_dyn<Dynamics>(mdl);
new (&dyn) Dynamics(src_dyn);
if constexpr (is_detected_v<has_input_port_t, Dynamics>)
for (int i = 0, e = length(dyn.x); i != e; ++i)
dyn.x[i] = static_cast<u64>(-1);
if constexpr (is_detected_v<has_output_port_t, Dynamics>)
for (int i = 0, e = length(dyn.y); i != e; ++i)
dyn.y[i] = static_cast<u64>(-1);
});
return new_mdl;
}
status modeling::fill_component() noexcept
{
irt_return_if_fail(components.models.can_alloc(5), status::success);
{
auto& c = components.alloc();
compo.name.assign("QSS1 lotka volterra");
irt_return_if_bad(example_qss_lotka_volterra<component, 1>(*this, c));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS2 lotka volterra");
irt_return_if_bad(example_qss_lotka_volterra<component, 2>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS3 lotka volterra");
irt_return_if_bad(example_qss_lotka_volterra<component, 3>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS1 lif");
irt_return_if_bad(example_qss_lif<component, 1>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS2 lif");
irt_return_if_bad(example_qss_lif<component, 2>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS3 lif");
irt_return_if_bad(example_qss_lif<component, 3>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS1 izhikevich");
irt_return_if_bad(example_qss_izhikevich<component, 1>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS2 izhikevich");
irt_return_if_bad(example_qss_izhikevich<component, 2>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS3 izhikevich");
irt_return_if_bad(example_qss_izhikevich<component, 3>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS1 van der pol");
irt_return_if_bad(example_qss_van_der_pol<component, 1>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS2 van der pol");
irt_return_if_bad(example_qss_van_der_pol<component, 2>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS3 van der pol");
irt_return_if_bad(example_qss_van_der_pol<component, 3>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS1 negative lif");
irt_return_if_bad(example_qss_negative_lif<component, 1>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS2 negative lif");
irt_return_if_bad(example_qss_negative_lif<component, 2>(compo, e));
}
{
auto& compo = components.alloc();
compo.name.assign("QSS3 negative lif");
irt_return_if_bad(example_qss_negative_lif<component, 3>(compo, e));
}
return status::success;
}
status build_simulation(modeling& mod, simulation& sim)
{
if (auto* c_ref = mod.component_refs.try_to_get(mod.head); c_ref)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment