Skip to content

Commit d41bed3

Browse files
authored
Fix initial unknowns (#996)
1 parent 535e12b commit d41bed3

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

src/OMSimulatorLib/ComponentFMUCS.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,12 @@ oms::Component* oms::ComponentFMUCS::NewComponent(const oms::ComRef& cref, oms::
163163
fmi2_import_variable_t* varState = (fmi2_import_variable_t*)fmi2_import_get_real_variable_derivative_of(varReal);
164164
if (varState)
165165
{
166-
fmi2_value_reference_t state_vr = fmi2_import_get_variable_vr(varState);
166+
// IMPORTANT: vr is not unique!!! Do lookup with proper index or name
167+
const oms::ComRef stateName(fmi2_import_get_variable_name(varState));
167168
bool found = false;
168-
for (size_t i = 0; i < component->allVariables.size(); i++)
169+
for (size_t i=0; i < component->allVariables.size(); i++)
169170
{
170-
if (state_vr == component->allVariables[i].getValueReference())
171+
if (stateName == component->allVariables[i].getCref())
171172
{
172173
component->allVariables[i].markAsState();
173174
found = true;

src/OMSimulatorLib/ComponentFMUME.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ oms::Component* oms::ComponentFMUME::NewComponent(const oms::ComRef& cref, oms::
165165
fmi2_import_variable_t* varState = (fmi2_import_variable_t*)fmi2_import_get_real_variable_derivative_of(varReal);
166166
if (varState)
167167
{
168-
fmi2_value_reference_t state_vr = fmi2_import_get_variable_vr(varState);
168+
// IMPORTANT: vr is not unique!!! Do lookup with proper index or name
169+
const oms::ComRef stateName(fmi2_import_get_variable_name(varState));
169170
bool found = false;
170-
for (size_t i = 0; i < component->allVariables.size(); i++)
171+
for (size_t i=0; i < component->allVariables.size(); i++)
171172
{
172-
if (state_vr == component->allVariables[i].getValueReference())
173+
if (stateName == component->allVariables[i].getCref())
173174
{
174175
component->allVariables[i].markAsState();
175176
found = true;

src/OMSimulatorLib/Variable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <JM/jm_portability.h>
3838

3939

40-
oms::Variable::Variable(fmi2_import_variable_t *var, unsigned int index)
40+
oms::Variable::Variable(fmi2_import_variable_t* var, unsigned int index)
4141
: is_state(false), is_der(false), cref(fmi2_import_get_variable_name(var)), index(index)
4242
{
4343
// extract the attributes

src/OMSimulatorLib/Variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace oms
4545
class Variable
4646
{
4747
public:
48-
Variable(fmi2_import_variable_t *var, unsigned int index);
48+
Variable(fmi2_import_variable_t* var, unsigned int index);
4949
~Variable();
5050

5151
void markAsState() { is_state = true; }

testsuite/OMSimulator/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import_parameter_mapping_from_ssm.lua \
2121
import_parameter_mapping_inline.lua \
2222
importPartialSnapshot.lua \
2323
importStartValues.lua \
24-
importStartValues.lua \
2524
multipleConnections.lua \
2625
partialSnapshot.lua \
2726
PI_Controller.lua \

0 commit comments

Comments
 (0)