Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .CI/installLibraries.mos
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ for l in {
{"Modelica_Synchronous", "master"},
{"ModelicaByExample", "master"},
{"ModelicaTestOverdetermined", "master"},
{"NeuralNetwork", "main"},
{"ObjectStab", "master"},
{"OpenHydraulics", "main"},
{"OpenIMDML", "main"},
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ defining `MSLREFERENCE` and `REFERENCEFILES`.

Some result file locations:

- Modelica Association: [https://github.com/modelica/MAP-LIB_ReferenceResults](modelica/MAP-LIB_ReferenceResults)
- PNLib: [https://github.com/AMIT-HSBI/PNlib](AMIT-HSBI/PNlib)
- DLR-SR: [https://github.com/DLR-SR/ThermoFluidStream-Regression](DLR-SR/ThermoFluidStream-Regression)
and [https://github.com/DLR-SR/PlanarMechanics_ReferenceResults](DLR-SR/PlanarMechanics_ReferenceResults)
- Modelica Association: [modelica/MAP-LIB_ReferenceResults](https://github.com/modelica/MAP-LIB_ReferenceResults)
- PNLib: [AMIT-HSBI/PNlib](https://github.com/AMIT-HSBI/PNlib)
- DLR-SR: [DLR-SR/ThermoFluidStream-Regression](https://github.com/DLR-SR/ThermoFluidStream-Regression)
and [DLR-SR/PlanarMechanics_ReferenceResults](https://github.com/DLR-SR/PlanarMechanics_ReferenceResults)

To download the MSL reference files create a file
installReferenceResults.sh with
Expand Down
20 changes: 4 additions & 16 deletions conversionscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from multiprocessing import Pool
import time


parser = argparse.ArgumentParser(description='OpenModelica library testing tool')
parser.add_argument('libdir', nargs=1)
parser.add_argument('--diff', action="store_true")
Expand All @@ -33,17 +32,6 @@
os.mkdir("converted-libraries/.openmodelica")
os.mkdir("converted-libraries/.openmodelica/libraries")

def omcAssert(omc: OMCSessionZMQ, cmd: str, extra: str = ""):
res = omc.sendExpression(cmd)
if not res:
raise Exception(cmd + "\n" + extra + "\n" + (omc.sendExpression("getErrorString()") or ""))

def omcSendExpression(omc: OMCSessionZMQ, cmd: str, extra: str = ""):
try:
return omc.sendExpression(cmd)
except pyparsing.ParseException as e:
raise Exception(str(e) + "\n" + cmd + "\n" + extra + "\n" + (omc.sendExpression("getErrorString()") or ""))

mslPath = "%s/Modelica 4.0.0+maint.om/" % libdir
with open("%s/openmodelica.metadata.json" % mslPath) as f:
mslData = json.load(f)
Expand Down Expand Up @@ -84,7 +72,7 @@ def convertPackage(p):
print("Start working on %s" % libnameOnFile)
omc = OMCSessionZMQ()
libnameOnFileFullPath = "converted-libraries/.openmodelica/libraries/%s/package.mo" % libnameOnFile
omcAssert(omc, 'loadFile("%s", uses=false)' % libnameOnFileFullPath)
omc.sendExpression('loadFile("%s", uses=false)' % libnameOnFileFullPath)
errString = omc.sendExpression("getErrorString()")
if errString:
print(errString)
Expand All @@ -93,12 +81,12 @@ def convertPackage(p):
raise Exception("Expected to have loaded %s but got %s" % (libnameOnFileFullPath, loadedFilePath))
gcProfStatsBeforeConversion = omc.sendExpression("GC_get_prof_stats()")
timeBeforeConvert = time.time()
omcAssert(omc, 'runConversionScript(%s, "%s")' % (libname, conversionScript))
omc.sendExpression('runConversionScript(%s, "%s")' % (libname, conversionScript))
print("runConversionScript(%s, %s) OK" % (libnameOnFile, conversionScript))
uses = data["uses"]
for (n,v) in data["uses"].items():
if n in ["Modelica", "ModelicaServices", "Complex"]:
omcAssert(omc, 'addClassAnnotation(%s, annotate=$annotation(uses(%s(version="4.0.0"))))' % (libname, n))
omc.sendExpression('addClassAnnotation(%s, annotate=$annotation(uses(%s(version="4.0.0"))))' % (libname, n))
data["uses"][n] = "4.0.0"
names = omc.sendExpression('getClassNames(%s, sort=true, recursive=true)' % libname)
names = list(names)
Expand Down Expand Up @@ -150,7 +138,7 @@ def convertPackage(p):
print(errStr)
raise Exception('--allowErrorsInDiff is not active:\necho(false);before:=readFile("%s");\nafter:=readFile("%s");echo(true);\ndiffModelicaFileListings(before, after, OpenModelica.Scripting.DiffFormat.plain, failOnSemanticsChange=true);\ngetErrorString();' % (oldFile, newFile))
else:
omcAssert(omc, 'writeFile("%s", res)' % (newFile))
omc.sendExpression('writeFile("%s", res)' % (newFile))
isDiff = before != res
if before != res:
nDiff += 1
Expand Down
17 changes: 11 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,10 @@ def hashReferenceFiles(s):

try:
omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch))
except OMCSessionException:
try:
print("Failed to load library %s %s: %s" % (library,versions,omc.sendExpression('OpenModelica.Scripting.getErrorString()')))
except:
print("Failed to load library %s %s. OpenModelica.Scripting.getErrorString() failed..." % (library,conf["libraryVersion"]))
except OMCSessionException as e:
print("Failed to load library %s %s" % (library,versions))
print(e)

# adrpo: do not sort the top level names as sometimes that loads a bad MSL version
# conf["loadFiles"] = sorted(omc.sendExpression("{getSourceFile(cl) for cl in getClassNames()}"))
conf["loadFiles"] = omc.sendExpression("{getSourceFile(cl) for cl in getClassNames()}")
Expand Down Expand Up @@ -728,7 +727,13 @@ def hashReferenceFiles(s):
if conf.get("fmi") and fmisimulatorversion:
conf["libraryVersionRevision"] = conf["libraryVersionRevision"] + " " + fmisimulatorversion.decode("ascii")
conf["libraryLastChange"] = conf["libraryLastChange"] + " " + fmisimulatorversion.decode("ascii")
res=omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library)
res = []
try:
res = omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library)
except OMCSessionException as e:
print("Failed to get class names of library %s", library)
print(e)

if conf.get("ignoreModelPrefix"):
if isinstance(conf["ignoreModelPrefix"], list):
prefixes = conf["ignoreModelPrefix"]
Expand Down
Loading