Quellcode durchsuchen

material for loading fmus

Claudio Gomes vor 6 Jahren
Ursprung
Commit
ca45986908
100 geänderte Dateien mit 2304 neuen und 6960 gelöschten Zeilen
  1. 2 0
      .gitignore
  2. 7 2
      Dockerfile
  3. 9 0
      cosimlibrary/LICENSE
  4. 0 0
      cosimlibrary/cosimlibrary/__init__.py
  5. BIN
      cosimlibrary/cosimlibrary/__pycache__/__init__.cpython-36.pyc
  6. 6 0
      cosimlibrary/cosimlibrary/autoinit.py
  7. 12 0
      cosimlibrary/cosimlibrary/jacobi_runner.py
  8. 80 0
      cosimlibrary/cosimlibrary/jacobit_it_runner.py
  9. 44 0
      cosimlibrary/cosimlibrary/loader.py
  10. 7 0
      cosimlibrary/cosimlibrary/results.py
  11. 136 0
      cosimlibrary/cosimlibrary/runner.py
  12. 51 0
      cosimlibrary/cosimlibrary/scenario.py
  13. 65 0
      cosimlibrary/cosimlibrary/virtual_fmus.py
  14. 100 0
      cosimlibrary/double_msd/fmus.py
  15. 0 0
      cosimlibrary/tests/__init__.py
  16. 59 0
      cosimlibrary/tests/test_run_cosim.py
  17. 1 26
      examples/Example1_CruiseController/.ipynb_checkpoints/Example1_CruiseController-checkpoint.ipynb
  18. 1 26
      examples/Example1_CruiseController/Example1_CruiseController.ipynb
  19. BIN
      examples/Example1_CruiseController/car_example.pdf
  20. 343 0
      examples/Example2_MassSpringDamper/.ipynb_checkpoints/Example2_MassSpringDamper-checkpoint.ipynb
  21. 343 0
      examples/Example2_MassSpringDamper/Example2_MassSpringDamper.ipynb
  22. 514 0
      examples/Loading_FunctionalMockupUnits/.ipynb_checkpoints/Loading_FunctionalMockupUnits-checkpoint.ipynb
  23. 514 0
      examples/Loading_FunctionalMockupUnits/Loading_FunctionalMockupUnits.ipynb
  24. 10 13
      examples/mass_spring_damper/double_mass_spring_damper.ipynb
  25. 0 352
      examples/mass_spring_damper/.ipynb_checkpoints/double_mass_spring_damper-checkpoint.ipynb
  26. 0 242
      examples/mass_spring_damper/.ipynb_checkpoints/mass_spring_damper-checkpoint.ipynb
  27. BIN
      examples/mass_spring_damper/assets/715979.png
  28. BIN
      examples/mass_spring_damper/double_msd_example_trace.pdf
  29. 0 198
      examples/mass_spring_damper/fmusdk/CMakeLists.txt
  30. 0 183
      examples/mass_spring_damper/fmusdk/CONTRIBUTING.md
  31. 0 25
      examples/mass_spring_damper/fmusdk/LICENSE.md
  32. 0 73
      examples/mass_spring_damper/fmusdk/Makefile
  33. 0 190
      examples/mass_spring_damper/fmusdk/README.md
  34. BIN
      examples/mass_spring_damper/fmusdk/docs/bouncingBallCalc.png
  35. BIN
      examples/mass_spring_damper/fmusdk/docs/fmu10-xml-schema.png
  36. BIN
      examples/mass_spring_damper/fmusdk/docs/fmus.jpg
  37. 0 11
      examples/mass_spring_damper/fmusdk/fmu20/Makefile
  38. BIN
      examples/mass_spring_damper/fmusdk/fmu20/bin/7z.dll
  39. BIN
      examples/mass_spring_damper/fmusdk/fmu20/bin/7z.exe
  40. 0 57
      examples/mass_spring_damper/fmusdk/fmu20/bin/License.txt
  41. BIN
      examples/mass_spring_damper/fmusdk/fmu20/bin/win32/fmusim_cs.exe
  42. BIN
      examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/bouncingBall.fmu
  43. BIN
      examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/dq.fmu
  44. BIN
      examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/inc.fmu
  45. BIN
      examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/values.fmu
  46. BIN
      examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/vanDerPol.fmu
  47. 0 88
      examples/mass_spring_damper/fmusdk/fmu20/src/Makefile
  48. 0 20
      examples/mass_spring_damper/fmusdk/fmu20/src/build_all.bat
  49. 0 69
      examples/mass_spring_damper/fmusdk/fmu20/src/build_fmusim_cs.bat
  50. 0 181
      examples/mass_spring_damper/fmusdk/fmu20/src/co_simulation/main.c
  51. 0 72
      examples/mass_spring_damper/fmusdk/fmu20/src/models/Makefile
  52. 0 3
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/Makefile
  53. 0 131
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/bouncingBall.c
  54. 0 55
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/index.html
  55. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/model.png
  56. 0 62
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/modelDescription_cs.xml
  57. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/plot_h.PNG
  58. 0 55
      examples/mass_spring_damper/fmusdk/fmu20/src/models/build_fmu
  59. 0 93
      examples/mass_spring_damper/fmusdk/fmu20/src/models/build_fmu.bat
  60. 0 3
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/Makefile
  61. 0 71
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/dq.c
  62. 0 33
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/index.html
  63. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/model.png
  64. 0 47
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/modelDescription_cs.xml
  65. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/plot_x.PNG
  66. 0 925
      examples/mass_spring_damper/fmusdk/fmu20/src/models/fmuTemplate.c
  67. 0 170
      examples/mass_spring_damper/fmusdk/fmu20/src/models/fmuTemplate.h
  68. 0 3
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/Makefile
  69. 0 61
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/inc.c
  70. 0 22
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/index.html
  71. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/model.png
  72. 0 36
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/modelDescription_cs.xml
  73. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/plot_counter.PNG
  74. 0 3
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/Makefile
  75. 0 23
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/index.html
  76. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/model.png
  77. 0 72
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/modelDescription_cs.xml
  78. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/values.PNG
  79. 0 90
      examples/mass_spring_damper/fmusdk/fmu20/src/models/values/values.c
  80. 0 3
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/Makefile
  81. 0 27
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/index.html
  82. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/model.png
  83. 0 57
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/modelDescription_cs.xml
  84. BIN
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/plot_states.png
  85. 0 77
      examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/vanDerPol.c
  86. 0 91
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/fmi2.h
  87. 0 243
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2FunctionTypes.h
  88. 0 333
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2Functions.h
  89. 0 115
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2TypesPlatform.h
  90. 0 676
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlElement.cpp
  91. 0 328
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParser.cpp
  92. 0 242
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParserCApi.cpp
  93. 0 203
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParserCApi.h
  94. 0 163
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlElement.h
  95. 0 129
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlParser.h
  96. 0 58
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlParserException.h
  97. 0 173
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/SAX.h
  98. 0 176
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/SAX2.h
  99. 0 80
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/dict.h
  100. 0 0
      examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/encoding.h

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+.idea/
+*.pyc

+ 7 - 2
Dockerfile

@@ -4,9 +4,14 @@ FROM continuumio/anaconda3:latest
 # Install Jupyter
 RUN /opt/conda/bin/conda install jupyter -y --quiet
 
-# Copy local examples to the remote notebooks
+# Install fmipy
+RUN /opt/conda/bin/conda install -c conda-forge fmpy -y --quiet
+
+# Copy local files to the remote notebooks
 RUN mkdir /opt/notebooks
-COPY examples /opt/notebooks
+COPY examples /opt/notebooks/examples
+COPY fmus /opt/notebooks/fmus
+COPY cosimlibrary /opt/notebooks/cosimlibrary
 
 # Port
 EXPOSE 8888

Datei-Diff unterdrückt, da er zu groß ist
+ 9 - 0
cosimlibrary/LICENSE


+ 0 - 0
cosimlibrary/cosimlibrary/__init__.py


BIN
cosimlibrary/cosimlibrary/__pycache__/__init__.cpython-36.pyc


+ 6 - 0
cosimlibrary/cosimlibrary/autoinit.py

@@ -0,0 +1,6 @@
+class AutoInit:
+    def __init__(self, **args):
+        for (k, v) in args.items():
+            if not hasattr(self, k):
+                raise RuntimeError("Unknown attribute: ", k)
+            setattr(self, k, v)

+ 12 - 0
cosimlibrary/cosimlibrary/jacobi_runner.py

@@ -0,0 +1,12 @@
+from cosimlibrary.runner import CosimRunner
+from cosimlibrary.scenario import CosimScenario
+
+
+class JacobiRunner(CosimRunner):
+    """
+    This class implements the jacobi co-simulation algorithm.
+    """
+    def run_cosim_step(self, time, scenario: CosimScenario):
+        for f in scenario.fmus:
+            f.doStep(time, scenario.step_size)
+        self.propagate_outputs(scenario)

+ 80 - 0
cosimlibrary/cosimlibrary/jacobit_it_runner.py

@@ -0,0 +1,80 @@
+from typing import List
+
+from cosimlibrary.runner import CosimRunner
+from cosimlibrary.scenario import CosimScenario, VarType
+import numpy as np
+
+class JacobiIterativeRunner(CosimRunner):
+    def __init__(self, max_iterations: int, tol: float):
+        self.max_iterations = max_iterations
+        self.tol = tol
+
+    def run_cosim_step(self, time, scenario: CosimScenario):
+        has_converged = False
+        previous_outputs: List[List[float]] = None
+        new_outputs: List[List[float]] = []
+        iteration_count = 0
+        while not has_converged:
+            # Record state
+            old_states = [(f, f.getFMUstate()) for f in scenario.fmus]
+
+            # Feed the outputs recorded in the previous iteration
+            no_output_records = previous_outputs is None
+            output_index = 0
+            for c in scenario.connections:
+                if c.target_fmu is not None:
+                    if c.value_type == VarType.REAL:
+                        previous_output_value = None
+                        if no_output_records:
+                            new_output_value = c.source_fmu.getReal(c.source_vr)
+                            previous_output_value = new_output_value
+                        else:
+                            previous_output_value = previous_outputs[output_index]
+                        output_index += 1
+                        c.target_fmu.setReal(c.target_vr, previous_output_value)
+                    else:
+                        # TODO: find a way to support the multiple types elegantly.
+                        raise NotImplementedError()
+
+            # Run cosim step
+            for f in scenario.fmus:
+                f.doStep(time, scenario.step_size)
+
+            # Record new outputs, and check for convergence
+            output_index = 0
+            has_converged = True
+            for c in scenario.connections:
+                if c.target_fmu is not None:
+                    if c.value_type == VarType.REAL:
+                        # Gets the new output value, but forwards the previous output value.
+                        # This way, we make sure that every FMU keeps getting updated outputs at every iteration.
+                        # The propagation of outputs to inputs is slower this way,
+                        #   but the alternative is to select a few strategic connections to do this,
+                        #   which is harder to implement.
+                        new_output_value = c.source_fmu.getReal(c.source_vr)
+                        new_outputs.append(new_output_value)
+                        if no_output_records:
+                            has_converged = False
+                        else:
+                            previous_output_value = previous_outputs[output_index]
+                            assert len(previous_output_value) == len(new_output_value)
+                            if has_converged:
+                                for (po,no) in zip(previous_output_value, new_output_value):
+                                    if (not np.isclose(po, no,rtol=self.tol,
+                                                            atol=self.tol)):
+                                        has_converged = False
+                        output_index += 1
+                    else:
+                        # TODO: find a way to support the multiple types elegantly.
+                        raise NotImplementedError()
+
+            previous_outputs = new_outputs
+            new_outputs = []
+
+            # Check if convergence has been achieved, or the max number of iterations has been reached.
+            iteration_count += 1
+            has_converged = has_converged or iteration_count > self.max_iterations
+            if not has_converged:
+                # Rollback and Repeat if necessary
+                for (f,s) in old_states:
+                    f.setFMUstate(s)

+ 44 - 0
cosimlibrary/cosimlibrary/loader.py

@@ -0,0 +1,44 @@
+from fmpy import read_model_description, extract
+from typing import Dict
+import shutil
+from fmpy.fmi2 import FMU2Slave
+from fmpy.model_description import ScalarVariable
+from cosimlibrary.autoinit import AutoInit
+
+
+class LoadedFMU(AutoInit):
+    fmu: FMU2Slave = None
+    dir: str = None
+    vars: Dict[str, ScalarVariable] = None
+
+
+class FMULoader:
+
+    @staticmethod
+    def get_vars(model_description):
+        vrs = {}
+        for variable in model_description.modelVariables:
+            vrs[variable.name] = variable
+        return vrs
+
+    @staticmethod
+    def load(fmu_path, instance_name, logger):
+        unzipdir = extract(fmu_path)
+        desc = read_model_description(fmu_path)
+        vars = FMULoader.get_vars(desc)
+        fmu = FMU2Slave(guid=desc.guid,
+                        unzipDirectory=unzipdir,
+                        modelIdentifier=desc.coSimulation.modelIdentifier,
+                        instanceName=instance_name,
+                        fmiCallLogger=logger)
+        return LoadedFMU(fmu=fmu, dir=unzipdir, vars=vars)
+
+    @staticmethod
+    def unload(loaded_fmu: LoadedFMU):
+        loaded_fmu.fmu.freeInstance()
+        shutil.rmtree(loaded_fmu.dir)
+
+
+
+
+

+ 7 - 0
cosimlibrary/cosimlibrary/results.py

@@ -0,0 +1,7 @@
+from typing import Dict, List
+
+
+class CosimResults:
+    signals: Dict[str, Dict[int, List[float]]] # Stores all signals in a continuous timeline (consistent with timestamps)
+    timestamps: List[float]
+    abstract_modes: Dict[str, Dict[int, List[float]]] # Stores the sequences of modes (not consistent with timeline)

+ 136 - 0
cosimlibrary/cosimlibrary/runner.py

@@ -0,0 +1,136 @@
+from typing import List, Callable
+import numpy as np
+from cosimlibrary.results import CosimResults
+from cosimlibrary.scenario import CosimScenario, VarType, SignalType
+
+class CosimRunner:
+    """
+    This class is responsible for running co-simulations.
+    It gets a set of FMUs, their interconnections, parameters, and runs them.
+    It assumes that the FMUs are loaded and have been instantiated elsewhere.
+    The outputs are handled by some other objects as well.
+    The concrete co-simulation step is implemented by subclasses.
+    """
+
+    def propagate_initial_outputs(self, scenario: CosimScenario):
+        """
+        To be subclassed by specialized methods.
+        Default implementation is normal output propagation.
+        :param scenario:
+        :return:
+        """
+        self.propagate_outputs(scenario)
+
+    def propagate_outputs(self, scenario: CosimScenario):
+        """
+        For now, we use the order of the connections as an indicator for the order of output propagation.
+        This means the user is responsible for providing this information.
+        """
+        for c in scenario.connections:
+            if c.target_fmu is not None:
+                if c.value_type == VarType.REAL:
+                    c.target_fmu.setReal(c.target_vr, c.source_fmu.getReal(c.source_vr))
+                else:
+                    c.target_fmu.setBoolean(c.target_vr, c.source_fmu.getBoolean(c.source_vr))
+
+    def init_results(self, scenario: CosimScenario):
+        results = CosimResults()
+        results.timestamps = []
+        results.signals = {}
+        results.abstract_modes = {}
+        for ov in scenario.outputs:
+            if ov.source_fmu.instanceName not in results.signals.keys():
+                assert ov.source_fmu.instanceName not in results.abstract_modes.keys(), "Using duplicate connections for output is not allowed."
+                results.signals[ov.source_fmu.instanceName] = {}
+                results.abstract_modes[ov.source_fmu.instanceName] = {}
+            for vr in ov.source_vr:
+                assert vr not in results.signals[ov.source_fmu.instanceName].keys(), "Using duplicate connections for output is not allowed."
+                results.signals[ov.source_fmu.instanceName][vr] = []
+            # Init the modes (only for discontinuous signals)
+            if ov.signal_type == SignalType.DISCONTINUOUS:
+                for vr in ov.source_vr:
+                    assert vr not in results.abstract_modes[ov.source_fmu.instanceName].keys()
+                    results.abstract_modes[ov.source_fmu.instanceName][vr] = []
+        return results
+
+    def snapshot(self, time:float, scenario: CosimScenario, results: CosimResults):
+        results.timestamps.append(time)
+        for ov in scenario.outputs:
+            values: List = None
+            if ov.value_type == VarType.REAL:
+                values = ov.source_fmu.getReal(ov.source_vr)
+            else:
+                values = ov.source_fmu.getBoolean(ov.source_vr)
+            # Each item with index i in values corresponds to the value of item with index i in ov.source_vr
+            for i in range(len(values)):
+                value_append = values[i]
+                vr: int = ov.source_vr[i]
+                signal = results.signals[ov.source_fmu.instanceName][vr]
+                signal.append(value_append)
+            # Aggregate modes
+            if ov.signal_type==SignalType.DISCONTINUOUS:
+                # If last known mode has changed (module quantization_tol), then it's a new mode.
+                for i in range(len(values)):
+                    current_mode = values[i]
+                    vr: int = ov.source_vr[i]
+                    abstract_modes = results.abstract_modes[ov.source_fmu.instanceName][vr]
+                    if len(abstract_modes) == 0:
+                        abstract_modes.append(current_mode)
+                    else:
+                        last_mode = abstract_modes[-1]
+                        if not np.isclose(current_mode, last_mode, rtol=ov.quantization_tol, atol=ov.quantization_tol):
+                            abstract_modes.append(current_mode)
+
+    def should_continue(self, scenario, time):
+        end_connection = scenario.stop_condition
+        if end_connection is None:
+            assert scenario.stop_time > 0.0
+            return (time < scenario.stop_time) or \
+                   np.isclose(time, scenario.stop_time, rtol=scenario.step_size * 1e-03, atol=scenario.step_size * 1e-03)
+        last_value = end_connection.source_fmu.getReal(end_connection.source_vr)[0]
+        return last_value > 0.0 and not \
+            np.isclose(last_value, 0.0, rtol=scenario.step_size*1e-3, atol=scenario.step_size*1e-3)
+
+    def run_cosim_step(self, time, scenario: CosimScenario):
+        """
+        To be overriden.
+        Implements the cosim step algorithm.
+        :param time:
+        :param scenario:
+        :return:
+        """
+        raise NotImplementedError("This method needs to be overriden.")
+
+    def run_cosim(self, scenario: CosimScenario, status: Callable):
+        # Init results
+        results = self.init_results(scenario)
+
+        for f in scenario.fmus:
+            f.setupExperiment()
+            f.enterInitializationMode()
+
+        # TODO Support fixed point iteration initialization
+        self.propagate_initial_outputs(scenario)
+
+        for f in scenario.fmus:
+            f.exitInitializationMode()
+
+        time = 0.0
+        print_frequency = int(scenario.print_interval / scenario.step_size)
+        print_counter = print_frequency
+
+        self.snapshot(time, scenario, results)
+        should_continue = self.should_continue(scenario, time)
+        # TODO: Take output snapshot
+        while should_continue:
+            self.run_cosim_step(time, scenario)
+
+            print_counter -= 1
+            time += scenario.step_size
+            should_continue = self.should_continue(scenario, time)
+            if print_counter == 0:
+                status(time)
+                self.snapshot(time, scenario, results)
+                print_counter = print_frequency
+
+        return results

+ 51 - 0
cosimlibrary/cosimlibrary/scenario.py

@@ -0,0 +1,51 @@
+from enum import Enum,auto
+from typing import List, Dict, Callable
+from fmpy.fmi2 import FMU2Slave
+from cosimlibrary.autoinit import AutoInit
+
+
+class VarType(Enum):
+    REAL = auto()
+    BOOL = auto()
+
+class SignalType(Enum):
+    CONTINUOUS = auto()
+    DISCONTINUOUS = auto()
+
+class Connection(AutoInit):
+    value_type: VarType = None
+    signal_type: SignalType = None
+    quantization_tol: float = 1e-3 # Determines the different modes considered.
+    source_fmu: FMU2Slave = None
+    target_fmu: FMU2Slave = None
+    source_vr: List[int] = None
+    target_vr: List[int] = None
+
+class OutputConnection(Connection):
+    pass
+
+class CosimScenario(AutoInit):
+    """
+    This class represents a co-simulation scenario: fmu instances, how they are connected, and default parameters
+    """
+    fmus: List[FMU2Slave] = None
+    connections: List[Connection] = None
+    step_size: float = 1e-3
+    stop_time: float = -1.0
+    stop_condition: Connection = None
+    print_interval: int = 1e-2
+    outputs: List[OutputConnection] = None
+    # TODO: FMU parameters
+    fmu_connections: Dict[str, Dict[int, Connection]]
+
+    def __init__(self, **args):
+        super().__init__(**args)
+
+        # Build fmu connections
+        self.fmu_connections = {}
+        for c in self.outputs:
+            if c.source_fmu.instanceName not in self.fmu_connections.keys():
+                self.fmu_connections[c.source_fmu.instanceName] = {}
+            for vr in c.source_vr:
+                assert vr not in self.fmu_connections[c.source_fmu.instanceName].keys()
+                self.fmu_connections[c.source_fmu.instanceName][vr] = c

+ 65 - 0
cosimlibrary/cosimlibrary/virtual_fmus.py

@@ -0,0 +1,65 @@
+from typing import List, Callable
+
+from fmpy.fmi2 import FMU2Slave, fmi2OK, fmi2True
+
+
+class VirtualFMU(FMU2Slave):
+    """
+    Utility class to override the FMI2 C methods.
+    """
+    state: List[float] = None
+    state_size: int = 0
+
+    def __init__(self, instanceName: str, state_size: int):
+        self.instanceName = instanceName
+        self.state_size = state_size
+        self.reset()
+
+    def reset(self):
+        self.state = [0.0] * self.state_size
+
+    def instantiate(self, visible=False, callbacks=None, loggingOn=False):
+        pass
+
+    def terminate(self):
+        pass
+
+    def doStep(self, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint=fmi2True):
+        return fmi2OK
+
+    def setupExperiment(self, tolerance=None, startTime=0.0, stopTime=None):
+        pass
+
+    def enterInitializationMode(self):
+        pass
+
+    def exitInitializationMode(self):
+        pass
+
+    def getReal(self, vr):
+        values = [self.state[v] for v in vr]
+        return values
+
+    def getInteger(self, vr):
+        values = self.getReal(vr)
+        return [int(n) for n in values]
+
+    def getBoolean(self, vr):
+        values = self.getReal(vr)
+        return [v > 0.5 for v in values]
+
+    def setReal(self, vr, value):
+        for i in range(len(value)):
+            self.state[vr[i]] = value[i]
+
+    def setInteger(self, vr, value):
+        self.setReal(vr, value)
+
+    def setBoolean(self, vr, value):
+        self.setReal(vr, [(1.0 if b else 0.0) for b in value])
+
+    def getFMUstate(self):
+        return self.state.copy()
+
+    def setFMUstate(self, state):
+        self.state = state.copy()

+ 100 - 0
cosimlibrary/double_msd/fmus.py

@@ -0,0 +1,100 @@
+from fmpy.fmi2 import fmi2True
+
+from cosimlibrary.virtual_fmus import VirtualFMU
+
+
+class MSD1(VirtualFMU):
+    def __init__(self, instanceName):
+        ref = 0
+        self.x = ref;
+        ref += 1
+        self.v = ref;
+        ref += 1
+        self.m = ref;
+        ref += 1
+        self.c = ref;
+        ref += 1
+        self.cf = ref;
+        ref += 1
+        self.fe = ref;
+        ref += 1
+
+        super().__init__(instanceName, ref)
+
+    def reset(self):
+        super().reset()
+
+        self.state[self.x] = 1.0
+        self.state[self.v] = 0.0
+        self.state[self.m] = 1.0
+        self.state[self.c] = 1.0
+        self.state[self.cf] = 1.0
+        self.state[self.fe] = 0.0
+
+    def doStep(self, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint=fmi2True):
+        n = 10
+        h = communicationStepSize / n
+        for i in range(n):
+            der_x = self.state[self.v]
+            der_v = (1.0 / self.state[self.m]) * (- self.state[self.c] * self.state[self.x]
+                                                  - self.state[self.cf] * self.state[self.v]
+                                                  + self.state[self.fe])
+
+            self.state[self.x] = self.state[self.x] + der_x * h
+            self.state[self.v] = self.state[self.v] + der_v * h
+
+
+class MSD2(VirtualFMU):
+    def __init__(self, instanceName):
+        ref = 0
+        self.x = ref;
+        ref += 1
+        self.v = ref;
+        ref += 1
+        self.m = ref;
+        ref += 1
+        self.c = ref;
+        ref += 1
+        self.cf = ref;
+        ref += 1
+        self.ce = ref;
+        ref += 1
+        self.cef = ref;
+        ref += 1
+        self.fe = ref;
+        ref += 1
+        self.xe = ref;
+        ref += 1
+        self.ve = ref;
+        ref += 1
+
+        super().__init__(instanceName, ref)
+
+    def reset(self):
+        super().reset()
+
+        self.state[self.x] = 0.0
+        self.state[self.v] = 0.0
+        self.state[self.m] = 1.0
+        self.state[self.c] = 1.0
+        self.state[self.cf] = 0.0
+        self.state[self.ce] = 1.0
+        self.state[self.cef] = 1.0
+        self.state[self.fe] = 0.0
+        self.state[self.xe] = 0.0
+        self.state[self.ve] = 0.0
+
+    def doStep(self, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint=fmi2True):
+        n = 10
+        h = communicationStepSize / n
+        for i in range(n):
+            self.state[self.fe] = self.state[self.ce] * (self.state[self.x] - self.state[self.xe]) \
+                                  + self.state[self.cef] * (self.state[self.v] - self.state[self.ve])
+
+            der_x = self.state[self.v]
+            der_v = (1.0 / self.state[self.m]) * (- self.state[self.c] * self.state[self.x]
+                                                  - self.state[self.cf] * self.state[self.v]
+                                                  - self.state[self.fe])
+
+            self.state[self.x] = self.state[self.x] + der_x * h
+            self.state[self.v] = self.state[self.v] + der_v * h

+ 0 - 0
cosimlibrary/tests/__init__.py


+ 59 - 0
cosimlibrary/tests/test_run_cosim.py

@@ -0,0 +1,59 @@
+import unittest
+
+from cosimlibrary.jacobit_it_runner import JacobiIterativeRunner
+from cosimlibrary.scenario import Connection, VarType, SignalType, OutputConnection, CosimScenario
+from double_msd.fmus import *
+
+
+class CosimTestSuite(unittest.TestCase):
+    """Basic test cases."""
+
+    def build_double_msd_scenario(self):
+        msd1 = MSD1("msd1")
+        msd1.instantiate()
+        msd2 = MSD2("msd2")
+        msd2.instantiate()
+
+        msd1_out = Connection(value_type=VarType.REAL,
+                              signal_type=SignalType.CONTINUOUS,
+                              source_fmu=msd1,
+                              target_fmu=msd2,
+                              source_vr=[msd1.x, msd1.v],
+                              target_vr=[msd2.xe, msd2.ve])
+        msd1_in = Connection(value_type=VarType.REAL,
+                             signal_type=SignalType.CONTINUOUS,
+                             source_fmu=msd2,
+                             target_fmu=msd1,
+                             source_vr=[msd2.fe],
+                             target_vr=[msd1.fe])
+        msd2_out = OutputConnection(value_type=VarType.REAL,
+                                    signal_type=SignalType.CONTINUOUS,
+                                    source_fmu=msd2,
+                                    source_vr=[msd2.x, msd2.v])
+
+        connections = [msd1_out, msd1_in]
+        out_connections = [msd1_out, msd1_in, msd2_out]
+        scenario = CosimScenario(
+            fmus=[msd1, msd2],
+            connections=connections,
+            step_size=0.01,
+            print_interval=0.1,
+            stop_time=7.0,
+            outputs=out_connections)
+        return scenario
+
+    def test_run_dmsd_jacobiIt(self):
+        scenario = self.build_double_msd_scenario()
+
+        runner = JacobiIterativeRunner(100, 1e-4)
+
+        results = runner.run_cosim(scenario, lambda t: None)
+
+        for f in scenario.fmus:
+            f.terminate()
+
+        msd1 = next(f for f in scenario.fmus if f.instanceName == "msd1")
+        msd2 = next(f for f in scenario.fmus if f.instanceName == "msd2")
+
+        self.assertTrue(results.timestamps[-1] > 6.0)
+        self.assertTrue(results.signals[msd1.instanceName][msd1.x][-1] > -1.0)

+ 1 - 26
examples/Example1_CruiseController/.ipynb_checkpoints/Example1_CruiseController-checkpoint.ipynb

@@ -236,7 +236,7 @@
     "v_t_example = v_t.subs(m,1576.0).subs(vd,40).subs(v0,v0_num).subs(k,1000).subs(d,0.5)\n",
     "dv_dt_example = dv_dt.subs(m,1576.0).subs(vd,40).subs(v0,v0_num).subs(k,1000).subs(d,0.5)\n",
     "\n",
-    "# Define simulation step size\n",
+    "# Define simulation step size, time range, and total number of steps to be taken.\n",
     "h=0.2\n",
     "t_range = np.arange(0,7,h)\n",
     "num_steps = len(t_range)\n",
@@ -267,31 +267,6 @@
     "\n",
     "plt.show()"
    ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "def convert_autonomous_ode(A, B, x0):\n",
-    "    n = np.shape(A)[0]\n",
-    "    x0 = np.concatenate((x0, np.matrix([[1]])), axis=0) # vertical\n",
-    "    A_expanded = np.concatenate((np.concatenate((A,             B)            , axis=1),\n",
-    "                                 np.concatenate((np.zeros((1,n)), np.zeros((1,1))), axis=1)), axis=0)\n",
-    "    return (A_expanded, x0)\n",
-    "\n",
-    "def analytical_solution_matrix(A, B, x0, h, max_steps):\n",
-    "    # Computes solution to dx/dt = A*x + B\n",
-    "    n = np.shape(A)[0]\n",
-    "    (A_expanded, x) =  convert_autonomous_ode(A, B, x0)\n",
-    "    exphA = linalg.expm(h*A_expanded)\n",
-    "    xs = [x]\n",
-    "    for i in range(1, max_steps):\n",
-    "        x = exphA * x\n",
-    "        xs.append(x)\n",
-    "    return [x[0:n] for x in xs]"
-   ]
   }
  ],
  "metadata": {

+ 1 - 26
examples/Example1_CruiseController/Example1_CruiseController.ipynb

@@ -236,7 +236,7 @@
     "v_t_example = v_t.subs(m,1576.0).subs(vd,40).subs(v0,v0_num).subs(k,1000).subs(d,0.5)\n",
     "dv_dt_example = dv_dt.subs(m,1576.0).subs(vd,40).subs(v0,v0_num).subs(k,1000).subs(d,0.5)\n",
     "\n",
-    "# Define simulation step size\n",
+    "# Define simulation step size, time range, and total number of steps to be taken.\n",
     "h=0.2\n",
     "t_range = np.arange(0,7,h)\n",
     "num_steps = len(t_range)\n",
@@ -267,31 +267,6 @@
     "\n",
     "plt.show()"
    ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "def convert_autonomous_ode(A, B, x0):\n",
-    "    n = np.shape(A)[0]\n",
-    "    x0 = np.concatenate((x0, np.matrix([[1]])), axis=0) # vertical\n",
-    "    A_expanded = np.concatenate((np.concatenate((A,             B)            , axis=1),\n",
-    "                                 np.concatenate((np.zeros((1,n)), np.zeros((1,1))), axis=1)), axis=0)\n",
-    "    return (A_expanded, x0)\n",
-    "\n",
-    "def analytical_solution_matrix(A, B, x0, h, max_steps):\n",
-    "    # Computes solution to dx/dt = A*x + B\n",
-    "    n = np.shape(A)[0]\n",
-    "    (A_expanded, x) =  convert_autonomous_ode(A, B, x0)\n",
-    "    exphA = linalg.expm(h*A_expanded)\n",
-    "    xs = [x]\n",
-    "    for i in range(1, max_steps):\n",
-    "        x = exphA * x\n",
-    "        xs.append(x)\n",
-    "    return [x[0:n] for x in xs]"
-   ]
   }
  ],
  "metadata": {

BIN
examples/Example1_CruiseController/car_example.pdf


Datei-Diff unterdrückt, da er zu groß ist
+ 343 - 0
examples/Example2_MassSpringDamper/.ipynb_checkpoints/Example2_MassSpringDamper-checkpoint.ipynb


Datei-Diff unterdrückt, da er zu groß ist
+ 343 - 0
examples/Example2_MassSpringDamper/Example2_MassSpringDamper.ipynb


Datei-Diff unterdrückt, da er zu groß ist
+ 514 - 0
examples/Loading_FunctionalMockupUnits/.ipynb_checkpoints/Loading_FunctionalMockupUnits-checkpoint.ipynb


Datei-Diff unterdrückt, da er zu groß ist
+ 514 - 0
examples/Loading_FunctionalMockupUnits/Loading_FunctionalMockupUnits.ipynb


+ 10 - 13
examples/mass_spring_damper/double_mass_spring_damper.ipynb

@@ -7,26 +7,23 @@
     "# Double Mass Spring Damper Co-simulation Example"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Load required libraries:"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 1,
    "metadata": {},
    "outputs": [],
    "source": [
-    "from sympy import *\n",
-    "init_printing()\n",
     "import matplotlib.pyplot as plt\n",
-    "from scipy import linalg\n",
-    "from scipy.linalg import expm\n",
-    "import numpy as np\n",
-    "from numpy import linalg as LA\n",
-    "from matplotlib.backends.backend_pdf import PdfPages\n",
-    "from collections import deque\n",
-    "\n",
-    "# Import local code\n",
     "import sys\n",
-    "sys.path.append(\"C:\\\\srcctrl\\\\2019.SummerSim.Paper\\\\experiments\\\\PowerWindow\\\\FaultInjectionCosim\")\n",
-    "from fmifaultinjection.core import *"
+    "sys.path.append(\"../../cosimlibrary\")\n",
+    "from cosimlibrary.loader import FMULoader"
    ]
   },
   {
@@ -344,7 +341,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.6.5"
+   "version": "3.6.8"
   }
  },
  "nbformat": 4,

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 352
examples/mass_spring_damper/.ipynb_checkpoints/double_mass_spring_damper-checkpoint.ipynb


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 242
examples/mass_spring_damper/.ipynb_checkpoints/mass_spring_damper-checkpoint.ipynb


BIN
examples/mass_spring_damper/assets/715979.png


BIN
examples/mass_spring_damper/double_msd_example_trace.pdf


+ 0 - 198
examples/mass_spring_damper/fmusdk/CMakeLists.txt

@@ -1,198 +0,0 @@
-cmake_minimum_required (VERSION 3.2)
-
-FUNCTION(cat IN_FILE OUT_FILE)
-  file(READ ${IN_FILE} CONTENTS)
-  file(APPEND ${OUT_FILE} "${CONTENTS}")
-ENDFUNCTION()
-
-project (FMUSDK)
-
-if (WIN32)
-   set(FMI_PLATFORM win)
-elseif (APPLE)
-   set(FMI_PLATFORM darwin)
-else ()
-   set(FMI_PLATFORM linux)
-endif ()
-
-if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
-    set (FMI_PLATFORM ${FMI_PLATFORM}64)
-else ()
-    set (FMI_PLATFORM ${FMI_PLATFORM}32)
-endif ()
-
-MESSAGE("FMI_PLATFORM: " ${FMI_PLATFORM})
-
-# --------------------- FMU models ---------------------
-foreach (FMI_VERSION 20)
-foreach (FMI_TYPE cs)
-foreach (MODEL_NAME bouncingBall dq inc values vanDerPol)
-
-set(TARGET_NAME ${MODEL_NAME}_${FMI_VERSION}_${FMI_TYPE})
-
-add_library(${TARGET_NAME} SHARED fmu${FMI_VERSION}/src/models/${MODEL_NAME}/${MODEL_NAME}.c fmu${FMI_VERSION}/src/models/${MODEL_NAME}/modelDescription_${FMI_TYPE}.xml)
-
-file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE})
-
-target_compile_definitions(${TARGET_NAME} PRIVATE DISABLE_PREFIX)
-
-if (${FMI_TYPE} MATCHES "cs")
-  target_compile_definitions(${TARGET_NAME} PRIVATE FMI_COSIMULATION)
-endif()
-
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/models")
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/include")
-
-set(FMU_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/temp/fmu${FMI_VERSION}/${FMI_TYPE}/${MODEL_NAME})
-
-set_target_properties(${TARGET_NAME} PROPERTIES
-    RUNTIME_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    RUNTIME_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    LIBRARY_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    LIBRARY_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    LIBRARY_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    ARCHIVE_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    ARCHIVE_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-    ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}/binaries/${FMI_PLATFORM}"
-)
-
-set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "")
-set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME ${MODEL_NAME})
-
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-  ${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/models/${MODEL_NAME}/modelDescription_${FMI_TYPE}.xml
-  "${FMU_BUILD_DIR}/modelDescription.xml"
-)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/models/${MODEL_NAME}/${MODEL_NAME}.c"
-  "${FMU_BUILD_DIR}/sources/${MODEL_NAME}.c"
-)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/models/fmuTemplate.c"
-  "${FMU_BUILD_DIR}/sources/fmuTemplate.c"
-)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-  "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/models/fmuTemplate.h"
-  "${FMU_BUILD_DIR}/sources/fmuTemplate.h"
-)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE}/${MODEL_NAME}.fmu" --format=zip
-  "modelDescription.xml"
-  "binaries"
-  "sources"
-  WORKING_DIRECTORY ${FMU_BUILD_DIR}
-)
-
-endforeach(MODEL_NAME)
-endforeach(FMI_TYPE)
-endforeach(FMI_VERSION)
-
-# --------------------- FMU simulators ---------------------
-foreach (FMI_VERSION 20)
-foreach (FMI_TYPE cs)
-set(TARGET_NAME fmusim_${FMI_VERSION}_${FMI_TYPE})
-
-if (${FMI_TYPE} STREQUAL "cs")
-  set(SIM_TYPE co_simulation)
-else ()
-  set(SIM_TYPE model_exchange)
-endif ()
-
-set(SRCS
-  "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/sim_support.c"
-  "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/xmlVersionParser.c")
-
-if (${FMI_VERSION} EQUAL 10)
-  set(SRCS ${SRCS}
-    "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/stack.c"
-    "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/xml_parser.c")
-else ()
-  set(SRCS ${SRCS}
-    "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/XmlElement.cpp"
-    "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/XmlParser.cpp"
-    "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/XmlParserCApi.cpp")
-endif ()
-
-add_executable(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/${SIM_TYPE}/main.c" ${SRCS})
-
-file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE})
-
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/${SIM_TYPE}")
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared")
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/include")
-target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser")
-
-if (${FMI_TYPE} STREQUAL "cs")
-  target_compile_definitions(${TARGET_NAME} PRIVATE FMI_COSIMULATION)
-endif ()
-target_compile_definitions(${TARGET_NAME} PRIVATE STANDALONE_XML_PARSER)
-target_compile_definitions(${TARGET_NAME} PRIVATE LIBXML_STATIC)
-
-if (WIN32)
-  set(TARGET_OUTPUT_NAME "${TARGET_NAME}.exe")
-  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
-  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
-  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
-
-  target_link_libraries (${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/${FMI_PLATFORM}/libxml2.lib")
-  if (${FMI_VERSION} EQUAL 10)
-    target_link_libraries (${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/fmu${FMI_VERSION}/src/shared/parser/${FMI_PLATFORM}/libexpatMT.lib")
-  endif ()
-else ()
-  set(TARGET_OUTPUT_NAME "${TARGET_NAME}")
-  target_link_libraries (${TARGET_NAME} PRIVATE "dl")
-  target_link_libraries (${TARGET_NAME} PRIVATE "xml2")
-  target_link_libraries (${TARGET_NAME} PRIVATE "expat")
-endif ()
-
-
-set(FMU_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/temp/fmu${FMI_VERSION}/${FMI_TYPE})
-
-set_target_properties(${TARGET_NAME} PROPERTIES
-    RUNTIME_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}"
-    RUNTIME_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}"
-    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}"
-    LIBRARY_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}"
-    LIBRARY_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}"
-    LIBRARY_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}"
-    ARCHIVE_OUTPUT_DIRECTORY         "${FMU_BUILD_DIR}"
-    ARCHIVE_OUTPUT_DIRECTORY_DEBUG   "${FMU_BUILD_DIR}"
-    ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${FMU_BUILD_DIR}"
-)
-
-add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-  "${FMU_BUILD_DIR}/${TARGET_OUTPUT_NAME}"
-  "${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE}/"
-)
-
-endforeach(FMI_TYPE)
-endforeach(FMI_VERSION)
-
-# --------------------- test simulators and models ---------------------
-enable_testing()
-foreach (FMI_VERSION 20)
-foreach (FMI_TYPE cs)
-foreach (MODEL_NAME bouncingBall dq inc values vanDerPol)
-
-set(FMU_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/temp/fmu${FMI_VERSION}/${FMI_TYPE})
-set(TEST_NAME test_${MODEL_NAME}_${FMI_VERSION}_${FMI_TYPE})
-
-add_test(NAME ${TEST_NAME}
-	COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE}/fmusim_${FMI_VERSION}_${FMI_TYPE}"
-			"${CMAKE_CURRENT_SOURCE_DIR}/dist/fmu${FMI_VERSION}/${FMI_TYPE}/${MODEL_NAME}.fmu"
-	WORKING_DIRECTORY "${FMU_BUILD_DIR}/${MODEL_NAME}"
-)
-set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT FMUSDK_HOME=${CMAKE_CURRENT_SOURCE_DIR})
- 
-endforeach(MODEL_NAME)
-endforeach(FMI_TYPE)
-endforeach(FMI_VERSION)
-

+ 0 - 183
examples/mass_spring_damper/fmusdk/CONTRIBUTING.md

@@ -1,183 +0,0 @@
-# Contributing to this project
-
-Please take a moment to review this document in order to make the contribution
-process easy and effective for everyone involved.
-
-Following these guidelines helps to communicate that you respect the time of
-the developers managing and developing this open source project. In return,
-they should reciprocate that respect in addressing your issue or assessing
-patches and features.
-
-
-## Using the issue tracker
-
-The issue tracker is the preferred channel for [bug reports](#bugs),
-[features requests](#features) and [submitting pull
-requests](#pull-requests), but please respect the following restrictions:
-
-* Please **do not** use the issue tracker for personal support requests (use
-  [Stack Overflow](http://stackoverflow.com) or IRC).
-
-* Please **do not** derail or troll issues. Keep the discussion on topic and
-  respect the opinions of others.
-
-
-## Bug reports
-
-A bug is a _demonstrable problem_ that is caused by the code in the repository.
-Good bug reports are extremely helpful - thank you!
-
-Guidelines for bug reports:
-
-1. **Use the GitHub issue search** &mdash; check if the issue has already been
-   reported.
-
-2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
-   latest `master` or development branch in the repository.
-
-3. **Isolate the problem** &mdash; create a reduced test
-   case or example.
-
-A good bug report shouldn't leave others needing to chase you up for more
-information. Please try to be as detailed as possible in your report. What is
-your environment? What steps will reproduce the issue? What browser(s) and OS
-experience the problem? What would you expect to be the outcome? All these
-details will help people to fix any potential bugs.
-
-Example:
-
-> Short and descriptive example bug report title
->
-> A summary of the issue and the platform/OS environment in which it occurs. If
-> suitable, include the steps required to reproduce the bug.
->
-> 1. This is the first step
-> 2. This is the second step
-> 3. Further steps, etc.
->
-> `<url>` - a link to the reduced test case
->
-> Any other information you want to share that is relevant to the issue being
-> reported. This might include the lines of code that you have identified as
-> causing the bug, and potential solutions (and your opinions on their
-> merits).
-
-
-## Feature requests
-
-Feature requests are welcome. But take a moment to find out whether your idea
-fits with the scope and aims of the project. It's up to *you* to make a strong
-case to convince the project's developers of the merits of this feature. Please
-provide as much detail and context as possible.
-
-
-## Commit messages
-
-Please follow [the seven rules of a great Git commit message](https://chris.beams.io/posts/git-commit/) when committing your changes:
-
-- Separate subject from body with a blank line
-- Limit the subject line to 50 characters
-- Capitalize the subject line
-- Do not end the subject line with a period
-- Use the imperative mood in the subject line
-- Wrap the body at 72 characters
-- Use the body to explain what and why vs. how
-
-For example:
-
-```
-Summarize changes in around 50 characters or less
-
-More detailed explanatory text, if necessary. Wrap it to about 72
-characters or so. In some contexts, the first line is treated as the
-subject of the commit and the rest of the text as the body. The
-blank line separating the summary from the body is critical (unless
-you omit the body entirely); various tools like `log`, `shortlog`
-and `rebase` can get confused if you run the two together.
-
-Explain the problem that this commit is solving. Focus on why you
-are making this change as opposed to how (the code explains that).
-Are there side effects or other unintuitive consequences of this
-change? Here's the place to explain them.
-
-Further paragraphs come after blank lines.
-
- - Bullet points are okay, too
-
- - Typically a hyphen or asterisk is used for the bullet, preceded
-   by a single space, with blank lines in between, but conventions
-   vary here
-
-If you use an issue tracker, put references to them at the bottom,
-like this:
-
-Resolves: #123
-See also: #456, #789
-```
-
-## Pull requests
-
-Good pull requests - patches, improvements, new features - are a fantastic
-help. They should remain focused in scope and avoid containing unrelated
-commits.
-
-**Please ask first** before embarking on any significant pull request (e.g.
-implementing features, refactoring code, porting to a different language),
-otherwise you risk spending a lot of time working on something that the
-project's developers might not want to merge into the project.
-
-Please adhere to the coding conventions used throughout a project (indentation,
-accurate comments, etc.) and any other requirements (such as test coverage).
-
-Follow this process if you'd like your work considered for inclusion in the
-project:
-
-1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
-   and configure the remotes:
-
-   ```bash
-   # Clone your fork of the repo into the current directory
-   git clone https://github.com/<your-username>/<repo-name>
-   # Navigate to the newly cloned directory
-   cd <repo-name>
-   # Assign the original repo to a remote called "upstream"
-   git remote add upstream https://github.com/<upstream-owner>/<repo-name>
-   ```
-
-2. If you cloned a while ago, get the latest changes from upstream:
-
-   ```bash
-   git checkout <dev-branch>
-   git pull upstream <dev-branch>
-   ```
-
-3. Create a new topic branch (off the main project development branch) to
-   contain your feature, change, or fix:
-
-   ```bash
-   git checkout -b <topic-branch-name>
-   ```
-
-4. Commit your changes in logical chunks. Please adhere to these [git commit
-   message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
-   or your code is unlikely be merged into the main project. Use Git's
-   [interactive rebase](https://help.github.com/articles/interactive-rebase)
-   feature to tidy up your commits before making them public.
-
-5. Locally merge (or rebase) the upstream development branch into your topic branch:
-
-   ```bash
-   git pull [--rebase] upstream <dev-branch>
-   ```
-
-6. Push your topic branch up to your fork:
-
-   ```bash
-   git push origin <topic-branch-name>
-   ```
-
-7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
-    with a clear title and description.
-
-**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
-license your work under the same [license](../LICENSE.md) as that used by the project.

+ 0 - 25
examples/mass_spring_damper/fmusdk/LICENSE.md

@@ -1,25 +0,0 @@
-# FMU SDK License
-
-Copyright (c) 2008-2018, QTronic GmbH. All rights reserved.
-The FMU SDK is licensed by the copyright holder under the [2-Clause BSD License](https://www.opensource.org/licenses/bsd-license.html):
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-- Redistributions of source code must retain the above copyright notice,
-  this list of conditions and the following disclaimer.
-  
-- Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY QTRONIC GMBH "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL QTRONIC GMBH BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 73
examples/mass_spring_damper/fmusdk/Makefile

@@ -1,73 +0,0 @@
-all:
-	(cd fmu10; $(MAKE))
-	(cd fmu20; $(MAKE))
-
-clean:
-	(cd fmu10; $(MAKE) clean)
-	(cd fmu20; $(MAKE) clean)
-
-distclean: clean
-	rm -f fmu10/bin/fmusim_cs* fmu10/bin/fmusim_me*
-	rm -f fmu20/bin/fmusim_cs* fmu20/bin/fmusim_me*
-	rm -rf fmu10/fmu
-	rm -rf fmu20/fmu
-	rm -rf fmuTmp* 
-	rm -f *.csv
-	find . -name "*~" -exec rm {} \;
-	find . -name "#*~" -exec rm {} \;
-
-run_all: run_all_fmu10 run_all_fmu20
-
-# Run all the fmu10 fmus.  Args are from run_all.bat
-run_all_fmu10:
-	fmu10/bin/fmusim_me fmu10/fmu/me/bouncingBall.fmu 4 0.01 0 c
-	mv result.csv result_me10_bouncingBall.csv
-	fmu10/bin/fmusim_cs fmu10/fmu/cs/bouncingBall.fmu 4 0.01 0 c
-	mv result.csv result_cs10_bouncingBall.csv
-	#
-	fmu10/bin/fmusim_me fmu10/fmu/me/vanDerPol.fmu 5 0.1 0 c
-	mv result.csv result_me10_vanDerPol.csv
-	fmu10/bin/fmusim_cs fmu10/fmu/cs/vanDerPol.fmu 5 0.1 0 c
-	mv result.csv result_cs10_vanDerPol.csv
-	#
-	fmu10/bin/fmusim_me fmu10/fmu/me/dq.fmu 1 0.1 0 c
-	mv result.csv result_me10_dq.csv
-	fmu10/bin/fmusim_cs fmu10/fmu/cs/dq.fmu 1 0.1 0 c
-	mv result.csv result_cs10_dq.csv
-	#
-	fmu10/bin/fmusim_me fmu10/fmu/me/inc.fmu 15 0.1 0 c
-	mv result.csv result_me10_inc.csv
-	fmu10/bin/fmusim_cs fmu10/fmu/cs/inc.fmu 15 0.1 0 c
-	mv result.csv result_cs10_inc.csv
-	#
-	fmu10/bin/fmusim_me fmu10/fmu/me/values.fmu 12 0.1 0 c
-	mv result.csv result_me10_values.csv
-	fmu10/bin/fmusim_cs fmu10/fmu/cs/values.fmu 12 0.1 0 c
-	mv result.csv result_cs10_values.csv
-
-# Run all the fmu20 fmus.  Args are from run_all.bat
-run_all_fmu20:
-	fmu20/bin/fmusim_me fmu20/fmu/me/bouncingBall.fmu 4 0.01 0 c
-	mv result.csv result_me20_bouncingBall.csv
-	fmu20/bin/fmusim_cs fmu20/fmu/cs/bouncingBall.fmu 4 0.01 0 c
-	mv result.csv result_cs20_bouncingBall.csv
-	#
-	fmu20/bin/fmusim_me fmu20/fmu/me/vanDerPol.fmu 5 0.1 0 c
-	mv result.csv result_me20_vanDerPol.csv
-	fmu20/bin/fmusim_cs fmu20/fmu/cs/vanDerPol.fmu 5 0.1 0 c
-	mv result.csv result_cs20_vanDerPol.csv
-	#
-	fmu20/bin/fmusim_me fmu20/fmu/me/dq.fmu 1 0.1 0 c
-	mv result.csv result_me20_dq.csv
-	fmu20/bin/fmusim_cs fmu20/fmu/cs/dq.fmu 1 0.1 0 c
-	mv result.csv result_cs20_dq.csv
-	#
-	fmu20/bin/fmusim_me fmu20/fmu/me/inc.fmu 15 0.1 0 c
-	mv result.csv result_me20_inc.csv
-	fmu20/bin/fmusim_cs fmu20/fmu/cs/inc.fmu 15 0.1 0 c
-	mv result.csv result_cs20_inc.csv
-	#
-	fmu20/bin/fmusim_me fmu20/fmu/me/values.fmu 12 0.1 0 c
-	mv result.csv result_me20_values.csv
-	fmu20/bin/fmusim_cs fmu20/fmu/cs/values.fmu 12 0.1 0 c
-	mv result.csv result_cs20_values.csv

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 190
examples/mass_spring_damper/fmusdk/README.md


BIN
examples/mass_spring_damper/fmusdk/docs/bouncingBallCalc.png


BIN
examples/mass_spring_damper/fmusdk/docs/fmu10-xml-schema.png


BIN
examples/mass_spring_damper/fmusdk/docs/fmus.jpg


+ 0 - 11
examples/mass_spring_damper/fmusdk/fmu20/Makefile

@@ -1,11 +0,0 @@
-all:
-	(cd src; $(MAKE))
-
-clean:
-	(cd src; $(MAKE) clean)
-
-distclean: clean
-	rm -f bin/fmusim_cs* bin/fmusim_me*
-	rm -rf fmu
-	find . -name "*~" -exec rm {} \;
-	find . -name "#*~" -exec rm {} \;

BIN
examples/mass_spring_damper/fmusdk/fmu20/bin/7z.dll


BIN
examples/mass_spring_damper/fmusdk/fmu20/bin/7z.exe


+ 0 - 57
examples/mass_spring_damper/fmusdk/fmu20/bin/License.txt

@@ -1,57 +0,0 @@
-  7-Zip
-  ~~~~~
-  License for use and distribution
-  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-  7-Zip Copyright (C) 1999-2007 Igor Pavlov.
-
-  Licenses for files are:
-
-    1) 7z.dll: GNU LGPL + unRAR restriction
-    2) All other files:  GNU LGPL
-
-  The GNU LGPL + unRAR restriction means that you must follow both 
-  GNU LGPL rules and unRAR restriction rules.
-
-
-  Note: 
-    You can use 7-Zip on any computer, including a computer in a commercial 
-    organization. You don't need to register or pay for 7-Zip.
-
-
-  GNU LGPL information
-  --------------------
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-  unRAR restriction
-  -----------------
-
-    The decompression engine for RAR archives was developed using source 
-    code of unRAR program.
-    All copyrights to original unRAR code are owned by Alexander Roshal.
-
-    The license for original unRAR code has the following restriction:
-
-      The unRAR sources cannot be used to re-create the RAR compression algorithm, 
-      which is proprietary. Distribution of modified unRAR sources in separate form 
-      or as a part of other software is permitted, provided that it is clearly
-      stated in the documentation and source comments that the code may
-      not be used to develop a RAR (WinRAR) compatible archiver.
-
-
-  --
-  Igor Pavlov

BIN
examples/mass_spring_damper/fmusdk/fmu20/bin/win32/fmusim_cs.exe


BIN
examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/bouncingBall.fmu


BIN
examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/dq.fmu


BIN
examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/inc.fmu


BIN
examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/values.fmu


BIN
examples/mass_spring_damper/fmusdk/fmu20/fmu/cs/win32/vanDerPol.fmu


+ 0 - 88
examples/mass_spring_damper/fmusdk/fmu20/src/Makefile

@@ -1,88 +0,0 @@
-# fmusim makefile for Mac OS X
-
-EXECS = \
-	fmusim_cs \
-	fmusim_me
-
-# Build simulators for co_simulation and model_exchange and then build the .fmu files.
-all: $(EXECS)
-	(cd models; $(MAKE))
-
-clean:
-	rm -f $(EXECS)
-	rm -rf  *.dSYM
-	rm -f cosimulation/*.o
-	rm -f model_exchange/*.o
-	(cd models; $(MAKE) clean)
-
-# Sources shared between co-simulation and model exchange
-SHARED_SRCS = \
-	shared/sim_support.c \
-	shared/xmlVersionParser.c
-
-CPP_SRCS = \
-	shared/parser/XmlElement.cpp \
-	shared/parser/XmlParser.cpp \
-	shared/parser/XmlParserCApi.cpp
-
-# Dependencies for only fmusim_cs
-CO_SIMULATION_DEPS = \
-	co_simulation/main.c
-
-# Dependencies for only fmusim_me
-MODEL_EXCHANGE_DEPS = \
-	model_exchange/main.c
-
-# Dependencies shared between both fmusim_cs and fmusim_me
-SHARED_DEPS = \
-	shared/sim_support.c \
-	shared/sim_support.h \
-	shared/xmlVersionParser.c \
-	shared/xmlVersionParser.h \
-	shared/fmi2.h \
-	shared/include/fmi2Functions.h \
-	shared/include/fmi2FunctionTypes.h \
-	shared/include/fmi2TypesPlatform.h \
-	shared/parser/fmu20/XmlElement.h \
-	shared/parser/fmu20/XmlParser.h \
-	shared/parser/fmu20/XmlParserException.h \
-	shared/parser/XmlParserCApi.h
-
-# Set CFLAGS to -m32 to build for linux32
-#CFLAGS=-m32
-# See also models/build_fmu
-
-CXX=c++
-# Create the binaries in the current directory because co_simulation already has
-# a directory named "fmusim_cs"
-fmusim_cs: $(CO_SIMULATION_DEPS) $(SHARED_DEPS) ../bin/
-	$(CC) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
-		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
-		-Ishared/include -Ishared/parser -Ishared \
-		co_simulation/main.c $(SHARED_SRCS) \
-		-c
-	$(CXX) $(CFLAGS) -g -Wall -DFMI_COSIMULATION \
-		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
-		-Ishared/include -Ishared/parser -Ishared \
-		main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
-		-o $@ -ldl -lxml2
-	cp fmusim_cs ../bin/
-
-fmusim_me: $(MODEL_EXCHANGE_DEPS) $(SHARED_DEPS) ../bin/
-	$(CC) $(CFLAGS) -g -Wall \
-		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
-		-Ishared/include -Ishared/parser -Ishared \
-		model_exchange/main.c $(SHARED_SRCS) \
-		-c
-	$(CXX) $(CFLAGS) -g -Wall \
-		-DSTANDALONE_XML_PARSER -DLIBXML_STATIC \
-		-Ishared/include -Ishared/parser -Ishared \
-		main.o sim_support.o xmlVersionParser.o $(CPP_SRCS) \
-		-o $@ -ldl -lxml2
-	cp fmusim_me ../bin/
-
-../bin/:
-	if [ ! -d ../bin ]; then \
-		echo "Creating ../bin/"; \
-		mkdir ../bin/; \
-	fi

+ 0 - 20
examples/mass_spring_damper/fmusdk/fmu20/src/build_all.bat

@@ -1,20 +0,0 @@
-@echo off
-
-rem ------------------------------------------------------------
-rem This batch builds both simulators and all FMUs of the FmuSDK
-rem Copyright QTronic GmbH. All rights reserved.
-rem ------------------------------------------------------------
-
-rem First argument %1 should be empty for win32, and '-win64' for win64 build.
-call build_fmusim_cs %1
-echo -----------------------------------------------------------
-echo Making the FMUs of the FmuSDK ...
-pushd models
-
-call build_fmu cs dq %1
-call build_fmu cs inc %1
-call build_fmu cs values %1
-call build_fmu cs vanDerPol %1
-call build_fmu cs bouncingBall %1
-
-popd

+ 0 - 69
examples/mass_spring_damper/fmusdk/fmu20/src/build_fmusim_cs.bat

@@ -1,69 +0,0 @@
-@echo off 
-rem ------------------------------------------------------------
-rem This batch builds the FMU simulator fmu20sim_cs.exe
-rem Usage: build_fmusim_cs.bat (-win64)
-rem Copyright QTronic GmbH. All rights reserved
-rem ------------------------------------------------------------
-
-setlocal
-
-echo -----------------------------------------------------------
-echo building fmusim_cs.exe - FMI for Co-Simulation 2.0
-echo -----------------------------------------------------------
-
-rem save env variable settings
-set PREV_PATH=%PATH%
-if defined INCLUDE set PREV_INCLUDE=%INLUDE%
-if defined LIB     set PREV_LIB=%LIB%
-if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
-
-if "%1"=="-win64" (set FMI_PLATFORM=win64) else (set FMI_PLATFORM=win32)
-if not exist ..\bin\%FMI_PLATFORM% mkdir ..\bin\%FMI_PLATFORM%
-
-rem setup the compiler
-if %FMI_PLATFORM%==win64 (
-if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-goto noCompiler
-) else (
-if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
-if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
-if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
-if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
-if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
-if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
-goto noCompiler
-)
-
-set SRC=main.c ..\shared\sim_support.c ..\shared\xmlVersionParser.c ..\shared\parser\XmlParser.cpp ..\shared\parser\XmlElement.cpp ..\shared\parser\XmlParserCApi.cpp
-set INC=/I..\shared\include /I..\shared /I..\shared\parser
-set OPTIONS=/DFMI_COSIMULATION /nologo /EHsc /DSTANDALONE_XML_PARSER /DLIBXML_STATIC
-
-rem create fmusim_cs.exe in co_simulation dir
-pushd co_simulation
-cl %SRC% %INC% %OPTIONS% /Fefmusim_cs.exe /link /LIBPATH:..\shared\parser\%FMI_PLATFORM%
-del *.obj
-popd
-if not exist co_simulation\fmusim_cs.exe goto compileError
-move /Y co_simulation\fmusim_cs.exe ..\bin\%FMI_PLATFORM%
-goto done
-
-:noCompiler
-echo No Microsoft Visual C compiler found
-
-:compileError
-echo build of fmusim_cs.exe failed
-
-:done
-rem undo variable settings performed by vsvars32.bat
-set PATH=%PREV_PATH%
-if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
-if defined PREV_LIB     set LIB=%PREV_LIB%
-if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
-echo done.
-
-endlocal

+ 0 - 181
examples/mass_spring_damper/fmusdk/fmu20/src/co_simulation/main.c

@@ -1,181 +0,0 @@
-/* -------------------------------------------------------------------------
- * main.c
- * Implements simulation of a single FMU instance
- * that implements the "FMI for Co-Simulation 2.0" interface.
- * Command syntax: see printHelp()
- * Simulates the given FMU from t = 0 .. tEnd with fixed step size h and
- * writes the computed solution to file 'result.csv'.
- * The CSV file (comma-separated values) may e.g. be plotted using
- * OpenOffice Calc or Microsoft Excel.
- * This program demonstrates basic use of an FMU.
- * Real applications may use advanced master algorithms to co-simulate
- * many FMUs, limit the numerical error using error estimation
- * and back-stepping, provide graphical plotting utilities, debug support,
- * and user control of parameter and start values, or perform a clean
- * error handling (e.g. call freeSlaveInstance when a call to the fmu
- * returns with error). All this is missing here.
- *
- * Revision history
- *  07.03.2014 initial version released in FMU SDK 2.0.0
- *
- * Free libraries and tools used to implement this simulator:
- *  - header files from the FMI specification
- *  - libxml2 XML parser, see http://xmlsoft.org
- *  - 7z.exe 4.57 zip and unzip tool, see http://www.7-zip.org
- * Author: Adrian Tirea
- * Copyright QTronic GmbH. All rights reserved.
- * -------------------------------------------------------------------------*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "fmi2.h"
-#include "sim_support.h"
-
-FMU fmu; // the fmu to simulate
-
-// simulate the given FMU from tStart = 0 to tEnd.
-static int simulate(FMU* fmu, double tEnd, double h, fmi2Boolean loggingOn, char separator,
-                    int nCategories, char **categories) {
-    double time;
-    double tStart = 0;                      // start time
-    const char *guid;                       // global unique id of the fmu
-    const char *instanceName;               // instance name
-    fmi2Component c;                        // instance of the fmu
-    fmi2Status fmi2Flag;                    // return code of the fmu functions
-    char *fmuResourceLocation = getTempResourcesLocation(); // path to the fmu resources as URL, "file://C:\QTronic\sales"
-    fmi2Boolean visible = fmi2False;        // no simulator user interface
-
-    fmi2CallbackFunctions callbacks = {fmuLogger, calloc, free, NULL, fmu};  // called by the model during simulation
-    ModelDescription* md;                      // handle to the parsed XML file
-    fmi2Boolean toleranceDefined = fmi2False;  // true if model description define tolerance
-    fmi2Real tolerance = 0;                    // used in setting up the experiment
-    ValueStatus vs = valueMissing;
-    int nSteps = 0;
-    double hh = h;
-    Element *defaultExp;
-    FILE* file;
-
-    // instantiate the fmu
-    md = fmu->modelDescription;
-    guid = getAttributeValue((Element *)md, att_guid);
-    instanceName = getAttributeValue((Element *)getCoSimulation(md), att_modelIdentifier);
-    c = fmu->instantiate(instanceName, fmi2CoSimulation, guid, fmuResourceLocation,
-                    &callbacks, visible, loggingOn);
-    free(fmuResourceLocation);
-    if (!c) return error("could not instantiate model");
-
-    if (nCategories > 0) {
-        fmi2Flag = fmu->setDebugLogging(c, fmi2True, nCategories, categories);
-        if (fmi2Flag > fmi2Warning) {
-            return error("could not initialize model; failed FMI set debug logging");
-        }
-    }
-
-    defaultExp = getDefaultExperiment(md);
-    if (defaultExp) tolerance = getAttributeDouble(defaultExp, att_tolerance, &vs);
-    if (vs == valueDefined) {
-        toleranceDefined = fmi2True;
-    }
-
-    fmi2Flag = fmu->setupExperiment(c, toleranceDefined, tolerance, tStart, fmi2True, tEnd);
-    if (fmi2Flag > fmi2Warning) {
-        return error("could not initialize model; failed FMI setup experiment");
-    }
-    fmi2Flag = fmu->enterInitializationMode(c);
-    if (fmi2Flag > fmi2Warning) {
-        return error("could not initialize model; failed FMI enter initialization mode");
-    }
-    fmi2Flag = fmu->exitInitializationMode(c);
-    if (fmi2Flag > fmi2Warning) {
-        return error("could not initialize model; failed FMI exit initialization mode");
-    }
-
-    // open result file
-    if (!(file = fopen(RESULT_FILE, "w"))) {
-        printf("could not write %s because:\n", RESULT_FILE);
-        printf("    %s\n", strerror(errno));
-        return 0; // failure
-    }
-
-    // output solution for time t0
-    outputRow(fmu, c, tStart, file, separator, fmi2True);  // output column names
-    outputRow(fmu, c, tStart, file, separator, fmi2False); // output values
-
-    // enter the simulation loop
-    time = tStart;
-    while (time < tEnd) {
-        // check not to pass over end time
-        if (h > tEnd - time) {
-            hh = tEnd - time;
-        }
-        fmi2Flag = fmu->doStep(c, time, hh, fmi2True);
-        if (fmi2Flag == fmi2Discard) {
-            fmi2Boolean b;
-            // check if model requests to end simulation
-            if (fmi2OK != fmu->getBooleanStatus(c, fmi2Terminated, &b)) {
-                return error("could not complete simulation of the model. getBooleanStatus return other than fmi2OK");
-            }
-            if (b == fmi2True) {
-                return error("the model requested to end the simulation");
-            }
-            return error("could not complete simulation of the model");
-        }
-        if (fmi2Flag != fmi2OK) return error("could not complete simulation of the model");
-        time += hh;
-        outputRow(fmu, c, time, file, separator, fmi2False); // output values for this step
-        nSteps++;
-    }
-
-    // end simulation
-    fmu->terminate(c);
-    fmu->freeInstance(c);
-    fclose(file);
-
-    // print simulation summary
-    printf("Simulation from %g to %g terminated successful\n", tStart, tEnd);
-    printf("  steps ............ %d\n", nSteps);
-    printf("  fixed step size .. %g\n", h);
-    return 1; // success
-}
-
-int main(int argc, char *argv[]) {
-    const char* fmuFileName;
-    int i;
-
-    // parse command line arguments and load the FMU
-    // default arguments value
-    double tEnd = 1.0;
-    double h=0.1;
-    int loggingOn = 0;
-    char csv_separator = ',';
-    char **categories = NULL;
-    int nCategories = 0;
-
-    parseArguments(argc, argv, &fmuFileName, &tEnd, &h, &loggingOn, &csv_separator, &nCategories, &categories);
-    loadFMU(fmuFileName);
-
-  // run the simulation
-    printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c' ",
-            fmuFileName, tEnd, h, loggingOn, csv_separator);
-    printf("log categories={ ");
-    for (i = 0; i < nCategories; i++) printf("%s ", categories[i]);
-    printf("}\n");
-
-    simulate(&fmu, tEnd, h, loggingOn, csv_separator, nCategories, categories);
-    printf("CSV file '%s' written\n", RESULT_FILE);
-
-    // release FMU
-#if WINDOWS
-    FreeLibrary(fmu.dllHandle);
-#else /* WINDOWS */
-    dlclose(fmu.dllHandle);
-#endif /* WINDOWS */
-    freeModelDescription(fmu.modelDescription);
-    if (categories) free(categories);
-
-    // delete temp files obtained by unzipping the FMU
-    deleteUnzippedFiles();
-
-    return EXIT_SUCCESS;
-}

+ 0 - 72
examples/mass_spring_damper/fmusdk/fmu20/src/models/Makefile

@@ -1,72 +0,0 @@
-# Build the .fmu files for both co-simulation and model-exchange.
-#
-# The build_fmu script calls make with the appropriate makefile variables set.
-
-# The architecture: linux32, linux64, darwin32, darwin64
-ARCH = darwin64
-
-# Either cs for co-simuluation or me for model exchange.
-CSORME = cs
-INCLUDE = -I../../co_simulation/include
-
-# The suffix for shared libraries.
-# dylib for Mac OS X, so for Linux
-SHARED_LIBRARY_SUFFIX = dylib
-#SHARED_LIBRARY_SUFFIX = so
-
-# Empty for Mac OS X, -fPIC for Linux
-PIC =
-#PIC = -fPIC
-
-# Build the .fmu files for both co-simulation and model-exchange
-all:
-	chmod 777 build_fmu
-	./build_fmu me bouncingBall
-	./build_fmu me dq
-	./build_fmu me inc
-	./build_fmu me values
-	./build_fmu me vanDerPol
-	./build_fmu cs bouncingBall
-	./build_fmu cs dq
-	./build_fmu cs inc
-	./build_fmu cs values
-	./build_fmu cs vanDerPol
-
-# CBITSFLAGS is set to -m32 to build linux32 fmus
-
-%.o: %.c
-	echo `pwd`
-	$(CC) -g -c $(CBITSFLAGS) $(PIC) -Wall $(INCLUDE) $(CFLAGS) $< -o $@
-
-# Under Linux, compile with -fvisibility=hidden, see
-# https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
-%.so: %.o
-	$(CC) $(CBITSFLAGS) -fvisibility=hidden -shared -Wl,-soname,$@ -o $@ $<
-
-%.dylib: %.o
-	$(CC) -dynamiclib -o $@ $<
-
-%.fmu: %.$(SHARED_LIBRARY_SUFFIX)
-	rm -rf fmu
-	mkdir -p fmu/binaries/$(ARCH) fmu/sources fmu/documentation
-	cp $< fmu/binaries/$(ARCH)
-	-cp *.c fmu/sources
-	rsync -av --ignore-missing-args ./*.h ./fmu/sources
-	-cp *.html *.png fmu/documentation
-	cp modelDescription_$(CSORME).xml fmu/modelDescription.xml
-	cp model.png fmu
-	@if [ ! -d ../../../fmu/$(CSORME) ]; then \
-		echo "mkdir -p ../../../fmu/$(CSORME)"; \
-		mkdir -p ../../../fmu/$(CSORME); \
-	fi
-	(cd fmu; zip -q -r ../../../../fmu/$(CSORME)/$@ *)
-
-clean:
-	(cd bouncingBall; make dirclean)
-	(cd dq; make dirclean)
-	(cd inc; make dirclean)
-	(cd values; make dirclean)
-	(cd vanDerPol; make dirclean)
-
-dirclean:
-	rm -rf *.so *.dylib *.o *.fmu *~ fmu

+ 0 - 3
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/Makefile

@@ -1,3 +0,0 @@
-CFLAGS = -I..
-
-include ../Makefile

+ 0 - 131
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/bouncingBall.c

@@ -1,131 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU - a bouncing ball. 
- * This demonstrates the use of state events and reinit of states.
- * Equations:
- *  der(h) = v;
- *  der(v) = -g;
- *  when h<0 then v := -e * v;
- *  where
- *    h      height [m], used as state, start = 1
- *    v      velocity of ball [m/s], used as state
- *    der(h) velocity of ball [m/s]
- *    der(v) acceleration of ball [m/s2]
- *    g      acceleration of gravity [m/s2], a parameter, start = 9.81
- *    e      a dimensionless parameter, start = 0.7
- *
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-// define class name and unique id
-#define MODEL_IDENTIFIER bouncingBall
-#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f003}"
-
-// define model size
-#define NUMBER_OF_REALS 6
-#define NUMBER_OF_INTEGERS 0
-#define NUMBER_OF_BOOLEANS 0
-#define NUMBER_OF_STRINGS 0
-#define NUMBER_OF_STATES 2
-#define NUMBER_OF_EVENT_INDICATORS 1
-
-// include fmu header files, typedefs and macros
-#include "fmuTemplate.h"
-
-// define all model variables and their value references
-// conventions used here:
-// - if x is a variable, then macro x_ is its variable reference
-// - the vr of a variable is its index in array  r, i, b or s
-// - if k is the vr of a real state, then k+1 is the vr of its derivative
-#define h_      0
-#define der_h_  1
-#define v_      2
-#define der_v_  3
-#define g_      4
-#define e_      5
-
-// define initial state vector as vector of value references
-#define STATES { h_, v_ }
-
-// called by fmi2Instantiate
-// Set values for all variables that define a start value
-// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
-void setStartValues(ModelInstance *comp) {
-    r(h_)     =  1;
-    r(v_)     =  0;
-    r(g_)     =  9.81;
-    r(e_)     =  0.7;
-}
-
-// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
-// if setStartValues or environment set new values through fmi2SetXXX.
-// Lazy set values for all variable that are computed from other variables.
-void calculateValues(ModelInstance *comp) {
-    if (comp->state == modelInitializationMode) {
-        r(der_v_) = -r(g_);
-        pos(0) = r(h_) > 0;
-
-        // set first time event, if any, using comp->eventInfo.nextEventTime
-    }
-}
-
-// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
-fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr) {
-    switch (vr) {
-        case h_     : return r(h_);
-        case der_h_ : return r(v_);
-        case v_     : return r(v_);
-        case der_v_ : return r(der_v_);
-        case g_     : return r(g_);
-        case e_     : return r(e_);
-        default: return 0;
-    }
-}
-
-// offset for event indicator, adds hysteresis and prevents z=0 at restart 
-#define EPS_INDICATORS 1e-14
-
-fmi2Real getEventIndicator(ModelInstance* comp, int z) {
-    switch (z) {
-        case 0 : return r(h_) + (pos(0) ? EPS_INDICATORS : -EPS_INDICATORS);
-        default: return 0;
-    }
-}
-
-// previous value of r(v_).
-fmi2Real prevV;
-
-// used to set the next time event, if any.
-void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
-
-	eventInfo->newDiscreteStatesNeeded = fmi2False;
-	eventInfo->terminateSimulation = fmi2False;
-	eventInfo->nominalsOfContinuousStatesChanged = fmi2False;
-	eventInfo->valuesOfContinuousStatesChanged = fmi2False;
-	eventInfo->nextEventTimeDefined = fmi2False;
-
-	if (isNewEventIteration) {
-        prevV = r(v_);
-    }
-    
-	pos(0) = r(h_) > 0;
-    
-	if (!pos(0)) {
-
-        fmi2Real tempV = - r(e_) * prevV;
-
-        if (r(v_) != tempV) {
-			r(h_) = 0;
-            r(v_) = tempV;
-            eventInfo->valuesOfContinuousStatesChanged = fmi2True;
-        }
-
-        // avoid fall-through effect. The ball will not jump high enough, so v and der_v is set to 0 at this surface impact.
-        if (r(v_) < 1e-3) {
-            r(v_) = 0;
-            r(der_v_) = 0;  // turn off gravity.
-        }
-    }
-}
-
-// include code that implements the FMI based on the above definitions
-#include "fmuTemplate.c"

+ 0 - 55
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/index.html

@@ -1,55 +0,0 @@
-<html>
-<head>
-    <title>Documentation for bouncingBall.fmu</title>
-<style type="text/css">
-  html { font-family: Verdana, Arial, Helvetica, sans-serif; }
-  h1   { color: #000066; }
-</style>
-</head>
-<body>
-<h1>bouncingBall.fmu</h1>
-The bouncingBall implements the following equation: 
-<ul>
-<li> der(h) = v;
-<li> der(v) = -g;
-<li> when h<0 then v := -e* v
-</ul>
-with start values h=1, e=0.7, g = 9.81 and
-<ul>
-<li> h: height [m], used as state
-<li> v: velocity of ball [m/s], used as state
-<li> der(h): velocity of ball [m/s]
-<li> der(v): acceleration of ball [m/s2]
-<li> g: acceleration of gravity [m/s2], a parameter
-<li> e: a dimensionless parameter
-</ul>
-
-<br>
-<img src="plot_h.png">
-<br>
-The figure shows the solution computed with Silver 
-for height h of the ball for the start values given above.
-
-<p>
-The chain of events during simulation is as follows
-<ol>
-<li> initially h>0 and pos(0)=true </li>
-<li> continuous integration until a state event is detected, i.e.
-     until h + EPS_INDICATORS = 0.
-     At this time h < 0, the EPS_INDICATORS adds hysteresis.</li>
-<li> the simulator calls eventUpdate once which reverses the speed direction
-     v of the ball: v = -e * v, and sets pos(0)=false</li>
-<li> continuous integration until state event is detected, i.e.
-     until h - EPS_INDICATORS = 0.
-     At this time h > 0, the EPS_INDICATORS adds hysteresis.</li>
-<li> the simulator calls  eventUpdate once more which sets pos(0)=true.</li>
-<li> goto 2</li>
-</ol>
-The above description refers to the variables used 
-in file <code>bouncingBall.c</code>.
-
-<h2><a name="license">License conditions</a></h2>
-The FMU is provided by QTronic under the
-<a href="http://www.opensource.org/licenses/bsd-license.html">BSD License</a>.
-</body>
-</html>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/model.png


+ 0 - 62
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/modelDescription_cs.xml

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<fmiModelDescription
-  fmiVersion="2.0"
-  modelName="bouncingBall"
-  guid="{8c4e810f-3df3-4a00-8276-176fa3c9f003}"
-  numberOfEventIndicators="1">
-
-<CoSimulation
-  modelIdentifier="bouncingBall"
-  canHandleVariableCommunicationStepSize="true">
-  <SourceFiles>
-    <File name="bouncingBall.c"/>
-  </SourceFiles>
-</CoSimulation>
-
-
-<LogCategories>
-  <Category name="logAll"/>
-  <Category name="logError"/>
-  <Category name="logFmiCall"/>
-  <Category name="logEvent"/>
-</LogCategories>
-
-<ModelVariables>
-  <ScalarVariable name="h" valueReference="0" description="height, used as state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(h)" valueReference="1" description="velocity of ball"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="v" valueReference="2" description="velocity of ball, used as state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="0" reinit="true"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(v)" valueReference="3" description="acceleration of ball"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="3"/>
-  </ScalarVariable>
-  <ScalarVariable name="g" valueReference="4" description="acceleration of gravity"
-                  causality="parameter" variability="fixed" initial="exact">
-    <Real start="9.81"/>
-  </ScalarVariable>
-  <ScalarVariable name="e" valueReference="5" description="dimensionless parameter"
-                  causality="parameter" variability="tunable" initial="exact">
-    <Real start="0.7" min="0.5" max="1"/>
-  </ScalarVariable>
-</ModelVariables>
-
-<ModelStructure>
-  <Derivatives>
-    <Unknown index="2" />
-    <Unknown index="4" />
-  </Derivatives>
-  <InitialUnknowns>
-    <Unknown index="2"/>
-    <Unknown index="4"/>
-  </InitialUnknowns>
-</ModelStructure>
-
-</fmiModelDescription>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/bouncingBall/plot_h.PNG


+ 0 - 55
examples/mass_spring_damper/fmusdk/fmu20/src/models/build_fmu

@@ -1,55 +0,0 @@
-#!/bin/sh
-# Build a model exchange or co-simulation fmu
-# Usage: build_fmu cs|me directory
-
-if [ $# -ne 2 ]; then
-   echo "Usage: $0 cs|me directory"
-   exit 2
-fi
-
-csOrMe=$1
-directory=$2
-
-# Error checking
-if [ "$csOrMe" != "me" -a "$csOrMe" != "cs" ]; then
-   echo "$0: first argument must be either 'me' or 'cs', not $csOrMe"
-   exit 3
-fi
-
-if [ ! -d $directory ]; then
-   echo "$0: directory $directory does not exist"
-   exit 4
-fi
-
-include="-DDISABLE_PREFIX -I../../shared/include"
-
-case "`uname -s`" in
-     CYGWIN*) arch=win
-     	      sharedLibrarySuffix=dll;;
-     Darwin)  arch=darwin
-     	      sharedLibrarySuffix=dylib;;
-     Linux)   arch=linux
-     	      pic=-fPIC
-     	      sharedLibrarySuffix=so;;
-esac     
-
-# Number of bits, default to 64
-bits=64
-case "`uname -m`" in
-     *64)      bits=64;;
-     *32)      bits=32;;
-     *i[3-6]86) bits=32;;
-esac
-
-# Uncomment the next line to force building 32-bit
-#bits=32
-# See also ../Makefile
-
-if [ $arch = linux -a $bits = 32 ]; then
-    CBITSFLAGS=-m32
-fi
-
-set -x
-(cd $directory; \
-    make dirclean; \
-    make ARCH=${arch}${bits} CBITSFLAGS=${CBITSFLAGS} CSORME=${csOrMe} INCLUDE="${include}" PIC=${pic} SHARED_LIBRARY_SUFFIX=${sharedLibrarySuffix} $directory.fmu)

+ 0 - 93
examples/mass_spring_damper/fmusdk/fmu20/src/models/build_fmu.bat

@@ -1,93 +0,0 @@
-@echo off 
-rem ------------------------------------------------------------
-rem This batch builds an FMU of the FMU SDK
-rem Usage: build_fmu (me|cs) <fmu_dir_name> (-win64)
-rem Copyright QTronic GmbH. All rights reserved
-rem ------------------------------------------------------------
-
-setlocal
-
-echo -----------------------------------------------------------
-if %1==cs (^
-echo building FMU %2 - FMI for Co-Simulation 2.0) else ^
-echo building FMU %2 - FMI for Model Exchange 2.0
-
-rem save env variable settings
-set PREV_PATH=%PATH%
-if defined INCLUDE set PREV_INCLUDE=%INLUDE%
-if defined LIB     set PREV_LIB=%LIB%
-if defined LIBPATH set PREV_LIBPATH=%LIBPATH%
-
-if "%3"=="-win64" (set FMI_PLATFORM=win64) else (set FMI_PLATFORM=win32)
-
-rem setup the compiler
-if %FMI_PLATFORM%==win64 (
-if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64) else ^
-goto noCompiler
-) else (
-if defined VS140COMNTOOLS (call "%VS140COMNTOOLS%\vsvars32.bat") else ^
-if defined VS120COMNTOOLS (call "%VS120COMNTOOLS%\vsvars32.bat") else ^
-if defined VS110COMNTOOLS (call "%VS110COMNTOOLS%\vsvars32.bat") else ^
-if defined VS100COMNTOOLS (call "%VS100COMNTOOLS%\vsvars32.bat") else ^
-if defined VS90COMNTOOLS (call "%VS90COMNTOOLS%\vsvars32.bat") else ^
-if defined VS80COMNTOOLS (call "%VS80COMNTOOLS%\vsvars32.bat") else ^
-goto noCompiler
-)
-
-rem create the %2.dll in the temp dir
-if not exist temp mkdir temp 
-pushd temp
-if exist *.dll del /Q *.dll
-
-cl /LD /nologo /DDISABLE_PREFIX ..\%2\%2.c /I ..\. /I ..\..\shared\include
-if not exist %2.dll goto compileError
-
-rem create FMU dir structure with root 'fmu'
-set BIN_DIR=fmu\binaries\%FMI_PLATFORM%
-set SRC_DIR=fmu\sources
-set DOC_DIR=fmu\documentation
-if not exist %BIN_DIR% mkdir %BIN_DIR%
-if not exist %SRC_DIR% mkdir %SRC_DIR%
-if not exist %DOC_DIR% mkdir %DOC_DIR%
-move /Y %2.dll %BIN_DIR%
-if exist ..\%2\*~ del /Q ..\%2\*~
-copy ..\%2\%2.c %SRC_DIR% 
-type ..\%2\modelDescription_%1.xml > fmu\modelDescription.xml
-copy ..\%2\model.png fmu
-copy ..\fmuTemplate.c %SRC_DIR%
-copy ..\fmuTemplate.h %SRC_DIR%
-copy ..\%2\*.html %DOC_DIR%
-copy ..\%2\*.png  %DOC_DIR%
-del %DOC_DIR%\model.png 
-
-rem zip the directory tree and move to fmu directory
-cd fmu
-set FMU_FILE=..\..\..\..\fmu\%1\%FMI_PLATFORM%\%2.fmu
-if exist %FMU_FILE% del %FMU_FILE%
-..\..\..\..\bin\7z.exe a -tzip %FMU_FILE% ^
-  modelDescription.xml model.png binaries sources documentation
-goto cleanup
-
-:noCompiler
-echo No Microsoft Visual C compiler found
-
-:compileError
-echo build of %2 failed
-
-:cleanup
-popd
-if exist temp rmdir /S /Q temp
-
-rem undo variable settings performed by vsvars32.bat
-set PATH=%PREV_PATH%
-if defined PREV_INCLUDE set INCLUDE=%PREV_INLUDE%
-if defined PREV_LIB     set LIB=%PREV_LIB%
-if defined PREV_LIBPATH set LIBPATH=%PREV_LIBPATH%
-echo done.
-
-endlocal

+ 0 - 3
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/Makefile

@@ -1,3 +0,0 @@
-CFLAGS = -I..
-
-include ../Makefile

+ 0 - 71
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/dq.c

@@ -1,71 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU - the Dahlquist test equation.
- *
- *   der(x) = - k * x and x(0) = 1. 
- *   Analytical solution: x(t) = exp(-k*t).
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-// define class name and unique id
-#define MODEL_IDENTIFIER dq
-#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f000}"
-
-// define model size
-#define NUMBER_OF_REALS 3
-#define NUMBER_OF_INTEGERS 0
-#define NUMBER_OF_BOOLEANS 0
-#define NUMBER_OF_STRINGS 0
-#define NUMBER_OF_STATES 1
-#define NUMBER_OF_EVENT_INDICATORS 0
-
-// include fmu header files, typedefs and macros
-#include "fmuTemplate.h"
-
-// define all model variables and their value references
-// conventions used here:
-// - if x is a variable, then macro x_ is its variable reference
-// - the vr of a variable is its index in array  r, i, b or s
-// - if k is the vr of a real state, then k+1 is the vr of its derivative
-#define x_     0
-#define der_x_ 1
-#define k_     2
-
-// define state vector as vector of value references
-#define STATES { x_ }
-
-// called by fmi2Instantiate
-// Set values for all variables that define a start value
-// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
-void setStartValues(ModelInstance *comp) {
-    r(x_) = 1;
-    r(k_) = 1;
-}
-
-// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
-// if setStartValues or environment set new values through fmi2SetXXX.
-// Lazy set values for all variable that are computed from other variables.
-void calculateValues(ModelInstance *comp) {
-    //if (comp->state == modelInitializationMode) {
-    //  initialization code here
-    //  set first time event, if any, using comp->eventInfo.nextEventTime
-    //}
-}
-
-// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
-fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr){
-    switch (vr) {
-        case x_     : return r(x_);
-        case der_x_ : return - r(k_) * r(x_);
-        case k_     : return r(k_);
-        default: return 0;
-    }
-}
-
-// used to set the next time event, if any.
-void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
-} 
-
-// include code that implements the FMI based on the above definitions
-#include "fmuTemplate.c"
-
-

+ 0 - 33
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/index.html

@@ -1,33 +0,0 @@
-<html>
-<head>
-<title>Documentation for dq.fmu</title>
-<style type="text/css">
-  html { font-family: Verdana, Arial, Helvetica, sans-serif; }
-  h1   { color: #000066; }
-</style>
-</head>
-<body>
-<h1>dq.fmu</h1>
-This FMU implements the equation 
-<ul>
-<li> der(x) = -k * x </li>
-</ul>
-The analytical solution of this system is 
-<ul>
-<li> x(t) = exp(-k*t) </li>
-</ul>
-The above equation is also known as 
-<a href="http://en.wikipedia.org/wiki/Germund_Dahlquist" target="_blank">Dahlquist</a> 
-test equation.
-<br/>
-<img src="plot_x.png">
-<br/>
-The figure shows the solution for x computed with Silver 
-for start values k = 1 and x = 1.
-
-<h2><a name="license">License conditions</a></h2>
-The FMU is provided by QTronic under the
-<a href="http://www.opensource.org/licenses/bsd-license.html">BSD License</a>.
-</body>
-</html>
-

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/model.png


+ 0 - 47
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/modelDescription_cs.xml

@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<fmiModelDescription
-  fmiVersion="2.0"
-  modelName="dq"
-  guid="{8c4e810f-3df3-4a00-8276-176fa3c9f000}"
-  numberOfEventIndicators="0">
-
-<CoSimulation
-  modelIdentifier="dq"
-  canHandleVariableCommunicationStepSize="true">
-  <SourceFiles>
-    <File name="dq.c"/>
-  </SourceFiles>
-</CoSimulation>
-
-<LogCategories>
-  <Category name="logAll"/>
-  <Category name="logError"/>
-  <Category name="logFmiCall"/>
-  <Category name="logEvent"/>
-</LogCategories>
-
-<ModelVariables>
-  <ScalarVariable name="x" valueReference="0" description="the only state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(x)" valueReference="1"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="k" valueReference="2"
-                  causality="parameter" variability="fixed" initial="exact">
-    <Real start="1"/>
-  </ScalarVariable>
-</ModelVariables>
-
-<ModelStructure>
-  <Derivatives>
-    <Unknown index="2" />
-  </Derivatives>
-  <InitialUnknowns>
-    <Unknown index="2"/>
-  </InitialUnknowns>
-</ModelStructure>
-
-</fmiModelDescription>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/dq/plot_x.PNG


+ 0 - 925
examples/mass_spring_damper/fmusdk/fmu20/src/models/fmuTemplate.c

@@ -1,925 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * fmuTemplate.c
- * Implementation of the FMI interface based on functions and macros to
- * be defined by the includer of this file.
- * The "FMI for Co-Simulation 2.0", implementation assumes that exactly the
- * following capability flags are set to fmi2True:
- *    canHandleVariableCommunicationStepSize, i.e. fmi2DoStep step size can vary
- * and all other capability flags are set to default, i.e. to fmi2False or 0.
- *
- * Revision history
- *  07.03.2014 initial version released in FMU SDK 2.0.0
- *  02.04.2014 allow modules to request termination of simulation, better time
- *             event handling, initialize() moved from fmi2EnterInitialization to
- *             fmi2ExitInitialization, correct logging message format in fmi2DoStep.
- *  10.04.2014 use FMI 2.0 headers that prefix function and types names with 'fmi2'.
- *  13.06.2014 when fmi2setDebugLogging is called with 0 categories, set all
- *             categories to loggingOn value.
- *  09.07.2014 track all states of Model-exchange and Co-simulation and check
- *             the allowed calling sequences, explicit isTimeEvent parameter for
- *             eventUpdate function of the model, lazy computation of computed values.
- *
- * Author: Adrian Tirea
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// macro to be used to log messages. The macro check if current 
-// log category is valid and, if true, call the logger provided by simulator.
-#define FILTERED_LOG(instance, status, categoryIndex, message, ...) if (status == fmi2Error || status == fmi2Fatal || isCategoryLogged(instance, categoryIndex)) \
-        instance->functions->logger(instance->functions->componentEnvironment, instance->instanceName, status, \
-        logCategoriesNames[categoryIndex], message, ##__VA_ARGS__);
-
-static fmi2String logCategoriesNames[] = {"logAll", "logError", "logFmiCall", "logEvent"};
-
-// array of value references of states
-#if NUMBER_OF_STATES>0
-fmi2ValueReference vrStates[NUMBER_OF_STATES] = STATES;
-#endif
-
-#ifndef max
-#define max(a,b) ((a)>(b) ? (a) : (b))
-#endif
-
-#ifndef DT_EVENT_DETECT
-#define DT_EVENT_DETECT 1e-10
-#endif
-
-// ---------------------------------------------------------------------------
-// Private helpers used below to validate function arguments
-// ---------------------------------------------------------------------------
-
-fmi2Boolean isCategoryLogged(ModelInstance *comp, int categoryIndex);
-
-static fmi2Boolean invalidNumber(ModelInstance *comp, const char *f, const char *arg, int n, int nExpected) {
-    if (n != nExpected) {
-        comp->state = modelError;
-        FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Invalid argument %s = %d. Expected %d.", f, arg, n, nExpected)
-        return fmi2True;
-    }
-    return fmi2False;
-}
-
-static fmi2Boolean invalidState(ModelInstance *comp, const char *f, int statesExpected) {
-    if (!comp)
-        return fmi2True;
-    if (!(comp->state & statesExpected)) {
-        comp->state = modelError;
-        FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Illegal call sequence.", f)
-        return fmi2True;
-    }
-    return fmi2False;
-}
-
-static fmi2Boolean nullPointer(ModelInstance* comp, const char *f, const char *arg, const void *p) {
-    if (!p) {
-        comp->state = modelError;
-        FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Invalid argument %s = NULL.", f, arg)
-        return fmi2True;
-    }
-    return fmi2False;
-}
-
-static fmi2Boolean vrOutOfRange(ModelInstance *comp, const char *f, fmi2ValueReference vr, int end) {
-    if (vr >= end) {
-        FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Illegal value reference %u.", f, vr)
-        comp->state = modelError;
-        return fmi2True;
-    }
-    return fmi2False;
-}
-
-static fmi2Status unsupportedFunction(fmi2Component c, const char *fName, int statesExpected) {
-    ModelInstance *comp = (ModelInstance *)c;
-    fmi2CallbackLogger log = comp->functions->logger;
-    if (invalidState(comp, fName, statesExpected))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, fName);
-    FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "%s: Function not implemented.", fName)
-    return fmi2Error;
-}
-
-fmi2Status setString(fmi2Component comp, fmi2ValueReference vr, fmi2String value) {
-    return fmi2SetString(comp, &vr, 1, &value);
-}
-
-// ---------------------------------------------------------------------------
-// Private helpers logger
-// ---------------------------------------------------------------------------
-
-// return fmi2True if logging category is on. Else return fmi2False.
-fmi2Boolean isCategoryLogged(ModelInstance *comp, int categoryIndex) {
-    if (categoryIndex < NUMBER_OF_CATEGORIES
-        && (comp->logCategories[categoryIndex] || comp->logCategories[LOG_ALL])) {
-        return fmi2True;
-    }
-    return fmi2False;
-}
-
-// ---------------------------------------------------------------------------
-// FMI functions
-// ---------------------------------------------------------------------------
-fmi2Component fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID,
-                            fmi2String fmuResourceLocation, const fmi2CallbackFunctions *functions,
-                            fmi2Boolean visible, fmi2Boolean loggingOn) {
-    // ignoring arguments: fmuResourceLocation, visible
-    ModelInstance *comp;
-    if (!functions->logger) {
-        return NULL;
-    }
-
-    if (!functions->allocateMemory || !functions->freeMemory) {
-        functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
-                "fmi2Instantiate: Missing callback function.");
-        return NULL;
-    }
-    if (!instanceName || strlen(instanceName) == 0) {
-        functions->logger(functions->componentEnvironment, "?", fmi2Error, "error",
-                "fmi2Instantiate: Missing instance name.");
-        return NULL;
-    }
-    if (!fmuGUID || strlen(fmuGUID) == 0) {
-        functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
-                "fmi2Instantiate: Missing GUID.");
-        return NULL;
-    }
-    if (strcmp(fmuGUID, MODEL_GUID)) {
-        functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
-                "fmi2Instantiate: Wrong GUID %s. Expected %s.", fmuGUID, MODEL_GUID);
-        return NULL;
-    }
-    comp = (ModelInstance *)functions->allocateMemory(1, sizeof(ModelInstance));
-    if (comp) {
-        int i;
-        comp->r = (fmi2Real *)   functions->allocateMemory(NUMBER_OF_REALS,    sizeof(fmi2Real));
-        comp->i = (fmi2Integer *)functions->allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmi2Integer));
-        comp->b = (fmi2Boolean *)functions->allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmi2Boolean));
-        comp->s = (fmi2String *) functions->allocateMemory(NUMBER_OF_STRINGS,  sizeof(fmi2String));
-        comp->isPositive = (fmi2Boolean *)functions->allocateMemory(NUMBER_OF_EVENT_INDICATORS,
-            sizeof(fmi2Boolean));
-        comp->instanceName = (char *)functions->allocateMemory(1 + strlen(instanceName), sizeof(char));
-        comp->GUID = (char *)functions->allocateMemory(1 + strlen(fmuGUID), sizeof(char));
-
-        // set all categories to on or off. fmi2SetDebugLogging should be called to choose specific categories.
-        for (i = 0; i < NUMBER_OF_CATEGORIES; i++) {
-            comp->logCategories[i] = loggingOn;
-        }
-    }
-    if (!comp || !comp->r || !comp->i || !comp->b || !comp->s || !comp->isPositive
-        || !comp->instanceName || !comp->GUID) {
-
-        functions->logger(functions->componentEnvironment, instanceName, fmi2Error, "error",
-            "fmi2Instantiate: Out of memory.");
-        return NULL;
-    }
-    comp->time = 0; // overwrite in fmi2SetupExperiment, fmi2SetTime
-    strcpy((char *)comp->instanceName, (char *)instanceName);
-    comp->type = fmuType;
-    strcpy((char *)comp->GUID, (char *)fmuGUID);
-    comp->functions = functions;
-    comp->componentEnvironment = functions->componentEnvironment;
-    comp->loggingOn = loggingOn;
-    comp->state = modelInstantiated;
-    setStartValues(comp); // to be implemented by the includer of this file
-    comp->isDirtyValues = fmi2True; // because we just called setStartValues
-    comp->isNewEventIteration = fmi2False;
-
-    comp->eventInfo.newDiscreteStatesNeeded = fmi2False;
-    comp->eventInfo.terminateSimulation = fmi2False;
-    comp->eventInfo.nominalsOfContinuousStatesChanged = fmi2False;
-    comp->eventInfo.valuesOfContinuousStatesChanged = fmi2False;
-    comp->eventInfo.nextEventTimeDefined = fmi2False;
-    comp->eventInfo.nextEventTime = 0;
-
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Instantiate: GUID=%s", fmuGUID)
-
-    return comp;
-}
-
-fmi2Status fmi2SetupExperiment(fmi2Component c, fmi2Boolean toleranceDefined, fmi2Real tolerance,
-                            fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime) {
-
-    // ignore arguments: stopTimeDefined, stopTime
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetupExperiment", MASK_fmi2SetupExperiment))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetupExperiment: toleranceDefined=%d tolerance=%g",
-        toleranceDefined, tolerance)
-
-    comp->time = startTime;
-    return fmi2OK;
-}
-
-fmi2Status fmi2EnterInitializationMode(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2EnterInitializationMode", MASK_fmi2EnterInitializationMode))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2EnterInitializationMode")
-
-    comp->state = modelInitializationMode;
-    return fmi2OK;
-}
-
-fmi2Status fmi2ExitInitializationMode(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2ExitInitializationMode", MASK_fmi2ExitInitializationMode))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2ExitInitializationMode")
-
-    // if values were set and no fmi2GetXXX triggered update before,
-    // ensure calculated values are updated now
-    if (comp->isDirtyValues) {
-        calculateValues(comp);
-        comp->isDirtyValues = fmi2False;
-    }
-
-    if (comp->type == fmi2ModelExchange) {
-        comp->state = modelEventMode;
-        comp->isNewEventIteration = fmi2True;
-    }
-    else comp->state = modelStepComplete;
-    return fmi2OK;
-}
-
-fmi2Status fmi2Terminate(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2Terminate", MASK_fmi2Terminate))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Terminate")
-
-    comp->state = modelTerminated;
-    return fmi2OK;
-}
-
-fmi2Status fmi2Reset(fmi2Component c) {
-    ModelInstance* comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2Reset", MASK_fmi2Reset))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2Reset")
-
-    comp->state = modelInstantiated;
-    setStartValues(comp); // to be implemented by the includer of this file
-    comp->isDirtyValues = fmi2True; // because we just called setStartValues
-    return fmi2OK;
-}
-
-void fmi2FreeInstance(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (!comp) return;
-    if (invalidState(comp, "fmi2FreeInstance", MASK_fmi2FreeInstance))
-        return;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2FreeInstance")
-
-    if (comp->r) comp->functions->freeMemory(comp->r);
-    if (comp->i) comp->functions->freeMemory(comp->i);
-    if (comp->b) comp->functions->freeMemory(comp->b);
-    if (comp->s) {
-        int i;
-        for (i = 0; i < NUMBER_OF_STRINGS; i++){
-            if (comp->s[i]) comp->functions->freeMemory((void *)comp->s[i]);
-        }
-        comp->functions->freeMemory((void *)comp->s);
-    }
-    if (comp->isPositive) comp->functions->freeMemory(comp->isPositive);
-    if (comp->instanceName) comp->functions->freeMemory((void *)comp->instanceName);
-    if (comp->GUID) comp->functions->freeMemory((void *)comp->GUID);
-    comp->functions->freeMemory(comp);
-}
-
-// ---------------------------------------------------------------------------
-// FMI functions: class methods not depending of a specific model instance
-// ---------------------------------------------------------------------------
-
-const char* fmi2GetVersion() {
-    return fmi2Version;
-}
-
-const char* fmi2GetTypesPlatform() {
-    return fmi2TypesPlatform;
-}
-
-// ---------------------------------------------------------------------------
-// FMI functions: logging control, setters and getters for Real, Integer,
-// Boolean, String
-// ---------------------------------------------------------------------------
-
-fmi2Status fmi2SetDebugLogging(fmi2Component c, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[]) {
-    int i, j;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetDebugLogging", MASK_fmi2SetDebugLogging))
-        return fmi2Error;
-    comp->loggingOn = loggingOn;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetDebugLogging")
-
-    // reset all categories
-    for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
-        comp->logCategories[j] = fmi2False;
-    }
-
-    if (nCategories == 0) {
-        // no category specified, set all categories to have loggingOn value
-        for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
-            comp->logCategories[j] = loggingOn;
-        }
-    } else {
-        // set specific categories on
-        for (i = 0; i < nCategories; i++) {
-            fmi2Boolean categoryFound = fmi2False;
-            for (j = 0; j < NUMBER_OF_CATEGORIES; j++) {
-                if (strcmp(logCategoriesNames[j], categories[i]) == 0) {
-                    comp->logCategories[j] = loggingOn;
-                    categoryFound = fmi2True;
-                    break;
-                }
-            }
-            if (!categoryFound) {
-                comp->functions->logger(comp->componentEnvironment, comp->instanceName, fmi2Warning,
-                    logCategoriesNames[LOG_ERROR],
-                    "logging category '%s' is not supported by model", categories[i]);
-            }
-        }
-    }
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetReal (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetReal", MASK_fmi2GetReal))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "vr[]", vr))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetReal", "value[]", value))
-        return fmi2Error;
-    if (nvr > 0 && comp->isDirtyValues) {
-        calculateValues(comp);
-        comp->isDirtyValues = fmi2False;
-    }
-#if NUMBER_OF_REALS > 0
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2GetReal", vr[i], NUMBER_OF_REALS))
-            return fmi2Error;
-        value[i] = getReal(comp, vr[i]); // to be implemented by the includer of this file
-
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetReal: #r%u# = %.16g", vr[i], value[i])
-    }
-#endif
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetInteger", MASK_fmi2GetInteger))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetInteger", "vr[]", vr))
-            return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetInteger", "value[]", value))
-            return fmi2Error;
-    if (nvr > 0 && comp->isDirtyValues) {
-        calculateValues(comp);
-        comp->isDirtyValues = fmi2False;
-    }
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2GetInteger", vr[i], NUMBER_OF_INTEGERS))
-            return fmi2Error;
-        value[i] = comp->i[vr[i]];
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetInteger: #i%u# = %d", vr[i], value[i])
-    }
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetBoolean", MASK_fmi2GetBoolean))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetBoolean", "vr[]", vr))
-            return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2GetBoolean", "value[]", value))
-            return fmi2Error;
-    if (nvr > 0 && comp->isDirtyValues) {
-        calculateValues(comp);
-        comp->isDirtyValues = fmi2False;
-    }
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2GetBoolean", vr[i], NUMBER_OF_BOOLEANS))
-            return fmi2Error;
-        value[i] = comp->b[vr[i]];
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetBoolean: #b%u# = %s", vr[i], value[i]? "true" : "false")
-    }
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetString (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, fmi2String value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetString", MASK_fmi2GetString))
-        return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2GetString", "vr[]", vr))
-            return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2GetString", "value[]", value))
-            return fmi2Error;
-    if (nvr > 0 && comp->isDirtyValues) {
-        calculateValues(comp);
-        comp->isDirtyValues = fmi2False;
-    }
-    for (i=0; i<nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2GetString", vr[i], NUMBER_OF_STRINGS))
-            return fmi2Error;
-        value[i] = comp->s[vr[i]];
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetString: #s%u# = '%s'", vr[i], value[i])
-    }
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetReal (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetReal", MASK_fmi2SetReal))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2SetReal", "vr[]", vr))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2SetReal", "value[]", value))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetReal: nvr = %d", nvr)
-    // no check whether setting the value is allowed in the current state
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2SetReal", vr[i], NUMBER_OF_REALS))
-            return fmi2Error;
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetReal: #r%d# = %.16g", vr[i], value[i])
-        comp->r[vr[i]] = value[i];
-    }
-    if (nvr > 0) comp->isDirtyValues = fmi2True;
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetInteger(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetInteger", MASK_fmi2SetInteger))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2SetInteger", "vr[]", vr))
-        return fmi2Error;
-    if (nvr > 0 && nullPointer(comp, "fmi2SetInteger", "value[]", value))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetInteger: nvr = %d", nvr)
-
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2SetInteger", vr[i], NUMBER_OF_INTEGERS))
-            return fmi2Error;
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetInteger: #i%d# = %d", vr[i], value[i])
-        comp->i[vr[i]] = value[i];
-    }
-    if (nvr > 0) comp->isDirtyValues = fmi2True;
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetBoolean(fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetBoolean", MASK_fmi2SetBoolean))
-        return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2SetBoolean", "vr[]", vr))
-        return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2SetBoolean", "value[]", value))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetBoolean: nvr = %d", nvr)
-
-    for (i = 0; i < nvr; i++) {
-        if (vrOutOfRange(comp, "fmi2SetBoolean", vr[i], NUMBER_OF_BOOLEANS))
-            return fmi2Error;
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetBoolean: #b%d# = %s", vr[i], value[i] ? "true" : "false")
-        comp->b[vr[i]] = value[i];
-    }
-    if (nvr > 0) comp->isDirtyValues = fmi2True;
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetString (fmi2Component c, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[]) {
-    int i, n;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetString", MASK_fmi2SetString))
-        return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2SetString", "vr[]", vr))
-        return fmi2Error;
-    if (nvr>0 && nullPointer(comp, "fmi2SetString", "value[]", value))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetString: nvr = %d", nvr)
-
-    for (i = 0; i < nvr; i++) {
-        char *string = (char *)comp->s[vr[i]];
-        if (vrOutOfRange(comp, "fmi2SetString", vr[i], NUMBER_OF_STRINGS))
-            return fmi2Error;
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetString: #s%d# = '%s'", vr[i], value[i])
-
-        if (value[i] == NULL) {
-            if (string) comp->functions->freeMemory(string);
-            comp->s[vr[i]] = NULL;
-            FILTERED_LOG(comp, fmi2Warning, LOG_ERROR, "fmi2SetString: string argument value[%d] = NULL.", i);
-        } else {
-            if (string == NULL || strlen(string) < strlen(value[i])) {
-                if (string) comp->functions->freeMemory(string);
-                comp->s[vr[i]] = (char *)comp->functions->allocateMemory(1 + strlen(value[i]), sizeof(char));
-                if (!comp->s[vr[i]]) {
-                    comp->state = modelError;
-                    FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "fmi2SetString: Out of memory.")
-                    return fmi2Error;
-                }
-            }
-            strcpy((char *)comp->s[vr[i]], (char *)value[i]);
-        }
-    }
-    if (nvr > 0) comp->isDirtyValues = fmi2True;
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetFMUstate (fmi2Component c, fmi2FMUstate* FMUstate) {
-    return unsupportedFunction(c, "fmi2GetFMUstate", MASK_fmi2GetFMUstate);
-}
-fmi2Status fmi2SetFMUstate (fmi2Component c, fmi2FMUstate FMUstate) {
-    return unsupportedFunction(c, "fmi2SetFMUstate", MASK_fmi2SetFMUstate);
-}
-fmi2Status fmi2FreeFMUstate(fmi2Component c, fmi2FMUstate* FMUstate) {
-    return unsupportedFunction(c, "fmi2FreeFMUstate", MASK_fmi2FreeFMUstate);
-}
-fmi2Status fmi2SerializedFMUstateSize(fmi2Component c, fmi2FMUstate FMUstate, size_t *size) {
-    return unsupportedFunction(c, "fmi2SerializedFMUstateSize", MASK_fmi2SerializedFMUstateSize);
-}
-fmi2Status fmi2SerializeFMUstate (fmi2Component c, fmi2FMUstate FMUstate, fmi2Byte serializedState[], size_t size) {
-    return unsupportedFunction(c, "fmi2SerializeFMUstate", MASK_fmi2SerializeFMUstate);
-}
-fmi2Status fmi2DeSerializeFMUstate (fmi2Component c, const fmi2Byte serializedState[], size_t size,
-                                    fmi2FMUstate* FMUstate) {
-    return unsupportedFunction(c, "fmi2DeSerializeFMUstate", MASK_fmi2DeSerializeFMUstate);
-}
-
-fmi2Status fmi2GetDirectionalDerivative(fmi2Component c, const fmi2ValueReference vUnknown_ref[], size_t nUnknown,
-                                        const fmi2ValueReference vKnown_ref[] , size_t nKnown,
-                                        const fmi2Real dvKnown[], fmi2Real dvUnknown[]) {
-    return unsupportedFunction(c, "fmi2GetDirectionalDerivative", MASK_fmi2GetDirectionalDerivative);
-}
-
-// ---------------------------------------------------------------------------
-// Functions for FMI for Co-Simulation
-// ---------------------------------------------------------------------------
-/* Simulating the slave */
-fmi2Status fmi2SetRealInputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
-                                     const fmi2Integer order[], const fmi2Real value[]) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetRealInputDerivatives", MASK_fmi2SetRealInputDerivatives)) {
-        return fmi2Error;
-    }
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetRealInputDerivatives: nvr= %d", nvr)
-    FILTERED_LOG(comp, fmi2Error, LOG_ERROR, "fmi2SetRealInputDerivatives: ignoring function call."
-        " This model cannot interpolate inputs: canInterpolateInputs=\"fmi2False\"")
-    return fmi2Error;
-}
-
-fmi2Status fmi2GetRealOutputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
-                                      const fmi2Integer order[], fmi2Real value[]) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetRealOutputDerivatives", MASK_fmi2GetRealOutputDerivatives))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetRealOutputDerivatives: nvr= %d", nvr)
-    FILTERED_LOG(comp, fmi2Error, LOG_ERROR,"fmi2GetRealOutputDerivatives: ignoring function call."
-        " This model cannot compute derivatives of outputs: MaxOutputDerivativeOrder=\"0\"")
-    for (i = 0; i < nvr; i++) value[i] = 0;
-    return fmi2Error;
-}
-
-fmi2Status fmi2CancelStep(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2CancelStep", MASK_fmi2CancelStep)) {
-        // always fmi2CancelStep is invalid, because model is never in modelStepInProgress state.
-        return fmi2Error;
-    }
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2CancelStep")
-    FILTERED_LOG(comp, fmi2Error, LOG_ERROR,"fmi2CancelStep: Can be called when fmi2DoStep returned fmi2Pending."
-        " This is not the case.");
-    // comp->state = modelStepCanceled;
-    return fmi2Error;
-}
-
-fmi2Status fmi2DoStep(fmi2Component c, fmi2Real currentCommunicationPoint,
-                    fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint) {
-    ModelInstance *comp = (ModelInstance *)c;
-    double h = communicationStepSize / 10;
-    int k,i;
-    const int n = 10; // how many Euler steps to perform for one do step
-    double prevState[max(NUMBER_OF_STATES, 1)];
-    double prevEventIndicators[max(NUMBER_OF_EVENT_INDICATORS, 1)];
-    int stateEvent = 0;
-    int timeEvent = 0;
-
-    if (invalidState(comp, "fmi2DoStep", MASK_fmi2DoStep))
-        return fmi2Error;
-
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2DoStep: "
-        "currentCommunicationPoint = %g, "
-        "communicationStepSize = %g, "
-        "noSetFMUStatePriorToCurrentPoint = fmi2%s",
-        currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint ? "True" : "False")
-
-    if (communicationStepSize <= 0) {
-        FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
-            "fmi2DoStep: communication step size must be > 0. Fount %g.", communicationStepSize)
-        comp->state = modelError;
-        return fmi2Error;
-    }
-
-#if NUMBER_OF_EVENT_INDICATORS>0
-    // initialize previous event indicators with current values
-    for (i = 0; i < NUMBER_OF_EVENT_INDICATORS; i++) {
-        prevEventIndicators[i] = getEventIndicator(comp, i);
-    }
-#endif
-
-    // break the step into n steps and do forward Euler.
-    comp->time = currentCommunicationPoint;
-    for (k = 0; k < n; k++) {
-        comp->time += h;
-
-#if NUMBER_OF_STATES>0
-        for (i = 0; i < NUMBER_OF_STATES; i++) {
-            prevState[i] = r(vrStates[i]);
-        }
-        for (i = 0; i < NUMBER_OF_STATES; i++) {
-            fmi2ValueReference vr = vrStates[i];
-            r(vr) += h * getReal(comp, vr + 1); // forward Euler step
-        }
-#endif
-
-#if NUMBER_OF_EVENT_INDICATORS>0
-        // check for state event
-        for (i = 0; i < NUMBER_OF_EVENT_INDICATORS; i++) {
-            double ei = getEventIndicator(comp, i);
-            if (ei * prevEventIndicators[i] < 0) {
-                FILTERED_LOG(comp, fmi2OK, LOG_EVENT,
-                    "fmi2DoStep: state event at %g, z%d crosses zero -%c-", comp->time, i, ei < 0 ? '\\' : '/')
-                stateEvent++;
-            }
-            prevEventIndicators[i] = ei;
-        }
-#endif
-        // check for time event
-        if (comp->eventInfo.nextEventTimeDefined && (comp->time - comp->eventInfo.nextEventTime > -DT_EVENT_DETECT)) {
-            FILTERED_LOG(comp, fmi2OK, LOG_EVENT, "fmi2DoStep: time event detected at %g", comp->time)
-            timeEvent = 1;
-        }
-
-        if (stateEvent || timeEvent) {
-            eventUpdate(comp, &comp->eventInfo, timeEvent, fmi2True);
-            timeEvent = 0;
-            stateEvent = 0;
-        }
-
-        // terminate simulation, if requested by the model in the previous step
-        if (comp->eventInfo.terminateSimulation) {
-            FILTERED_LOG(comp, fmi2Discard, LOG_ALL, "fmi2DoStep: model requested termination at t=%g", comp->time)
-            comp->state = modelStepFailed;
-            return fmi2Discard; // enforce termination of the simulation loop
-        }
-    }
-    return fmi2OK;
-}
-
-/* Inquire slave status */
-static fmi2Status getStatus(char* fname, fmi2Component c, const fmi2StatusKind s) {
-    const char *statusKind[3] = {"fmi2DoStepStatus","fmi2PendingStatus","fmi2LastSuccessfulTime"};
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, fname, MASK_fmi2GetStatus)) // all get status have the same MASK_fmi2GetStatus
-            return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "$s: fmi2StatusKind = %s", fname, statusKind[s])
-
-    switch(s) {
-        case fmi2DoStepStatus: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
-            "%s: Can be called with fmi2DoStepStatus when fmi2DoStep returned fmi2Pending."
-            " This is not the case.", fname)
-            break;
-        case fmi2PendingStatus: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
-            "%s: Can be called with fmi2PendingStatus when fmi2DoStep returned fmi2Pending."
-            " This is not the case.", fname)
-            break;
-        case fmi2LastSuccessfulTime: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
-            "%s: Can be called with fmi2LastSuccessfulTime when fmi2DoStep returned fmi2Discard."
-            " This is not the case.", fname)
-            break;
-        case fmi2Terminated: FILTERED_LOG(comp, fmi2Error, LOG_ERROR,
-            "%s: Can be called with fmi2Terminated when fmi2DoStep returned fmi2Discard."
-            " This is not the case.", fname)
-            break;
-    }
-    return fmi2Discard;
-}
-
-fmi2Status fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status *value) {
-    return getStatus("fmi2GetStatus", c, s);
-}
-
-fmi2Status fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real *value) {
-    if (s == fmi2LastSuccessfulTime) {
-        ModelInstance *comp = (ModelInstance *)c;
-        if (invalidState(comp, "fmi2GetRealStatus", MASK_fmi2GetRealStatus))
-            return fmi2Error;
-        *value = comp->time;
-        return fmi2OK;
-    }
-    return getStatus("fmi2GetRealStatus", c, s);
-}
-
-fmi2Status fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value) {
-    return getStatus("fmi2GetIntegerStatus", c, s);
-}
-
-fmi2Status fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value) {
-    if (s == fmi2Terminated) {
-        ModelInstance *comp = (ModelInstance *)c;
-        if (invalidState(comp, "fmi2GetBooleanStatus", MASK_fmi2GetBooleanStatus))
-            return fmi2Error;
-        *value = comp->eventInfo.terminateSimulation;
-        return fmi2OK;
-    }
-    return getStatus("fmi2GetBooleanStatus", c, s);
-}
-
-fmi2Status fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String *value) {
-    return getStatus("fmi2GetStringStatus", c, s);
-}
-
-// ---------------------------------------------------------------------------
-// Functions for FMI2 for Model Exchange
-// ---------------------------------------------------------------------------
-/* Enter and exit the different modes */
-fmi2Status fmi2EnterEventMode(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2EnterEventMode", MASK_fmi2EnterEventMode))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2EnterEventMode")
-
-    comp->state = modelEventMode;
-    comp->isNewEventIteration = fmi2True;
-    return fmi2OK;
-}
-
-fmi2Status fmi2NewDiscreteStates(fmi2Component c, fmi2EventInfo *eventInfo) {
-    ModelInstance *comp = (ModelInstance *)c;
-    int timeEvent = 0;
-    if (invalidState(comp, "fmi2NewDiscreteStates", MASK_fmi2NewDiscreteStates))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2NewDiscreteStates")
-
-    comp->eventInfo.newDiscreteStatesNeeded = fmi2False;
-    comp->eventInfo.terminateSimulation = fmi2False;
-    comp->eventInfo.nominalsOfContinuousStatesChanged = fmi2False;
-    comp->eventInfo.valuesOfContinuousStatesChanged = fmi2False;
-
-    if (comp->eventInfo.nextEventTimeDefined && comp->eventInfo.nextEventTime <= comp->time) {
-        timeEvent = 1;
-    }
-    eventUpdate(comp, &comp->eventInfo, timeEvent, comp->isNewEventIteration);
-    comp->isNewEventIteration = fmi2False;
-
-    // copy internal eventInfo of component to output eventInfo
-    eventInfo->newDiscreteStatesNeeded = comp->eventInfo.newDiscreteStatesNeeded;
-    eventInfo->terminateSimulation = comp->eventInfo.terminateSimulation;
-    eventInfo->nominalsOfContinuousStatesChanged = comp->eventInfo.nominalsOfContinuousStatesChanged;
-    eventInfo->valuesOfContinuousStatesChanged = comp->eventInfo.valuesOfContinuousStatesChanged;
-    eventInfo->nextEventTimeDefined = comp->eventInfo.nextEventTimeDefined;
-    eventInfo->nextEventTime = comp->eventInfo.nextEventTime;
-
-    return fmi2OK;
-}
-
-fmi2Status fmi2EnterContinuousTimeMode(fmi2Component c) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2EnterContinuousTimeMode", MASK_fmi2EnterContinuousTimeMode))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL,"fmi2EnterContinuousTimeMode")
-
-    comp->state = modelContinuousTimeMode;
-    return fmi2OK;
-}
-
-fmi2Status fmi2CompletedIntegratorStep(fmi2Component c, fmi2Boolean noSetFMUStatePriorToCurrentPoint,
-                                     fmi2Boolean *enterEventMode, fmi2Boolean *terminateSimulation) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2CompletedIntegratorStep", MASK_fmi2CompletedIntegratorStep))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2CompletedIntegratorStep", "enterEventMode", enterEventMode))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2CompletedIntegratorStep", "terminateSimulation", terminateSimulation))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL,"fmi2CompletedIntegratorStep")
-    *enterEventMode = fmi2False;
-    *terminateSimulation = fmi2False;
-    return fmi2OK;
-}
-
-/* Providing independent variables and re-initialization of caching */
-fmi2Status fmi2SetTime(fmi2Component c, fmi2Real time) {
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2SetTime", MASK_fmi2SetTime))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetTime: time=%.16g", time)
-    comp->time = time;
-    return fmi2OK;
-}
-
-fmi2Status fmi2SetContinuousStates(fmi2Component c, const fmi2Real x[], size_t nx){
-    ModelInstance *comp = (ModelInstance *)c;
-    int i;
-    if (invalidState(comp, "fmi2SetContinuousStates", MASK_fmi2SetContinuousStates))
-        return fmi2Error;
-    if (invalidNumber(comp, "fmi2SetContinuousStates", "nx", nx, NUMBER_OF_STATES))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2SetContinuousStates", "x[]", x))
-        return fmi2Error;
-#if NUMBER_OF_STATES>0
-    for (i = 0; i < nx; i++) {
-        fmi2ValueReference vr = vrStates[i];
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2SetContinuousStates: #r%d#=%.16g", vr, x[i])
-        assert(vr < NUMBER_OF_REALS);
-        comp->r[vr] = x[i];
-    }
-#endif
-    return fmi2OK;
-}
-
-/* Evaluation of the model equations */
-fmi2Status fmi2GetDerivatives(fmi2Component c, fmi2Real derivatives[], size_t nx) {
-    int i;
-    ModelInstance* comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetDerivatives", MASK_fmi2GetDerivatives))
-        return fmi2Error;
-    if (invalidNumber(comp, "fmi2GetDerivatives", "nx", nx, NUMBER_OF_STATES))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2GetDerivatives", "derivatives[]", derivatives))
-        return fmi2Error;
-#if NUMBER_OF_STATES>0
-    for (i = 0; i < nx; i++) {
-        fmi2ValueReference vr = vrStates[i] + 1;
-        derivatives[i] = getReal(comp, vr); // to be implemented by the includer of this file
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetDerivatives: #r%d# = %.16g", vr, derivatives[i])
-    }
-#endif
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetEventIndicators(fmi2Component c, fmi2Real eventIndicators[], size_t ni) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetEventIndicators", MASK_fmi2GetEventIndicators))
-        return fmi2Error;
-    if (invalidNumber(comp, "fmi2GetEventIndicators", "ni", ni, NUMBER_OF_EVENT_INDICATORS))
-        return fmi2Error;
-#if NUMBER_OF_EVENT_INDICATORS>0
-    for (i = 0; i < ni; i++) {
-        eventIndicators[i] = getEventIndicator(comp, i); // to be implemented by the includer of this file
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetEventIndicators: z%d = %.16g", i, eventIndicators[i])
-    }
-#endif
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetContinuousStates(fmi2Component c, fmi2Real states[], size_t nx) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetContinuousStates", MASK_fmi2GetContinuousStates))
-        return fmi2Error;
-    if (invalidNumber(comp, "fmi2GetContinuousStates", "nx", nx, NUMBER_OF_STATES))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2GetContinuousStates", "states[]", states))
-        return fmi2Error;
-#if NUMBER_OF_STATES>0
-    for (i = 0; i < nx; i++) {
-        fmi2ValueReference vr = vrStates[i];
-        states[i] = getReal(comp, vr); // to be implemented by the includer of this file
-        FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetContinuousStates: #r%u# = %.16g", vr, states[i])
-    }
-#endif
-    return fmi2OK;
-}
-
-fmi2Status fmi2GetNominalsOfContinuousStates(fmi2Component c, fmi2Real x_nominal[], size_t nx) {
-    int i;
-    ModelInstance *comp = (ModelInstance *)c;
-    if (invalidState(comp, "fmi2GetNominalsOfContinuousStates", MASK_fmi2GetNominalsOfContinuousStates))
-        return fmi2Error;
-    if (invalidNumber(comp, "fmi2GetNominalContinuousStates", "nx", nx, NUMBER_OF_STATES))
-        return fmi2Error;
-    if (nullPointer(comp, "fmi2GetNominalContinuousStates", "x_nominal[]", x_nominal))
-        return fmi2Error;
-    FILTERED_LOG(comp, fmi2OK, LOG_FMI_CALL, "fmi2GetNominalContinuousStates: x_nominal[0..%d] = 1.0", nx-1)
-    for (i = 0; i < nx; i++)
-        x_nominal[i] = 1;
-    return fmi2OK;
-}
-
-#ifdef __cplusplus
-} // closing brace for extern "C"
-#endif

+ 0 - 170
examples/mass_spring_damper/fmusdk/fmu20/src/models/fmuTemplate.h

@@ -1,170 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * fmuTemplate.h
- * Definitions by the includer of this file
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-// C-code FMUs have functions names prefixed with MODEL_IDENTIFIER_.
-// Define DISABLE_PREFIX to build a binary FMU.
-#ifndef DISABLE_PREFIX
-#define pasteA(a,b)     a ## b
-#define pasteB(a,b)    pasteA(a,b)
-#define FMI2_FUNCTION_PREFIX pasteB(MODEL_IDENTIFIER, _)
-#endif
-#include "fmi2Functions.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// macros used to define variables
-#define  r(vr) comp->r[vr]
-#define  i(vr) comp->i[vr]
-#define  b(vr) comp->b[vr]
-#define  s(vr) comp->s[vr]
-#define pos(z) comp->isPositive[z]
-#define copy(vr, value) setString(comp, vr, value)
-
-fmi2Status setString(fmi2Component comp, fmi2ValueReference vr, fmi2String value);
-
-// categories of logging supported by model.
-// Value is the index in logCategories of a ModelInstance.
-#define LOG_ALL       0
-#define LOG_ERROR     1
-#define LOG_FMI_CALL  2
-#define LOG_EVENT     3
-
-#define NUMBER_OF_CATEGORIES 4
-
-typedef enum {
-    modelStartAndEnd        = 1<<0,
-    modelInstantiated       = 1<<1,
-    modelInitializationMode = 1<<2,
-
-    // ME states
-    modelEventMode          = 1<<3,
-    modelContinuousTimeMode = 1<<4,
-    // CS states
-    modelStepComplete       = 1<<5,
-    modelStepInProgress     = 1<<6,
-    modelStepFailed         = 1<<7,
-    modelStepCanceled       = 1<<8,
-
-    modelTerminated         = 1<<9,
-    modelError              = 1<<10,
-    modelFatal              = 1<<11,
-} ModelState;
-
-// ---------------------------------------------------------------------------
-// Function calls allowed state masks for both Model-exchange and Co-simulation
-// ---------------------------------------------------------------------------
-#define MASK_fmi2GetTypesPlatform        (modelStartAndEnd | modelInstantiated | modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepInProgress | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2GetVersion              MASK_fmi2GetTypesPlatform
-#define MASK_fmi2SetDebugLogging         (modelInstantiated | modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepInProgress | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2Instantiate             (modelStartAndEnd)
-#define MASK_fmi2FreeInstance            (modelInstantiated | modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2SetupExperiment         modelInstantiated
-#define MASK_fmi2EnterInitializationMode modelInstantiated
-#define MASK_fmi2ExitInitializationMode  modelInitializationMode
-#define MASK_fmi2Terminate               (modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepFailed)
-#define MASK_fmi2Reset                   MASK_fmi2FreeInstance
-#define MASK_fmi2GetReal                 (modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2GetInteger              MASK_fmi2GetReal
-#define MASK_fmi2GetBoolean              MASK_fmi2GetReal
-#define MASK_fmi2GetString               MASK_fmi2GetReal
-#define MASK_fmi2SetReal                 (modelInstantiated | modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete)
-#define MASK_fmi2SetInteger              (modelInstantiated | modelInitializationMode \
-                                        | modelEventMode \
-                                        | modelStepComplete)
-#define MASK_fmi2SetBoolean              MASK_fmi2SetInteger
-#define MASK_fmi2SetString               MASK_fmi2SetInteger
-#define MASK_fmi2GetFMUstate             MASK_fmi2FreeInstance
-#define MASK_fmi2SetFMUstate             MASK_fmi2FreeInstance
-#define MASK_fmi2FreeFMUstate            MASK_fmi2FreeInstance
-#define MASK_fmi2SerializedFMUstateSize  MASK_fmi2FreeInstance
-#define MASK_fmi2SerializeFMUstate       MASK_fmi2FreeInstance
-#define MASK_fmi2DeSerializeFMUstate     MASK_fmi2FreeInstance
-#define MASK_fmi2GetDirectionalDerivative (modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelStepComplete | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-
-// ---------------------------------------------------------------------------
-// Function calls allowed state masks for Model-exchange
-// ---------------------------------------------------------------------------
-#define MASK_fmi2EnterEventMode          (modelEventMode | modelContinuousTimeMode)
-#define MASK_fmi2NewDiscreteStates       modelEventMode
-#define MASK_fmi2EnterContinuousTimeMode modelEventMode
-#define MASK_fmi2CompletedIntegratorStep modelContinuousTimeMode
-#define MASK_fmi2SetTime                 (modelEventMode | modelContinuousTimeMode)
-#define MASK_fmi2SetContinuousStates     modelContinuousTimeMode
-#define MASK_fmi2GetEventIndicators      (modelInitializationMode \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2GetContinuousStates     MASK_fmi2GetEventIndicators
-#define MASK_fmi2GetDerivatives          (modelEventMode | modelContinuousTimeMode \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2GetNominalsOfContinuousStates ( modelInstantiated \
-                                        | modelEventMode | modelContinuousTimeMode \
-                                        | modelTerminated | modelError)
-
-// ---------------------------------------------------------------------------
-// Function calls allowed state masks for Co-simulation
-// ---------------------------------------------------------------------------
-#define MASK_fmi2SetRealInputDerivatives (modelInstantiated | modelInitializationMode \
-                                        | modelStepComplete)
-#define MASK_fmi2GetRealOutputDerivatives (modelStepComplete | modelStepFailed | modelStepCanceled \
-                                        | modelTerminated | modelError)
-#define MASK_fmi2DoStep                  modelStepComplete
-#define MASK_fmi2CancelStep              modelStepInProgress
-#define MASK_fmi2GetStatus               (modelStepComplete | modelStepInProgress | modelStepFailed \
-                                        | modelTerminated)
-#define MASK_fmi2GetRealStatus           MASK_fmi2GetStatus
-#define MASK_fmi2GetIntegerStatus        MASK_fmi2GetStatus
-#define MASK_fmi2GetBooleanStatus        MASK_fmi2GetStatus
-#define MASK_fmi2GetStringStatus         MASK_fmi2GetStatus
-
-typedef struct {
-    fmi2Real    *r;
-    fmi2Integer *i;
-    fmi2Boolean *b;
-    fmi2String  *s;
-    fmi2Boolean *isPositive;
-
-    fmi2Real time;
-    fmi2String instanceName;
-    fmi2Type type;
-    fmi2String GUID;
-    const fmi2CallbackFunctions *functions;
-    fmi2Boolean loggingOn;
-    fmi2Boolean logCategories[NUMBER_OF_CATEGORIES];
-
-    fmi2ComponentEnvironment componentEnvironment;
-    ModelState state;
-    fmi2EventInfo eventInfo;
-    fmi2Boolean isDirtyValues;
-    fmi2Boolean isNewEventIteration;
-} ModelInstance;
-
-#ifdef __cplusplus
-} // closing brace for extern "C"
-#endif

+ 0 - 3
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/Makefile

@@ -1,3 +0,0 @@
-CFLAGS = -I..
-
-include ../Makefile

+ 0 - 61
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/inc.c

@@ -1,61 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU - increments an int counter every second.
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-// define class name and unique id
-#define MODEL_IDENTIFIER inc
-#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f008}"
-
-// define model size
-#define NUMBER_OF_REALS 0
-#define NUMBER_OF_INTEGERS 1
-#define NUMBER_OF_BOOLEANS 0
-#define NUMBER_OF_STRINGS 0
-#define NUMBER_OF_STATES 0
-#define NUMBER_OF_EVENT_INDICATORS 0
-
-// include fmu header files, typedefs and macros
-#include "fmuTemplate.h"
-
-// define all model variables and their value references
-// conventions used here:
-// - if x is a variable, then macro x_ is its variable reference
-// - the vr of a variable is its index in array  r, i, b or s
-// - if k is the vr of a real state, then k+1 is the vr of its derivative
-#define counter_ 0
-
-// called by fmi2Instantiate
-// Set values for all variables that define a start value
-// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
-void setStartValues(ModelInstance *comp) {
-    i(counter_) = 1;
-}
-
-// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
-// if setStartValues or environment set new values through fmi2SetXXX.
-// Lazy set values for all variable that are computed from other variables.
-void calculateValues(ModelInstance *comp) {
-    if (comp->state == modelInitializationMode) {
-        // set first time event
-        comp->eventInfo.nextEventTimeDefined   = fmi2True;
-        comp->eventInfo.nextEventTime          = 1 + comp->time;
-    }
-}
-
-// used to set the next time event, if any.
-void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int timeEvent, int isNewEventIteration) {
-    if (timeEvent) {
-        i(counter_) += 1;
-        if (i(counter_) == 13) {
-            eventInfo->terminateSimulation  = fmi2True;
-            eventInfo->nextEventTimeDefined = fmi2False;
-        } else {
-            eventInfo->nextEventTimeDefined   = fmi2True;
-            eventInfo->nextEventTime          = 1 + comp->time;
-        }
-    }
-}
-
-// include code that implements the FMI based on the above definitions
-#include "fmuTemplate.c"

+ 0 - 22
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/index.html

@@ -1,22 +0,0 @@
-<html>
-<head>
-    <title>Documentation for inc.fmu</title>
-<style type="text/css">
-  html { font-family: Verdana, Arial, Helvetica, sans-serif; }
-  h1   { color: #000066; }
-</style>
-</head>
-<body>
-<h1>inc.fmu</h1>
-This FMU generates time events to increment an integer counter every second and terminates simulation at t=12 sec.
-<br/>    
-<img src="plot_counter.PNG">
-<br/>
-The figure shows the solution computed with Silver.
-
-<h2><a name="license">License conditions</a></h2>
-The FMU is provided by QTronic under the
-<a href="http://www.opensource.org/licenses/bsd-license.html">BSD License</a>.
-</body>
-</html>
-

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/model.png


+ 0 - 36
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/modelDescription_cs.xml

@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<fmiModelDescription
-  fmiVersion="2.0"
-  modelName="inc"
-  guid="{8c4e810f-3df3-4a00-8276-176fa3c9f008}"
-  numberOfEventIndicators="0">
-
-<CoSimulation
-  modelIdentifier="inc"
-  canHandleVariableCommunicationStepSize="true">
-  <SourceFiles>
-    <File name="inc.c"/>
-  </SourceFiles>
-</CoSimulation>
-
-<LogCategories>
-  <Category name="logAll"/>
-  <Category name="logError"/>
-  <Category name="logFmiCall"/>
-  <Category name="logEvent"/>
-</LogCategories>
-
-<ModelVariables>
-  <ScalarVariable name="counter" valueReference="0" description="counts the seconds"
-                  causality="output" variability="discrete" initial="exact">
-     <Integer start="1"/>
-  </ScalarVariable>
-</ModelVariables>
-
-<ModelStructure>
-  <Outputs>
-    <Unknown index="1" />
-  </Outputs>
-</ModelStructure>
-
-</fmiModelDescription>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/inc/plot_counter.PNG


+ 0 - 3
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/Makefile

@@ -1,3 +0,0 @@
-CFLAGS = -I..
-
-include ../Makefile

+ 0 - 23
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/index.html

@@ -1,23 +0,0 @@
-<html>
-<head>
-    <title>Documentation for values.fmu</title>
-<style type="text/css">
-  html { font-family: Verdana, Arial, Helvetica, sans-serif; }
-  h1   { color: #000066; }
-</style>
-</head>
-<body>
-    <h1>values.fmu</h1>
-    This FMU demonstrates the use of all four scalar FMU data types 
-    and terminates simulation at t=12 sec.
-    <img src="values.PNG">
-<br>
-The figure shows the solution computed with fmusim using the command 
-<code>fmusim me fmu\me\values.fmu 12 12</code>.
-
-<h2><a name="license">License conditions</a></h2>
-The FMU is provided by QTronic under the
-<a href="http://www.opensource.org/licenses/bsd-license.html">BSD License</a>.
-</body>
-</html>
-

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/model.png


+ 0 - 72
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/modelDescription_cs.xml

@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<fmiModelDescription
-  fmiVersion="2.0"
-  modelName="values"
-  guid="{8c4e810f-3df3-4a00-8276-176fa3c9f004}"
-  numberOfEventIndicators="0">
-
-<CoSimulation
-  modelIdentifier="values"
-  canHandleVariableCommunicationStepSize="true">
-  <SourceFiles>
-    <File name="values.c"/>
-  </SourceFiles>
-</CoSimulation>
-
-<LogCategories>
-  <Category name="logAll"/>
-  <Category name="logError"/>
-  <Category name="logFmiCall"/>
-  <Category name="logEvent"/>
-</LogCategories>
-
-<ModelVariables>
-  <ScalarVariable name="x" valueReference="0" description="used as continuous state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(x)" valueReference="1" description="time derivative of x"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="1"/>
-  </ScalarVariable>
-  <ScalarVariable name="int_in" valueReference="0" description="integer input"
-                  causality="input" variability="discrete">
-    <Integer start="2"/>
-  </ScalarVariable>
-  <ScalarVariable name="int_out" valueReference="1" description="index in string array 'month'"
-                  causality="output" variability="discrete" initial="exact">
-    <Integer start="0"/>
-  </ScalarVariable>
-  <ScalarVariable name="bool_in" valueReference="0" description="boolean input"
-                  causality="input" variability="discrete">
-    <Boolean start="true"/>
-  </ScalarVariable>
-  <ScalarVariable name="bool_out" valueReference="1" description="boolean output"
-                  causality="output" variability="discrete" initial="exact">
-    <Boolean start="false"/>
-  </ScalarVariable>
-  <ScalarVariable name="string_in" valueReference="0" description="string input"
-                  causality="input" variability="discrete">
-    <String start="QTronic"/>
-  </ScalarVariable>
-  <ScalarVariable name="string_out" valueReference="1" description="the string month[int_out]"
-                  causality="output" variability="discrete" initial="exact">
-    <String start="jan"/>
-  </ScalarVariable>
-</ModelVariables>
-
-<ModelStructure>
-  <Outputs>
-    <Unknown index="4" />
-    <Unknown index="6" />
-    <Unknown index="8" />
-  </Outputs>
-  <Derivatives>
-    <Unknown index="2" />
-  </Derivatives>
-  <InitialUnknowns>
-    <Unknown index="2"/>
-  </InitialUnknowns>
-</ModelStructure>
-
-</fmiModelDescription>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/values.PNG


+ 0 - 90
examples/mass_spring_damper/fmusdk/fmu20/src/models/values/values.c

@@ -1,90 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU.
- * This demonstrates the use of all FMU variable types.
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-// define class name and unique id
-#define MODEL_IDENTIFIER values
-#define MODEL_GUID "{8c4e810f-3df3-4a00-8276-176fa3c9f004}"
-
-// define model size
-#define NUMBER_OF_REALS 2
-#define NUMBER_OF_INTEGERS 2
-#define NUMBER_OF_BOOLEANS 2
-#define NUMBER_OF_STRINGS 2
-#define NUMBER_OF_STATES 1
-#define NUMBER_OF_EVENT_INDICATORS 0
-
-// include fmu header files, typedefs and macros
-#include "fmuTemplate.h"
-
-// define all model variables and their value references
-// conventions used here:
-// - if x is a variable, then macro x_ is its variable reference
-// - the vr of a variable is its index in array  r, i, b or s
-// - if k is the vr of a real state, then k+1 is the vr of its derivative
-#define x_          0
-#define der_x_      1
-#define int_in_     0
-#define int_out_    1
-#define bool_in_    0
-#define bool_out_   1
-#define string_in_  0
-#define string_out_ 1
-
-// define state vector as vector of value references
-#define STATES { x_ }
-
-const char *month[] = {
-    "jan","feb","march","april","may","june","july",
-    "august","sept","october","november","december"
-};
-
-// called by fmi2Instantiate
-// Set values for all variables that define a start value
-// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
-void setStartValues(ModelInstance *comp) {
-    r(x_) = 1;
-    i(int_in_) = 2;
-    i(int_out_) = 0;
-    b(bool_in_) = fmi2True;
-    b(bool_out_) = fmi2False;
-    copy(string_in_, "QTronic");
-    copy(string_out_, month[0]);
-}
-
-// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
-// if setStartValues or environment set new values through fmi2SetXXX.
-// Lazy set values for all variable that are computed from other variables.
-void calculateValues(ModelInstance *comp) {
-    if (comp->state == modelInitializationMode) {
-        // set first time event
-        comp->eventInfo.nextEventTimeDefined = fmi2True;
-        comp->eventInfo.nextEventTime        = 1 + comp->time;
-    }
-}
-
-// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
-fmi2Real getReal(ModelInstance *comp, fmi2ValueReference vr){
-    switch (vr) {
-        case x_     : return   r(x_);
-        case der_x_ : return - r(x_);
-        default: return 0;
-    }
-}
-
-// used to set the next time event, if any.
-void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
-    if (isTimeEvent) {
-        eventInfo->nextEventTimeDefined = fmi2True;
-        eventInfo->nextEventTime        = 1 + comp->time;
-        i(int_out_) += 1;
-        b(bool_out_) = !b(bool_out_);
-        if (i(int_out_) < 12) copy(string_out_, month[i(int_out_)]);
-        else eventInfo->terminateSimulation = fmi2True;
-    }
-}
-
-// include code that implements the FMI based on the above definitions
-#include "fmuTemplate.c"

+ 0 - 3
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/Makefile

@@ -1,3 +0,0 @@
-CFLAGS = -I..
-
-include ../Makefile

+ 0 - 27
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/index.html

@@ -1,27 +0,0 @@
-<html>
-<head>
-<title>Documentation for vanDerPol.fmu</title>
-<style type="text/css">
-  html { font-family: Verdana, Arial, Helvetica, sans-serif; }
-  h1   { color: #000066; }
-</style>
-</head>
-<body>
-<h1>vanDerPol.fmu</h1>
-This FMU implements the famous
-<a href="http://en.wikipedia.org/wiki/Van_der_Pol_oscillator" target="_blank">Van der Pol oscillator</a>.
-<ul>
-<li> der(x0) = x1 </li>
-<li> der(x1) = mu * ((1 - x0 * x0) * x1) - x0</li>
-</ul>
-<img src="plot_states.png">
-<br/>
-The figure shows the solution computed with Silver 
-for start values x0 = 2, x1 = 0, mu = 1.
-
-<h2><a name="license">License conditions</a></h2>
-The FMU is provided by QTronic under the
-<a href="http://www.opensource.org/licenses/bsd-license.html">BSD License</a>.
-</body>
-</html>
-

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/model.png


+ 0 - 57
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/modelDescription_cs.xml

@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<fmiModelDescription
-  fmiVersion="2.0"
-  modelName="van der Pol oscillator"
-  guid="{8c4e810f-3da3-4a00-8276-176fa3c9f000}"
-  numberOfEventIndicators="0">
-
-<CoSimulation
-  modelIdentifier="vanDerPol"
-  canHandleVariableCommunicationStepSize="true">
-  <SourceFiles>
-    <File name="vanDerPol.c"/>
-  </SourceFiles>
-</CoSimulation>
-
-<LogCategories>
-  <Category name="logAll"/>
-  <Category name="logError"/>
-  <Category name="logFmiCall"/>
-  <Category name="logEvent"/>
-</LogCategories>
-
-<ModelVariables>
-  <ScalarVariable name="x0" valueReference="0" description="the first state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="2"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(x0)" valueReference="1"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="1"/>
-  </ScalarVariable> 
-  <ScalarVariable name="x1" valueReference="2" description="the second state"
-                  causality="local" variability="continuous" initial="exact">
-    <Real start="0"/>
-  </ScalarVariable>
-  <ScalarVariable name="der(x1)" valueReference="3"
-                  causality="local" variability="continuous" initial="calculated">
-    <Real derivative="3"/>
-  </ScalarVariable> 
-  <ScalarVariable name="mu" valueReference="4" causality="parameter"
-                  variability="fixed" initial="exact">
-    <Real start="1"/>
-  </ScalarVariable>
-</ModelVariables>
-
-<ModelStructure>
-  <Derivatives>
-    <Unknown index="2" />
-    <Unknown index="4" />
-  </Derivatives>
-  <InitialUnknowns>
-    <Unknown index="2"/>
-    <Unknown index="4"/>
-  </InitialUnknowns>
-</ModelStructure>
-
-</fmiModelDescription>

BIN
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/plot_states.png


+ 0 - 77
examples/mass_spring_damper/fmusdk/fmu20/src/models/vanDerPol/vanDerPol.c

@@ -1,77 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * Sample implementation of an FMU - the Van der Pol oscillator.
- * See http://en.wikipedia.org/wiki/Van_der_Pol_oscillator
- *  
- *   der(x0) = x1
- *   der(x1) = mu * ((1 - x0 ^ 2) * x1) - x0;
- *
- *   start values: x0=2, x1=0, mue=1
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-// define class name and unique id
-#define MODEL_IDENTIFIER vanDerPol
-#define MODEL_GUID "{8c4e810f-3da3-4a00-8276-176fa3c9f000}"
-
-// define model size
-#define NUMBER_OF_REALS 5
-#define NUMBER_OF_INTEGERS 0
-#define NUMBER_OF_BOOLEANS 0
-#define NUMBER_OF_STRINGS 0
-#define NUMBER_OF_STATES 2
-#define NUMBER_OF_EVENT_INDICATORS 0
-
-// include fmu header files, typedefs and macros
-#include "fmuTemplate.h"
-
-// define all model variables and their value references
-// conventions used here:
-// - if x is a variable, then macro x_ is its variable reference
-// - the vr of a variable is its index in array  r, i, b or s
-// - if k is the vr of a real state, then k+1 is the vr of its derivative
-#define x0_     0
-#define der_x0_ 1
-#define x1_     2
-#define der_x1_ 3
-#define mu_     4
-
-// define state vector as vector of value references
-#define STATES { x0_, x1_ }
-
-// called by fmi2Instantiate
-// Set values for all variables that define a start value
-// Settings used unless changed by fmi2SetX before fmi2EnterInitializationMode
-void setStartValues(ModelInstance *comp) {
-    r(x0_) = 2;
-    r(x1_) = 0;
-    r(mu_) = 1;
-}
-
-// called by fmi2GetReal, fmi2GetInteger, fmi2GetBoolean, fmi2GetString, fmi2ExitInitialization
-// if setStartValues or environment set new values through fmi2SetXXX.
-// Lazy set values for all variable that are computed from other variables.
-void calculateValues(ModelInstance *comp) {
-    //if (comp->state == modelInitializationMode) {
-    //  initialization code here
-    //  set first time event, if any, using comp->eventInfo.nextEventTime
-    //}
-}
-
-// called by fmi2GetReal, fmi2GetContinuousStates and fmi2GetDerivatives
-fmi2Real getReal(ModelInstance* comp, fmi2ValueReference vr){
-    switch (vr) {
-        case x0_     : return r(x0_);
-        case x1_     : return r(x1_);
-        case der_x0_ : return r(x1_);
-        case der_x1_ : return r(mu_) * ((1.0-r(x0_)*r(x0_))*r(x1_)) - r(x0_);
-        case mu_     : return r(mu_);
-        default: return 0;
-    }
-}
-
-// used to set the next time event, if any.
-void eventUpdate(ModelInstance *comp, fmi2EventInfo *eventInfo, int isTimeEvent, int isNewEventIteration) {
-} 
-
-// include code that implements the FMI based on the above definitions
-#include "fmuTemplate.c"

+ 0 - 91
examples/mass_spring_damper/fmusdk/fmu20/src/shared/fmi2.h

@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------------- 
- * fmi.h
- * Struct with the corresponding function pointers for FMI 2.0.
- * Copyright QTronic GmbH. All rights reserved.
- * -------------------------------------------------------------------------*/
-
-#ifndef FMI_H
-#define FMI_H
-
-#ifdef _MSC_VER
-#include <windows.h>
-#define WINDOWS 1
-#if (_MSC_VER >= 1900)
-#pragma comment(lib, "legacy_stdio_definitions.lib")
-#endif /* _MSC_VER >= 1900 */
-#else /* _MSC_VER */
-#include <errno.h>
-#define WINDOWS 0
-#define TRUE 1
-#define FALSE 0
-#define min(a,b) (a>b ? b : a)
-#define HMODULE void *
-/* See http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html */
-#include <dlfcn.h>
-#endif /* _MSC_VER */
-
-#include "fmi2Functions.h"
-
-#include "XmlParserCApi.h"
-
-typedef struct {
-    ModelDescription* modelDescription;
-
-    HMODULE dllHandle; // fmu.dll handle
-    /***************************************************
-    Common Functions
-    ****************************************************/
-    fmi2GetTypesPlatformTYPE         *getTypesPlatform;
-    fmi2GetVersionTYPE               *getVersion;
-    fmi2SetDebugLoggingTYPE          *setDebugLogging;
-    fmi2InstantiateTYPE              *instantiate;
-    fmi2FreeInstanceTYPE             *freeInstance;
-    fmi2SetupExperimentTYPE          *setupExperiment;
-    fmi2EnterInitializationModeTYPE  *enterInitializationMode;
-    fmi2ExitInitializationModeTYPE   *exitInitializationMode;
-    fmi2TerminateTYPE                *terminate;
-    fmi2ResetTYPE                    *reset;
-    fmi2GetRealTYPE                  *getReal;
-    fmi2GetIntegerTYPE               *getInteger;
-    fmi2GetBooleanTYPE               *getBoolean;
-    fmi2GetStringTYPE                *getString;
-    fmi2SetRealTYPE                  *setReal;
-    fmi2SetIntegerTYPE               *setInteger;
-    fmi2SetBooleanTYPE               *setBoolean;
-    fmi2SetStringTYPE                *setString;
-    fmi2GetFMUstateTYPE              *getFMUstate;
-    fmi2SetFMUstateTYPE              *setFMUstate;
-    fmi2FreeFMUstateTYPE             *freeFMUstate;
-    fmi2SerializedFMUstateSizeTYPE   *serializedFMUstateSize;
-    fmi2SerializeFMUstateTYPE        *serializeFMUstate;
-    fmi2DeSerializeFMUstateTYPE      *deSerializeFMUstate;
-    fmi2GetDirectionalDerivativeTYPE *getDirectionalDerivative;
-    /***************************************************
-    Functions for FMI2 for Co-Simulation
-    ****************************************************/
-    fmi2SetRealInputDerivativesTYPE  *setRealInputDerivatives;
-    fmi2GetRealOutputDerivativesTYPE *getRealOutputDerivatives;
-    fmi2DoStepTYPE                   *doStep;
-    fmi2CancelStepTYPE               *cancelStep;
-    fmi2GetStatusTYPE                *getStatus;
-    fmi2GetRealStatusTYPE            *getRealStatus;
-    fmi2GetIntegerStatusTYPE         *getIntegerStatus;
-    fmi2GetBooleanStatusTYPE         *getBooleanStatus;
-    fmi2GetStringStatusTYPE          *getStringStatus;
-    /***************************************************
-    Functions for FMI2 for Model Exchange
-    ****************************************************/
-    fmi2EnterEventModeTYPE                *enterEventMode;
-    fmi2NewDiscreteStatesTYPE             *newDiscreteStates;
-    fmi2EnterContinuousTimeModeTYPE       *enterContinuousTimeMode;
-    fmi2CompletedIntegratorStepTYPE       *completedIntegratorStep;
-    fmi2SetTimeTYPE                       *setTime;
-    fmi2SetContinuousStatesTYPE           *setContinuousStates;
-    fmi2GetDerivativesTYPE                *getDerivatives;
-    fmi2GetEventIndicatorsTYPE            *getEventIndicators;
-    fmi2GetContinuousStatesTYPE           *getContinuousStates;
-    fmi2GetNominalsOfContinuousStatesTYPE *getNominalsOfContinuousStates;
-} FMU;
-
-#endif // FMI_H
-

+ 0 - 243
examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2FunctionTypes.h

@@ -1,243 +0,0 @@
-#ifndef fmi2FunctionTypes_h
-#define fmi2FunctionTypes_h
-
-#include "fmi2TypesPlatform.h"
-
-/* This header file must be utilized when compiling an FMU or an FMI master.
-   It declares data and function types for FMI 2.0
-
-   Revisions:
-   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
-   - Apr.  3, 2014: Added #include <stddef.h> for size_t definition
-   - Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179)
-   - Mar. 26, 2014: Introduced function argument "void" for the functions (#171)
-                      fmiGetTypesPlatformTYPE and fmiGetVersionTYPE
-   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
-                      fmiInstantiateModelTYPE , fmiInstantiateSlaveTYPE  -> fmiInstantiateTYPE
-                      fmiFreeModelInstanceTYPE, fmiFreeSlaveInstanceTYPE -> fmiFreeInstanceTYPE
-                      fmiEnterModelInitializationModeTYPE, fmiEnterSlaveInitializationModeTYPE -> fmiEnterInitializationModeTYPE
-                      fmiExitModelInitializationModeTYPE , fmiExitSlaveInitializationModeTYPE  -> fmiExitInitializationModeTYPE
-                      fmiTerminateModelTYPE , fmiTerminateSlaveTYPE  -> fmiTerminate
-                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
-                    Functions renamed
-                      fmiUpdateDiscreteStatesTYPE -> fmiNewDiscreteStatesTYPE
-                    Renamed elements of the enumeration fmiEventInfo
-                      upcomingTimeEvent             -> nextEventTimeDefined // due to generic naming scheme: varDefined + var
-                      newUpdateDiscreteStatesNeeded -> newDiscreteStatesNeeded;
-   - June 13, 2013: Changed type fmiEventInfo
-                    Functions removed:
-                       fmiInitializeModelTYPE
-                       fmiEventUpdateTYPE
-                       fmiCompletedEventIterationTYPE
-                       fmiInitializeSlaveTYPE
-                    Functions added:
-                       fmiEnterModelInitializationModeTYPE
-                       fmiExitModelInitializationModeTYPE
-                       fmiEnterEventModeTYPE
-                       fmiUpdateDiscreteStatesTYPE
-                       fmiEnterContinuousTimeModeTYPE
-                       fmiEnterSlaveInitializationModeTYPE;
-                       fmiExitSlaveInitializationModeTYPE;
-   - Feb. 17, 2013: Added third argument to fmiCompletedIntegratorStepTYPE
-                    Changed function name "fmiTerminateType" to "fmiTerminateModelType" (due to #113)
-                    Changed function name "fmiGetNominalContinuousStateTYPE" to
-                                          "fmiGetNominalsOfContinuousStatesTYPE"
-                    Removed fmiGetStateValueReferencesTYPE.
-   - Nov. 14, 2011: First public Version
-
-
-   Copyright © 2011 MODELISAR consortium,
-               2012-2013 Modelica Association Project "FMI"
-               All rights reserved.
-   This file is licensed by the copyright holders under the BSD 2-Clause License
-   (http://www.opensource.org/licenses/bsd-license.html):
-
-   ----------------------------------------------------------------------------
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-
-   - Redistributions of source code must retain the above copyright notice,
-     this list of conditions and the following disclaimer.
-   - Redistributions in binary form must reproduce the above copyright notice,
-     this list of conditions and the following disclaimer in the documentation
-     and/or other materials provided with the distribution.
-   - Neither the name of the copyright holders nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-   ----------------------------------------------------------------------------
-
-   with the extension:
-
-   You may distribute or publicly perform any modification only under the
-   terms of this license.
-   (Note, this means that if you distribute a modified file,
-    the modified file must also be provided under this license).
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* make sure all compiler use the same alignment policies for structures */
-#if defined _MSC_VER || defined __GNUC__
-#pragma pack(push,8)
-#endif
-
-/* Include stddef.h, in order that size_t etc. is defined */
-#include <stddef.h>
-
-
-/* Type definitions */
-typedef enum {
-    fmi2OK,
-    fmi2Warning,
-    fmi2Discard,
-    fmi2Error,
-    fmi2Fatal,
-    fmi2Pending
-} fmi2Status;
-
-typedef enum {
-    fmi2ModelExchange,
-    fmi2CoSimulation
-} fmi2Type;
-
-typedef enum {
-    fmi2DoStepStatus,
-    fmi2PendingStatus,
-    fmi2LastSuccessfulTime,
-    fmi2Terminated
-} fmi2StatusKind;
-
-typedef void      (*fmi2CallbackLogger)        (fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...);
-typedef void*     (*fmi2CallbackAllocateMemory)(size_t, size_t);
-typedef void      (*fmi2CallbackFreeMemory)    (void*);
-typedef void      (*fmi2StepFinished)          (fmi2ComponentEnvironment, fmi2Status);
-
-typedef struct {
-   const fmi2CallbackLogger         logger;
-   const fmi2CallbackAllocateMemory allocateMemory;
-   const fmi2CallbackFreeMemory     freeMemory;
-   const fmi2StepFinished           stepFinished;
-   const fmi2ComponentEnvironment   componentEnvironment;
-} fmi2CallbackFunctions;
-
-typedef struct {
-	 fmi2Boolean newDiscreteStatesNeeded;
-   fmi2Boolean terminateSimulation;
-   fmi2Boolean nominalsOfContinuousStatesChanged;
-   fmi2Boolean valuesOfContinuousStatesChanged;
-   fmi2Boolean nextEventTimeDefined;
-   fmi2Real    nextEventTime;
-} fmi2EventInfo;
-
-
-/* reset alignment policy to the one set before reading this file */
-#if defined _MSC_VER || defined __GNUC__
-#pragma pack(pop)
-#endif
-
-
-/* Define fmi2 function pointer types to simplify dynamic loading */
-
-/***************************************************
-Types for Common Functions
-****************************************************/
-
-/* Inquire version numbers of header files and setting logging status */
-   typedef const char* fmi2GetTypesPlatformTYPE(void);
-   typedef const char* fmi2GetVersionTYPE(void);
-   typedef fmi2Status  fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]);
-
-/* Creation and destruction of FMU instances and setting debug status */
-   typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean);
-   typedef void          fmi2FreeInstanceTYPE(fmi2Component);
-
-/* Enter and exit initialization mode, terminate and reset */
-   typedef fmi2Status fmi2SetupExperimentTYPE        (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real);
-   typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component);
-   typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component);
-   typedef fmi2Status fmi2TerminateTYPE              (fmi2Component);
-   typedef fmi2Status fmi2ResetTYPE                  (fmi2Component);
-
-/* Getting and setting variable values */
-   typedef fmi2Status fmi2GetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real   []);
-   typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]);
-   typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]);
-   typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []);
-
-   typedef fmi2Status fmi2SetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real   []);
-   typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]);
-   typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]);
-   typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []);
-
-/* Getting and setting the internal FMU state */
-   typedef fmi2Status fmi2GetFMUstateTYPE           (fmi2Component, fmi2FMUstate*);
-   typedef fmi2Status fmi2SetFMUstateTYPE           (fmi2Component, fmi2FMUstate);
-   typedef fmi2Status fmi2FreeFMUstateTYPE          (fmi2Component, fmi2FMUstate*);
-   typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component, fmi2FMUstate, size_t*);
-   typedef fmi2Status fmi2SerializeFMUstateTYPE     (fmi2Component, fmi2FMUstate, fmi2Byte[], size_t);
-   typedef fmi2Status fmi2DeSerializeFMUstateTYPE   (fmi2Component, const fmi2Byte[], size_t, fmi2FMUstate*);
-
-/* Getting partial derivatives */
-   typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component, const fmi2ValueReference[], size_t,
-                                                                   const fmi2ValueReference[], size_t,
-                                                                   const fmi2Real[], fmi2Real[]);
-
-/***************************************************
-Types for Functions for FMI2 for Model Exchange
-****************************************************/
-
-/* Enter and exit the different modes */
-   typedef fmi2Status fmi2EnterEventModeTYPE         (fmi2Component);
-   typedef fmi2Status fmi2NewDiscreteStatesTYPE      (fmi2Component, fmi2EventInfo*);
-   typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component);
-   typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*);
-
-/* Providing independent variables and re-initialization of caching */
-   typedef fmi2Status fmi2SetTimeTYPE            (fmi2Component, fmi2Real);
-   typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t);
-
-/* Evaluation of the model equations */
-   typedef fmi2Status fmi2GetDerivativesTYPE               (fmi2Component, fmi2Real[], size_t);
-   typedef fmi2Status fmi2GetEventIndicatorsTYPE           (fmi2Component, fmi2Real[], size_t);
-   typedef fmi2Status fmi2GetContinuousStatesTYPE          (fmi2Component, fmi2Real[], size_t);
-   typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t);
-
-
-/***************************************************
-Types for Functions for FMI2 for Co-Simulation
-****************************************************/
-
-/* Simulating the slave */
-   typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []);
-   typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []);
-
-   typedef fmi2Status fmi2DoStepTYPE     (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean);
-   typedef fmi2Status fmi2CancelStepTYPE (fmi2Component);
-
-/* Inquire slave status */
-   typedef fmi2Status fmi2GetStatusTYPE       (fmi2Component, const fmi2StatusKind, fmi2Status* );
-   typedef fmi2Status fmi2GetRealStatusTYPE   (fmi2Component, const fmi2StatusKind, fmi2Real*   );
-   typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*);
-   typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*);
-   typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* );
-
-
-#ifdef __cplusplus
-}  /* end of extern "C" { */
-#endif
-
-#endif /* fmi2FunctionTypes_h */

+ 0 - 333
examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2Functions.h

@@ -1,333 +0,0 @@
-#ifndef fmi2Functions_h
-#define fmi2Functions_h
-
-/* This header file must be utilized when compiling a FMU.
-   It defines all functions of the
-         FMI 2.0 Model Exchange and Co-Simulation Interface.
-
-   In order to have unique function names even if several FMUs
-   are compiled together (e.g. for embedded systems), every "real" function name
-   is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
-   Therefore, the typical usage is:
-
-      #define FMI2_FUNCTION_PREFIX MyModel_
-      #include "fmi2Functions.h"
-
-   As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
-   is actually getting the name "MyModel_fmi2GetDerivatives".
-
-   This only holds if the FMU is shipped in C source code, or is compiled in a
-   static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
-   names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
-
-   Revisions:
-   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
-   - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX
-                    are not defined (#173)
-   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
-                      fmiInstantiateModel , fmiInstantiateSlave  -> fmiInstantiate
-                      fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
-                      fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
-                      fmiExitModelInitializationMode , fmiExitSlaveInitializationMode  -> fmiExitInitializationMode
-                      fmiTerminateModel, fmiTerminateSlave  -> fmiTerminate
-                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
-                    Functions renamed:
-                      fmiUpdateDiscreteStates -> fmiNewDiscreteStates
-   - June 13, 2013: Functions removed:
-                       fmiInitializeModel
-                       fmiEventUpdate
-                       fmiCompletedEventIteration
-                       fmiInitializeSlave
-                    Functions added:
-                       fmiEnterModelInitializationMode
-                       fmiExitModelInitializationMode
-                       fmiEnterEventMode
-                       fmiUpdateDiscreteStates
-                       fmiEnterContinuousTimeMode
-                       fmiEnterSlaveInitializationMode;
-                       fmiExitSlaveInitializationMode;
-   - Feb. 17, 2013: Portability improvements:
-                       o DllExport changed to FMI_Export
-                       o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
-                       o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
-                    Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
-                    Changed function name "fmiGetNominalContinuousState" to
-                                          "fmiGetNominalsOfContinuousStates"
-                    Removed fmiGetStateValueReferences.
-   - Nov. 14, 2011: Adapted to FMI 2.0:
-                       o Split into two files (fmiFunctions.h, fmiTypes.h) in order
-                         that code that dynamically loads an FMU can directly
-                         utilize the header files).
-                       o Added C++ encapsulation of C-part, in order that the header
-                         file can be directly utilized in C++ code.
-                       o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
-                       o stepFinished within fmiCallbackFunctions has as first
-                         argument "fmiComponentEnvironment" and not "fmiComponent".
-                       o New functions to get and set the complete FMU state
-                         and to compute partial derivatives.
-   - Nov.  4, 2010: Adapted to specification text:
-                       o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
-                       o fmiInstantiateSlave: Argument GUID     replaced by fmuGUID
-                                              Argument mimetype replaced by mimeType
-                       o tabs replaced by spaces
-   - Oct. 16, 2010: Functions for FMI for Co-simulation added
-   - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
-                    (by M. Otter, DLR)
-                    Added WIN32 pragma to define the struct layout (ticket #34)
-                    (by J. Mauss, QTronic)
-   - Jan.  4, 2010: Removed argument intermediateResults from fmiInitialize
-                    Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
-                    Renamed macro fmiModelFunctionsVersion to fmiVersion
-                    Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
-                    (by J. Mauss, QTronic)
-   - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
-   - Dez. 14, 2009: Added eventInfo to meInitialize and added
-                    meGetNominalContinuousStates (by Martin Otter, DLR)
-   - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
-                    (by A. Junghanns, QTronic)
-   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
-                    meInquireModelTypesVersion     -> meGetModelTypesPlatform
-                    meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
-                    meSetStates                    -> meSetContinuousStates
-                    meGetStates                    -> meGetContinuousStates
-                    removal of meInitializeModelClass
-                    removal of meGetTime
-                    change of arguments of meInstantiateModel
-                    change of arguments of meCompletedIntegratorStep
-                    (by Martin Otter, DLR):
-   - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
-   - March 2, 2009: Changed function definitions according to the last design
-                    meeting with additional improvements (by Martin Otter, DLR).
-   - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
-
-   Copyright © 2008-2011 MODELISAR consortium,
-               2012-2013 Modelica Association Project "FMI"
-               All rights reserved.
-   This file is licensed by the copyright holders under the BSD 2-Clause License
-   (http://www.opensource.org/licenses/bsd-license.html):
-
-   ----------------------------------------------------------------------------
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-
-   - Redistributions of source code must retain the above copyright notice,
-     this list of conditions and the following disclaimer.
-   - Redistributions in binary form must reproduce the above copyright notice,
-     this list of conditions and the following disclaimer in the documentation
-     and/or other materials provided with the distribution.
-   - Neither the name of the copyright holders nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-   ----------------------------------------------------------------------------
-
-   with the extension:
-
-   You may distribute or publicly perform any modification only under the
-   terms of this license.
-   (Note, this means that if you distribute a modified file,
-    the modified file must also be provided under this license).
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "fmi2TypesPlatform.h"
-#include "fmi2FunctionTypes.h"
-#include <stdlib.h>
-
-
-/*
-  Export FMI2 API functions on Windows and under GCC.
-  If custom linking is desired then the FMI2_Export must be
-  defined before including this file. For instance,
-  it may be set to __declspec(dllimport).
-*/
-#if !defined(FMI2_Export)
-  #if !defined(FMI2_FUNCTION_PREFIX)
-    #if defined _WIN32 || defined __CYGWIN__
-     /* Note: both gcc & MSVC on Windows support this syntax. */
-        #define FMI2_Export __declspec(dllexport)
-    #else
-      #if __GNUC__ >= 4
-        #define FMI2_Export __attribute__ ((visibility ("default")))
-      #else
-        #define FMI2_Export
-      #endif
-    #endif
-  #else
-    #define FMI2_Export
-  #endif
-#endif
-
-/* Macros to construct the real function name
-   (prepend function name by FMI2_FUNCTION_PREFIX) */
-#if defined(FMI2_FUNCTION_PREFIX)
-  #define fmi2Paste(a,b)     a ## b
-  #define fmi2PasteB(a,b)    fmi2Paste(a,b)
-  #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
-#else
-  #define fmi2FullName(name) name
-#endif
-
-/***************************************************
-Common Functions
-****************************************************/
-#define fmi2GetTypesPlatform         fmi2FullName(fmi2GetTypesPlatform)
-#define fmi2GetVersion               fmi2FullName(fmi2GetVersion)
-#define fmi2SetDebugLogging          fmi2FullName(fmi2SetDebugLogging)
-#define fmi2Instantiate              fmi2FullName(fmi2Instantiate)
-#define fmi2FreeInstance             fmi2FullName(fmi2FreeInstance)
-#define fmi2SetupExperiment          fmi2FullName(fmi2SetupExperiment)
-#define fmi2EnterInitializationMode  fmi2FullName(fmi2EnterInitializationMode)
-#define fmi2ExitInitializationMode   fmi2FullName(fmi2ExitInitializationMode)
-#define fmi2Terminate                fmi2FullName(fmi2Terminate)
-#define fmi2Reset                    fmi2FullName(fmi2Reset)
-#define fmi2GetReal                  fmi2FullName(fmi2GetReal)
-#define fmi2GetInteger               fmi2FullName(fmi2GetInteger)
-#define fmi2GetBoolean               fmi2FullName(fmi2GetBoolean)
-#define fmi2GetString                fmi2FullName(fmi2GetString)
-#define fmi2SetReal                  fmi2FullName(fmi2SetReal)
-#define fmi2SetInteger               fmi2FullName(fmi2SetInteger)
-#define fmi2SetBoolean               fmi2FullName(fmi2SetBoolean)
-#define fmi2SetString                fmi2FullName(fmi2SetString)
-#define fmi2GetFMUstate              fmi2FullName(fmi2GetFMUstate)
-#define fmi2SetFMUstate              fmi2FullName(fmi2SetFMUstate)
-#define fmi2FreeFMUstate             fmi2FullName(fmi2FreeFMUstate)
-#define fmi2SerializedFMUstateSize   fmi2FullName(fmi2SerializedFMUstateSize)
-#define fmi2SerializeFMUstate        fmi2FullName(fmi2SerializeFMUstate)
-#define fmi2DeSerializeFMUstate      fmi2FullName(fmi2DeSerializeFMUstate)
-#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
-
-
-/***************************************************
-Functions for FMI2 for Model Exchange
-****************************************************/
-#define fmi2EnterEventMode                fmi2FullName(fmi2EnterEventMode)
-#define fmi2NewDiscreteStates             fmi2FullName(fmi2NewDiscreteStates)
-#define fmi2EnterContinuousTimeMode       fmi2FullName(fmi2EnterContinuousTimeMode)
-#define fmi2CompletedIntegratorStep       fmi2FullName(fmi2CompletedIntegratorStep)
-#define fmi2SetTime                       fmi2FullName(fmi2SetTime)
-#define fmi2SetContinuousStates           fmi2FullName(fmi2SetContinuousStates)
-#define fmi2GetDerivatives                fmi2FullName(fmi2GetDerivatives)
-#define fmi2GetEventIndicators            fmi2FullName(fmi2GetEventIndicators)
-#define fmi2GetContinuousStates           fmi2FullName(fmi2GetContinuousStates)
-#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
-
-
-/***************************************************
-Functions for FMI2 for Co-Simulation
-****************************************************/
-#define fmi2SetRealInputDerivatives      fmi2FullName(fmi2SetRealInputDerivatives)
-#define fmi2GetRealOutputDerivatives     fmi2FullName(fmi2GetRealOutputDerivatives)
-#define fmi2DoStep                       fmi2FullName(fmi2DoStep)
-#define fmi2CancelStep                   fmi2FullName(fmi2CancelStep)
-#define fmi2GetStatus                    fmi2FullName(fmi2GetStatus)
-#define fmi2GetRealStatus                fmi2FullName(fmi2GetRealStatus)
-#define fmi2GetIntegerStatus             fmi2FullName(fmi2GetIntegerStatus)
-#define fmi2GetBooleanStatus             fmi2FullName(fmi2GetBooleanStatus)
-#define fmi2GetStringStatus              fmi2FullName(fmi2GetStringStatus)
-
-/* Version number */
-#define fmi2Version "2.0"
-
-
-/***************************************************
-Common Functions
-****************************************************/
-
-/* Inquire version numbers of header files */
-   FMI2_Export fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;
-   FMI2_Export fmi2GetVersionTYPE       fmi2GetVersion;
-   FMI2_Export fmi2SetDebugLoggingTYPE  fmi2SetDebugLogging;
-
-/* Creation and destruction of FMU instances */
-   FMI2_Export fmi2InstantiateTYPE  fmi2Instantiate;
-   FMI2_Export fmi2FreeInstanceTYPE fmi2FreeInstance;
-
-/* Enter and exit initialization mode, terminate and reset */
-   FMI2_Export fmi2SetupExperimentTYPE         fmi2SetupExperiment;
-   FMI2_Export fmi2EnterInitializationModeTYPE fmi2EnterInitializationMode;
-   FMI2_Export fmi2ExitInitializationModeTYPE  fmi2ExitInitializationMode;
-   FMI2_Export fmi2TerminateTYPE               fmi2Terminate;
-   FMI2_Export fmi2ResetTYPE                   fmi2Reset;
-
-/* Getting and setting variables values */
-   FMI2_Export fmi2GetRealTYPE    fmi2GetReal;
-   FMI2_Export fmi2GetIntegerTYPE fmi2GetInteger;
-   FMI2_Export fmi2GetBooleanTYPE fmi2GetBoolean;
-   FMI2_Export fmi2GetStringTYPE  fmi2GetString;
-
-   FMI2_Export fmi2SetRealTYPE    fmi2SetReal;
-   FMI2_Export fmi2SetIntegerTYPE fmi2SetInteger;
-   FMI2_Export fmi2SetBooleanTYPE fmi2SetBoolean;
-   FMI2_Export fmi2SetStringTYPE  fmi2SetString;
-
-/* Getting and setting the internal FMU state */
-   FMI2_Export fmi2GetFMUstateTYPE            fmi2GetFMUstate;
-   FMI2_Export fmi2SetFMUstateTYPE            fmi2SetFMUstate;
-   FMI2_Export fmi2FreeFMUstateTYPE           fmi2FreeFMUstate;
-   FMI2_Export fmi2SerializedFMUstateSizeTYPE fmi2SerializedFMUstateSize;
-   FMI2_Export fmi2SerializeFMUstateTYPE      fmi2SerializeFMUstate;
-   FMI2_Export fmi2DeSerializeFMUstateTYPE    fmi2DeSerializeFMUstate;
-
-/* Getting partial derivatives */
-   FMI2_Export fmi2GetDirectionalDerivativeTYPE fmi2GetDirectionalDerivative;
-
-
-/***************************************************
-Functions for FMI2 for Model Exchange
-****************************************************/
-
-/* Enter and exit the different modes */
-   FMI2_Export fmi2EnterEventModeTYPE               fmi2EnterEventMode;
-   FMI2_Export fmi2NewDiscreteStatesTYPE            fmi2NewDiscreteStates;
-   FMI2_Export fmi2EnterContinuousTimeModeTYPE      fmi2EnterContinuousTimeMode;
-   FMI2_Export fmi2CompletedIntegratorStepTYPE      fmi2CompletedIntegratorStep;
-
-/* Providing independent variables and re-initialization of caching */
-   FMI2_Export fmi2SetTimeTYPE             fmi2SetTime;
-   FMI2_Export fmi2SetContinuousStatesTYPE fmi2SetContinuousStates;
-
-/* Evaluation of the model equations */
-   FMI2_Export fmi2GetDerivativesTYPE                fmi2GetDerivatives;
-   FMI2_Export fmi2GetEventIndicatorsTYPE            fmi2GetEventIndicators;
-   FMI2_Export fmi2GetContinuousStatesTYPE           fmi2GetContinuousStates;
-   FMI2_Export fmi2GetNominalsOfContinuousStatesTYPE fmi2GetNominalsOfContinuousStates;
-
-
-/***************************************************
-Functions for FMI2 for Co-Simulation
-****************************************************/
-
-/* Simulating the slave */
-   FMI2_Export fmi2SetRealInputDerivativesTYPE  fmi2SetRealInputDerivatives;
-   FMI2_Export fmi2GetRealOutputDerivativesTYPE fmi2GetRealOutputDerivatives;
-
-   FMI2_Export fmi2DoStepTYPE     fmi2DoStep;
-   FMI2_Export fmi2CancelStepTYPE fmi2CancelStep;
-
-/* Inquire slave status */
-   FMI2_Export fmi2GetStatusTYPE        fmi2GetStatus;
-   FMI2_Export fmi2GetRealStatusTYPE    fmi2GetRealStatus;
-   FMI2_Export fmi2GetIntegerStatusTYPE fmi2GetIntegerStatus;
-   FMI2_Export fmi2GetBooleanStatusTYPE fmi2GetBooleanStatus;
-   FMI2_Export fmi2GetStringStatusTYPE  fmi2GetStringStatus;
-
-#ifdef __cplusplus
-}  /* end of extern "C" { */
-#endif
-
-#endif /* fmi2Functions_h */

+ 0 - 115
examples/mass_spring_damper/fmusdk/fmu20/src/shared/include/fmi2TypesPlatform.h

@@ -1,115 +0,0 @@
-#ifndef fmi2TypesPlatform_h
-#define fmi2TypesPlatform_h
-
-/* Standard header file to define the argument types of the
-   functions of the Functional Mock-up Interface 2.0.
-   This header file must be utilized both by the model and
-   by the simulation engine.
-
-   Revisions:
-   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
-   - Mar   31, 2014: New datatype fmiChar introduced.
-   - Feb.  17, 2013: Changed fmiTypesPlatform from "standard32" to "default".
-                     Removed fmiUndefinedValueReference since no longer needed
-                     (because every state is defined in ScalarVariables).
-   - March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
-   - Nov.  14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
-                     both for "FMI for model exchange" and for "FMI for co-simulation"
-                     New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
-                     The implementation of "fmiBoolean" is change from "char" to "int".
-                     The #define "fmiPlatform" changed to "fmiTypesPlatform"
-                     (in order that #define and function call are consistent)
-   - Oct.   4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
-                     for the co-simulation interface
-   - Jan.   4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
-   - Dec.  21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
-                     according to meeting on Dec. 18 (by Martin Otter, DLR)
-   - Dec.   6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
-   - Sept.  9, 2009: Changes according to FMI-meeting on July 21:
-                     Changed "version" to "platform", "standard" to "standard32",
-                     Added a precise definition of "standard32" as comment
-                     (by Martin Otter, DLR)
-   - July  19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
-                     and changed meValueReferenced from int to unsigned int
-                     (by Martin Otter, DLR).
-   - March  2, 2009: Moved enums and function pointer definitions to
-                     ModelFunctions.h (by Martin Otter, DLR).
-   - Dec.  3, 2008 : First version by Martin Otter (DLR) and
-                     Hans Olsson (Dynasim).
-
-
-   Copyright © 2008-2011 MODELISAR consortium,
-               2012-2013 Modelica Association Project "FMI"
-               All rights reserved.
-   This file is licensed by the copyright holders under the BSD 2-Clause License
-   (http://www.opensource.org/licenses/bsd-license.html):
-
-   ----------------------------------------------------------------------------
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-
-   - Redistributions of source code must retain the above copyright notice,
-     this list of conditions and the following disclaimer.
-   - Redistributions in binary form must reproduce the above copyright notice,
-     this list of conditions and the following disclaimer in the documentation
-     and/or other materials provided with the distribution.
-   - Neither the name of the copyright holders nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-   ----------------------------------------------------------------------------
-
-   with the extension:
-
-   You may distribute or publicly perform any modification only under the
-   terms of this license.
-   (Note, this means that if you distribute a modified file,
-    the modified file must also be provided under this license).
-*/
-
-/* Platform (unique identification of this header file) */
-#define fmi2TypesPlatform "default"
-
-/* Type definitions of variables passed as arguments
-   Version "default" means:
-
-   fmi2Component           : an opaque object pointer
-   fmi2ComponentEnvironment: an opaque object pointer
-   fmi2FMUstate            : an opaque object pointer
-   fmi2ValueReference      : handle to the value of a variable
-   fmi2Real                : double precision floating-point data type
-   fmi2Integer             : basic signed integer data type
-   fmi2Boolean             : basic signed integer data type
-   fmi2Char                : character data type
-   fmi2String              : a pointer to a vector of fmi2Char characters
-                             ('\0' terminated, UTF8 encoded)
-   fmi2Byte                : smallest addressable unit of the machine, typically one byte.
-*/
-   typedef void*           fmi2Component;               /* Pointer to FMU instance       */
-   typedef void*           fmi2ComponentEnvironment;    /* Pointer to FMU environment    */
-   typedef void*           fmi2FMUstate;                /* Pointer to internal FMU state */
-   typedef unsigned int    fmi2ValueReference;
-   typedef double          fmi2Real   ;
-   typedef int             fmi2Integer;
-   typedef int             fmi2Boolean;
-   typedef char            fmi2Char;
-   typedef const fmi2Char* fmi2String;
-   typedef char            fmi2Byte;
-
-/* Values for fmi2Boolean  */
-#define fmi2True  1
-#define fmi2False 0
-
-
-#endif /* fmi2TypesPlatform_h */

+ 0 - 676
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlElement.cpp

@@ -1,676 +0,0 @@
-/*
- * Copyright QTronic GmbH. All rights reserved.
- */
-
-/* ---------------------------------------------------------------------------*
- * XmlElement.cpp
- * Elements implementation that describe content of model description of a
- * FMI 2.0 model. All elements have Element as parent class. Elements have
- * attributes and other specific content.
- *
- * Author: Adrian Tirea
- * ---------------------------------------------------------------------------*/
-
-#include "fmu20/XmlElement.h"
-#include <assert.h>
-#include <map>
-#include <string>
-#include <vector>
-#include <string.h> // strcmp
-#include "fmu20/XmlParserException.h"
-
-#ifdef STANDALONE_XML_PARSER
-#define logThis(n, ...) printf(__VA_ARGS__); printf("\n")
-#else
-#include "GlobalIncludes.h"
-#include "logging.h"  // logThis
-#endif  // STANDALONE_XML_PARSER
-
-Element::~Element() {
-    for (std::map<XmlParser::Att, char *>::const_iterator it = attributes.begin(); it != attributes.end(); ++it) {
-        free(it->second);
-    }
-    attributes.clear();
-}
-template <typename T> void Element::deleteListOfElements(const std::vector<T *> &list) {
-    typename std::vector<T*>::const_iterator it;
-    for (it = list.begin(); it != list.end(); ++it) {
-        delete *it;
-    }
-}
-void Element::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    throw XmlParserException("Elements are not expected inside '%s'. Found instead '%s'",
-        XmlParser::elmNames[type],
-        childName);
-}
-void Element::printElement(int indent) {
-    std::string indentS(indent, ' ');
-    logThis(ERROR_INFO, "%s%s", indentS.c_str(), XmlParser::elmNames[type]);
-    for (std::map<XmlParser::Att, char *>::const_iterator it = attributes.begin(); it != attributes.end(); ++it) {
-        logThis(ERROR_INFO, "%s%s=%s", indentS.c_str(), XmlParser::attNames[it->first], it->second);
-    }
-}
-template <typename T> void Element::printListOfElements(int indent, const std::vector<T *> &list) {
-    typename std::vector<T*>::const_iterator it;
-    for (it = list.begin(); it != list.end(); ++it) {
-        (*it)->printElement(indent);
-    }
-}
-
-const char *Element::getAttributeValue(XmlParser::Att att) {
-    std::map<XmlParser::Att, char *>::const_iterator it = attributes.find(att);
-    if (it != attributes.end()) {
-        return it->second;
-    }
-    return NULL;
-}
-int Element::getAttributeInt(XmlParser::Att att, XmlParser::ValueStatus *vs) {
-    int n = 0;
-    const char *value = getAttributeValue(att);
-    if (!value) { *vs = XmlParser::valueMissing; return n; }
-    *vs = (1 == sscanf(value, "%d", &n)) ? XmlParser::valueDefined : XmlParser::valueIllegal;
-    return n;
-}
-unsigned int Element::getAttributeUInt(XmlParser::Att att, XmlParser::ValueStatus *vs) {
-    unsigned int u = -1;
-    const char* value = getAttributeValue(att);
-    if (!value) { *vs = XmlParser::valueMissing; return u; }
-    *vs = (1 == sscanf(value, "%u", &u)) ? XmlParser::valueDefined : XmlParser::valueIllegal;
-    return u;
-}
-double Element::getAttributeDouble(XmlParser::Att att, XmlParser::ValueStatus *vs) {
-    double d = 0;
-    const char* value = getAttributeValue(att);
-    if (!value) { *vs = XmlParser::valueMissing; return d; }
-    *vs = (1 == sscanf(value, "%lf", &d)) ? XmlParser::valueDefined : XmlParser::valueIllegal;
-    return d;
-}
-bool Element::getAttributeBool(XmlParser::Att att, XmlParser::ValueStatus *vs) {
-    const char* value = getAttributeValue(att);
-    if (!value) {*vs = XmlParser::valueMissing; return false;}
-    *vs = XmlParser::valueDefined;
-    if (!strcmp(value, "true")) return true;
-    if (!strcmp(value, "false")) return false;
-    *vs = XmlParser::valueIllegal;
-    return false;
-}
-
-ListElement::~ListElement() {
-    deleteListOfElements(list);
-}
-void ListElement::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    if (childType == XmlParser::elm_Item) {
-        Element *item = new Element;
-        item->type = childType;
-        parser->parseElementAttributes(item);
-        if (!isEmptyElement) {
-            parser->parseEndElement();
-        }
-        list.push_back(item);
-    } else {
-        throw XmlParserException("Expected '%s' element inside '%s'. Found instead: '%s'.",
-                XmlParser::elmNames[XmlParser::elm_Item],
-                XmlParser::elmNames[XmlParser::elm_Enumeration],
-                childName);
-    }
-}
-void ListElement::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    printListOfElements(childIndent, list);
-}
-
-
-Unit::Unit() {
-    baseUnit = NULL;
-}
-Unit::~Unit() {
-    if (baseUnit) delete baseUnit;
-    deleteListOfElements(displayUnits);
-}
-void Unit::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    if (childType == XmlParser::elm_BaseUnit) {
-        baseUnit = new Element;
-        baseUnit->type = childType;
-        parser->parseElementAttributes(baseUnit);
-        if (!isEmptyElement) {
-            parser->parseEndElement();
-        }
-    } else if (childType == XmlParser::elm_DisplayUnit) {
-        Element *displayUnit = new Element;
-        displayUnit->type = childType;
-        parser->parseElementAttributes(displayUnit);
-        displayUnits.push_back(displayUnit);
-        if (!isEmptyElement) {
-            parser->parseEndElement();
-        }
-    } else {
-        throw XmlParserException("Expected '%s' | '%s' element inside '%s'. Found instead: '%s'.",
-            XmlParser::elmNames[XmlParser::elm_BaseUnit],
-            XmlParser::elmNames[XmlParser::elm_DisplayUnit],
-            XmlParser::elmNames[XmlParser::elm_SourceFiles],
-            childName);
-    }
-}
-void Unit::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    if (baseUnit) baseUnit->printElement(childIndent);
-    printListOfElements(childIndent, displayUnits);
-}
-Element *Unit::getDisplayUnit(const char *name) {
-    if (!name) return NULL;
-    for (std::vector<Element *>::const_iterator it = displayUnits.begin(); it != displayUnits.end(); ++it) {
-        const char *unitName = (*it)->getAttributeValue(XmlParser::att_name);
-        if (unitName && 0 == strcmp(name, unitName)) {
-            return (*it);
-        }
-    }
-    return NULL;
-}
-
-
-SimpleType::SimpleType() {
-    typeSpec = NULL;
-}
-SimpleType::~SimpleType() {
-    if (typeSpec) delete typeSpec;
-}
-void SimpleType::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    switch (childType) {
-        case XmlParser::elm_Real:
-        case XmlParser::elm_Integer:
-        case XmlParser::elm_Boolean:
-        case XmlParser::elm_String: {
-            typeSpec = new Element;
-            typeSpec->type = childType;
-            parser->parseElementAttributes(typeSpec);
-            if (!isEmptyElement) {
-                parser->parseEndElement();
-            }
-            break;
-        }
-        case XmlParser::elm_Enumeration: {
-            typeSpec = new ListElement;
-            typeSpec->type = childType;
-            parser->parseElementAttributes(typeSpec);
-            if (!isEmptyElement) {
-                parser->parseChildElements(typeSpec);
-            }
-            break;
-        }
-        default: {
-            throw XmlParserException(
-                "Expected '%s' | '%s' | '%s' | '%s' | '%s' element inside '%s'. Found instead: '%s'.",
-                XmlParser::elmNames[XmlParser::elm_Real],
-                XmlParser::elmNames[XmlParser::elm_Integer],
-                XmlParser::elmNames[XmlParser::elm_Boolean],
-                XmlParser::elmNames[XmlParser::elm_String],
-                XmlParser::elmNames[XmlParser::elm_Enumeration],
-                XmlParser::elmNames[type],
-                childName);
-        }
-    }
-}
-void SimpleType::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    if (typeSpec) typeSpec->printElement(childIndent);
-}
-
-
-Component::~Component() {
-    deleteListOfElements(files);
-}
-void Component::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    if (childType == XmlParser::elm_SourceFiles) {
-        if (!isEmptyElement) {
-            parser->parseChildElements(this);
-        }
-    } else if (childType == XmlParser::elm_File) {
-        Element *sourceFile = new Element;
-        sourceFile->type = childType;
-        parser->parseElementAttributes(sourceFile);
-        if (!isEmptyElement) {
-            parser->parseEndElement();
-        }
-        files.push_back(sourceFile);
-    } else {
-        throw XmlParserException("Expected '%s' | '%s' element inside '%s'. Found instead: '%s'.",
-            XmlParser::elmNames[XmlParser::elm_File],
-            XmlParser::elmNames[XmlParser::elm_SourceFiles],
-            XmlParser::elmNames[type],
-            childName);
-    }
-}
-void Component::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    printListOfElements(childIndent, files);
-}
-
-
-ScalarVariable::ScalarVariable() {
-    typeSpec = NULL;
-}
-ScalarVariable::~ScalarVariable() {
-    delete typeSpec;
-    deleteListOfElements(annotations);
-}
-void ScalarVariable::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    switch (childType) {
-        case XmlParser::elm_Real:
-        case XmlParser::elm_Integer:
-        case XmlParser::elm_Boolean:
-        case XmlParser::elm_String:
-        case XmlParser::elm_Enumeration: {
-            typeSpec = new Element;
-            typeSpec->type = childType;
-            parser->parseElementAttributes(typeSpec);
-            if (!isEmptyElement) {
-                parser->parseEndElement();
-            }
-            break;
-        }
-        case XmlParser::elm_Annotations: {
-            // no attributes expected; this class handles also the Tool
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-        case XmlParser::elm_Tool: {
-            Element *tool = new Element;
-            tool->type = childType;
-            parser->parseElementAttributes(tool, false);
-            if (!isEmptyElement) {
-                parser->parseSkipChildElement();
-            }
-            annotations.push_back(tool);
-            break;
-        }
-        default: {
-            throw XmlParserException(
-                "Expected '%s' | '%s' | '%s' | '%s' | '%s' | '%s' | '%s' element inside '%s'. Found instead: '%s'.",
-                XmlParser::elmNames[XmlParser::elm_Real],
-                XmlParser::elmNames[XmlParser::elm_Integer],
-                XmlParser::elmNames[XmlParser::elm_Boolean],
-                XmlParser::elmNames[XmlParser::elm_String],
-                XmlParser::elmNames[XmlParser::elm_Enumeration],
-                XmlParser::elmNames[XmlParser::elm_Annotations],
-                XmlParser::elmNames[XmlParser::elm_Tool],
-                XmlParser::elmNames[type],
-                childName);
-        }
-    }
-}
-fmi2ValueReference ScalarVariable::getValueReference() {
-    XmlParser::ValueStatus vs;
-    fmi2ValueReference ref = getAttributeUInt(XmlParser::att_valueReference, &vs);
-    assert(vs == XmlParser::valueDefined);  // this is a required attribute
-    return ref;
-}
-XmlParser::Enu ScalarVariable::getVariability() {
-    const char *value = getAttributeValue(XmlParser::att_variability);
-    if (!value) {
-        return XmlParser::enu_continuous;  // default
-    }
-    try {
-        return XmlParser::checkEnumValue(value);
-    } catch (XmlParserException& ) {
-        return XmlParser::enu_BAD_DEFINED;
-    }
-}
-XmlParser::Enu ScalarVariable::getCausality() {
-    const char *value = getAttributeValue(XmlParser::att_causality);
-    if (!value) {
-        return XmlParser::enu_local;  // default
-    }
-    try {
-        return XmlParser::checkEnumValue(value);
-    } catch (XmlParserException& ) {
-        return XmlParser::enu_BAD_DEFINED;
-    }
-}
-void ScalarVariable::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    typeSpec->printElement(childIndent);
-    printListOfElements(childIndent, annotations);
-}
-
-ModelStructure::ModelStructure() {
-    unknownParentType = XmlParser::elm_BAD_DEFINED;
-}
-
-ModelStructure::~ModelStructure() {
-    deleteListOfElements(outputs);
-    deleteListOfElements(derivatives);
-    deleteListOfElements(discreteStates);
-    deleteListOfElements(initialUnknowns);
-}
-void ModelStructure::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    switch (childType) {
-    case XmlParser::elm_Outputs:
-    case XmlParser::elm_Derivatives:
-    case XmlParser::elm_DiscreteStates:
-    case XmlParser::elm_InitialUnknowns:
-        {
-            // no attributes expected; this class handles also the Unknown
-            if (!isEmptyElement) {
-                unknownParentType = childType;
-                parser->parseChildElements(this);
-            }
-            break;
-        }
-    case XmlParser::elm_Unknown:
-        {
-            Element *unknown = new Element;
-            unknown->type = childType;
-            parser->parseElementAttributes(unknown);
-            if (!isEmptyElement) {
-                parser->parseEndElement();
-            }
-            switch (unknownParentType) {
-                case XmlParser::elm_Outputs:
-                    outputs.push_back(unknown);
-                    break;
-                case XmlParser::elm_Derivatives:
-                    derivatives.push_back(unknown);
-                    break;
-                case XmlParser::elm_DiscreteStates:
-                    discreteStates.push_back(unknown);
-                    break;
-                case XmlParser::elm_InitialUnknowns:
-                    initialUnknowns.push_back(unknown);
-                    break;
-                default: {
-                    throw XmlParserException(
-                    "Element '%s' must be inside of '%s' | '%s' | '%s' | '%s'.",
-                    XmlParser::elmNames[XmlParser::elm_Unknown],
-                    XmlParser::elmNames[XmlParser::elm_Outputs],
-                    XmlParser::elmNames[XmlParser::elm_Derivatives],
-                    XmlParser::elmNames[XmlParser::elm_DiscreteStates],
-                    XmlParser::elmNames[XmlParser::elm_InitialUnknowns]);
-}
-            }
-            break;
-        }
-    default:
-        {
-            throw XmlParserException(
-                "Expected '%s' | '%s' | '%s' | '%s' | '%s' element inside '%s'. Found instead: '%s'.",
-                XmlParser::elmNames[XmlParser::elm_Outputs],
-                XmlParser::elmNames[XmlParser::elm_Derivatives],
-                XmlParser::elmNames[XmlParser::elm_DiscreteStates],
-                XmlParser::elmNames[XmlParser::elm_InitialUnknowns],
-                XmlParser::elmNames[XmlParser::elm_Unknown],
-                XmlParser::elmNames[type],
-                childName);
-        }
-    }
-}
-void ModelStructure::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-    printListOfElements(childIndent, outputs);
-    printListOfElements(childIndent, derivatives);
-    printListOfElements(childIndent, discreteStates);
-    printListOfElements(childIndent, initialUnknowns);
-}
-
-
-ModelDescription::ModelDescription() {
-    modelExchange = NULL;
-    coSimulation = NULL;
-    defaultExperiment = NULL;
-    modelStructure = NULL;
-}
-ModelDescription::~ModelDescription() {
-    deleteListOfElements(unitDefinitions);
-    deleteListOfElements(typeDefinitions);
-    if (coSimulation) delete coSimulation;
-    if (modelExchange) delete modelExchange;
-    deleteListOfElements(logCategories);
-    if (defaultExperiment) delete defaultExperiment;
-    deleteListOfElements(vendorAnnotations);
-    deleteListOfElements(modelVariables);
-    if (modelStructure) delete modelStructure;
-}
-void ModelDescription::handleElement(XmlParser *parser, const char *childName, int isEmptyElement) {
-    XmlParser::Elm childType = parser->checkElement(childName);
-    switch (childType) {
-    case XmlParser::elm_CoSimulation:
-        {
-            coSimulation = new Component;
-            coSimulation->type = childType;
-            parser->parseElementAttributes(coSimulation);
-            if (!isEmptyElement) {
-                parser->parseChildElements(coSimulation);
-            }
-            break;
-        }
-    case XmlParser::elm_ModelExchange:
-        {
-            modelExchange = new Component;
-            modelExchange->type = childType;
-            parser->parseElementAttributes(modelExchange);
-            if (!isEmptyElement) {
-                parser->parseChildElements(modelExchange);
-            }
-            break;
-        }
-    case XmlParser::elm_UnitDefinitions:
-        {
-            // no attributes expected; this class handles the Category
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-    case XmlParser::elm_Unit:
-        {
-            Unit *unit = new Unit;
-            unit->type = childType;
-            parser->parseElementAttributes(unit);
-            if (!isEmptyElement) {
-                parser->parseChildElements(unit);
-            }
-            unitDefinitions.push_back(unit);
-            break;
-        }
-    case XmlParser::elm_TypeDefinitions:
-        {
-            // no attributes expected; this class handles also the SimpleType
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-    case XmlParser::elm_SimpleType:
-        {
-            SimpleType *type = new SimpleType;
-            type->type = childType;
-            parser->parseElementAttributes(type);
-            if (!isEmptyElement) {
-                parser->parseChildElements(type);
-            }
-            typeDefinitions.push_back(type);
-            break;
-        }
-    case XmlParser::elm_DefaultExperiment:
-        {
-            defaultExperiment = new Element;
-            defaultExperiment->type = childType;
-            parser->parseElementAttributes(defaultExperiment);
-            if (!isEmptyElement) {
-                parser->parseEndElement();
-            }
-            break;
-        }
-    case XmlParser::elm_LogCategories:
-        {
-            // no attributes expected; this class handles also the Category
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-    case XmlParser::elm_Category:
-        {
-            Element *category = new Element;
-            category->type = childType;
-            parser->parseElementAttributes(category);
-            if (!isEmptyElement) {
-                parser->parseEndElement();
-            }
-            logCategories.push_back(category);
-            break;
-        }
-    case XmlParser::elm_VendorAnnotations:
-        {
-            // no attributes expected; this class handles also the Tool
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-    case XmlParser::elm_Tool:
-        {
-            Element *tool = new Element;
-            tool->type = childType;
-            parser->parseElementAttributes(tool, false);
-            if (!isEmptyElement) {
-                parser->parseSkipChildElement();
-            }
-            vendorAnnotations.push_back(tool);
-            break;
-        }
-    case XmlParser::elm_ModelVariables:
-        {
-            // no attributes expected; this class handles also the ScalarVariable
-            if (!isEmptyElement) parser->parseChildElements(this);
-            break;
-        }
-    case XmlParser::elm_ScalarVariable:
-        {
-            ScalarVariable *variable = new ScalarVariable;
-            variable->type = childType;
-            parser->parseElementAttributes(variable);
-            if (!isEmptyElement) {
-                parser->parseChildElements(variable);
-            }
-            modelVariables.push_back(variable);
-            break;
-        }
-    case XmlParser::elm_ModelStructure:
-        {
-            modelStructure = new ModelStructure;
-            modelStructure->type = childType;
-            parser->parseElementAttributes(modelStructure);
-            if (!isEmptyElement) {
-                parser->parseChildElements(modelStructure);
-            }
-            break;
-        }
-    default:
-        throw XmlParserException("Element '%s' is not expected inside of '%s' | '%s' | '%s' | '%s'.",
-            childName,
-            XmlParser::elmNames[type]);
-    }
-}
-
-void ModelDescription::printElement(int indent) {
-    Element::printElement(indent);
-    int childIndent = indent + 1;
-
-    if (coSimulation) coSimulation->printElement(childIndent);
-    if (modelExchange) modelExchange->printElement(childIndent);
-    for (std::vector<Unit *>::const_iterator it = unitDefinitions.begin(); it != unitDefinitions.end(); ++it) {
-        (*it)->printElement(childIndent);
-    }
-    for (std::vector<SimpleType *>::const_iterator it = typeDefinitions.begin(); it != typeDefinitions.end(); ++it) {
-        (*it)->printElement(childIndent);
-    }
-    for (std::vector<Element *>::const_iterator it = logCategories.begin(); it != logCategories.end(); ++it) {
-        (*it)->printElement(childIndent);
-    }
-    if (defaultExperiment) defaultExperiment->printElement(childIndent);
-    for (std::vector<Element *>::const_iterator it = vendorAnnotations.begin(); it != vendorAnnotations.end(); ++it) {
-        (*it)->printElement(childIndent);
-    }
-    for (std::vector<ScalarVariable *>::const_iterator it = modelVariables.begin(); it != modelVariables.end(); ++it) {
-        (*it)->printElement(childIndent);
-    }
-    if (modelStructure) modelStructure->printElement(childIndent);
-}
-
-SimpleType *ModelDescription::getSimpleType(const char *name) {
-    for (std::vector<SimpleType *>::const_iterator it = typeDefinitions.begin(); it != typeDefinitions.end(); ++it) {
-        const char *typeName = (*it)->getAttributeValue(XmlParser::att_name);
-        if (typeName && 0 == strcmp(typeName, name)) {
-            return (*it);
-        }
-    }
-    return NULL;
-}
-
-ScalarVariable *ModelDescription::getVariable(const char *name) {
-    if (!name) return NULL;
-    for (std::vector<ScalarVariable *>::const_iterator it = modelVariables.begin(); it != modelVariables.end(); ++it) {
-        const char *varName = (*it)->getAttributeValue(XmlParser::att_name);
-        if (varName && 0 == strcmp(name, varName)) {
-            return (*it);
-        }
-    }
-    return NULL;
-}
-
-// Enumeration and Integer have the same base type while
-// Real, String, Boolean define own base types.
-static int sameBaseType(XmlParser::Elm  t1, XmlParser::Elm  t2){
-    return t1 == t2 ||
-           t1 == XmlParser::elm_Enumeration && t2 == XmlParser::elm_Integer ||
-           t2 == XmlParser::elm_Enumeration && t1 == XmlParser::elm_Integer;
-}
-
-ScalarVariable *ModelDescription::getVariable(fmi2ValueReference vr, XmlParser::Elm type) {
-    for (std::vector<ScalarVariable *>::const_iterator it = modelVariables.begin(); it != modelVariables.end(); ++it) {
-        if (vr == (*it)->getValueReference() && sameBaseType(type, (*it)->typeSpec->type)) {
-            return (*it);
-        }
-    }
-    return NULL;
-}
-
-const char *ModelDescription::getDescriptionForVariable(ScalarVariable *sv) {
-    const char *desc = sv->getAttributeValue(XmlParser::att_description);
-    // found description
-    if (desc) return desc;
-    // look for description of declared type:
-    const char *typeName = sv->typeSpec->getAttributeValue(XmlParser::att_declaredType);
-    if (typeName) {
-        SimpleType *type = getSimpleType(typeName);
-        if (type) return type->getAttributeValue(XmlParser::att_description);
-    }
-    return NULL;
-}
-
-const char *ModelDescription::getAttributeFromTypeOrDeclaredType(ScalarVariable *sv, XmlParser::Att a) {
-    const char *stringValue = sv->typeSpec->getAttributeValue(a);
-    if (stringValue) return stringValue;
-    // look for stringValue inside declared type:
-    const char *typeName = sv->typeSpec->getAttributeValue(XmlParser::att_declaredType);
-    if (typeName) {
-        SimpleType *type = getSimpleType(typeName);
-        if (type) return type->typeSpec->getAttributeValue(a);
-    }
-    return NULL;
-}
-
-Unit *ModelDescription::getUnit(const char *name) {
-    if (!name) return NULL;
-    for (std::vector<Unit *>::const_iterator it = unitDefinitions.begin(); it != unitDefinitions.end(); ++it) {
-        const char *unitName = (*it)->getAttributeValue(XmlParser::att_name);
-        if (unitName && 0 == strcmp(name, unitName)) {
-            return (*it);
-        }
-    }
-    return NULL;
-}

+ 0 - 328
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParser.cpp

@@ -1,328 +0,0 @@
-/*
- * Copyright QTronic GmbH. All rights reserved.
- */
-
-/* ---------------------------------------------------------------------------*
- * XmlParser.cpp
- * Parser implementation for xml model description file of a FMI 2.0 model.
- * The result of parsing is a ModelDescription object that can be queried to
- * get necessary information. The parsing is based on libxml2.lib.
- *
- * Author: Adrian Tirea
- * ---------------------------------------------------------------------------*/
-
-#include "fmu20/XmlParser.h"
-#include <utility>
-#include <vector>
-#include <string.h>
-#include "fmu20/XmlElement.h"
-#include "fmu20/XmlParserException.h"
-
-#ifdef STANDALONE_XML_PARSER
-#define logThis(n, ...) printf(__VA_ARGS__); printf("\n")
-#define checkStrdup(str) strdup(str)
-#else
-#include "GlobalIncludes.h"
-#include "logging.h"  // logThis
-#include "minutil.h"  // checkStrdup
-#endif  // STANDALONE_XML_PARSER
-
-/* Helper functions to check validity of xml. */
-static int checkAttribute(const char* att);
-
-const char *XmlParser::elmNames[SIZEOF_ELM] = {
-    "fmiModelDescription", "ModelExchange", "CoSimulation", "SourceFiles", "File",
-    "UnitDefinitions", "Unit", "BaseUnit", "DisplayUnit", "TypeDefinitions",
-    "SimpleType", "Real", "Integer", "Boolean", "String",
-    "Enumeration", "Item", "LogCategories", "Category", "DefaultExperiment",
-    "VendorAnnotations", "Tool", "ModelVariables", "ScalarVariable", "Annotations",
-    "ModelStructure", "Outputs", "Derivatives", "DiscreteStates", "InitialUnknowns",
-    "Unknown"
-};
-
-const char *XmlParser::attNames[SIZEOF_ATT] = {
-    "fmiVersion", "modelName", "guid", "description", "author",
-    "version", "copyright", "license", "generationTool", "generationDateAndTime",
-    "variableNamingConvention", "numberOfEventIndicators", "name", "kg", "m",
-    "s", "A", "K", "mol", "cd",
-    "rad", "factor", "offset", "quantity", "unit",
-    "displayUnit", "relativeQuantity", "min", "max", "nominal",
-    "unbounded", "value", "startTime", "stopTime", "tolerance",
-    "stepSize", "valueReference", "causality", "variability", "initial",
-    "previous", "canHandleMultipleSetPerTimeInstant", "declaredType", "start", "derivative",
-    "reinit", "index", "dependencies", "dependenciesKind", "modelIdentifier",
-    "needsExecutionTool", "completedIntegratorStepNotNeeded", "canBeInstantiatedOnlyOncePerProcess",
-        "canNotUseMemoryManagementFunctions", "canGetAndSetFMUstate",
-    "canSerializeFMUstate", "providesDirectionalDerivative", "canHandleVariableCommunicationStepSize",
-        "canInterpolateInputs", "maxOutputDerivativeOrder",
-    "canRunAsynchronuously",
-
-    // not conform with the FMI 2.0 doc.  // TODO : remove when used models become mature.
-    "xmlns:xsi",                       // Dymola examples from 2014 FD01
-    "providesDirectionalDerivatives",  // Dymola examples from 2014 FD01
-    "canHandleEvents"                  // Dymola examples from 2014 FD01
-};
-
-const char *XmlParser::enuNames[SIZEOF_ENU] = {
-    "flat", "structured", "dependent", "constant", "fixed",
-    "tunable", "discrete", "parameter", "calculatedParameter", "input",
-    "output", "local", "independent", "continuous", "exact",
-    "approx", "calculated"
-};
-
-XmlParser::XmlParser(char *xmlPath) {
-    this->xmlPath = (char *)checkStrdup(xmlPath);
-    xmlReader = NULL;
-}
-
-XmlParser::~XmlParser() {
-    free(xmlPath);
-    // do NOT call here xmlCleanupParser() because we don't know all other modules linked into this DLL that
-    // might be using libxml2. For memory leak detections call xmlCleanupParser() just before exit()
-    //xmlCleanupParser();
-}
-
-ModelDescription *XmlParser::parse() {
-    xmlReader = xmlReaderForFile(xmlPath, NULL, 0);
-    ModelDescription *md = NULL;
-    if (xmlReader != NULL) {
-        try {
-            if (readNextInXml()) {
-                // I expect that first element is fmiModelDescription.
-                if (0 != strcmp((char *)xmlTextReaderConstLocalName(xmlReader), elmNames[elm_fmiModelDescription])) {
-                    throw XmlParserException("Expected '%s' element. Found instead: '%s'.",
-                        elmNames[elm_fmiModelDescription],
-                        xmlTextReaderConstLocalName(xmlReader));
-                }
-
-                md = new ModelDescription;
-                md->type = elm_fmiModelDescription;
-                parseElementAttributes((Element *)md);
-                parseChildElements(md);
-            } else {
-                throw XmlParserException("Syntax error parsing xml file '%s'", xmlPath);
-            }
-        } catch (XmlParserException& e) {
-            logThis(ERROR_ERROR, "%s", e.what());
-            md = NULL;
-        } catch (std::bad_alloc& ) {
-            logThis(ERROR_FATAL, "Out of memory");
-            md = NULL;
-        }
-        xmlFreeTextReader(xmlReader);
-    } else {
-        logThis(ERROR_ERROR, "Unable to open '%s'", xmlPath);
-    }
-
-    return validate(md);
-}
-
-void XmlParser::parseElementAttributes(Element *element, bool ignoreUnknownAttributes) {
-    while (xmlTextReaderMoveToNextAttribute(xmlReader)) {
-        xmlChar *name = xmlTextReaderName(xmlReader);
-        xmlChar *value = xmlTextReaderValue(xmlReader);
-        try {
-            XmlParser::Att key = checkAttribute((char *)name);
-            char *theValue = value ? (char *)checkStrdup((char *)value) : NULL;
-            element->attributes.insert(std::pair<XmlParser::Att, char *>(key, theValue));
-        } catch (XmlParserException &ex) {
-            if (ignoreUnknownAttributes) {
-                xmlFree(name);
-                xmlFree(value);
-                throw;
-            }
-        }
-        xmlFree(name);
-        xmlFree(value);
-    }
-}
-
-void XmlParser::parseElementAttributes(Element *element) {
-    parseElementAttributes(element, true);
-}
-
-void XmlParser::parseChildElements(Element *el) {
-    int elementIsEmpty = xmlTextReaderIsEmptyElement(xmlReader);
-    if (elementIsEmpty == -1) {
-        throw XmlParserException("Error parsing xml file '%s'", xmlPath);
-    } else if (elementIsEmpty == 1) {
-        return;
-    }
-
-    bool ret = readNextInXml();
-    while (ret  && xmlTextReaderNodeType(xmlReader) != XML_READER_TYPE_END_ELEMENT) {
-        if (xmlTextReaderNodeType(xmlReader) == XML_READER_TYPE_ELEMENT) {
-            const char *localName = (char *)xmlTextReaderConstLocalName(xmlReader);
-            int depthBefore = xmlTextReaderDepth(xmlReader);
-            int isEmptyElement = xmlTextReaderIsEmptyElement(xmlReader);
-            el->handleElement(this, localName, isEmptyElement);
-            if (!isEmptyElement) {
-                int depthAfter = xmlTextReaderDepth(xmlReader);
-                if (depthBefore != depthAfter) {
-                    throw XmlParserException("Parser error. Depth wrong after parsing sub-tree for %s.", localName);
-                }
-            }
-        }
-        ret = readNextInXml();
-    }
-    if (!ret) {
-        throw XmlParserException("Error parsing xml file '%s'", xmlPath);
-    }
-}
-
-void XmlParser::parseEndElement() {
-    bool ret = readNextInXml();
-    while (ret  && xmlTextReaderNodeType(xmlReader) != XML_READER_TYPE_END_ELEMENT) {
-        ret = readNextInXml();
-    }
-    if (!ret) {
-        throw XmlParserException("Error parsing xml file '%s'", xmlPath);
-    }
-}
-
-void XmlParser::parseSkipChildElement() {
-    int depthBefore = xmlTextReaderDepth(xmlReader);
-    int depth = 0;
-    do {
-        bool ret = readNextInXml();
-        if (!ret) {
-            throw XmlParserException("Error parsing xml file '%s'", xmlPath);
-        }
-        depth = xmlTextReaderDepth(xmlReader);
-    } while (depth >= depthBefore);
-}
-
-bool XmlParser::readNextInXml() {
-    int ret;
-    do {
-        ret = xmlTextReaderRead(xmlReader);
-    } while (ret == 1 && xmlTextReaderNodeType(xmlReader) == XML_READER_TYPE_COMMENT);
-
-    if (ret != 1) {
-        return false;
-    }
-    return true;
-}
-
-/* -------------------------------------------------------------------------* 
- * Helper functions to check validity of xml.
- * -------------------------------------------------------------------------*/
-
-// Returns the index of name in the array.
-// Throw exception if name not found (invalid).
-static int checkName(const char *name, const char *kind, const char *array[], int n) {
-    for (int i = 0; i < n; i++) {
-        if (!strcmp(name, array[i])) {
-            return i;
-        }
-    }
-    throw XmlParserException("Illegal %s %s", kind, name);
-}
-
-XmlParser::Att XmlParser::checkAttribute(const char *att) {
-    return (XmlParser::Att)checkName(att, "attribute", XmlParser::attNames, XmlParser::SIZEOF_ATT);
-}
-
-XmlParser::Elm XmlParser::checkElement(const char *elm) {
-    return (XmlParser::Elm)checkName(elm, "element", XmlParser::elmNames, XmlParser::SIZEOF_ELM);
-}
-
-XmlParser::Enu XmlParser::checkEnumValue(const char *enu) {
-    return (XmlParser::Enu)checkName(enu, "enum value", XmlParser::enuNames, XmlParser::SIZEOF_ENU);
-}
-
-ModelDescription *XmlParser::validate(ModelDescription *md) {
-    if (md == NULL) return NULL;
-    int errors = 0;
-    // check modelDescription required attributes
-    if (!(md->getAttributeValue(XmlParser::att_fmiVersion)
-        && md->getAttributeValue(XmlParser::att_modelName)
-        && md->getAttributeValue(XmlParser::att_guid))) {
-            logThis(ERROR_ERROR, "Model description miss required attributes in file %s", xmlPath);
-            return NULL;
-    }
-
-    if (!(md->coSimulation || md->modelExchange)) {
-        logThis(ERROR_ERROR, "Model description must have a co-simulation or model exchange component in file %s",
-            xmlPath);
-            return NULL;
-    }
-
-    // check model variables
-    for (std::vector<ScalarVariable *>::const_iterator it = md->modelVariables.begin(); it != md->modelVariables.end();
-            ++it) {
-        const char *varName = (*it)->getAttributeValue(XmlParser::att_name);
-        if (!varName) {
-            logThis(ERROR_ERROR, "Scalar variable miss required %s attribute in modelDescription.xml",
-                XmlParser::attNames[XmlParser::att_name]);
-            errors++;
-            continue;
-        }
-        XmlParser::ValueStatus vs;
-        (*it)->getAttributeUInt(XmlParser::att_valueReference, &vs);
-        if (vs == XmlParser::valueMissing) {
-            logThis(ERROR_ERROR, "Scalar variable %s miss required %s attribute in modelDescription.xml",
-                varName, XmlParser::attNames[XmlParser::att_valueReference]);
-            errors++;
-            continue;
-        }
-        if (vs == XmlParser::valueIllegal) {
-            logThis(ERROR_ERROR, "Scalar variable %s has illegal format for %s attribute in modelDescription.xml",
-                varName, XmlParser::attNames[XmlParser::att_valueReference]);
-            errors++;
-            continue;
-        }
-
-        if (!(*it)->typeSpec) {
-            logThis(ERROR_ERROR, "Scalar variable %s miss type specification in modelDescription.xml",
-                varName);
-            errors++;
-            continue;
-        }
-        if ((*it)->typeSpec->type == XmlParser::elm_Enumeration) {
-            const char *typeName = (*it)->typeSpec->getAttributeValue(XmlParser::att_declaredType);
-            if (!typeName) {
-                logThis(ERROR_ERROR, "Scalar variable %s with enum type specification miss required %s attribute in "
-                        "modelDescription.xml", varName, XmlParser::attNames[XmlParser::att_declaredType]);
-                errors++;
-                continue;
-            }
-            if (!md->getSimpleType(typeName)) {
-                logThis(ERROR_ERROR, "Declared type %s of variable %s not found in modelDescription.xml",
-                     typeName, varName);
-                errors++;
-                continue;
-            }
-        }
-    }
-
-    // check existence of model structure
-    if (!(md->modelStructure)) {
-        logThis(ERROR_ERROR, "Model description must contain model structure in file %s",
-            xmlPath);
-        return NULL;
-    }
-
-    if (errors > 0) {
-        logThis(ERROR_ERROR, "Found %d error in file %s", errors, xmlPath);
-        return NULL;
-    }
-    return md;
-}
-
-// #define TEST
-#ifdef TEST
-int main() {
-    // { char c='c'; while(c!='g') scanf("%c", &c); } // to debug: wait for the g key
-
-    XmlParser *parser =
-        new XmlParser("c:\\_data\\fmi-fmu\\fmi-fmuVS\\fmi-fmuVS\\modelDescriptionDymola - ManuallyModifiedCopy.xml");
-    ModelDescription *md = parser->parse();
-    if (md) md->printElement(0);
-    delete parser;
-    if (md) delete md;
-
-    dumpMemoryLeaks();
-    return 0;
-}
-#endif  // TEST

+ 0 - 242
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParserCApi.cpp

@@ -1,242 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * XmlParserCApi.cpp
- * Expose functionality of XmlParser.cpp as a c API.
- * Call functions of this file to parse and get information from xml
- * model description file of a FMI 2.0 model.
- *
- * Author: Adrian Tirea
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-#include "XmlParserCApi.h"
-#include "fmu20/XmlParser.h"
-#include "fmu20/XmlElement.h"
-
-#ifdef STANDALONE_XML_PARSER
-#define logThis(n, ...) printf(__VA_ARGS__); printf("\n")
-#define checkStrdup(str) strdup(str)
-#else
-#include "logging.h"  // logThis
-#endif  // STANDALONE_XML_PARSER
-
-ModelDescription* parse(char* xmlPath) {
-    XmlParser parser(xmlPath);
-    return parser.parse();
-}
-void freeModelDescription(ModelDescription *md) {
-    if (md) delete md;
-}
-
-/* ModelDescription fields access*/
-int getUnitDefinitionsSize(ModelDescription *md) {
-    return md->unitDefinitions.size();
-}
-
-Unit *getUnitDefinition(ModelDescription *md, int index) {
-    return md->unitDefinitions.at(index);
-}
-
-int getTypeDefinitionsSize(ModelDescription *md) {
-    return md->typeDefinitions.size();
-}
-
-SimpleType *getTypeDefinition(ModelDescription *md, int index) {
-    return md->typeDefinitions.at(index);
-}
-
-Component *getModelExchange(ModelDescription *md) {
-    return md->modelExchange;
-}
-
-Component *getCoSimulation(ModelDescription *md) {
-    return md->coSimulation;
-}
-
-int getLogCategoriesSize(ModelDescription *md) {
-    return md->logCategories.size();
-}
-
-Element *getLogCategory(ModelDescription *md, int index) {
-    return md->logCategories.at(index);
-}
-
-Element *getDefaultExperiment(ModelDescription *md) {
-    return md->defaultExperiment;
-}
-
-int getVendorAnnotationsSize(ModelDescription *md) {
-    return md->vendorAnnotations.size();
-}
-
-Element *getVendorAnnotation(ModelDescription *md, int index) {
-    return md->vendorAnnotations.at(index);
-}
-
-int getScalarVariableSize(ModelDescription *md) {
-    return md->modelVariables.size();
-}
-
-ScalarVariable *getScalarVariable(ModelDescription *md, int index) {
-    return md->modelVariables.at(index);
-}
-
-ModelStructure  *getModelStructure (ModelDescription *md) {
-    return md->modelStructure;
-}
-
-SimpleType *getSimpleType(ModelDescription *md, const char *name) {
-    return md->getSimpleType(name);
-}
-
-ScalarVariable *getVariable(ModelDescription *md, const char *name) {
-    return md->getVariable(name);
-}
-
-const char *getDescriptionForVariable(ModelDescription *md, ScalarVariable *sv) {
-    return md->getDescriptionForVariable(sv);
-}
-
-/* ModelStructure fields access */
-int getOutputs(ModelStructure *ms) {
-    return ms->outputs.size();
-}
-
-Element *getOutput(ModelStructure *ms, int index) {
-    return ms->outputs.at(index);
-}
-
-int getDerivativesSize(ModelStructure *ms) {
-    return ms->derivatives.size();
-}
-
-Element *getDerivative(ModelStructure *ms, int index) {
-    return ms->derivatives.at(index);
-}
-
-int getDiscreteStates(ModelStructure *ms) {
-    return ms->discreteStates.size();
-}
-
-Element *getDiscreteState(ModelStructure *ms, int index) {
-    return ms->discreteStates.at(index);
-}
-
-int getInitialUnknowns(ModelStructure *ms) {
-    return ms->initialUnknowns.size();
-}
-
-Element *getInitialUnknown(ModelStructure *ms, int index) {
-    return ms->initialUnknowns.at(index);
-}
-
-/* ScalarVariable field access */
-Element *getTypeSpec(ScalarVariable *sv) {
-    return sv->typeSpec;
-}
-
-int getAnnotationsSize(ScalarVariable *sv) {
-    return sv->annotations.size();
-}
-
-Element *getAnnotation(ScalarVariable *sv, int index) {
-    return sv->annotations.at(index);
-}
-
-fmi2ValueReference getValueReference(ScalarVariable *sv) {
-    return sv->getValueReference();
-}
-// returns one of constant, fixed, tunable, discrete, continuous.
-// If value is missing, the default continuous is returned.
-// If unknown value, return enu_BAD_DEFINED.
-Enu getVariability(ScalarVariable *sv) {
-    return (Enu)sv->getVariability();
-}
-// returns one of parameter, calculatedParameter, input, output, local, independent.
-// If value is missing, the default local is returned.
-// If unknown value, return enu_BAD_DEFINED.
-Enu getCausality(ScalarVariable *sv) {
-    return (Enu)sv->getCausality();
-}
-
-/* Component field access */
-int getFilesSize(Component *c) {
-    return c->files.size();
-}
-
-Element *getFile(Component *c, int index) {
-    return c->files.at(index);
-}
-
-/* SimpleType field access */
-Element *getTypeSpecDef(SimpleType *st) {
-    return st->typeSpec;
-}
-
-/* Unit field access */
-Element *getBaseUnit(Unit *u) {
-    return u->baseUnit;
-}
-
-int getDisplayUnitsSize(Unit *u) {
-    return u->displayUnits.size();
-}
-
-Element *getDisplayUnit(Unit *u, int index) {
-    return u->displayUnits.at(index);
-}
-
-/* ListElement field access */
-int getListSize(ListElement *le) {
-    return le->list.size();
-}
-
-Element *getElementFromList(ListElement *le, int index) {
-    return le->list.at(index);
-}
-
-/* Element functions */
-Elm getElementType(Element *el) {
-    return (Elm)el->type;
-}
-
-const char *getElementTypeName(Element *el) {
-    return XmlParser::elmNames[el->type];
-}
-
-const char **getAttributesAsArray(Element *el, int *n) {
-    *n = el->attributes.size();
-    const char **result = (const char **)calloc(2 * (*n), sizeof(char *));
-    if (!result) {
-        logThis(ERROR_FATAL, "Out of memory");
-        n = 0;
-        return NULL;
-    }
-    int i = 0;
-    for (std::map<XmlParser::Att, char *>::iterator it = el->attributes.begin(); it != el->attributes.end(); ++it ) {
-        result[i] = (const char*)XmlParser::attNames[it->first];
-        result[i + 1] = it->second;
-        i = i + 2;
-    }
-    return result;
-}
-
-const char *getAttributeValue(Element *el, Att att) {
-    return el->getAttributeValue((XmlParser::Att)att);
-}
-
-int getAttributeInt(Element *el, Att att, ValueStatus *vs) {
-    return el->getAttributeInt((XmlParser::Att)att, (XmlParser::ValueStatus *)vs);
-}
-
-unsigned int getAttributeUInt(Element *el, Att att, ValueStatus *vs) {
-    return el->getAttributeUInt((XmlParser::Att)att, (XmlParser::ValueStatus *)vs);
-}
-
-double getAttributeDouble(Element *el, Att att, ValueStatus *vs) {
-    return el->getAttributeDouble((XmlParser::Att)att, (XmlParser::ValueStatus *)vs);
-}
-
-int getAttributeBool(Element *el, Att att, ValueStatus *vs) {
-    if (el->getAttributeBool((XmlParser::Att)att, (XmlParser::ValueStatus *)vs)) return 1;
-    return 0;
-}

+ 0 - 203
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/XmlParserCApi.h

@@ -1,203 +0,0 @@
-/* ---------------------------------------------------------------------------*
- * XmlParserCApi.cpp
- * Expose functionality of XmlParser.cpp as a c API.
- * Call functions of this file to parse and get information from xml
- * model description file of a FMI 2.0 model.
- *
- * Author: Adrian Tirea
- * Copyright QTronic GmbH. All rights reserved.
- * ---------------------------------------------------------------------------*/
-
-#ifndef XML_PARSER_C_API_H
-#define XML_PARSER_C_API_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef fmi2TypesPlatform_h
-// same as in FMI 2.0 specification
-typedef unsigned int fmi2ValueReference;
-#endif
-
-// elements from ModelDescription
-typedef struct ModelDescription ModelDescription;
-typedef struct ModelStructure ModelStructure;
-typedef struct ScalarVariable ScalarVariable;
-typedef struct Component Component;
-typedef struct SimpleType SimpleType;
-typedef struct Unit Unit;
-typedef struct ListElement ListElement;
-typedef struct Element Element;
-
-// Elements names used in ModelDescription.xml
-typedef enum {
-    elm_BAD_DEFINED = -1,
-    elm_fmiModelDescription, elm_ModelExchange, elm_CoSimulation, elm_SourceFiles, elm_File,
-    elm_UnitDefinitions, elm_Unit, elm_BaseUnit, elm_DisplayUnit, elm_TypeDefinitions,
-    elm_SimpleType, elm_Real, elm_Integer, elm_Boolean, elm_String,
-    elm_Enumeration, elm_Item, elm_LogCategories, elm_Category, elm_DefaultExperiment,
-    elm_VendorAnnotations, elm_Tool, elm_ModelVariables, elm_ScalarVariable, elm_Annotations,
-    elm_ModelStructure, elm_Outputs, elm_Derivatives, elm_DiscreteStates, elm_InitialUnknowns,
-    elm_Unknown
-} Elm;
-
-// Attributes names used in ModelDescription.xml
-typedef enum {
-    att_BAD_DEFINED = -1,
-    att_fmiVersion, att_modelName, att_guid, att_description, att_author,
-    att_version, att_copyright, att_license, att_generationTool, att_generationDateAndTime,
-    att_variableNamingConvention, att_numberOfEventIndicators, att_name, att_kg, att_m,
-    att_s, att_A, att_K, att_mol, att_cd,
-    att_rad, att_factor, att_offset, att_quantity, att_unit,
-    att_displayUnit, att_relativeQuantity, att_min, att_max, att_nominal,
-    att_unbounded, att_value, att_startTime, att_stopTime, att_tolerance,
-    att_stepSize, att_valueReference, att_causality, att_variability, att_initial,
-    att_previous, att_canHandleMultipleSetPerTimeInstant, att_declaredType, att_start, att_derivative,
-    att_reinit, att_index, att_dependencies, att_dependenciesKind, att_modelIdentifier,
-    att_needsExecutionTool, att_completedIntegratorStepNotNeeded, att_canBeInstantiatedOnlyOncePerProcess, att_canNotUseMemoryManagementFunctions, att_canGetAndSetFMUstate,
-    att_canSerializeFMUstate, att_providesDirectionalDerivative, att_canHandleVariableCommunicationStepSize, att_canInterpolateInputs, att_maxOutputDerivativeOrder,
-    att_canRunAsynchronuously
-} Att;
-
-// Enumerated values names used in ModelDescription.xml
-typedef enum {
-    enu_BAD_DEFINED = -1,
-    enu_flat, enu_structured, enu_dependent, enu_constant, enu_fixed,
-    enu_tunable, enu_discrete, enu_parameter, enu_calculatedParameter, enu_input,
-    enu_output, enu_local, enu_independent, enu_continuous, enu_exact,
-    enu_approx, enu_calculated
-} Enu;
-
-typedef enum {
-    valueMissing,
-    valueDefined,
-    valueIllegal
-} ValueStatus;
-
-// Returns NULL to indicate failure
-// Otherwise, return the root node md of the AST. From the result of this
-// function user can access all other elements from ModelDescription.xml.
-// The receiver must call freeModelDescription(md) to release AST memory.
-ModelDescription* parse(char* xmlPath);
-void freeModelDescription(ModelDescription *md);
-
-
-/* ModelDescription functions */
-// get number of unit definitions
-int getUnitDefinitionsSize(ModelDescription *md);
-// get unit definition at index
-Unit *getUnitDefinition(ModelDescription *md, int index);
-// get number of type definitions
-int getTypeDefinitionsSize(ModelDescription *md);
-// get type definition at index
-SimpleType *getTypeDefinition(ModelDescription *md, int index);
-// Null or component for ModelExchange
-Component *getModelExchange(ModelDescription *md);
-// Null or component for CoSimulation
-Component *getCoSimulation(ModelDescription *md);
-// get number of log categories
-int getLogCategoriesSize(ModelDescription *md);
-// get log category at index
-Element *getLogCategory(ModelDescription *md, int index);
-// Null or DefaultExperiment
-Element *getDefaultExperiment(ModelDescription *md);
-// get number of vendor annotations
-int getVendorAnnotationsSize(ModelDescription *md);
-// get vendor annotation at index
-Element *getVendorAnnotation(ModelDescription *md, int index);
-// get number of scalar variables
-int getScalarVariableSize(ModelDescription *md);
-// get scalar variable at index
-ScalarVariable *getScalarVariable(ModelDescription *md, int index);
-// Null or ModelStructure
-ModelStructure  *getModelStructure (ModelDescription *md);
-
-// get the SimpleType definition by name, if any. NULL if not found.
-SimpleType *getSimpleType(ModelDescription *md, const char *name);
-// get the ScalarVariable by name, if any. NULL if not found.
-ScalarVariable *getVariable(ModelDescription *md, const char *name);
-// get description from variable, if not present look for type definition description.
-const char *getDescriptionForVariable(ModelDescription *md, ScalarVariable *sv);
-
-/* ModelStructure functions */
-// get number of outputs
-int getOutputsSize(ModelStructure *ms);
-// get output at index
-Element *getOutput(ModelStructure *ms, int index);
-// get number of derivatives
-int getDerivativesSize(ModelStructure *ms);
-// get derivative at index
-Element *getDerivative(ModelStructure *ms, int index);
-// get number of discrete states
-int getDiscreteStatesSize(ModelStructure *ms);
-// get discrete state at index
-Element *getDiscreteState(ModelStructure *ms, int index);
-// get number of initial unknowns
-int getInitialUnknownsSize(ModelStructure *ms);
-// get initial unknown at index
-Element *getInitialUnknown(ModelStructure *ms, int index);
-
-/* ScalarVariable functions */
-// one of Real, Integer, etc.
-Element *getTypeSpec(ScalarVariable *sv);
-// get number of annotations
-int getAnnotationsSize(ScalarVariable *sv);
-// get annotation at index
-Element *getAnnotation(ScalarVariable *sv, int index);
-
-// get the valueReference of current variable. This attribute is mandatory for a variable.
-fmi2ValueReference getValueReference(ScalarVariable *sv);
-// returns one of constant, fixed, tunable, discrete, continuous.
-// If value is missing, the default continuous is returned.
-// If unknown value, return enu_BAD_DEFINED.
-Enu getVariability(ScalarVariable *sv);
-// returns one of parameter, calculatedParameter, input, output, local, independent.
-// If value is missing, the default local is returned.
-// If unknown value, return enu_BAD_DEFINED.
-Enu getCausality(ScalarVariable *sv);
-
-/* Component functions */
-// get number of files
-int getFilesSize(Component *c);
-// get file at index
-Element *getFile(Component *c, int index);
-
-/* SimpleType functions */
-// one of RealType, IntegerType etc.
-Element *getTypeSpecDef(SimpleType *st);
-
-/* Unit functions */
-// Null or base unit.
-Element *getBaseUnit(Unit *u);
-// get number of display units
-int getDisplayUnitsSize(Unit *u);
-// get display unit at index
-Element *getDisplayUnit(Unit *u, int index);
-
-/* ListElement functions */
-// get list size
-int getListSize(ListElement *le);
-// get element at index
-Element *getElementFromList(ListElement *le, int index);
-
-/* Element functions. All upper types are also an Element,
- * therefore first parameter can be those types. */
-Elm getElementType(Element *el);
-// get name of the element type
-const char *getElementTypeName(Element *el);
-// get array with all attributes. Caller must free the array, but not the content.
-// The result array is formed by key1, value1, key2, value2, ...
-// n is output with size of array, even number.
-const char **getAttributesAsArray(Element *el, int *n);
-// value or NULL if attribute not present
-const char *getAttributeValue(Element *el, Att att);
-int getAttributeInt(Element *el, Att att, ValueStatus *vs);
-unsigned int getAttributeUInt(Element *el, Att att, ValueStatus *vs);
-double getAttributeDouble(Element *el, Att att, ValueStatus *vs);
-// 0 for false, otherwise 1
-int getAttributeBool(Element *el, Att att, ValueStatus *vs);
-
-#ifdef __cplusplus
-} // closing brace for extern "C"
-#endif
-#endif // XML_PARSER_C_API_H

+ 0 - 163
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlElement.h

@@ -1,163 +0,0 @@
-/*
- * Copyright QTronic GmbH. All rights reserved.
- */
-
-/* ---------------------------------------------------------------------------*
- * XmlElement.h
- * Contains elements classes that describe content of model description of a
- * FMI 2.0 model. All elements have Element as parent class. Elements have
- * attributes and other specific content.
- *
- * Author: Adrian Tirea
- * ---------------------------------------------------------------------------*/
-
-#ifndef FMU20_XML_ELEMENT_H
-#define FMU20_XML_ELEMENT_H
-
-#include <map>
-#include <vector>
-#include "fmu20/XmlParser.h"
-
-class Element {
- public:
-    XmlParser::Elm type;  // element type
-    std::map<XmlParser::Att, char*> attributes;  // map with key one of XmlParser::Att
-
- public:
-    virtual ~Element();
-    virtual void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    virtual void printElement(int indent);
-    const char *getAttributeValue(XmlParser::Att att);  // value or NULL if not present
-    int getAttributeInt(XmlParser::Att att, XmlParser::ValueStatus *vs);
-    unsigned int getAttributeUInt(XmlParser::Att att, XmlParser::ValueStatus *vs);
-    double getAttributeDouble(XmlParser::Att att, XmlParser::ValueStatus *vs);
-    bool getAttributeBool(XmlParser::Att att, XmlParser::ValueStatus *vs);
-
-    template <typename T> void printListOfElements(int indent, const std::vector<T *> &list);
-    template <typename T> void deleteListOfElements(const std::vector<T *> &list);
-};
-
-
-class ListElement : public Element {
- public:
-    std::vector<Element*> list;  // list of Element
-
- public:
-    ~ListElement();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-};
-
-
-class Unit : public Element {
- public:
-    std::vector<Element *> displayUnits;  // list of DisplayUnit
-    Element *baseUnit;                    // null or BaseUnit
-
- public:
-    Unit();
-    ~Unit();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-    Element *getDisplayUnit(const char *name);
-};
-
-
-class SimpleType : public Element {
- public:
-    Element *typeSpec;  // one of RealType, IntegerType etc.
-
- public:
-    SimpleType();
-    ~SimpleType();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-};
-
-
-class Component : public Element {
- public:
-    std::vector<Element *> files;  // list of File. Only meaningful for source code FMUs (not .dll).
-
- public:
-    ~Component();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-};
-
-
-class ScalarVariable : public Element {
- public :
-    Element *typeSpec;                   // one of Real, Integer, etc
-    std::vector<Element *> annotations;  // list of Annotations
-    // int modelIdx;                     // only used in fmu10
-
- public:
-    ScalarVariable();
-    ~ScalarVariable();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-    // get the valueReference of current variable. This attribute is mandatory for a variable.
-    fmi2ValueReference getValueReference();
-    // returns one of constant, fixed, tunable, discrete, continuous.
-    // If value is missing, the default continuous is returned.
-    // If unknown value, return enu_BAD_DEFINED.
-    XmlParser::Enu getVariability();
-    // returns one of parameter, calculatedParameter, input, output, local, independent.
-    // If value is missing, the default local is returned.
-    // If unknown value, return enu_BAD_DEFINED.
-    XmlParser::Enu getCausality();
-};
-
-
-class ModelStructure : public Element {
- private:
-    XmlParser::Elm unknownParentType;  // used in handleElement to know in which list next Unknown belongs.
-
- public:
-    std::vector<Element *> outputs;            // list of Unknown
-    std::vector<Element *> derivatives;        // list of Unknown
-    std::vector<Element *> discreteStates;     // list of Unknown
-    std::vector<Element *> initialUnknowns;    // list of Unknown
-
- public:
-    ModelStructure();
-    ~ModelStructure();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-};
-
-class ModelDescription : public Element {
- public:
-    std::vector<Unit *> unitDefinitions;        // list of Units
-    std::vector<SimpleType *> typeDefinitions;  // list of Types
-    Component *modelExchange;                   // NULL or ModelExchange
-    Component *coSimulation;                    // NULL or CoSimulation
-                                                // At least one of CoSimulation, ModelExchange must be present.
-    std::vector<Element *> logCategories;       // list of Category
-    Element *defaultExperiment;                 // NULL or DefaultExperiment
-    std::vector<Element *> vendorAnnotations;   // list of Tools
-    std::vector<ScalarVariable *> modelVariables;  // list of ScalarVariable
-    ModelStructure *modelStructure;             // not NULL ModelStructure
-
- public:
-    ModelDescription();
-    ~ModelDescription();
-    void handleElement(XmlParser *parser, const char *childName, int isEmptyElement);
-    void printElement(int indent);
-    // get the SimpleType definition by name, if any. NULL if not found.
-    SimpleType *getSimpleType(const char *name);
-    // get the ScalarVariable by name, if any. NULL if not found.
-    ScalarVariable *getVariable(const char *name);
-    // get the ScalarVariable by vr and type. NULL if not found.
-    ScalarVariable *getVariable(fmi2ValueReference vr, XmlParser::Elm type);
-    // get description from variable, if not present look for type definition description.
-    const char *getDescriptionForVariable(ScalarVariable *sv);
-    // get attribute from type, if not present look for it inside declared type.
-    // Attributes example: 'min', 'max', 'quantity'.
-    const char *getAttributeFromTypeOrDeclaredType(ScalarVariable *sv, XmlParser::Att a);
-    // get the Unit as defined in UnitDefinitions. NULL if not found.
-    Unit *getUnit(const char *name);
-};
-
-#endif // FMU20_XML_ELEMENT_H

+ 0 - 129
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlParser.h

@@ -1,129 +0,0 @@
-/*
- * Copyright QTronic GmbH. All rights reserved.
- */
-
-/* ---------------------------------------------------------------------------*
- * XmlParser.h
- * Parser for xml model description file of a FMI 2.0 model.
- * The result of parsing is a ModelDescription object that can be queried to
- * get necessary information. The parsing is based on libxml2.lib.
- *
- * Author: Adrian Tirea
- * ---------------------------------------------------------------------------*/
-
-#ifndef FMU20_XML_PARSER_H
-#define FMU20_XML_PARSER_H
-
-#include <libxml/xmlreader.h>
-
-#ifdef _MSC_VER
-#pragma comment(lib, "libxml2.lib")
-#pragma comment(lib, "wsock32.lib")
-#endif
-
-#ifndef fmi2TypesPlatform_h
-// same as in FMI 2.0 specification
-typedef unsigned int fmi2ValueReference;
-#endif
-
-class Element;
-class ModelDescription;
-
-class XmlParser {
- public:
-    // Elements
-    static const int SIZEOF_ELM = 31;
-    static const char *elmNames[SIZEOF_ELM];
-    enum Elm {
-        elm_BAD_DEFINED = -1,
-        elm_fmiModelDescription, elm_ModelExchange, elm_CoSimulation, elm_SourceFiles, elm_File,
-        elm_UnitDefinitions, elm_Unit, elm_BaseUnit, elm_DisplayUnit, elm_TypeDefinitions,
-        elm_SimpleType, elm_Real, elm_Integer, elm_Boolean, elm_String,
-        elm_Enumeration, elm_Item, elm_LogCategories, elm_Category, elm_DefaultExperiment,
-        elm_VendorAnnotations, elm_Tool, elm_ModelVariables, elm_ScalarVariable, elm_Annotations,
-        elm_ModelStructure, elm_Outputs, elm_Derivatives, elm_DiscreteStates, elm_InitialUnknowns,
-        elm_Unknown
-    };
-
-    // Attributes
-    static const int SIZEOF_ATT = 64;  // 61;
-    static const char *attNames[SIZEOF_ATT];
-    enum Att {
-        att_BAD_DEFINED = -1,
-        att_fmiVersion, att_modelName, att_guid, att_description, att_author,
-        att_version, att_copyright, att_license, att_generationTool, att_generationDateAndTime,
-        att_variableNamingConvention, att_numberOfEventIndicators, att_name, att_kg, att_m,
-        att_s, att_A, att_K, att_mol, att_cd,
-        att_rad, att_factor, att_offset, att_quantity, att_unit,
-        att_displayUnit, att_relativeQuantity, att_min, att_max, att_nominal,
-        att_unbounded, att_value, att_startTime, att_stopTime, att_tolerance,
-        att_stepSize, att_valueReference, att_causality, att_variability, att_initial,
-        att_previous, att_canHandleMultipleSetPerTimeInstant, att_declaredType, att_start, att_derivative,
-        att_reinit, att_index, att_dependencies, att_dependenciesKind, att_modelIdentifier,
-        att_needsExecutionTool, att_completedIntegratorStepNotNeeded, att_canBeInstantiatedOnlyOncePerProcess,
-            att_canNotUseMemoryManagementFunctions, att_canGetAndSetFMUstate,
-        att_canSerializeFMUstate, att_providesDirectionalDerivative, att_canHandleVariableCommunicationStepSize,
-            att_canInterpolateInputs, att_maxOutputDerivativeOrder,
-        att_canRunAsynchronuously,
-
-        att_xmlnsXsi, att_providesDirectionalDerivatives, att_canHandleEvents
-    };
-
-    // Enumeration values
-    static const int SIZEOF_ENU = 17;
-    static const char *enuNames[SIZEOF_ENU];
-    enum Enu {
-        enu_BAD_DEFINED = -1,
-        enu_flat, enu_structured, enu_dependent, enu_constant, enu_fixed,
-        enu_tunable, enu_discrete, enu_parameter, enu_calculatedParameter, enu_input,
-        enu_output, enu_local, enu_independent, enu_continuous, enu_exact,
-        enu_approx, enu_calculated
-    };
-
-    // Possible results when retrieving an attribute value from an element
-    enum ValueStatus {
-        valueMissing,
-        valueDefined,
-        valueIllegal
-    };
-
- private:
-    char *xmlPath;
-    xmlTextReaderPtr xmlReader;
-
- public:
-    // return the type of this element. Int value match the index in elmNames.
-    // throw XmlParserException if element is invalid.
-    static XmlParser::Elm checkElement(const char* elm);
-    // return the type of this attribute. Int value match the index in attNames.
-    // throw XmlParserException if attribute is invalid.
-    static XmlParser::Att checkAttribute(const char* att);
-    // return the type of this enum value. Int value match the index in enuNames.
-    // throw XmlParserException if enu is invalid.
-    static XmlParser::Enu checkEnumValue(const char* enu);
-
-    // Obs. the destructor calls xmlCleanupParser(). This is a single call for all parsers instantiated.
-    // Be carefully how you link XmlParser (i.e. multithreading, more parsers started at once).
-    explicit XmlParser(char *xmlPath);
-    ~XmlParser();
-    // return NULL on errors. Caller must free the result if not NULL.
-    ModelDescription *parse();
-
-    // throw XmlParserException if attribute invalid.
-    void parseElementAttributes(Element *element);
-    void parseElementAttributes(Element *element, bool ignoreUnknownAttributes);
-    void parseChildElements(Element *el);
-    // Consume the end of an element that has no child, but is not empty. i.e. <a name="name"></a>
-    void parseEndElement();
-    void parseSkipChildElement();
-
- private:
-    // advance reading in xml and skip comments if present.
-    bool readNextInXml();
-
-    // check some properties of model description (i.e. each variable has valueReference, ...)
-    // if valid return the input model description, else return NULL.
-    ModelDescription *validate(ModelDescription *md);
-};
-
-#endif // FMU20_XML_PARSER_H

+ 0 - 58
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/fmu20/XmlParserException.h

@@ -1,58 +0,0 @@
-/*
- * Copyright QTronic GmbH. All rights reserved.
- */
-
-/* ---------------------------------------------------------------------------*
- * XmlParserException.h
- * Exception used in parsing model description of a FMI 2.0 model.
- *
- * Author: Adrian Tirea
- * ---------------------------------------------------------------------------*/
-
-#ifndef FMU20_XML_PARSER_EXCEPTION_H
-#define FMU20_XML_PARSER_EXCEPTION_H
-
-#include <exception>
-#include <stdarg.h>
-
-static char* strallocprintf(const char *format, va_list argp);
-
-// message passed in constructor is freed in destructor.
-class XmlParserException : public std::exception {
- public:
-    char *message;
-
- public:
-    XmlParserException(const char *format, ...) {
-    va_list argp;
-    va_start(argp, format);
-    message = strallocprintf(format, argp);
-    va_end(argp);
-    }
-    ~XmlParserException() throw() {
-        if (message) delete[]message;
-    }
-
-    virtual const char *what() const throw() {
-        return message;
-    }
-};
-
-static char *strallocprintf(const char *format, va_list argp) {
-    int n;
-    char *result;
-#ifdef _MSC_VER
-    n = _vscprintf(format, argp);
-#else
-    va_list argcopy;
-    va_copy(argcopy, argp);
-    n = vsnprintf(NULL, 0, format, argcopy);
-    va_end(argcopy);
-#endif
-
-    result = new char[n + 1];
-    vsprintf(result, format, argp);
-    return result;
-}
-
-#endif // FMU20_XML_PARSER_EXCEPTION_H

+ 0 - 173
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/SAX.h

@@ -1,173 +0,0 @@
-/*
- * Summary: Old SAX version 1 handler, deprecated
- * Description: DEPRECATED set of SAX version 1 interfaces used to
- *              build the DOM tree.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-
-#ifndef __XML_SAX_H__
-#define __XML_SAX_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-#include <libxml/xlink.h>
-
-#ifdef LIBXML_LEGACY_ENABLED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-XMLPUBFUN const xmlChar * XMLCALL
-		getPublicId			(void *ctx);
-XMLPUBFUN const xmlChar * XMLCALL
-		getSystemId			(void *ctx);
-XMLPUBFUN void XMLCALL
-		setDocumentLocator		(void *ctx,
-						 xmlSAXLocatorPtr loc);
-
-XMLPUBFUN int XMLCALL
-		getLineNumber			(void *ctx);
-XMLPUBFUN int XMLCALL
-		getColumnNumber			(void *ctx);
-
-XMLPUBFUN int XMLCALL
-		isStandalone			(void *ctx);
-XMLPUBFUN int XMLCALL
-		hasInternalSubset		(void *ctx);
-XMLPUBFUN int XMLCALL
-		hasExternalSubset		(void *ctx);
-
-XMLPUBFUN void XMLCALL
-		internalSubset			(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *ExternalID,
-						 const xmlChar *SystemID);
-XMLPUBFUN void XMLCALL
-		externalSubset			(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *ExternalID,
-						 const xmlChar *SystemID);
-XMLPUBFUN xmlEntityPtr XMLCALL
-		getEntity			(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
-		getParameterEntity		(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN xmlParserInputPtr XMLCALL
-		resolveEntity			(void *ctx,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId);
-
-XMLPUBFUN void XMLCALL
-		entityDecl			(void *ctx,
-						 const xmlChar *name,
-						 int type,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId,
-						 xmlChar *content);
-XMLPUBFUN void XMLCALL
-		attributeDecl			(void *ctx,
-						 const xmlChar *elem,
-						 const xmlChar *fullname,
-						 int type,
-						 int def,
-						 const xmlChar *defaultValue,
-						 xmlEnumerationPtr tree);
-XMLPUBFUN void XMLCALL
-		elementDecl			(void *ctx,
-						 const xmlChar *name,
-						 int type,
-						 xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
-		notationDecl			(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
-		unparsedEntityDecl		(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId,
-						 const xmlChar *notationName);
-
-XMLPUBFUN void XMLCALL
-		startDocument			(void *ctx);
-XMLPUBFUN void XMLCALL
-		endDocument			(void *ctx);
-XMLPUBFUN void XMLCALL
-		attribute			(void *ctx,
-						 const xmlChar *fullname,
-						 const xmlChar *value);
-XMLPUBFUN void XMLCALL
-		startElement			(void *ctx,
-						 const xmlChar *fullname,
-						 const xmlChar **atts);
-XMLPUBFUN void XMLCALL
-		endElement			(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN void XMLCALL
-		reference			(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN void XMLCALL
-		characters			(void *ctx,
-						 const xmlChar *ch,
-						 int len);
-XMLPUBFUN void XMLCALL
-		ignorableWhitespace		(void *ctx,
-						 const xmlChar *ch,
-						 int len);
-XMLPUBFUN void XMLCALL
-		processingInstruction		(void *ctx,
-						 const xmlChar *target,
-						 const xmlChar *data);
-XMLPUBFUN void XMLCALL
-		globalNamespace			(void *ctx,
-						 const xmlChar *href,
-						 const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
-		setNamespace			(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN xmlNsPtr XMLCALL
-		getNamespace			(void *ctx);
-XMLPUBFUN int XMLCALL
-		checkNamespace			(void *ctx,
-						 xmlChar *nameSpace);
-XMLPUBFUN void XMLCALL
-		namespaceDecl			(void *ctx,
-						 const xmlChar *href,
-						 const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
-		comment				(void *ctx,
-						 const xmlChar *value);
-XMLPUBFUN void XMLCALL
-		cdataBlock			(void *ctx,
-						 const xmlChar *value,
-						 int len);
-
-#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN void XMLCALL
-		initxmlDefaultSAXHandler	(xmlSAXHandlerV1 *hdlr,
-						 int warning);
-#ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN void XMLCALL
-		inithtmlDefaultSAXHandler	(xmlSAXHandlerV1 *hdlr);
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN void XMLCALL
-		initdocbDefaultSAXHandler	(xmlSAXHandlerV1 *hdlr);
-#endif
-#endif /* LIBXML_SAX1_ENABLED */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBXML_LEGACY_ENABLED */
-
-#endif /* __XML_SAX_H__ */

+ 0 - 176
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/SAX2.h

@@ -1,176 +0,0 @@
-/*
- * Summary: SAX2 parser interface used to build the DOM tree
- * Description: those are the default SAX2 interfaces used by
- *              the library when building DOM tree.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-
-#ifndef __XML_SAX2_H__
-#define __XML_SAX2_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <libxml/xmlversion.h>
-#include <libxml/parser.h>
-#include <libxml/xlink.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-XMLPUBFUN const xmlChar * XMLCALL
-		xmlSAX2GetPublicId		(void *ctx);
-XMLPUBFUN const xmlChar * XMLCALL
-		xmlSAX2GetSystemId		(void *ctx);
-XMLPUBFUN void XMLCALL
-		xmlSAX2SetDocumentLocator	(void *ctx,
-						 xmlSAXLocatorPtr loc);
-
-XMLPUBFUN int XMLCALL
-		xmlSAX2GetLineNumber		(void *ctx);
-XMLPUBFUN int XMLCALL
-		xmlSAX2GetColumnNumber		(void *ctx);
-
-XMLPUBFUN int XMLCALL
-		xmlSAX2IsStandalone		(void *ctx);
-XMLPUBFUN int XMLCALL
-		xmlSAX2HasInternalSubset	(void *ctx);
-XMLPUBFUN int XMLCALL
-		xmlSAX2HasExternalSubset	(void *ctx);
-
-XMLPUBFUN void XMLCALL
-		xmlSAX2InternalSubset		(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *ExternalID,
-						 const xmlChar *SystemID);
-XMLPUBFUN void XMLCALL
-		xmlSAX2ExternalSubset		(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *ExternalID,
-						 const xmlChar *SystemID);
-XMLPUBFUN xmlEntityPtr XMLCALL
-		xmlSAX2GetEntity		(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
-		xmlSAX2GetParameterEntity	(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN xmlParserInputPtr XMLCALL
-		xmlSAX2ResolveEntity		(void *ctx,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId);
-
-XMLPUBFUN void XMLCALL
-		xmlSAX2EntityDecl		(void *ctx,
-						 const xmlChar *name,
-						 int type,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId,
-						 xmlChar *content);
-XMLPUBFUN void XMLCALL
-		xmlSAX2AttributeDecl		(void *ctx,
-						 const xmlChar *elem,
-						 const xmlChar *fullname,
-						 int type,
-						 int def,
-						 const xmlChar *defaultValue,
-						 xmlEnumerationPtr tree);
-XMLPUBFUN void XMLCALL
-		xmlSAX2ElementDecl		(void *ctx,
-						 const xmlChar *name,
-						 int type,
-						 xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
-		xmlSAX2NotationDecl		(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
-		xmlSAX2UnparsedEntityDecl	(void *ctx,
-						 const xmlChar *name,
-						 const xmlChar *publicId,
-						 const xmlChar *systemId,
-						 const xmlChar *notationName);
-
-XMLPUBFUN void XMLCALL
-		xmlSAX2StartDocument		(void *ctx);
-XMLPUBFUN void XMLCALL
-		xmlSAX2EndDocument		(void *ctx);
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
-XMLPUBFUN void XMLCALL
-		xmlSAX2StartElement		(void *ctx,
-						 const xmlChar *fullname,
-						 const xmlChar **atts);
-XMLPUBFUN void XMLCALL
-		xmlSAX2EndElement		(void *ctx,
-						 const xmlChar *name);
-#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED */
-XMLPUBFUN void XMLCALL
-		xmlSAX2StartElementNs		(void *ctx,
-						 const xmlChar *localname,
-						 const xmlChar *prefix,
-						 const xmlChar *URI,
-						 int nb_namespaces,
-						 const xmlChar **namespaces,
-						 int nb_attributes,
-						 int nb_defaulted,
-						 const xmlChar **attributes);
-XMLPUBFUN void XMLCALL
-		xmlSAX2EndElementNs		(void *ctx,
-						 const xmlChar *localname,
-						 const xmlChar *prefix,
-						 const xmlChar *URI);
-XMLPUBFUN void XMLCALL
-		xmlSAX2Reference		(void *ctx,
-						 const xmlChar *name);
-XMLPUBFUN void XMLCALL
-		xmlSAX2Characters		(void *ctx,
-						 const xmlChar *ch,
-						 int len);
-XMLPUBFUN void XMLCALL
-		xmlSAX2IgnorableWhitespace	(void *ctx,
-						 const xmlChar *ch,
-						 int len);
-XMLPUBFUN void XMLCALL
-		xmlSAX2ProcessingInstruction	(void *ctx,
-						 const xmlChar *target,
-						 const xmlChar *data);
-XMLPUBFUN void XMLCALL
-		xmlSAX2Comment			(void *ctx,
-						 const xmlChar *value);
-XMLPUBFUN void XMLCALL
-		xmlSAX2CDataBlock		(void *ctx,
-						 const xmlChar *value,
-						 int len);
-
-#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
-		xmlSAXDefaultVersion		(int version);
-#endif /* LIBXML_SAX1_ENABLED */
-
-XMLPUBFUN int XMLCALL
-		xmlSAXVersion			(xmlSAXHandler *hdlr,
-						 int version);
-XMLPUBFUN void XMLCALL
-		xmlSAX2InitDefaultSAXHandler    (xmlSAXHandler *hdlr,
-						 int warning);
-#ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN void XMLCALL
-		xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
-XMLPUBFUN void XMLCALL
-		htmlDefaultSAXHandlerInit	(void);
-#endif
-#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN void XMLCALL
-		xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
-XMLPUBFUN void XMLCALL
-		docbDefaultSAXHandlerInit	(void);
-#endif
-XMLPUBFUN void XMLCALL
-		xmlDefaultSAXHandlerInit	(void);
-#ifdef __cplusplus
-}
-#endif
-#endif /* __XML_SAX2_H__ */

+ 0 - 80
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/dict.h

@@ -1,80 +0,0 @@
-/*
- * Summary: string dictionnary
- * Description: dictionary of reusable strings, just used to avoid allocation
- *         and freeing operations.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Daniel Veillard
- */
-
-#ifndef __XML_DICT_H__
-#define __XML_DICT_H__
-
-#include <limits.h>
-#include <libxml/xmlversion.h>
-#include <libxml/tree.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * The dictionnary.
- */
-typedef struct _xmlDict xmlDict;
-typedef xmlDict *xmlDictPtr;
-
-/*
- * Initializer
- */
-XMLPUBFUN int XMLCALL  xmlInitializeDict(void);
-
-/*
- * Constructor and destructor.
- */
-XMLPUBFUN xmlDictPtr XMLCALL
-			xmlDictCreate	(void);
-XMLPUBFUN size_t XMLCALL
-			xmlDictSetLimit	(xmlDictPtr dict,
-                                         size_t limit);
-XMLPUBFUN size_t XMLCALL
-			xmlDictGetUsage (xmlDictPtr dict);
-XMLPUBFUN xmlDictPtr XMLCALL
-			xmlDictCreateSub(xmlDictPtr sub);
-XMLPUBFUN int XMLCALL
-			xmlDictReference(xmlDictPtr dict);
-XMLPUBFUN void XMLCALL
-			xmlDictFree	(xmlDictPtr dict);
-
-/*
- * Lookup of entry in the dictionnary.
- */
-XMLPUBFUN const xmlChar * XMLCALL
-			xmlDictLookup	(xmlDictPtr dict,
-		                         const xmlChar *name,
-		                         int len);
-XMLPUBFUN const xmlChar * XMLCALL
-			xmlDictExists	(xmlDictPtr dict,
-		                         const xmlChar *name,
-		                         int len);
-XMLPUBFUN const xmlChar * XMLCALL
-			xmlDictQLookup	(xmlDictPtr dict,
-		                         const xmlChar *prefix,
-		                         const xmlChar *name);
-XMLPUBFUN int XMLCALL
-			xmlDictOwns	(xmlDictPtr dict,
-					 const xmlChar *str);
-XMLPUBFUN int XMLCALL
-			xmlDictSize	(xmlDictPtr dict);
-
-/*
- * Cleanup function
- */
-XMLPUBFUN void XMLCALL
-                        xmlDictCleanup  (void);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* ! __XML_DICT_H__ */

+ 0 - 0
examples/mass_spring_damper/fmusdk/fmu20/src/shared/parser/libxml/encoding.h


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.