Skip to content

Rework native library #237

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

Merged
merged 9 commits into from
May 6, 2025
Merged

Rework native library #237

merged 9 commits into from
May 6, 2025

Conversation

markaren
Copy link
Member

@markaren markaren commented Apr 30, 2025

A first attempt to rework the native library.

  • PyState needs to be checked.
  • setup_experiment is removed (API change).
    • startTime is moved to enter_initiliaization_mode`
  • Fix logging possibly overriding importers debug request.
    • debug parameter to 'log' has no longer any effect and a warning is emitted on use
  • Fixes and enables disabled logging tests

This change should make it easier to understand the native workings and also make it easier to add FMI3 support. The structure is similar to fmu4cpp.

@markaren markaren requested a review from Copilot May 1, 2025 12:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reworks the native library by refactoring core FMU functions, improving logging behavior and error handling, and updating API usage for greater clarity and support for FMI3 in the future.

  • Refactored fmi2.cpp to replace reinterpret_cast with static_cast and improved logger usage.
  • Updated PySlaveInstance implementation and removed deprecated setup_experiment.
  • Removed legacy cppfmu_cs files and updated log message formatting.

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pythonfmu/fmu_except.hpp New exception class added for fatal errors.
pythonfmu/fmi2.cpp Refactored casting, logging, and FMI function implementations.
pythonfmu/SlaveInstance.hpp Updated interface for SlaveInstance with optional parameters.
pythonfmu/PySlaveInstance.{hpp,cpp} Reworked Python slave instance integration with improved resource handling.
pythonfmu/Logger.hpp Introduced a new PyLogger interface for consistent logging.
pythonfmu/cppfmu/cppfmu_cs.{hpp,cpp} Legacy co-simulation interface removed.
pythonfmu/logmsg.py Adjusted LogMsg class and its string formatting.
pythonfmu/fmi2slave.py Minor API changes in initialization mode and logging support.
pythonfmu/_version.py Version bumped to 0.7.0.
Files not reviewed (1)
  • pythonfmu/pythonfmu-export/src/CMakeLists.txt: Language not supported

@markaren markaren added the enhancement New feature or request label May 5, 2025
@markaren markaren merged commit 65295a9 into master May 6, 2025
@markaren markaren deleted the native_rework branch May 6, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant