Skip to content

Commit

Permalink
Merge branch 'release/v0.2.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Aug 1, 2020
2 parents e38ac31 + 7130a6c commit a79cf68
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 154 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.2.22 (2020-08-01)

- `FIXED' Forward fmi2NewDiscreteStates() in remoting client (#154)
- `FIXED` Fix createDesktopShortcut() and addFileAssociation() (#153)
- `NEW` Update FMI 3 API to 3.0-alpha.5

## v0.2.21 (2020-06-29)

- `FIXED` Set inputs in CVode root function before getting event indicators (#150)
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.21'
__version__ = '0.2.22'


# determine the platform
Expand Down
34 changes: 10 additions & 24 deletions fmpy/c-code/fmi3FunctionTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "fmi3PlatformTypes.h"

/*
This header file must be utilized when compiling an FMU or an FMI master.
It declares data and function types for FMI 3.0-alpha.3.
This header file defines the data and function types of FMI 3.0-alpha.5.
It must be used when compiling an FMU or an FMI master.
Copyright (C) 2011 MODELISAR consortium,
2012-2020 Modelica Association Project "FMI"
Expand Down Expand Up @@ -84,7 +84,7 @@ typedef void (*fmi3CallbackIntermediateUpdate) (
fmi3Float64 intermediateUpdateTime,
fmi3Boolean eventOccurred,
fmi3Boolean clocksTicked,
fmi3Boolean intermediateVariableSetAllowed,
fmi3Boolean intermediateVariableSetRequested,
fmi3Boolean intermediateVariableGetAllowed,
fmi3Boolean intermediateStepFinished,
fmi3Boolean canReturnEarly,
Expand Down Expand Up @@ -126,41 +126,27 @@ typedef fmi3Instance fmi3InstantiateModelExchangeTYPE(
fmi3InstanceEnvironment instanceEnvironment,
fmi3CallbackLogMessage logMessage);

typedef fmi3Instance fmi3InstantiateBasicCoSimulationTYPE(
typedef fmi3Instance fmi3InstantiateCoSimulationTYPE(
fmi3String instanceName,
fmi3String instantiationToken,
fmi3String resourceLocation,
fmi3Boolean visible,
fmi3Boolean loggingOn,
fmi3Boolean intermediateVariableGetRequired,
fmi3Boolean intermediateInternalVariableGetRequired,
fmi3Boolean intermediateVariableSetRequired,
fmi3Boolean eventModeRequired,
const fmi3ValueReference requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3InstanceEnvironment instanceEnvironment,
fmi3CallbackLogMessage logMessage,
fmi3CallbackIntermediateUpdate intermediateUpdate);

typedef fmi3Instance fmi3InstantiateHybridCoSimulationTYPE(
typedef fmi3Instance fmi3InstantiateScheduledExecutionTYPE(
fmi3String instanceName,
fmi3String instantiationToken,
fmi3String resourceLocation,
fmi3Boolean visible,
fmi3Boolean loggingOn,
fmi3Boolean intermediateVariableGetRequired,
fmi3Boolean intermediateInternalVariableGetRequired,
fmi3Boolean intermediateVariableSetRequired,
fmi3InstanceEnvironment instanceEnvironment,
fmi3CallbackLogMessage logMessage,
fmi3CallbackIntermediateUpdate intermediateUpdate);

typedef fmi3Instance fmi3InstantiateScheduledCoSimulationTYPE(
fmi3String instanceName,
fmi3String instantiationToken,
fmi3String resourceLocation,
fmi3Boolean visible,
fmi3Boolean loggingOn,
fmi3Boolean intermediateVariableGetRequired,
fmi3Boolean intermediateInternalVariableGetRequired,
fmi3Boolean intermediateVariableSetRequired,
const fmi3ValueReference requiredIntermediateVariables[],
size_t nRequiredIntermediateVariables,
fmi3InstanceEnvironment instanceEnvironment,
fmi3CallbackLogMessage logMessage,
fmi3CallbackIntermediateUpdate intermediateUpdate,
Expand Down
17 changes: 7 additions & 10 deletions fmpy/c-code/fmi3Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#define fmi3Functions_h

/*
This header file must be utilized when compiling a FMU.
It defines all functions of the
FMI 3.0-alpha.3 Model Exchange and Co-Simulation Interface.
This header file declares the functions of FMI 3.0-alpha.5.
It must be used when compiling an FMU.
In order to have unique function names even if several FMUs
are compiled together (e.g. for embedded systems), every "real" function name
Expand Down Expand Up @@ -83,7 +82,7 @@ This definition has been changed to add no prefix.
#define fmi3FullName(name) name

/* FMI version */
#define fmi3Version "3.0-alpha.3"
#define fmi3Version "3.0-alpha.5"

/***************************************************
Common Functions
Expand All @@ -95,9 +94,8 @@ Common Functions

/* Creation and destruction of FMU instances */
#define fmi3InstantiateModelExchange fmi3FullName(fmi3InstantiateModelExchange)
#define fmi3InstantiateBasicCoSimulation fmi3FullName(fmi3InstantiateBasicCoSimulation)
#define fmi3InstantiateHybridCoSimulation fmi3FullName(fmi3InstantiateHybridCoSimulation)
#define fmi3InstantiateScheduledCoSimulation fmi3FullName(fmi3InstantiateScheduledCoSimulation)
#define fmi3InstantiateCoSimulation fmi3FullName(fmi3InstantiateCoSimulation)
#define fmi3InstantiateScheduledExecution fmi3FullName(fmi3InstantiateScheduledExecution)
#define fmi3FreeInstance fmi3FullName(fmi3FreeInstance)

/* Enter and exit initialization mode, terminate and reset */
Expand Down Expand Up @@ -203,9 +201,8 @@ FMI3_Export fmi3SetDebugLoggingTYPE fmi3SetDebugLogging;

/* Creation and destruction of FMU instances */
FMI3_Export fmi3InstantiateModelExchangeTYPE fmi3InstantiateModelExchange;
FMI3_Export fmi3InstantiateBasicCoSimulationTYPE fmi3InstantiateBasicCoSimulation;
FMI3_Export fmi3InstantiateHybridCoSimulationTYPE fmi3InstantiateHybridCoSimulation;
FMI3_Export fmi3InstantiateScheduledCoSimulationTYPE fmi3InstantiateScheduledCoSimulation;
FMI3_Export fmi3InstantiateCoSimulationTYPE fmi3InstantiateCoSimulation;
FMI3_Export fmi3InstantiateScheduledExecutionTYPE fmi3InstantiateScheduledExecution;
FMI3_Export fmi3FreeInstanceTYPE fmi3FreeInstance;

/* Enter and exit initialization mode, terminate and reset */
Expand Down
6 changes: 2 additions & 4 deletions fmpy/c-code/fmi3PlatformTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
#define fmi3PlatformTypes_h

/*
Standard header file to define the argument types of the
functions of the Functional Mock-up Interface 3.0-alpha.3.
This header file must be utilized both by the model and
by the simulation engine.
This header file defines the data types of FMI 3.0-alpha.5.
It must be used by both FMU and FMI master.
Copyright (C) 2008-2011 MODELISAR consortium,
2012-2020 Modelica Association Project "FMI"
Expand Down
17 changes: 8 additions & 9 deletions fmpy/fmi3.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,15 @@ def __init__(self, instanceName=None, **kwargs):

super(FMU3Slave, self).__init__(**kwargs)

self._fmi3Function('fmi3InstantiateBasicCoSimulation', [
self._fmi3Function('fmi3InstantiateCoSimulation', [
(fmi3String, 'instanceName'),
(fmi3String, 'instantiationToken'),
(fmi3String, 'resourceLocation'),
(fmi3Boolean, 'visible'),
(fmi3Boolean, 'loggingOn'),
(fmi3Boolean, 'intermediateVariableGetRequired'),
(fmi3Boolean, 'intermediateInternalVariableGetRequired'),
(fmi3Boolean, 'intermediateVariableSetRequired'),
(fmi3Boolean, 'eventModeRequired'),
(POINTER(fmi3ValueReference), 'requiredIntermediateVariables'),
(c_size_t, 'nRequiredIntermediateVariables'),
(fmi3InstanceEnvironment, 'instanceEnvironment'),
(fmi3CallbackLogMessageTYPE, 'logMessage'),
(fmi3CallbackIntermediateUpdateTYPE, 'intermediateUpdate')
Expand Down Expand Up @@ -829,23 +829,22 @@ def __init__(self, instanceName=None, **kwargs):
(fmi3Float64, 'activationTime')
])

def instantiate(self, visible=False, loggingOn=False):
def instantiate(self, visible=False, loggingOn=False, eventModeRequired=False):

resourceLocation = pathlib.Path(self.unzipDirectory, 'resources').as_uri()

# save callbacks from GC
self.printLogMessage = fmi3CallbackLogMessageTYPE(printLogMessage)
self.intermediateUpdate = fmi3CallbackIntermediateUpdateTYPE(intermediateUpdate)

self.component = self.fmi3InstantiateBasicCoSimulation(
self.component = self.fmi3InstantiateCoSimulation(
self.instanceName.encode('utf-8'),
self.guid.encode('utf-8'),
resourceLocation.encode('utf-8'),
fmi3True if visible else fmi3False,
fmi3True if loggingOn else fmi3False,
fmi3False,
fmi3False,
fmi3False,
fmi3True if eventModeRequired else fmi3False,
None, 0,
fmi3InstanceEnvironment(),
self.printLogMessage,
self.intermediateUpdate)
Expand Down
10 changes: 7 additions & 3 deletions fmpy/gui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,18 +879,22 @@ def createDesktopShortcut(self):
from win32com.client import Dispatch
import sys

env = os.environ['CONDA_DEFAULT_ENV']
env = os.environ.get('CONDA_DEFAULT_ENV')

if env is None:
target_path = sys.executable
root, ext = os.path.splitext(target_path)
pythonw = root + 'w' + ext
if os.path.isfile(pythonw):
target_path = pythonw
arguments = '-m fmpy.gui'
else:
for path in os.environ["PATH"].split(os.pathsep):
activate = os.path.join(path, 'activate.bat')
if os.path.isfile(activate):
break

target_path = '%windir%\System32\cmd.exe'
target_path = r'%windir%\System32\cmd.exe'
arguments = '/C ""%s" %s && python -m fmpy.gui"' % (activate, env)

file_path = os.path.dirname(__file__)
Expand Down Expand Up @@ -924,7 +928,7 @@ def addFileAssociation(self):
try:
from winreg import HKEY_CURRENT_USER, KEY_WRITE, REG_SZ, OpenKey, CreateKey, SetValueEx, CloseKey

env = os.environ['CONDA_DEFAULT_ENV']
env = os.environ.get('CONDA_DEFAULT_ENV_')

if env is None:
python = sys.executable
Expand Down
6 changes: 3 additions & 3 deletions fmpy/gui/forms/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,6 @@ QToolButton:checked, QToolButton:hover:pressed {
<addaction name="menuFMI_Specifications"/>
<addaction name="actionOpenTestFMUs"/>
<addaction name="separator"/>
<addaction name="actionCreateDesktopShortcut"/>
<addaction name="actionAddFileAssociation"/>
<addaction name="separator"/>
<addaction name="actionOpenWebsite"/>
<addaction name="actionShowReleaseNotes"/>
<addaction name="separator"/>
Expand All @@ -1350,6 +1347,9 @@ QToolButton:checked, QToolButton:hover:pressed {
<property name="title">
<string>&amp;Tools</string>
</property>
<addaction name="actionCreateDesktopShortcut"/>
<addaction name="actionAddFileAssociation"/>
<addaction name="separator"/>
<addaction name="actionCompilePlatformBinary"/>
<addaction name="actionCreateCMakeProject"/>
<addaction name="actionAddRemoting"/>
Expand Down
2 changes: 1 addition & 1 deletion fmpy/model_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def read_model_description(filename, validate=True, validate_variable_names=Fals
'canSerializeFMUstate',
'providesDirectionalDerivative'])

for cs in root.findall('BasicCoSimulation'):
for cs in root.findall('CoSimulation'):
modelDescription.coSimulation = CoSimulation()
_copy_attributes(cs, modelDescription.coSimulation,
['modelIdentifier',
Expand Down
14 changes: 2 additions & 12 deletions fmpy/schema/fmi3/fmi3AttributeGroups.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,55 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------
</xs:documentation>
</xs:annotation>
<xs:attributeGroup name="fmi3RealAttributes">
<xs:attributeGroup name="fmi3RealBaseAttributes">
<xs:attribute name="quantity" type="xs:normalizedString"/>
<xs:attribute name="unit" type="xs:normalizedString"/>
<xs:attribute name="displayUnit" type="xs:normalizedString"/>
<xs:attribute name="relativeQuantity" type="xs:boolean" default="false"/>
<xs:attribute name="unbounded" type="xs:boolean" default="false"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Float64Attributes">
<xs:attributeGroup ref="fmi3RealAttributes"/>
<xs:attribute name="min" type="xs:double"/>
<xs:attribute name="max" type="xs:double"/>
<xs:attribute name="nominal" type="xs:double"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Float32Attributes">
<xs:attributeGroup ref="fmi3RealAttributes"/>
<xs:attribute name="min" type="xs:float"/>
<xs:attribute name="max" type="xs:float"/>
<xs:attribute name="nominal" type="xs:float"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3IntegerAttributes">
<xs:attributeGroup name="fmi3IntegerBaseAttributes">
<xs:attribute name="quantity" type="xs:normalizedString"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Int8Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:byte"/>
<xs:attribute name="max" type="xs:byte"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3UInt8Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:unsignedByte"/>
<xs:attribute name="max" type="xs:unsignedByte"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Int16Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:short"/>
<xs:attribute name="max" type="xs:short"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3UInt16Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:unsignedShort"/>
<xs:attribute name="max" type="xs:unsignedShort"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Int32Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:int"/>
<xs:attribute name="max" type="xs:int"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3UInt32Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:unsignedInt"/>
<xs:attribute name="max" type="xs:unsignedInt"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3Int64Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:long"/>
<xs:attribute name="max" type="xs:long"/>
</xs:attributeGroup>
<xs:attributeGroup name="fmi3UInt64Attributes">
<xs:attributeGroup ref="fmi3IntegerAttributes"/>
<xs:attribute name="min" type="xs:unsignedLong"/>
<xs:attribute name="max" type="xs:unsignedLong"/>
</xs:attributeGroup>
Expand Down
1 change: 1 addition & 0 deletions fmpy/schema/fmi3/fmi3InterfaceType.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<xs:attribute name="canHandleVariableCommunicationStepSize" type="xs:boolean" default="false"/>
<xs:attribute name="maxOutputDerivativeOrder" type="xs:unsignedInt" default="0"/>
<xs:attribute name="providesIntermediateVariableAccess" type="xs:boolean" default="false"/>
<xs:attribute name="recommendedIntermediateInputSmoothness" type="xs:int" default="0"/>
<xs:attribute name="canReturnEarlyAfterIntermediateUpdate" type="xs:boolean" default="false"/>
<xs:attribute name="fixedInternalStepSize" type="xs:double"/>
</xs:extension>
Expand Down
13 changes: 10 additions & 3 deletions fmpy/schema/fmi3/fmi3ModelDescription.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<xs:complexType>
<xs:sequence>
<xs:element name="ModelExchange" type="fmi3ModelExchange" minOccurs="0"/>
<xs:element name="BasicCoSimulation" type="fmi3CoSimulation" minOccurs="0"/>
<xs:element name="HybridCoSimulation" type="fmi3CoSimulation" minOccurs="0"/>
<xs:element name="ScheduledCoSimulation" type="fmi3CoSimulation" minOccurs="0"/>
<xs:element name="CoSimulation" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="fmi3CoSimulation">
<xs:attribute name="hasEventMode" type="xs:boolean" default="false"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="ScheduledExecution" type="fmi3CoSimulation" minOccurs="0"/>
<xs:element name="UnitDefinitions" minOccurs="0">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
Expand Down
Loading

0 comments on commit a79cf68

Please sign in to comment.