Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if model == 'Feedthrough':
start_values = {'real_fixed_param': 1, 'string_param': "FMI is awesome!"}
in_csv = os.path.join(test_fmus_dir, model, model + '_in.csv')
input = read_csv(in_csv)
else:
start_values = {}
input = None
ref_csv = os.path.join(test_fmus_dir, model, model + '_ref.csv')
for fmi_type in fmi_types:
ref = read_csv(ref_csv)
if compile:
compile_platform_binary(fmu_filename)
result = simulate_fmu(fmu_filename,
fmi_type=fmi_type,
start_values=start_values,
input=input)
dev = validate_result(result, ref)
self.assertLess(dev, 0.2, "Failed to validate " + model)
def test_compile(self):
""" Compile the platform binary """
for fmu in self.fmus:
download_file(self.url + fmu)
filename = os.path.basename(fmu)
compile_platform_binary(filename)
result = simulate_fmu(filename=filename)
self.assertIsNotNone(result)
messages = validate_fmu(args.fmu_filename)
if len(messages) == 0:
print('The validation passed')
else:
print('The following errors were found:')
for message in messages:
print()
print(message)
sys.exit(1)
elif args.command == 'compile':
from fmpy.util import compile_platform_binary
compile_platform_binary(args.fmu_filename)
elif args.command == 'add-cswrapper':
from fmpy.cswrapper import add_cswrapper
add_cswrapper(args.fmu_filename)
elif args.command == 'add-remoting':
from fmpy.util import add_remoting
add_remoting(args.fmu_filename)
elif args.command == 'simulate':
from fmpy import simulate_fmu
from fmpy.util import read_csv, write_csv, plot_result
def compilePlatformBinary(self):
""" Compile the platform binary """
from ..util import compile_platform_binary
platforms = supported_platforms(self.filename)
if fmpy.platform in platforms:
button = QMessageBox.question(self, "Platform binary already exists", "The FMU already contains a binary for the current platform. Do you want to compile and overwrite the existing binary?")
if button == QMessageBox.No:
return
try:
compile_platform_binary(self.filename)
except Exception as e:
QMessageBox.critical(self, "Failed to compile platform binaries", str(e))
return
self.load(self.filename)