Skip to content
Snippets Groups Projects
Select Git revision
  • 274eddf04408825a84e68b4d4678cfba13134c42
  • master default
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.1
  • v2014.0
  • v2013.0
10 results

PrettyPrint.jrag

Blame
  • Forked from Anders Blomdell / LabComm
    Source project has a limited visibility.
    utilities.jl 902 B
    export @periodically, init_sysfilter, sysfilter!
    
    """
    	@periodically(h, body)
    Ensures that the body is run with an interval of `h >= 0.001` seconds.
    """
    macro periodically(h, body)
    	quote
    		local start_time = time()
    		$(esc(body))
    		local execution_time = time()-start_time
    		sleep(max(0,$(esc(h))-execution_time))
    	end
    end
    
    """
    	state = init_sysfilter(sys::StateSpace)
    Use together with [`sysfilter!`](@ref)
    """
    function init_sysfilter(sys::StateSpace)
     	zeros(sys.nx,1)
    end
    
    """
    	output = sysfilter!(state, sys::StateSpace, input)
    Returns the filtered output `y` in `y = Cx+Du, x'=Ax+Bu`
    
    This function is used to implement control loops where a signal is filtered through a
    dynamical system, i.e., `U(z) = C(z)E(z)`. Initialize `state` using [`init_sysfilter`](@ref).
    """
    function sysfilter!(state, sys::StateSpace, input)
    	state .= sys.A*state + sys.B*input
    	output = sys.C*state + sys.D*input
    end