Commit 4ce3b903 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

next18

parent 7ec3baa6
Pipeline #2334 failed with stage
in 23 seconds
......@@ -54,23 +54,37 @@ struct ID2
ID id2{ 0 };
};
/**
* @brief Store atomic and executive behaviours.
* @details package and library specifies the package where found the library,
* library is the shared library to pickup the dynamics.
*
*/
struct Dynamics
{
std::string name;
std::string package;
std::string library;
std::string language;
std::string package; // where to found the shared library.
std::string library; // shared library name (toto equals libtoto.so or
// libtoto.dylib or libtoto.dll).
void* alloc = nullptr; // pointer to the factory.
enum class dynamics_type
{
local,
cpp,
js
};
dynamics_type type = dynamics_type::local;
};
struct View
{
std::string name;
std::string package;
std::string library;
std::string location;
double timestep = 1.0;
enum view_type
enum view_option
{
timed = 0,
alloc = 1 << 1,
......@@ -81,7 +95,14 @@ struct View
finish = 1 << 6,
};
unsigned type = view_type::timed;
enum class output_type
{
csv,
json
};
unsigned view = view_option::timed;
output_type type = output_type::csv;
};
struct vec2
......@@ -415,6 +436,12 @@ struct SimElement
simulator_element_type type = simulator_element_type::simulator;
};
struct InternalEvent
{
double time;
ID id;
};
struct Simulation
{
enum class simulation_type
......@@ -498,13 +525,12 @@ struct Vpz
Dynamics* dyn = nullptr;
while (dynamics.next(dyn)) {
fprintf(&f,
" <dynamic name=\"%s\" package=\"%s\" library=\"%s\" "
"language=\"%s\"\n",
dyn->name.c_str(),
dyn->package.c_str(),
dyn->library.c_str(),
dyn->language.c_str());
fprintf(
&f,
" <dynamic name=\"%s\" package=\"%s\" library=\"%s\" />\n",
dyn->name.c_str(),
dyn->package.c_str(),
dyn->library.c_str());
}
fprintf(&f, " </dynamics>\n");
......@@ -571,12 +597,9 @@ struct Vpz
View* view = nullptr;
while (views.next(view)) {
fprintf(&f,
" <output name=\"%s\" location=\"%s\" package=\"%s\" "
"library=\"%s\" />\n",
" <output name=\"%s\" location=\"%s\" />\n",
view->name.c_str(),
view->location.c_str(),
view->package.c_str(),
view->library.c_str());
view->location.c_str());
}
fprintf(&f, " </outputs>\n");
......@@ -641,17 +664,13 @@ struct Vpz
fprintf(&f, "</vle_project>\n");
}
Dynamics& add_dynamics(std::string name,
std::string package,
std::string library,
std::string language)
Dynamics& add_local_dynamics(std::string name, std::string library)
{
Dynamics& ret = dynamics.alloc();
ret.name = std::move(name);
ret.package = std::move(package);
ret.library = std::move(library);
ret.language = std::move(language);
ret.type = Dynamics::dynamics_type::local;
return ret;
}
......@@ -662,35 +681,31 @@ struct Vpz
}
View& add_timed_view(std::string name,
std::string package,
std::string library,
std::string location,
double timestep)
double timestep,
View::output_type type)
{
View& ret = views.alloc();
ret.name = std::move(name);
ret.package = std::move(package);
ret.library = std::move(library);
ret.location = std::move(location);
ret.timestep = timestep;
ret.type = View::view_type::timed;
ret.view = View::view_option::timed;
ret.type = type;
return ret;
}
View& add_event_view(std::string name,
std::string package,
std::string library,
std::string location,
int type)
unsigned view,
View::output_type type)
{
View& ret = views.alloc();
ret.name = std::move(name);
ret.package = std::move(package);
ret.library = std::move(library);
ret.location = std::move(location);
ret.view = view;
ret.type = type;
return ret;
......@@ -711,6 +726,17 @@ struct Vpz
return ret;
}
void make_parent(const Model& model, const Model& parent)
{
bits_assert(parent.type == Model::model_type::coupled);
auto id_model = models.get_id(model);
auto id_parent = models.get_id(parent);
model_parent[id_model] = id_parent;
model_children.emplace(id_parent, id_model);
}
void destroy(Model& model)
{
auto id_model = models.get_id(model);
......@@ -1023,16 +1049,6 @@ struct Vpz
return ret;
}
void destroy_input_port(Port& port)
{
input_ports.free(port);
}
void destroy_output_port(Port& port)
{
input_ports.free(port);
}
Port& add_output_port(const Model& model, std::string name)
{
Port& ret = output_ports.alloc();
......@@ -1045,12 +1061,14 @@ struct Vpz
return ret;
}
void make_parent(const Model& model, const Model& parent)
void destroy_input_port(Port& port)
{
auto id_model = models.get_id(model);
auto id_parent = models.get_id(parent);
input_ports.free(port);
}
model_parent[id_model] = id_parent;
void destroy_output_port(Port& port)
{
input_ports.free(port);
}
void make_connection(const Model& coupledmodel,
......@@ -1066,6 +1084,25 @@ struct Vpz
}
};
struct VLE
{
std::array<std::string, 5> paths; // Package patch to search.
};
VLE
init_vle() noexcept
{
std::array<std::string, 5> paths;
paths[0] = "/home/gquesnel/.vle3/packages";
paths[1] = "/usr/lib/vle3/pakages";
paths[2] = "/usr/local/lib/vle3/packages";
paths[2] = "/opt/vle3/packages";
paths[4] = ".";
return VLE{ paths };
}
} // vle
int
......
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