Skip to content

Commit

Permalink
Removing debug changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnHeuermann committed Sep 5, 2023
1 parent 4065992 commit 7990908
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/OMJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ function sendExpression(omc::OMCSession, expr::String; parsed=true)
return error("Process Exited, No connection with OMC. Create a new instance of OMCSession")
end

@info "sending expression: $(expr)"
@debug "sending expression: $(expr)"
ZMQ.Sockets.send(omc.socket, expr)
@info "Receiving message from ZMQ socket"
@debug "Receiving message from ZMQ socket"
message = ZMQ.Sockets.recv(omc.socket)
@info "Recieved message"
@debug "Recieved message"
if parsed
return Parser.parseOM(unsafe_string(message))
else
Expand Down
58 changes: 20 additions & 38 deletions test/omcTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import OMJulia

oldwd = pwd()
try
cd(workdir)

omc = OMJulia.OMCSession()
OMJulia.sendExpression(omc, "cd(\"$workdir\")")
version = OMJulia.sendExpression(omc, "getVersion()")
Expand All @@ -58,11 +56,7 @@ import OMJulia
@test occursin("The simulation finished successfully.", res["messages"])

@test 3 == OMJulia.sendExpression(omc, "1+2")

#ret = OMJulia.sendExpression(omc, "quit()", parsed=false)
#@test ret == "quit requested, shutting server down\n"
#kill(omc.omcprocess)
# This is all stuck!
# TODO: sendExpression(quit()) and kill(omc.omcprocess) get stuck on Ubuntu
finally
cd(oldwd)
end
Expand All @@ -81,36 +75,24 @@ import OMJulia
workdir2 = replace(workdir2, "\\" => "\\\\")
end

@info "Begin multiple sessions"
omc1 = OMJulia.OMCSession()
@info "AHeu1"
omc2 = OMJulia.OMCSession()
@info "AHeu2"

OMJulia.sendExpression(omc1, "cd(\"$workdir1\")")
@info "AHeu3"
@test true == OMJulia.sendExpression(omc1, "loadModel(Modelica)")
@info "AHeu4"
res = OMJulia.sendExpression(omc1, "simulate(Modelica.Blocks.Examples.PID_Controller)")
@info "AHeu5"
@test isfile(joinpath(@__DIR__, "test-omc1", "Modelica.Blocks.Examples.PID_Controller_res.mat"))
@info "AHeu6"

OMJulia.sendExpression(omc2, "cd(\"$workdir2\")")
@info "AHeu7"
@test true == OMJulia.sendExpression(omc2, "loadModel(Modelica)")
@info "AHeu8"
res = OMJulia.sendExpression(omc2, "simulate(Modelica.Blocks.Examples.PID_Controller)")
@info "AHeu9"
@test isfile(joinpath(@__DIR__, "test-omc2", "Modelica.Blocks.Examples.PID_Controller_res.mat"))
@info "AHeu10"

#OMJulia.sendExpression(omc1, "quit()", parsed=false)
#kill(omc1.omcprocess)
@info "AHeu11"
#OMJulia.sendExpression(omc2, "quit()", parsed=false)
#kill(omc2.omcprocess)
# This is all stuck!
@info "Fnished multiple sessions"
oldwd = pwd()
try
omc1 = OMJulia.OMCSession()
omc2 = OMJulia.OMCSession()

OMJulia.sendExpression(omc1, "cd(\"$workdir1\")")
@test true == OMJulia.sendExpression(omc1, "loadModel(Modelica)")
res = OMJulia.sendExpression(omc1, "simulate(Modelica.Blocks.Examples.PID_Controller)")
@test isfile(joinpath(@__DIR__, "test-omc1", "Modelica.Blocks.Examples.PID_Controller_res.mat"))

OMJulia.sendExpression(omc2, "cd(\"$workdir2\")")
@test true == OMJulia.sendExpression(omc2, "loadModel(Modelica)")
res = OMJulia.sendExpression(omc2, "simulate(Modelica.Blocks.Examples.PID_Controller)")
@test isfile(joinpath(@__DIR__, "test-omc2", "Modelica.Blocks.Examples.PID_Controller_res.mat"))

# TODO: sendExpression(quit()) and kill(omc.omcprocess) get stuck on Ubuntu
finally
cd(oldwd)
end
end
end

0 comments on commit 7990908

Please sign in to comment.