Skip to content

Commit c13cab6

Browse files
committed
allow stepSizeHint to be set through SSP
1 parent 7d3eb51 commit c13cab6

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/ecos/ssp/ssp.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,15 @@ Component parse_component(const std::filesystem::path& dir, const pugi::xml_node
149149
const std::string componentSource = node.attribute("source").as_string();
150150
const auto connectors = parse_connectors(node.child("ssd:Connectors"));
151151
const auto parameterSets = parse_parameter_bindings(dir, node.child("ssd:ParameterBindings"));
152-
return {componentName, componentSource, connectors, parameterSets};
152+
const auto annotations = node.child("ssd:Annotations");
153+
std::optional<double> stepSizeHint = std::nullopt;
154+
for (const auto& annotationNode : annotations) {
155+
if (std::string(annotationNode.attribute("type").as_string()) == "com.opensimulationplatform") {
156+
stepSizeHint = annotationNode.child("osp:StepSizeHint").attribute("value").as_double();
157+
}
158+
}
159+
160+
return {componentName, componentSource, stepSizeHint, connectors, parameterSets};
153161
}
154162

155163
std::unordered_map<std::string, Component> parse_components(const std::filesystem::path& dir, const pugi::xml_node& node)

src/ecos/ssp/ssp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct Component
6565
{
6666
std::string name;
6767
std::string source;
68+
std::optional<double> stepSizeHint;
6869
std::unordered_map<std::string, Connector> connectors;
6970
std::unordered_map<std::string, ParameterSet> parameterSets;
7071

src/ecos/ssp/ssp_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ssp_based_simulation_structure : public simulation_structure
2828
for (const auto& [name, component] : components) {
2929
auto model = resolver->resolve(desc_.dir(), component.source);
3030
if (!model) throw std::runtime_error("Could not resolve model: " + component.source);
31-
add_model(name, std::move(model));
31+
add_model(name, std::move(model), component.stepSizeHint);
3232
}
3333

3434
for (const auto& connection : connections) {

0 commit comments

Comments
 (0)