Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix linearfile for linearization() #53

Merged
merged 1 commit into from
Aug 10, 2021
Merged
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
15 changes: 11 additions & 4 deletions src/OMJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,19 @@ function linearize(omc)
# println(linearexpr)
sendExpression(omc, linearexpr)
omc.resultfile = replace(joinpath(omc.tempdir, join([omc.modelname,"_res.mat"])), r"[/\\]+" => "/")
omc.linearmodelname = join(["linear_",omc.modelname])
omc.linearmodelname = "linearized_model"
omc.linearfile = joinpath(omc.tempdir, join([omc.linearmodelname,".mo"]))

# support older openmodelica versions before OpenModelica v1.16.2 where linearize() generates "linear_modelname.mo" file
if(!isfile(omc.linearfile))
omc.linearmodelname = join(["linear_", omc.modelname])
omc.linearfile = joinpath(omc.tempdir, join([omc.linearmodelname, ".mo"]))
end

if (isfile(omc.linearfile))
loadmsg = sendExpression(omc, "loadFile(\"" * omc.linearfile * "\")")
if (!loadmsg)
return sendExpression(omc, "getErrorString()")
return println(sendExpression(omc, "getErrorString()"))
end
cNames = sendExpression(omc, "getClassNames()")
buildmodelexpr = join(["buildModel(",cNames[1],")"])
Expand All @@ -1068,11 +1075,11 @@ function linearize(omc)
linearMatrix = getLinearMatrix(omc)
return linearMatrix
else
return sendExpression(omc, "getErrorString()")
return println("Building linearized Model failed: ", sendExpression(omc, "getErrorString()"))
end
else
errormsg = sendExpression(omc, "getErrorString()")
println(errormsg)
return println("Linearization failed: ","\"" , omc.linearfile,"\"" ," not found \n", errormsg)
end
end

Expand Down