Skip to content

Commit

Permalink
Merge branch 'release/v0.2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Apr 15, 2020
2 parents bc6f924 + 07b3884 commit eb46215
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 16 deletions.
8 changes: 3 additions & 5 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FMPy
====

Copyright (c) 2017-2018 Dassault Systemes. All rights reserved.
FMPy is released under the 2-Clause BSD license:

Copyright (c) 2017-2020 Dassault Systemes. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand All @@ -14,10 +16,6 @@ modification, are permitted provided that the following conditions are met:
in the documentation and/or other materials provided with the
distribution.

* Neither the name Dassault Systemes 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ Please send an e-mail to [email protected] for a quote.

------------------------------------

© 2018 Dassault Systèmes
© 2020 Dassault Systèmes
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v0.2.19 (2020-04-15)

- `FIXED` fmi2SetupExperiment() is now called again in FMI 2.0 for Co-Simulation
- `FIXED` The working directory for the remoting server is now set to binaries/win32
- `FIXED` ssp.simulation.set_value() has been fixed for Integer and Enumeration variables
- `NEW` A license file is now added to documentation/licenses when adding the remoting binaries to an FMU
- `NEW` A stop_time parameter has been added to ssp.instantiate_fmu()
- `CHANGED` The license has been changed to 2-clause BSD

## v0.2.18 (2020-04-06)

- `FIXED` A list is now passed to np.stack() instead of an iterable and Iterable is now imported from collections.abc to avoid FutureWarnings.
Expand Down
2 changes: 1 addition & 1 deletion fmpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ctypes import *
import _ctypes

__version__ = '0.2.18'
__version__ = '0.2.19'


# determine the platform
Expand Down
2 changes: 1 addition & 1 deletion fmpy/gui/forms/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<item row="9" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string2018 Dassault Systèmes. All rights reserved.</string>
<string2020 Dassault Systèmes. All rights reserved.</string>
</property>
</widget>
</item>
Expand Down
31 changes: 31 additions & 0 deletions fmpy/remoting/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FMPy Remoting Binaries License
==============================

The 32-bit remoting binaries (binaries/win64/<model_name>.dll and
binaries/win64/server.exe) are part of FMPy (https://github.com/CATIA-Systems/FMPy)
and released under the 2-Clause BSD license:

Copyright (c) 2017-2020 Dassault Systemes. All rights reserved.

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 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
OWNER 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.
Binary file modified fmpy/remoting/server.exe
Binary file not shown.
11 changes: 8 additions & 3 deletions fmpy/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def simulate_fmu(filename,
if fmi_type == 'ModelExchange':
result = simulateME(model_description, fmu, start_time, stop_time, solver, step_size, relative_tolerance, start_values, apply_default_start_values, input, output, output_interval, record_events, timeout, step_finished)
elif fmi_type == 'CoSimulation':
result = simulateCS(model_description, fmu, start_time, stop_time, start_values, apply_default_start_values, input, output, output_interval, timeout, step_finished)
result = simulateCS(model_description, fmu, start_time, stop_time, relative_tolerance, start_values, apply_default_start_values, input, output, output_interval, timeout, step_finished)

if fmu_instance is None:
fmu.freeInstance()
Expand Down Expand Up @@ -898,21 +898,26 @@ def simulateME(model_description, fmu, start_time, stop_time, solver_name, step_
return recorder.result()


def simulateCS(model_description, fmu, start_time, stop_time, start_values, apply_default_start_values, input_signals, output, output_interval, timeout, step_finished):
def simulateCS(model_description, fmu, start_time, stop_time, relative_tolerance, start_values, apply_default_start_values, input_signals, output, output_interval, timeout, step_finished):

if output_interval is None:
output_interval = auto_interval(stop_time - start_time)

sim_start = current_time()

is_fmi1 = model_description.fmiVersion == '1.0'

if not is_fmi1:
fmu.setupExperiment(tolerance=relative_tolerance, startTime=start_time)

input = Input(fmu=fmu, modelDescription=model_description, signals=input_signals)

time = start_time

apply_start_values(fmu, model_description, start_values, apply_default_start_values)

# initialize the model
if model_description.fmiVersion == '1.0':
if is_fmi1:
input.apply(time)
fmu.initialize(tStart=time, stopTime=stop_time)
else:
Expand Down
8 changes: 4 additions & 4 deletions fmpy/ssp/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def set_value(component, name, value):
if variable.type == 'Real':
component.fmu.setReal(vr, [float(value)])
elif variable.type in ['Integer', 'Enumeration']:
component.fmu.setInteger(vr, [int(value)])[0]
component.fmu.setInteger(vr, [int(value)])
elif variable.type == 'Boolean':
# TODO: convert literals
component.fmu.setBoolean(vr, [value != 0.0])
Expand Down Expand Up @@ -69,7 +69,7 @@ def set_parameters(component, parameter_set):
set_value(component, variable_name, parameter.value)


def instantiate_fmu(component, ssp_unzipdir, start_time, parameter_set=None):
def instantiate_fmu(component, ssp_unzipdir, start_time, stop_time=None, parameter_set=None):
""" Instantiate an FMU """

fmu_filename = os.path.join(ssp_unzipdir, component.source)
Expand Down Expand Up @@ -98,7 +98,7 @@ def instantiate_fmu(component, ssp_unzipdir, start_time, parameter_set=None):
component.fmu.instantiate()
if parameter_set is not None:
set_parameters(component, parameter_set)
component.fmu.initialize()
component.fmu.initialize(stopTime=stop_time)
else:
component.fmu = FMU2Slave(**fmu_kwargs)
component.fmu.instantiate()
Expand Down Expand Up @@ -181,7 +181,7 @@ def simulate_ssp(ssp_filename, start_time=0.0, stop_time=None, step_size=None, p

# instantiate the FMUs
for component in components:
instantiate_fmu(component, ssp_unzipdir, start_time, parameter_set)
instantiate_fmu(component, ssp_unzipdir, start_time, stop_time, parameter_set)

time = start_time

Expand Down
4 changes: 4 additions & 0 deletions fmpy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ def add_remoting(filename):
current_dir = os.path.dirname(__file__)
client = os.path.join(current_dir, 'remoting', 'client.dll')
server = os.path.join(current_dir, 'remoting', 'server.exe')
license = os.path.join(current_dir, 'remoting', 'license.txt')

tempdir = extract(filename)

Expand All @@ -787,9 +788,12 @@ def add_remoting(filename):
else:
model_identifier = model_description.modelExchange.modelIdentifier

# copy the binaries & license
os.mkdir(os.path.join(tempdir, 'binaries', 'win64'))
copyfile(client, os.path.join(tempdir, 'binaries', 'win64', model_identifier + '.dll'))
copyfile(server, os.path.join(tempdir, 'binaries', 'win64', 'server.exe'))
os.mkdir(os.path.join(tempdir, 'documentation', 'licenses'))
copyfile(license, os.path.join(tempdir, 'documentation', 'licenses', 'fmpy-remoting-binaries.txt'))

# create a new archive from the existing files + remoting binaries
with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as zf:
Expand Down
1 change: 1 addition & 0 deletions remoting/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_include_directories(server PUBLIC
)

target_link_libraries(server
shlwapi.lib
"${RPCLIB}/lib/rpc.lib"
)

Expand Down
7 changes: 7 additions & 0 deletions remoting/server/server.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "rpc/server.h"
#include <Windows.h>
#include "Shlwapi.h"
#include <time.h>
#include <list>
#include <iostream>
Expand Down Expand Up @@ -114,6 +115,12 @@ class FMU {

FMU(const string &libraryPath) : srv(rpc::constants::DEFAULT_PORT) {

/* set the current directory to binaries/win32 */
char libraryDir[MAX_PATH];
strcpy(libraryDir, libraryPath.c_str());
PathRemoveFileSpec(libraryDir);
SetCurrentDirectory(libraryDir);

libraryHandle = LoadLibraryA(libraryPath.c_str());

m_callbacks.logger = logger;
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'logging/win32/logging.dll',
'logging/win64/logging.dll',
'remoting/client.dll',
'remoting/license.txt',
'remoting/server.exe',
'schema/fmi1/*.xsd',
'schema/fmi2/*.xsd',
Expand All @@ -61,7 +62,7 @@
extras_require['complete'] = sorted(set(sum(extras_require.values(), [])))

setup(name='FMPy',
version='0.2.18',
version='0.2.19',
description="Simulate Functional Mock-up Units (FMUs) in Python",
long_description=long_description,
author="Torsten Sommer",
Expand Down

0 comments on commit eb46215

Please sign in to comment.