Skip to content

Commit 7c83f80

Browse files
nl78Nicolas Laurent
and
Nicolas Laurent
authored
Ability to build an FMUContainer from SSP (#9)
* Remove uneeded import * Default -fmu-directory to "." * first code... * Remove uneeded import * Default -fmu-directory to "." * first code... * Fix spelling * Put icon in taskbar on window * Ability to call fmucontainer at lower speed (than internate freq) * update GUI icons * make icon appears in (macos) dock * GUI: keep windows trick * Fix SUFFIX spelling! * Fix unix remoting CMakelist * Fix CMakefile for Windows * Make remoting test windows only * Remove generated files * Ignore generated file * Port to darwin64 (partial) * unit test switch from FMUContainerSpec to Assembly * Switch from DescriptionSpec to Assembly * Fix location of description file for inclusion in container * Enhance diagnostic message * Add write_json * Finalize write_json * First json containers * WIP: json write * Write JSON * refactor Assembly class * Add json example * Fix container bouncing * Clean up * WIP * update icon * First working version of SSP read routine * Code cleanup * put SSD instead of whole SSP in the FMUcontainer * Clean up test_suite * Fix fmucontainer for some FMUs * Almost working for non-trivial SSP * Update drop down icon * update icon * Windows specific icon * Issue a warning instead of error it co-simulation step size missmatch with fmu step size * Add json sanitycheck at reading time * Fix typo in Elapse (profiling) * Container can handle variable co-simulation step size now * Avoid unhandled exception! * Make diagnostic message clearer! * SSD parsing: code refactoring * Remove properly transitent directories * FMUContainer support only Co-Simulation FMUs * Update Changelog --------- Co-authored-by: Nicolas Laurent <[email protected]>
1 parent d255c87 commit 7c83f80

36 files changed

+686
-256
lines changed

.gitignore

+18-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ __pycache__
44
.vs
55
*.dll
66
*.exe
7-
tests/bouncing_ball-keeponly.csv
8-
tests/bouncing_ball-keeponly.fmu
9-
tests/bouncing_ball-no-tl.csv
10-
tests/bouncing_ball-no-tl.fmu
11-
tests/bouncing_ball-removed.csv
12-
tests/bouncing_ball-removed.fmu
13-
tests/bouncing_ball-renamed.csv
14-
tests/bouncing_ball-renamed.fmu
7+
tests/operations/bouncing_ball-keeponly.csv
8+
tests/operations/bouncing_ball-keeponly.fmu
9+
tests/operations/bouncing_ball-no-tl.csv
10+
tests/operations/bouncing_ball-no-tl.fmu
11+
tests/operations/bouncing_ball-removed.csv
12+
tests/operations/bouncing_ball-removed.fmu
13+
tests/operations/bouncing_ball-renamed.csv
14+
tests/operations/bouncing_ball-renamed.fmu
1515
tests/bouncing_ball-win32.fmu
1616
remoting/out
1717
remoting/build
@@ -22,3 +22,13 @@ tests/containers/bouncing_ball/bouncing_auto.fmu
2222
tests/containers/bouncing_ball/bouncing_unlinked.fmu
2323
container/build-win64
2424
container/build
25+
tests/operations/bouncing_ball.csv
26+
fmu_manipulation_toolbox/resources/darwin64/client_sm.dylib
27+
fmu_manipulation_toolbox/resources/darwin64/container.dylib
28+
fmu_manipulation_toolbox/resources/darwin64/server_sm
29+
tests/containers/bouncing_ball/bouncing.json
30+
tests/containers/arch/hierarchical.fmu
31+
tests/containers/arch/flat.fmu
32+
tests/containers/arch/reversed.fmu
33+
tests/containers/ssp/bouncing.fmu
34+
tests/containers/ssp/bouncing

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This package was formerly know as `fmutool`.
44

55
## Version 1.8
66
* CHANGE: Package in now known as `fmu_manipulation`
7+
* ADDED: `fmucontainer` support `canHandleVariableCommunicationStepSize`
8+
* ADDED: `fmucontainer` support `.spp` or `.json` as input files
9+
* ADDED: `fmucontainer` new `-dump` option to save container description
710

811
## Version 1.7.4
912
* ADDED: `fmucontainer` Linux support

container/container.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ fmi2Component fmi2Instantiate(fmi2String instanceName,
556556
container->vr_strings = NULL;
557557

558558
container->time_step = 0.001;
559+
container->time = 0.0;
559560
container->tolerance = 1.0e-8;
560561

561562
logger(container, fmi2OK, "Container model loading...");
@@ -657,6 +658,7 @@ fmi2Status fmi2SetupExperiment(fmi2Component c,
657658
return status;
658659
}
659660

661+
container->time = startTime;
660662
logger(container, fmi2OK, "fmi2SetupExperiment -- OK");
661663
return fmi2OK;
662664
}
@@ -993,18 +995,27 @@ fmi2Status fmi2DoStep(fmi2Component c,
993995
fmi2Real current_time;
994996
fmi2Status status = fmi2OK;
995997

996-
for(current_time = currentCommunicationPoint;
998+
999+
/*
1000+
* Early return if requested end_time is lower than next container time step.
1001+
*/
1002+
if (end_time < container->time + container->time_step) {
1003+
return fmi2OK;
1004+
}
1005+
1006+
for(current_time = container->time;
9971007
current_time + container->time_step < end_time;
9981008
current_time += container->time_step) {
9991009
if (container->mt)
10001010
status = do_internal_step_parallel_mt(container, current_time, container->time_step, noSetFMUStatePriorToCurrentPoint);
10011011
else
10021012
status = do_internal_step_parallel(container, current_time, container->time_step, noSetFMUStatePriorToCurrentPoint);
10031013
}
1004-
1014+
container->time = current_time;
1015+
10051016
if (fabs(currentCommunicationPoint + communicationStepSize - current_time) > container->tolerance) {
1006-
logger(container, fmi2Error, "CommunicationStepSize should be divisible by %e", container->time_step);
1007-
return fmi2Error;
1017+
logger(container, fmi2Warning, "CommunicationStepSize should be divisible by %e", container->time_step);
1018+
return fmi2Warning;
10081019
}
10091020

10101021
return status;

container/container.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct container_s {
4747
container_vr_t *vr_strings;
4848

4949
fmi2Real time_step;
50+
fmi2Real time;
5051
fmi2Real tolerance;
5152

5253
fmu_t *fmu;

container/profile.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ profile_t *profile_new(void) {
1313
profile_t *profile = malloc(sizeof(*profile));
1414

1515
profile->current_tic = 0;
16-
profile->total_ellapsed = 0.0;
16+
profile->total_elapsed = 0.0;
1717

1818
return profile;
1919
}
@@ -54,7 +54,7 @@ double profile_toc(profile_t *profile, double current_time) {
5454
now += ts.tv_sec * 1000;
5555
#endif
5656

57-
profile->total_ellapsed += (now - profile->current_tic) / 1000.0;
58-
return current_time / profile->total_ellapsed;
57+
profile->total_elapsed += (now - profile->current_tic) / 1000.0;
58+
return current_time / profile->total_elapsed;
5959
}
6060

container/profile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typedef unsigned int profile_tic_t;
1010

1111
typedef struct {
1212
profile_tic_t current_tic; /* ms */
13-
double total_ellapsed;
13+
double total_elapsed; /* s */
1414
} profile_t;
1515

1616

doc/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FMU Manipulation Toolbox import supports FMI-2.0 and Co-Simulation interface.
2020
- Simulink
2121
- [Reference FMUs](https://github.com/modelica/Reference-FMUs)
2222

23-
Automated testsuite use [bouncing_ball.fmu](../tests/bouncing_ball.fmu).
23+
Automated testsuite use [bouncing_ball.fmu](../tests/operations/bouncing_ball.fmu).
2424

2525

2626
### FMU Export Compatibility information

0 commit comments

Comments
 (0)