|
| 1 | +## status: correct |
| 2 | +## teardown_command: |
| 3 | +## linux: yes |
| 4 | +## ucrt64: yes |
| 5 | +## win: yes |
| 6 | +## asan: no |
| 7 | + |
| 8 | + |
| 9 | +from OMSimulator import SSP, CRef, Settings |
| 10 | +Settings.suppressPath = True |
| 11 | + |
| 12 | +model = SSP() |
| 13 | +model.addResource('../../resources/Feedthrough3.fmu', new_name='resources/Feedthrough3.fmu') |
| 14 | + |
| 15 | +model.addComponent(CRef('default', 'Feedthrough'), 'resources/Feedthrough3.fmu') |
| 16 | + |
| 17 | +instantiated_model = model.instantiate() |
| 18 | +instantiated_model.setResultFile("") |
| 19 | +instantiated_model.setStopTime(10.0) |
| 20 | +instantiated_model.setTolerance(1e-5) |
| 21 | + |
| 22 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Float32_continuous_input'), 3.1) |
| 23 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Float64_continuous_input'), 3.3) |
| 24 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Int8_input'), 4) |
| 25 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Int16_input'), 5) |
| 26 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Int32_input'), 6) |
| 27 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Int64_input'), 7) |
| 28 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'UInt8_input'), 8) |
| 29 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'UInt16_input'), 9) |
| 30 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'UInt32_input'), 10) |
| 31 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'UInt64_input'), 11) |
| 32 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Boolean_input'), True) |
| 33 | +instantiated_model.setValue(CRef('default', 'Feedthrough', 'Enumeration_input'), 2) |
| 34 | + |
| 35 | +## need to implement fmi3causality table in fmi4c library if inital attribute is not present |
| 36 | +## instantiated_model.setValue(CRef('default', 'Feedthrough', 'String_parameter'), "Set me!") |
| 37 | + |
| 38 | +instantiated_model.initialize() |
| 39 | +instantiated_model.simulate() |
| 40 | + |
| 41 | +# --- Print all outputs and values that were set --- |
| 42 | +print(f"info: Feedthrough.Float32_continuous_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Float32_continuous_input'))}", flush=True) |
| 43 | +print(f"info: Feedthrough.Float64_continuous_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Float64_continuous_input'))}", flush=True) |
| 44 | +print(f"info: Feedthrough.Int8_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Int8_input'))}", flush=True) |
| 45 | +print(f"info: Feedthrough.Int16_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Int16_input'))}", flush=True) |
| 46 | +print(f"info: Feedthrough.Int32_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Int32_input'))}", flush=True) |
| 47 | +print(f"info: Feedthrough.Int64_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Int64_input'))}", flush=True) |
| 48 | +print(f"info: Feedthrough.UInt8_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'UInt8_input'))}", flush=True) |
| 49 | +print(f"info: Feedthrough.UInt16_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'UInt16_input'))}", flush=True) |
| 50 | +print(f"info: Feedthrough.UInt32_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'UInt32_input'))}", flush=True) |
| 51 | +print(f"info: Feedthrough.UInt64_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'UInt64_input'))}", flush=True) |
| 52 | +print(f"info: Feedthrough.Boolean_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Boolean_input'))}", flush=True) |
| 53 | +print(f"info: Feedthrough.Enumeration_input: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'Enumeration_input'))}", flush=True) |
| 54 | +print(f"info: Feedthrough.String_parameter: {instantiated_model.getValue(CRef('default', 'Feedthrough', 'String_parameter'))}", flush=True) |
| 55 | + |
| 56 | +instantiated_model.terminate() |
| 57 | +instantiated_model.delete() |
| 58 | + |
| 59 | + |
| 60 | +## Result: |
| 61 | +## warning: Unknown FMI3 base type for var : Binary_input |
| 62 | +## warning: Unknown FMI3 base type for var : Binary_output |
| 63 | +## Loading FMI version 3... |
| 64 | +## info: No result file will be created |
| 65 | +## info: Feedthrough.Float32_continuous_input: 3.0999999046325684 |
| 66 | +## info: Feedthrough.Float64_continuous_input: 3.3 |
| 67 | +## info: Feedthrough.Int8_input: 4 |
| 68 | +## info: Feedthrough.Int16_input: 5 |
| 69 | +## info: Feedthrough.Int32_input: 6 |
| 70 | +## info: Feedthrough.Int64_input: 7 |
| 71 | +## info: Feedthrough.UInt8_input: 8 |
| 72 | +## info: Feedthrough.UInt16_input: 9 |
| 73 | +## info: Feedthrough.UInt32_input: 10 |
| 74 | +## info: Feedthrough.UInt64_input: 11 |
| 75 | +## info: Feedthrough.Boolean_input: True |
| 76 | +## info: Feedthrough.Enumeration_input: 2 |
| 77 | +## info: Feedthrough.String_parameter: Set me! |
| 78 | +## info: 2 warnings |
| 79 | +## info: 0 errors |
| 80 | +## endResult |
0 commit comments