Skip to content

Commit

Permalink
Add initial dummy example code to illustrate draft spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmai committed Feb 6, 2017
1 parent 2d0a25d commit d6b0789
Show file tree
Hide file tree
Showing 13 changed files with 1,631 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
@@ -0,0 +1,4 @@
[submodule "examples/open-simulation-interface"]
path = examples/open-simulation-interface
url = https://github.com/OpenSimulationInterface/open-simulation-interface.git
branch = feature/initial-build-system
7 changes: 7 additions & 0 deletions LICENSE
@@ -1,3 +1,10 @@
The source code and documentation in this repository is distributed
under the terms of the Mozilla Public License, v. 2.0, attached below,
unless stated otherwise.

The files fmi2Functions.h, fmi2FunctionTypes.h and fmi2TypesPlatform.h
are distributed under the terms indicated in their header comments.

Mozilla Public License Version 2.0
==================================

Expand Down
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -187,7 +187,8 @@ The following basic conventions apply:

## Examples

An example dummy sensor model implementation is provided as a seperate
An example dummy sensor model implementation is provided in the
OSMPDummySensor sub-directory of the examples directory of this
repository. Below you can find an example modelDescription.xml
file that would satisfy the requirements of this document for a sensor
model FMU with one input and output and no additional features:
Expand Down Expand Up @@ -216,13 +217,13 @@ model FMU with one input and output and no additional features:
<ScalarVariable name="OSMPSensorDataIn.size" valueReference="2" causality="input" variability="discrete">
<Integer start="0"/>
</ScalarVariable>
<ScalarVariable name="OSMPSensorDataOut.base.lo" valueReference="3" causality="output" variability="discrete">
<ScalarVariable name="OSMPSensorDataOut.base.lo" valueReference="3" causality="output" variability="discrete" initial="exact">
<Integer start="0"/>
</ScalarVariable>
<ScalarVariable name="OSMPSensorDataOut.base.hi" valueReference="4" causality="output" variability="discrete">
<ScalarVariable name="OSMPSensorDataOut.base.hi" valueReference="4" causality="output" variability="discrete" initial="exact">
<Integer start="0"/>
</ScalarVariable>
<ScalarVariable name="OSMPSensorDataOut.size" valueReference="5" causality="output" variability="discrete">
<ScalarVariable name="OSMPSensorDataOut.size" valueReference="5" causality="output" variability="discrete" initial="exact">
<Integer start="0"/>
</ScalarVariable>
</ModelVariables>
Expand Down
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.7)
add_subdirectory( open-simulation-interface )
include_directories( includes )
add_subdirectory( OSMPDummySensor )
35 changes: 35 additions & 0 deletions examples/OSMPDummySensor/CMakeLists.txt
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.7)
project(OSMPDummySensor)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Protobuf 2.6.1 REQUIRED)
add_library(OSMPDummySensor SHARED OSMPDummySensor.cpp)
set_target_properties(OSMPDummySensor PROPERTIES PREFIX "")
include_directories(${OSI_PROTOBUF_INCLUDE_PATH})
target_link_libraries(OSMPDummySensor open_simulation_interface_pic)
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(FMI_BINARIES_PLATFORM "win64")
else()
set(FMI_BINARIES_PLATFORM "win32")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(FMI_BINARIES_PLATFORM "linux64")
else()
set(FMI_BINARIES_PLATFORM "linux32")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(FMI_BINARIES_PLATFORM "darwin64")
else()
set(FMI_BINARIES_PLATFORM "darwin32")
endif()
endif()
add_custom_command(TARGET OSMPDummySensor
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/buildfmu"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/modelDescription.xml" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu"
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:OSMPDummySensor> "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}"
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/buildfmu" ${CMAKE_COMMAND} -E tar "cfv" "../OSMPDummySensor.fmu" --format=zip "modelDescription.xml" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}")

0 comments on commit d6b0789

Please sign in to comment.