Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cse_local_slave_create is broken when adding more than one instance of the same FMU #381

Closed
markaren opened this issue Sep 23, 2019 · 0 comments · Fixed by #387
Closed
Labels
bug Something isn't working

Comments

@markaren
Copy link
Contributor

cse_slave* cse_local_slave_create(const char* fmuPath)
{
    try {
        const auto importer = cse::fmi::importer::create();
        const auto fmu = importer->import(fmuPath);
        auto slave = std::make_unique<cse_slave>();
        slave->name = fmu->model_description()->name;   // <----- HERE
        slave->instance = fmu->instantiate_slave(slave->name);
        // slave address not in use yet. Should be something else than a string.
        slave->address = "local";
        slave->source = fmuPath;
        return slave.release();
    } catch (...) {
        handle_current_exception();
        return nullptr;
    }
}

cse_slave_index cse_execution_add_slave(
    cse_execution* execution,
    cse_slave* slave)
{
    try {
        auto index = execution->cpp_execution->add_slave(cse::make_background_thread_slave(slave->instance), slave->name);
        execution->simulators[slave->name] = cse::simulator_map_entry{index, slave->source, slave->instance->model_description()}; // <---- HERE
        return index;
    } catch (...) {
        handle_current_exception();
        return failure;
    }
}

As highlighted above, execution->simulators[slave->name] is overwritten each time a new slave is added.

@markaren markaren added the bug Something isn't working label Sep 23, 2019
markaren added a commit that referenced this issue Sep 26, 2019
markaren added a commit that referenced this issue Sep 27, 2019
* Fix broken cse_local_slave_create #381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant