OpenModelica / OMSimulator

The OpenModelica FMI & SSP-based co-simulation environment.
Other
70 stars 50 forks source link

ssm from exportSSMTemplate, not recogized as ssm #1151

Closed Fredrik1Haider closed 2 years ago

Fredrik1Haider commented 2 years ago

Description

The SSM exported from exportSSMTemplate is not recognized as an ssm file, when added back to an oms model using addResource()

Steps to reproduce the behavior

A model is initialized with the ECS_HW.fmu (Embrace)

oms.setCommandLineOption("--suppressPath=True")
oms.setWorkingDirectory(path)
oms.setTempDirectory(tmppath)
oms.newModel("model")
oms.addSystem("model.root", oms.system_wc)

oms.addSubModel("model.root.modelName", pathToFMU)

exportSSMTemplate(”model”, save_path) 

exports the following file:

<?xml version=”1.0”?>
<ns0:ParameterMapping
                xmlns:ns0=”…”
                version=”1.0”>
<ns0:MappingEntry
                source = ”…”
                target=”…” />
…
</ns0:ParameterMapping>

note that what is supposed to be ssm is exported as ns0 the exported ssm, is read using the python lib xml.ETree and sources are added to a couple of the targets the modified ssm gets added back to the OMS model

oms.addResources(“model”, .ssm))

and the reference to the .ssm is added

oms.referencesResources(model.root:.ssv, .ssm)

finally, the resulting .ssp is exported oms.export("model", path)

Inspecting the resulting .ssp it is noted that the .ssm is empty only containing the boilerplate code i.e

<?xml version=”1.0”?>
<ssm:ParameterMapping
                xmlns:ssm=”…”
                version=”1.0”>
</ssm:ParameterMapping>

Running the simulation it can be confirmed that the mapping did not work.

In conclusion, ssm is replaced by ns0 in the exported .ssm, the file is no longer recognized as an .ssm file. Currently, the my work around is to replace as ns0 entries with ssm prior to adding the .ssm resource

Expected behavior

An exported .ssm is recognized as an .ssm when added to a model

What would be expected of the ssm export:

<?xml version=”1.0”?>
<ssm:ParameterMapping
                xmlns:ssm=”…”
                version=”1.0”>
<ssm:MappingEntry
                source = ”…”
                target=”…” />
…
</ssm:ParameterMapping>

Version and OS

arun3688 commented 2 years ago

@Fredrik1Haider I cannot reproduce the issue, for me it is working correctly as expected, see the following test example where the ssm template files are exported correctly https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/simulation/exportSSMTemplate.py, when adding the ssm file using addResources() API see the following example https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/api/addExternalResources4.py#L24,

Fredrik1Haider commented 2 years ago

@Fredrik1Haider I cannot reproduce the issue, for me it is working correctly as expected, see the following test example where the ssm template files are exported correctly https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/simulation/exportSSMTemplate.py, when adding the ssm file using addResources() API see the following example https://github.com/OpenModelica/OMSimulator/blob/master/testsuite/api/addExternalResources4.py#L24,

huh, odd the issue does not appear with the example code you provided. I will have to dig a bit deeper and see if I can figure out what the cause is for my code...

Fredrik1Haider commented 2 years ago

@arun3688 the underlying issue has been identified and is NOT related to OMS, this issue may be closed.