Skip to content

Commit 283f13b

Browse files
committed
Set Float32 in FMIGetInitialFloat*() and skip empty arrays
1 parent f485895 commit 283f13b

File tree

5 files changed

+88
-20
lines changed

5 files changed

+88
-20
lines changed
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
within FMI.FMI2.Functions;
22
impure function FMI2GetInitialReal
33
extends Modelica.Icons.Function;
4+
45
input Internal.ExternalFMU instance;
6+
57
input Real _time;
8+
69
input Integer realInputValueReferences[:] = fill(0, 0);
710
input Real realInputValues[:] = fill(0.0, 0);
11+
812
input Integer integerInputValueReferences[:] = fill(0, 0);
913
input Integer integerInputValues[:] = fill(0, 0);
14+
1015
input Integer booleanInputValueReferences[:] = fill(0, 0);
1116
input Boolean booleanInputValues[:] = fill(false, 0);
17+
1218
input Integer valueReference;
19+
1320
output Real value;
21+
1422
algorithm
15-
FMI2SetReal(instance, realInputValueReferences, size(realInputValueReferences, 1), realInputValues);
16-
FMI.Internal.Logging.logMessages(instance);
17-
FMI2SetInteger(instance, integerInputValueReferences, size(integerInputValueReferences, 1), integerInputValues);
18-
FMI.Internal.Logging.logMessages(instance);
19-
FMI2SetBoolean(instance, booleanInputValueReferences, size(booleanInputValueReferences, 1), booleanInputValues);
20-
FMI.Internal.Logging.logMessages(instance);
23+
24+
if size(realInputValueReferences, 1) > 0 then
25+
FMI2SetReal(instance, realInputValueReferences, size(realInputValueReferences, 1), realInputValues);
26+
end if;
27+
28+
if size(integerInputValueReferences, 1) > 0 then
29+
FMI2SetInteger(instance, integerInputValueReferences, size(integerInputValueReferences, 1), integerInputValues);
30+
end if;
31+
32+
if size(booleanInputValueReferences, 1) > 0 then
33+
FMI2SetBoolean(instance, booleanInputValueReferences, size(booleanInputValueReferences, 1), booleanInputValues);
34+
end if;
35+
2136
value := FMI2GetReal(instance, valueReference);
2237
FMI.Internal.Logging.logMessages(instance);
38+
2339
end FMI2GetInitialReal;

FMI/FMI3/Functions/FMI3GetInitialFloat32.mo

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,21 @@ impure function FMI3GetInitialFloat32
2727

2828
algorithm
2929

30-
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
31-
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
32-
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
33-
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
30+
if size(float32InputValueReferences, 1) > 0 then
31+
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
32+
end if;
33+
34+
if size(float64InputValueReferences, 1) > 0 then
35+
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
36+
end if;
37+
38+
if size(int32InputValueReferences, 1) > 0 then
39+
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
40+
end if;
41+
42+
if size(booleanInputValueReferences, 1) > 0 then
43+
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
44+
end if;
3445

3546
values := FMI3GetFloat32(instance, valueReference, nValues);
3647

FMI/FMI3/Functions/FMI3GetInitialFloat32Matrix.mo

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ impure function FMI3GetInitialFloat32Matrix
88
input Internal.ExternalFMU instance;
99
input Real _time;
1010

11+
input FMI3ValueReference float32InputValueReferences[:] = fill(0, 0);
12+
input FMI3Float32 float32InputValues[:] = fill(0.0, 0);
13+
1114
input FMI3ValueReference float64InputValueReferences[:] = fill(0, 0);
1215
input FMI3Float64 float64InputValues[:] = fill(0.0, 0);
1316

@@ -25,9 +28,21 @@ impure function FMI3GetInitialFloat32Matrix
2528

2629
algorithm
2730

28-
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
29-
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
30-
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
31+
if size(float32InputValueReferences, 1) > 0 then
32+
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
33+
end if;
34+
35+
if size(float64InputValueReferences, 1) > 0 then
36+
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
37+
end if;
38+
39+
if size(int32InputValueReferences, 1) > 0 then
40+
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
41+
end if;
42+
43+
if size(booleanInputValueReferences, 1) > 0 then
44+
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
45+
end if;
3146

3247
values := FMI3.Functions.FMI3GetFloat32Matrix(instance, valueReference, m, n, nValues);
3348

FMI/FMI3/Functions/FMI3GetInitialFloat64.mo

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,21 @@ impure function FMI3GetInitialFloat64
2727

2828
algorithm
2929

30-
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
31-
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
32-
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
33-
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
30+
if size(float32InputValueReferences, 1) > 0 then
31+
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
32+
end if;
33+
34+
if size(float64InputValueReferences, 1) > 0 then
35+
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
36+
end if;
37+
38+
if size(int32InputValueReferences, 1) > 0 then
39+
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
40+
end if;
41+
42+
if size(booleanInputValueReferences, 1) > 0 then
43+
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
44+
end if;
3445

3546
values := FMI3GetFloat64(instance, valueReference, nValues);
3647

FMI/FMI3/Functions/FMI3GetInitialFloat64Matrix.mo

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ impure function FMI3GetInitialFloat64Matrix
88
input Internal.ExternalFMU instance;
99
input Real _time;
1010

11+
input FMI3ValueReference float32InputValueReferences[:] = fill(0, 0);
12+
input FMI3Float32 float32InputValues[:] = fill(0.0, 0);
13+
1114
input FMI3ValueReference float64InputValueReferences[:] = fill(0, 0);
1215
input FMI3Float64 float64InputValues[:] = fill(0.0, 0);
1316

@@ -25,9 +28,21 @@ impure function FMI3GetInitialFloat64Matrix
2528

2629
algorithm
2730

28-
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
29-
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
30-
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
31+
if size(float32InputValueReferences, 1) > 0 then
32+
FMI3SetFloat32(instance, float32InputValueReferences, float32InputValues);
33+
end if;
34+
35+
if size(float64InputValueReferences, 1) > 0 then
36+
FMI3SetFloat64(instance, float64InputValueReferences, float64InputValues);
37+
end if;
38+
39+
if size(int32InputValueReferences, 1) > 0 then
40+
FMI3SetInt32(instance, int32InputValueReferences, int32InputValues);
41+
end if;
42+
43+
if size(booleanInputValueReferences, 1) > 0 then
44+
FMI3SetBoolean(instance, booleanInputValueReferences, booleanInputValues);
45+
end if;
3146

3247
values := FMI3.Functions.FMI3GetFloat64Matrix(instance, valueReference, m, n, nValues);
3348

0 commit comments

Comments
 (0)