Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@skipIf(platform != 'win32', "Current platform not supported by this SSP")
def test_simulate_sample_system_with_parameters(self):
ssv_filename = self.ssp_example_path('SampleSystemParameterValues.ssv')
parameter_set = read_ssv(ssv_filename)
filename = self.ssp_example_path('SampleSystem.ssp')
sine = lambda t: np.sin(t * 2 * np.pi)
result = simulate_ssp(filename, stop_time=1.0, step_size=0.01, parameter_set=parameter_set, input={'In1': sine})
# check if the input has been applied correctly
self.assertTrue(np.all(np.abs(result['In1'] - sine(result['time'])) < 0.01))
background-color: #5cb85c;
}
''')
html.write('\n')
for fmiVersion in fmiVersions:
for fmiType in fmiTypes:
platformDir = os.path.join(testFMUsDirectory,
'FMI_1.0' if fmiVersion == 'fmi1' else 'FMI_2.0',
'ModelExchange' if fmiType == 'me' else 'CoSimulation',
fmpy.platform)
for tool in os.listdir(platformDir):
if tools is not None and not tool in tools:
continue
toolDir = os.path.join(platformDir, tool)
if not os.path.isdir(toolDir):
continue
versions = os.listdir(toolDir)
version = sorted(versions)[-1] # take only the latest version
versionDir = os.path.join(toolDir, version)
for model in os.listdir(versionDir):
<table><tbody><tr><th>Model</th><th>XML</th><th>_in.csv</th><th>_cc.csv</th><th>_ref.csv</th></tr></tbody></table>
def copy_to_cross_check(build_dir, model_names, fmi_version, fmi_types):
if fmus_dir is None:
return
for fmi_type in fmi_types:
for model in model_names:
target_dir = os.path.join(fmus_dir, fmi_version, fmi_type, fmpy.platform, 'Test-FMUs', test_fmus_version, model)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
shutil.copy(os.path.join(build_dir, 'dist', model + '.fmu'), target_dir)
shutil.copy(os.path.join(test_fmus_dir, model, model + '_ref.csv'), target_dir)
shutil.copy(os.path.join(test_fmus_dir, model, model + '_ref.opt'), target_dir)
instanceName the name of the FMU instance
libraryPath path to the shared library
fmiCallLogger logger callback that takes a message as input
"""
self.guid = guid
self.modelIdentifier = modelIdentifier
self.unzipDirectory = unzipDirectory
self.instanceName = instanceName if instanceName is not None else self.modelIdentifier
self.fmiCallLogger = fmiCallLogger
# remember the current working directory
work_dir = os.getcwd()
if libraryPath is None:
library_dir = os.path.join(unzipDirectory, 'binaries', platform)
libraryPath = str(os.path.join(library_dir, self.modelIdentifier + sharedLibraryExtension))
else:
library_dir = os.path.dirname(libraryPath)
# check if shared library exists
if not os.path.isfile(libraryPath):
raise Exception("Cannot find shared library %s." % libraryPath)
# change to the library directory as some DLLs expect this to resolve dependencies
os.chdir(library_dir)
# load the shared library
try:
self.dll = cdll.LoadLibrary(libraryPath)
except Exception as e:
raise Exception("Failed to load shared library %s. %s" % (libraryPath, e))
self.fmiTypeComboBox.clear()
self.fmiTypeComboBox.addItems(fmi_types)
self.updateSimulationSettings()
self.setCurrentPage(self.ui.settingsPage)
self.ui.dockWidget.show()
self.ui.actionReload.setEnabled(True)
self.ui.actionSettings.setEnabled(True)
self.ui.actionShowLog.setEnabled(True)
self.ui.actionShowResults.setEnabled(False)
can_simulate = platform in platforms or platform == 'win64' and 'win32' in platforms
self.ui.actionLoadStartValues.setEnabled(can_simulate)
self.ui.actionSimulate.setEnabled(can_simulate)
self.stopTimeLineEdit.setEnabled(can_simulate)
self.fmiTypeComboBox.setEnabled(can_simulate and len(fmi_types) > 1)
self.ui.settingsGroupBox.setEnabled(can_simulate)
settings = QSettings()
recent_files = settings.value("recentFiles", defaultValue=[])
recent_files = self.removeDuplicates([filename] + recent_files)
# save the 10 most recent files
settings.setValue('recentFiles', recent_files[:10])
self.setWindowTitle("%s - FMPy" % os.path.normpath(filename))