Skip to content

Commit

Permalink
Change dimension variables in LinearTransform to Int32 (#41)
Browse files Browse the repository at this point in the history
fixes #5
  • Loading branch information
t-sommer authored May 31, 2020
1 parent facfce7 commit 70ed792
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions LinearTransform/FMI3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<DefaultExperiment startTime="0" stopTime="10"/>

<ModelVariables>
<Float64 name="m" valueReference="0" description="" causality="parameter" variability="constant" start="2"/>
<Float64 name="n" valueReference="1" description="" causality="parameter" variability="constant" start="3"/>
<Int32 name="m" valueReference="0" description="" causality="parameter" variability="constant" start="2"/>
<Int32 name="n" valueReference="1" description="" causality="parameter" variability="constant" start="3"/>
<Float64 name="u" valueReference="2" description="" causality="input" start="1">
<Dimension start="3"/>
</Float64>
Expand Down
1 change: 1 addition & 0 deletions LinearTransform/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#define GET_FLOAT64
#define SET_FLOAT64
#define GET_INT32
#define EVENT_UPDATE

#define FIXED_SOLVER_STEP 1
Expand Down
20 changes: 14 additions & 6 deletions LinearTransform/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ Status getFloat64(ModelInstance* comp, ValueReference vr, double *value, size_t
calculateValues(comp);

switch (vr) {
case vr_m:
value[(*index)++] = M(m);
return OK;
case vr_n:
value[(*index)++] = M(n);
return OK;
case vr_u:
value[(*index)++] = M(u)[0];
value[(*index)++] = M(u)[1];
Expand Down Expand Up @@ -72,6 +66,20 @@ Status setFloat64(ModelInstance* comp, ValueReference vr, const double *value, s
}
}

Status getInt32(ModelInstance* comp, ValueReference vr, int *value, size_t *index) {
calculateValues(comp);
switch (vr) {
case vr_m:
value[(*index)++] = M(m);
return OK;
case vr_n:
value[(*index)++] = M(n);
return OK;
default:
return Error;
}
}

void eventUpdate(ModelInstance *comp) {
comp->valuesOfContinuousStatesChanged = false;
comp->nominalsOfContinuousStatesChanged = false;
Expand Down

0 comments on commit 70ed792

Please sign in to comment.