Commit 5ec8280e authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

WIP

parent 608d9a2d
Pipeline #33715 failed with stage
in 1 minute and 16 seconds
......@@ -1634,6 +1634,7 @@ show_dynamics_values(simulation& /*sim*/, const generator& dyn)
static void
show_dynamics_values(simulation& /*sim*/, const constant& dyn)
{
ImGui::Text("next %.3f", dyn.sigma);
ImGui::Text("value %.3f", dyn.value);
}
......@@ -1945,7 +1946,7 @@ show_dynamics_inputs(simulation& /*sim*/, dynamic_queue& dyn)
ImGui::OpenPopup(title);
ImGui::SameLine();
//if (dyn.default_ta_source.data == nullptr) {
// if (dyn.default_ta_source.data == nullptr) {
// ImGui::TextUnformatted("<None>");
//} else {
// ImGui::Text("%" PRIu32 "-%" PRIu32,
......@@ -1953,7 +1954,7 @@ show_dynamics_inputs(simulation& /*sim*/, dynamic_queue& dyn)
// dyn.default_ta_source.id);
//}
//app.srcs.show_menu(title, dyn.default_ta_source);
// app.srcs.show_menu(title, dyn.default_ta_source);
}
static void
......@@ -1964,7 +1965,7 @@ show_dynamics_inputs(simulation& /*sim*/, priority_queue& dyn)
ImGui::OpenPopup(title);
ImGui::SameLine();
//if (dyn.default_ta_source.data == nullptr) {
// if (dyn.default_ta_source.data == nullptr) {
// ImGui::TextUnformatted("<None>");
//} else {
// ImGui::Text("%" PRIu32 "-%" PRIu32,
......@@ -1972,11 +1973,11 @@ show_dynamics_inputs(simulation& /*sim*/, priority_queue& dyn)
// dyn.default_ta_source.id);
//}
//app.srcs.show_menu(title, dyn.default_ta_source);
// app.srcs.show_menu(title, dyn.default_ta_source);
}
static void
show_dynamics_inputs(simulation& /*sim*/, generator& dyn)
show_dynamics_inputs(simulation& sim, generator& dyn)
{
ImGui::InputDouble("offset", &dyn.default_offset);
......@@ -1986,15 +1987,11 @@ show_dynamics_inputs(simulation& /*sim*/, generator& dyn)
ImGui::OpenPopup(title);
ImGui::SameLine();
//if (dyn.default_value_source.data == nullptr) {
// ImGui::TextUnformatted("<None>");
//} else {
// ImGui::Text("%" PRIu32 "-%" PRIu32,
// dyn.default_value_source.type,
// dyn.default_value_source.id);
//}
//app.srcs.show_menu(title, dyn.default_value_source);
if (auto* src = sim.sources.try_to_get(dyn.default_source_value); src) {
ImGui::Text("%" PRIu64 "-%d", src->id, src->type);
} else {
ImGui::TextUnformatted("None");
}
}
{
......@@ -2003,14 +2000,19 @@ show_dynamics_inputs(simulation& /*sim*/, generator& dyn)
ImGui::OpenPopup(title);
ImGui::SameLine();
//if (dyn.default_ta_source.data == nullptr) {
if (auto* src = sim.sources.try_to_get(dyn.default_source_ta); src) {
ImGui::Text("%" PRIu64 "-%d", src->id, src->type);
} else {
ImGui::TextUnformatted("None");
}
// if (dyn.default_ta_source.data == nullptr) {
// ImGui::TextUnformatted("<None>");
//} else {
// ImGui::Text("%" PRIu32 "-%" PRIu32,
// dyn.default_ta_source.type,
// dyn.default_ta_source.id);
//}
//app.srcs.show_menu(title, dyn.default_ta_source);
}
}
......@@ -2949,6 +2951,10 @@ editor::show_editor() noexcept
editor*
application::alloc_editor()
{
if (srcs.binary_file_sources.capacity() == 0) {
srcs.init(50);
}
if (!editors.can_alloc(1u)) {
log_w.log(2, "Too many open editor\n");
return nullptr;
......
......@@ -570,6 +570,9 @@ struct application
bool show_settings = false;
bool show_sources_window = false;
bool source_window_starting = true;
editor* alloc_editor();
void free_editor(editor& ed);
};
......
This diff is collapsed.
......@@ -5074,14 +5074,16 @@ struct generator
simulation* sim = nullptr;
double default_offset = 0.0;
source_id source_ta = undefined<source_id>();
source_id source_value = undefined<source_id>();
source_id default_source_ta = undefined<source_id>();
source_id default_source_value = undefined<source_id>();
source_id source_ta;
source_id source_value;
status initialize() noexcept
{
sigma = default_offset;
irt_return_if_bad(get_next_data(*sim, source_value, value));
source_ta = default_source_ta;
source_value = default_source_value;
return status::success;
}
......@@ -5704,13 +5706,16 @@ struct dynamic_queue
flat_double_list<dated_message> queue;
simulation* sim = nullptr;
source_id source_ta = undefined<source_id>();
source_id default_source_ta = undefined<source_id>();
source_id source_ta;
status initialize() noexcept
{
sigma = time_domain<time>::infinity;
queue.clear();
source_ta = default_source_ta;
return status::success;
}
......@@ -5763,7 +5768,8 @@ struct priority_queue
double default_ta = 1.0;
simulation* sim = nullptr;
source_id source_ta = undefined<source_id>();
source_id default_source_ta = undefined<source_id>();
source_id source_ta;
private:
status try_to_insert(const time t, const message& msg) noexcept
......
......@@ -7,12 +7,12 @@
#include <irritator/core.hpp>
#include <array>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <map>
#include <random>
#include <vector>
namespace irt {
......@@ -59,6 +59,7 @@ static inline const char* distribution_type_str[] = {
struct constant_source
{
small_string<23> name;
std::vector<double> buffer;
status operator()(source& src, source::operation_type /*op*/) noexcept
......@@ -79,6 +80,7 @@ struct constant_source
struct binary_file_source
{
small_string<23> name;
std::vector<double> buffer;
std::filesystem::path file_path;
std::ifstream ifs;
......@@ -169,6 +171,7 @@ private:
struct text_file_source
{
small_string<23> name;
std::vector<double> buffer;
std::filesystem::path file_path;
std::ifstream ifs;
......@@ -263,6 +266,7 @@ private:
struct random_source
{
small_string<23> name;
std::vector<double> buffer;
sz buffer_size = 0;
sz buffer_index = 0;
......
......@@ -1350,7 +1350,7 @@ private:
return false;
auto& src_ta = sim.sources.alloc();
dyn.source_ta = sim.sources.get_id(src_ta);
dyn.default_source_ta = sim.sources.get_id(src_ta);
if (!read_source(sim, src_ta, index, type))
return false;
......@@ -1370,7 +1370,7 @@ private:
return false;
auto& src_ta = sim.sources.alloc();
dyn.source_ta = sim.sources.get_id(src_ta);
dyn.default_source_ta = sim.sources.get_id(src_ta);
if (!read_source(sim, src_ta, index, type))
return false;
......@@ -1392,8 +1392,8 @@ private:
auto& src_ta = sim.sources.alloc();
auto& src_value = sim.sources.alloc();
dyn.source_ta = sim.sources.get_id(src_ta);
dyn.source_value = sim.sources.get_id(src_value);
dyn.default_source_ta = sim.sources.get_id(src_ta);
dyn.default_source_value = sim.sources.get_id(src_value);
if (!read_source(sim, src_ta, index[0], type[0]))
return false;
......@@ -1905,7 +1905,7 @@ private:
{
os << "dynamic_queue ";
if (const auto* src = sim.sources.try_to_get(dyn.source_ta); src) {
if (const auto* src = sim.sources.try_to_get(dyn.default_source_ta); src) {
const u32 index32 = static_cast<u32>(src->id & 0x00000000ffffffff);
const int index = static_cast<int>(index32);
os << index << ' ' << src->type;
......@@ -1920,7 +1920,7 @@ private:
{
os << "priority_queue ";
if (const auto* src = sim.sources.try_to_get(dyn.source_ta); src) {
if (const auto* src = sim.sources.try_to_get(dyn.default_source_ta); src) {
const u32 index32 = static_cast<u32>(src->id & 0x00000000ffffffff);
const int index = static_cast<int>(index32);
os << index << ' ' << src->type;
......@@ -1935,7 +1935,7 @@ private:
{
os << "generator " << dyn.default_offset << ' ';
if (const auto* src = sim.sources.try_to_get(dyn.source_ta); src) {
if (const auto* src = sim.sources.try_to_get(dyn.default_source_ta); src) {
const u32 index32 = static_cast<u32>(src->id & 0x00000000ffffffff);
const int index = static_cast<int>(index32);
os << index << ' ' << src->type;
......@@ -1945,7 +1945,7 @@ private:
os << ' ';
if (const auto* src = sim.sources.try_to_get(dyn.source_value); src) {
if (const auto* src = sim.sources.try_to_get(dyn.default_source_value); src) {
const u32 index32 = static_cast<u32>(src->id & 0x00000000ffffffff);
const int index = static_cast<int>(index32);
os << index << ' ' << src->type;
......
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