-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
99 additions
and
21 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
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,3 +1,4 @@ | ||
|
||
add_subdirectory(BouncingBall) | ||
add_subdirectory(SimplePendulum) | ||
add_subdirectory(Resource) |
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,6 @@ | ||
|
||
add_library(resource SHARED | ||
"resource.cpp" | ||
) | ||
|
||
generateFMU("resource" "${CMAKE_CURRENT_SOURCE_DIR}/resources") |
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,52 @@ | ||
|
||
|
||
#include <fmu4cpp/fmu_base.hpp> | ||
|
||
#include <fstream> | ||
|
||
using namespace fmu4cpp; | ||
|
||
|
||
class Resource : public fmu_base { | ||
|
||
public: | ||
Resource(const std::string &instanceName, const std::filesystem::path &resources) | ||
: fmu_base(instanceName, resources) { | ||
|
||
std::ifstream ifs(resources / "file.txt"); | ||
|
||
std::string line; | ||
std::getline(ifs, line); | ||
|
||
register_variable( | ||
string( | ||
"content", [line] { return line; }) | ||
.setVariability(variability_t::CONSTANT) | ||
.setCausality(causality_t::OUTPUT)); | ||
|
||
Resource::reset(); | ||
} | ||
|
||
bool do_step(double currentTime, double dt) override { | ||
|
||
debugLog(fmi2OK, get_string_variable("content")->get()); | ||
return true; | ||
} | ||
|
||
void reset() override { | ||
// do nothing | ||
} | ||
|
||
}; | ||
|
||
model_info fmu4cpp::get_model_info() { | ||
model_info info; | ||
info.modelName = "Resource"; | ||
info.description = "A model with resources"; | ||
info.modelIdentifier = FMU4CPP_MODEL_IDENTIFIER; | ||
return info; | ||
} | ||
|
||
std::unique_ptr<fmu_base> fmu4cpp::createInstance(const std::string &instanceName, const std::filesystem::path &fmuResourceLocation) { | ||
return std::make_unique<Resource>(instanceName, fmuResourceLocation); | ||
} |
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 @@ | ||
Hello World! |
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
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 @@ | ||
place fmu4cpp resources in this folder |
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