You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a variable total that each second is increased by an amount x taken from a text field in the UI. This is done asynchronously with a @task so that the program can listen to @onchange events.
using GenieFramework
@genietools@handlersbegin
p =@task1+1
total =0@in x =0.00@onchange x beginif!istaskstarted(p) ||istaskdone(p)
p =@taskbeginprintln("Task started")
while total <=100
total = total + x
println(total)
sleep(1)
endendschedule(p)
endendendfunctionui()
textfield("x value", :x)
end@page("/", ui)
Server.isrunning() || Server.up()
It works, but when I change the value of x from 1 to 2 I get the following:
Task started
1.02.03.04.0<---- Here I change x to 2
┌ Error:2023-01-1717:03:27 Failed to store session data
└ @ GenieSessionFileSession ~/.julia/packages/GenieSessionFileSession/otnJC/src/GenieSessionFileSession.jl:416.0┌ Error:2023-01-1717:03:27ErrorException("cannot serialize a running Task")
└ @ GenieSessionFileSession ~/.julia/packages/GenieSessionFileSession/otnJC/src/GenieSessionFileSession.jl:42
┌ Error:2023-01-1717:03:27 Resetting session
└ @ GenieSessionFileSession ~/.julia/packages/GenieSessionFileSession/otnJC/src/GenieSessionFileSession.jl:468.010.012.0
I've also tried defining the task outside of the @onchange block, but in that case the counter does not increase.
@handlersbegin
p =@task1+1
total =0@in x =0.00
p =@taskbeginprintln("Task started")
while total <=100
total = total + x
println(total)
sleep(1)
endend@onchange x beginif!istaskstarted(p) ||istaskdone(p)
schedule(p)
endendend
What is the cause of this error? Can it be fixed somehow?
The text was updated successfully, but these errors were encountered:
For a little more context, here's what I'm trying to do. I want to have a differential equation simulation running in the background, and control the eq's parameters in the UI. The simulation is run by calling a solver function in a loop over time. Whenever a parameter is changed, the diff eq should be instantly updated and the simulation proceed with the new parameters.
In the code below, the step! function in the while loop calculates the eq solution at t+t_step. The value of t_step can be set from the UI. This works well, only I'm getting the error in the previous post.
using GenieFramework
using DifferentialEquations, ModelingToolkit
@genietoolsfunctiondefine_ODE()
@parameters t σ ρ β
@variablesx(t) y(t) z(t)
D =Differential(t)
eqs = [D(x) ~ σ * (y - x),
D(y) ~ x * (ρ - z) - y,
D(z) ~ x * y - β * z]
@named sys =ODESystem(eqs)
sys =structural_simplify(sys)
u0 = [x =>1.0,
y =>0.0,
z =>0.0]
p = [σ =>10.0,
ρ =>28.0,
β =>8/3]
tspan = (0.0, 100.0)
ODEProblem(sys, u0, tspan, p, jac =true)
end
prob =define_ODE()
integrator = DifferentialEquations.init(prob, Tsit5())
t_end=100@handlersbegin
p =@task1+1schedule(p)
prob =define_ODE()
@in t_step =0.00@onchange t_step beginprintln(t_step)
if p._state ==1
p =@taskbegin@show p._state
while integrator.sol.t[end] <= t_end
sleep(1)
println(integrator.sol.t[end],'', t_step, '', p._state)
step!(integrator, t_step)
end
DifferentialEquations.reinit!(integrator)
endschedule(p)
endendendfunctionui()
textfield("Time step", :t_step)
end@page("/", ui)
Server.isrunning() || Server.up()
I have a variable
total
that each second is increased by an amountx
taken from a text field in the UI. This is done asynchronously with a @task so that the program can listen to @onchange events.It works, but when I change the value of
x
from 1 to 2 I get the following:I've also tried defining the task outside of the
@onchange
block, but in that case the counter does not increase.What is the cause of this error? Can it be fixed somehow?
The text was updated successfully, but these errors were encountered: