-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Vico-platform/fmu4cpp
- Loading branch information
Showing
14 changed files
with
156 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
# FMU4cpp (early prototype) | ||
|
||
FMU4cpp is a CMake template repository that allows you to easily create cross-platform FMUs compatible with [FMI 2.0](https://fmi-standard.org/downloads/) | ||
for Co-simulation using C++. | ||
FMU4cpp is a CMake template repository that allows you to easily create cross-platform FMUs | ||
compatible with [FMI 2.0](https://fmi-standard.org/downloads/) for Co-simulation using C++. | ||
|
||
The framework handles everything including generating the `modelDescription.xml`, | ||
and packaging of the content into an FMU archive. | ||
The framework generates the required `modelDescription.xml` and further packages | ||
the necessary content into a ready-to-use FMU archive. | ||
|
||
### How do I get started? | ||
|
||
1. Change the value of the `modelIdentifier` variable in `CMakeLists.txt` to something more appropriate. | ||
2. Edit the content of `src/model.cpp`. | ||
2. Edit the content of [model.cpp](src/model.cpp). | ||
3. Build. | ||
|
||
An FMU named `<modelIdentifier>.fmu` is now located in your build folder. | ||
|
||
Such easy, such wow. | ||
|
||
#### Cross-compilation | ||
|
||
Cross-compilation (64-bit linux/windows) occurs automatically when you push your changes to GitHub. | ||
Simply rename the produced `model.zip` to `<modelName>.fmu`. | ||
|
||
|
||
Such easy, such wow. | ||
|
||
|
||
### Requirements | ||
* C++17 compiler | ||
* CMake >= 3.15 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
#ifndef FMU4CPP_TEMPLATE_LOGGER_HPP | ||
#define FMU4CPP_TEMPLATE_LOGGER_HPP | ||
|
||
#include <memory> | ||
|
||
#include "fmi2/fmi2FunctionTypes.h" | ||
|
||
namespace fmu4cpp { | ||
class logger { | ||
|
||
public: | ||
logger(fmi2ComponentEnvironment c, fmi2CallbackFunctions f, std::string instanceName) | ||
: c_(c), | ||
fmiLogger_(f.logger), | ||
instanceName_(std::move(instanceName)) {} | ||
|
||
void setDebugLogging(bool flag) { | ||
debugLogging_ = flag; | ||
} | ||
|
||
// Logs a message. | ||
template<typename... Args> | ||
void log(fmi2Status s, const std::string &message, Args &&...args) { | ||
msgBuf_ = message; | ||
fmiLogger_(c_, instanceName_.c_str(), s, "", msgBuf_.c_str(), std::forward<Args>(args)...); | ||
} | ||
|
||
// Logs a message. | ||
template<typename... Args> | ||
void debug(fmi2Status s, const std::string &message, Args &&...args) { | ||
if (debugLogging_) { | ||
log(s, message, std::forward<Args>(args)...); | ||
} | ||
} | ||
|
||
private: | ||
bool debugLogging_{false}; | ||
std::string instanceName_; | ||
fmi2ComponentEnvironment c_; | ||
fmi2CallbackLogger fmiLogger_; | ||
std::string msgBuf_; | ||
}; | ||
|
||
}// namespace fmu4cpp | ||
|
||
#endif//FMU4CPP_TEMPLATE_LOGGER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.