Created
May 27, 2019 18:51
-
-
Save sjoelund/7df830e1ea8be4b3032023518cf9542d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OMPython | |
omc = OMPython.OMCSessionZMQ() | |
assert(omc.sendExpression("loadModel(ModelicaTest)")) | |
assert(omc.sendExpression('setCommandLineOptions("-g=MetaModelica")')) | |
experiments = omc.sendExpression("list(cl for cl guard isExperiment(cl) in getClassNames(recursive=true))") | |
assert(omc.sendExpression('setCommandLineOptions("-g=Modelica -d=newInst")')) | |
s = "" | |
i = 1 | |
for e in experiments: | |
s = s + (" %s class%d;\n" % (e,i)) | |
i = i + 1 | |
model = """model M | |
%s | |
end M;""" % s | |
assert(omc.sendExpression('loadString("%s")' % model)) | |
assert(omc.sendExpression('saveTotalModel("total.mo", M)')) | |
clBefore = set(omc.sendExpression('getClassNames(recursive=true)')) | |
omc.sendExpression('clear()') | |
assert(omc.sendExpression('loadFile("total.mo")')) | |
clAfter = set(omc.sendExpression('getClassNames(recursive=true)')) | |
print("Classes not tested") | |
print("==================") | |
for cl in clBefore.difference(clAfter): | |
print(cl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment