From d3af836b3805a8489f800d0ef073d82439278bf4 Mon Sep 17 00:00:00 2001
From: jwikmark <jacob@wikmark.se>
Date: Thu, 15 Mar 2018 11:27:56 +0100
Subject: [PATCH] bumpless transfer only if I is on

---
 src/tankdemo.jl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/tankdemo.jl b/src/tankdemo.jl
index 73516d6..ebff174 100644
--- a/src/tankdemo.jl
+++ b/src/tankdemo.jl
@@ -41,12 +41,14 @@ function runprocess(;simulated=false, webservice=true, port=8000, σ = 0.001, du
                 onv = Int.([gui[s]=="On" for s in [:pOn, :iOn, :dOn]])
                 rv = pidcontroller(r, y, onv)
                 if gui[:mode]=="Automatic"
-                    gui[:u] = clamp(round(rv,2), 0, 1) #u's constructor has a dummy graphic so this is fine
+                    gui[:u] = clamp(round(rv,2), 0, 1) #u's constructor has only a dummy graphic so this is fine
                     control(P, rv)
                 elseif gui[:mode]=="Manual"
                     control(P, gui[:u])
                     #bumpless transfer:
-                    pidcontroller.I = gui[:u]-(pidcontroller.Tot-pidcontroller.I)
+                    if gui[:iOn]=="On"
+                        pidcontroller.I = gui[:u]-(pidcontroller.Tot-pidcontroller.I)
+                    end
                 end
                 push!(gui, y, 1)
                 push!(gui, r, 2)
-- 
GitLab