Giter Club home page Giter Club logo

Comments (4)

ynedelec3 avatar ynedelec3 commented on August 25, 2024

Apparently a commented void should do a part of the job in simulation-editor.cpp ?

// static void
// initialize_observation(window_logger& log_w, irt::editor& ed) noexcept
//{
// observer* obs = nullptr;
// while (ed.sim.observers.next(obs)) {
// auto& output = ed.observation_outputs.emplace_back(obs->name.sv());
//
//
// if (output.plot) {
// output.xs.clear();
// output.ys.clear();
// output.xs.reserve(length);
// output.ys.reserve(length);
// }
//
// if (!obs->name.empty()) {
// const std::filesystem::path obs_file_path =
// ed.observation_directory / obs->name.c_str();
//
// if (output.file) {
// if (output.ofs.open(obs_file_path); !output.ofs.is_open())
// log_w.log(4,
// "Fail to open "
// "observation file: %s in "
// "%s\n",
// obs->name.c_str(),
//#if _WIN32
// ed.observation_directory.u8string().c_str());
//#else
// reinterpret_cast<const char*>(
// ed.observation_directory.u8string().c_str()));
//#endif
// }
// }
//
// obs->initialize = &observation_output_initialize;
// obs->observe = &observation_output_observe;
// obs->free = &observation_output_free;
// obs->user_data = static_cast<void*>(&output);
// }
//}

from irritator.

quesnel avatar quesnel commented on August 25, 2024

I confirm the bug. I will correct it.

from irritator.

ynedelec3 avatar ynedelec3 commented on August 25, 2024

Thanks
I introduced a member with output directory in observers and initialized it in the initialize_observation routine, if it may bring a little help.
It works but may not be well written, especially for linux as well as in terms of string management...

In simulation-editor.cpp :
void
observation_file_output_initialize(const irt::observer& obs,
const irt::time t) noexcept
{
if (!obs.user_data)
return;

auto* output = reinterpret_cast<file_output*>(obs.user_data);
output->tl = t;

//if (output->ofs.is_open())
    //fmt::print(output->ofs, "t,{}\n", output->name.c_str());
// Nedelec
char strFileName [110];
sprintf(strFileName,
        "%s\\%s.txt",
        obs.output_directory,
        output->name.c_str());
output->ofs.open(strFileName);
fmt::print(output->ofs, "t,{}\n", output->name.c_str());

}

...

static void
initialize_observation(window_logger& log_w, irt::editor& ed) noexcept
{
observer* obs = nullptr;
while (ed.sim.observers.next(obs)) {
// Nedelec
obs->output_directory = ed.observation_directory.string().c_str();

    //auto& output = ed.observation_outputs.emplace_back(obs->name.sv());

// if (output.plot) {
// output.xs.clear();
// output.ys.clear();
// output.xs.reserve(length);
// output.ys.reserve(length);
// }
//
//if (!obs->name.empty()) {

        //Nedelec
        //output->strOutputDirectory = ed.observation_directory;

// const std::filesystem::path obs_file_path =
// ed.observation_directory / obs->name.c_str();
//
// if (output.file) {
// if (output.ofs.open(obs_file_path); !output.ofs.is_open())
// log_w.log(4,
// "Fail to open "
// "observation file: %s in "
// "%s\n",
// obs->name.c_str(),
//#if _WIN32
// ed.observation_directory.u8string().c_str());
//#else
// reinterpret_cast<const char*>(
// ed.observation_directory.u8string().c_str()));
//#endif
// }
//}
//
// obs->initialize = &observation_output_initialize;
// obs->observe = &observation_output_observe;
// obs->free = &observation_output_free;
// obs->user_data = static_cast<void*>(&output);
}
}

...

The three calls to initialize_observation are uncommented

In core.hpp :

observer(const time time_step_,
         const char* name_,
         void* user_data_,
         void (*initialize_)(const observer& obs, const time t) noexcept,
         void (*observe_)(const observer& obs,
                          const time t,
                          const message& msg) noexcept,
         void (*free_)(const observer& obs, const time t) noexcept)
  : time_step(std::clamp(time_step_, 0.0, time_domain<time>::infinity))
  , name(name_)
  , user_data(user_data_)
  , initialize(initialize_)
  , observe(observe_)
  , free(free_)
{}

double tl = 0.0;
double time_step = 0.0;
small_string<8> name;
small_string<100> output_directory; // Nedelec
model_id model = static_cast<model_id>(0);

...

from irritator.

quesnel avatar quesnel commented on August 25, 2024

Thank you for the report. I fix the problem but for now, output files are open in the application directory (where you launch the irritator.exe).

from irritator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.