Skip to content

Commit 980eba4

Browse files
committed
fix calling the simulation executable on Windows
- add needed paths to PATH to dlls can be found
1 parent 6c40307 commit 980eba4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/OMJulia.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ mutable struct OMCSession
158158
end
159159
#sleep(5)
160160
fullpath=joinpath(tempdir(),portfile)
161+
@info("Path to zmq file=\"$fullpath\"")
161162
## Try to find better approach if possible, as sleep does not work properly across different platform
162163
filedata=""
163164
while true
@@ -544,7 +545,7 @@ function which simulates the modelica model based on the
544545
different settings made by users. Accepts three arguments
545546
second argument resultfile and third argument simflags are optional, An example usage
546547
>> simulate(omc) // default resultfilename is used
547-
>> simulate(omc,resultfile="tmpresult.mat") // user provided result file shall be used
548+
>> simulate(omc, resultfile="tmpresult.mat") // user provided result file shall be used
548549
>> simulate(omc, simflags="-noEmitEvent -override=e=0.3,g=9.3") // set runtime simulations flags provided by user
549550
"""
550551
function simulate(omc; resultfile=nothing, simflags=nothing)
@@ -592,7 +593,17 @@ function simulate(omc; resultfile=nothing, simflags=nothing)
592593
#remove empty args in cmd objects
593594
cmd=filter!(e->e"",[getexefile,overridevar,csvinput,r,simflags])
594595
#println(cmd)
595-
run(pipeline(`$cmd`,stdout="log.txt",stderr="error.txt"))
596+
if (Base.Sys.iswindows())
597+
installPath = sendExpression(omc, "getInstallationDirectoryPath()")
598+
envPath = ENV["PATH"]
599+
newPath = "$(envPath);$(installPath)/bin/;$(installPath)/lib/omc;$(installPath)/lib/omc/cpp;$(installPath)/lib/omc/omsicpp"
600+
# println("Path: $newPath")
601+
withenv("PATH"=>newPath) do
602+
run(pipeline(`$cmd`,stdout="log.txt",stderr="error.txt"))
603+
end
604+
else
605+
run(pipeline(`$cmd`,stdout="log.txt",stderr="error.txt"))
606+
end
596607
#omc.resultfile=replace(joinpath(omc.tempdir,join([omc.modelname,"_res.mat"])),r"[/\\]+" => "/")
597608
omc.simulationFlag=true
598609
else

0 commit comments

Comments
 (0)