@@ -27,15 +27,17 @@ $(TYPEDFIELDS)
2727end
2828
2929"""
30- Integrator(dt, i=1.0, x0=0.0)
30+ function Integrator(dt, i=1.0, x0=0.0)
3131
3232Constructor for discrete integrator with external reset.
3333
3434# Parameters
35-
3635- dt: timestep [s]
3736- i: integration constant
3837- x0: initial and last output
38+
39+ # Returns
40+ - a new struct of type `Integrator`
3941"""
4042function Integrator(dt, i= 1.0 , x0= 0.0 )
4143 Integrator(dt, i, x0, x0)
4749Reset the integrator `int` to the value `x0`.
4850
4951# Parameters
50-
5152- int::Integrator: An integrator struct
5253- x0: default value =0.0; initial and last output
54+
55+ # Returns
56+ - nothing
5357"""
5458function reset(int:: Integrator , x0= 0.0 )
5559 int. output = x0
@@ -66,6 +70,9 @@ Calculate and return the output without updating `last_output`.
6670
6771- int::Integrator: An integrator struct
6872- input: The input value
73+
74+ # Returns
75+ - the output value
6976"""
7077function calc_output(int:: Integrator , input)
7178 int. output = int. last_output + input * int. i * int. dt
@@ -79,6 +86,9 @@ Update the field `last_output`. Must be called once per time-step.
7986# Parameters
8087
8188- int::Integrator: An integrator struct
89+
90+ # Returns
91+ - nothing
8292"""
8393function on_timer(int:: Integrator )
8494 int. last_output = int. output
@@ -99,18 +109,55 @@ $(TYPEDFIELDS)
99109 last_input = 0
100110end
101111
112+ """
113+ calc_output(ud::UnitDelay, input)
114+
115+ Calculate and return the output and update the `last_input`, but not the `last_output`.
116+
117+ # Parameters
118+ - int::UnitDelay: A `UnitDelay` struct
119+ - input: The input value
120+
121+ # Returns
122+ - the last output
123+ """
102124function calc_output(ud:: UnitDelay , input)
103125 ud. last_input = input
104126 ud. last_output
105127end
106128
129+ """
130+ on_timer(ud::UnitDelay)
131+
132+ Update the field `last_output`. Must be called once per time-step.
133+
134+ # Parameters
135+
136+ - ud::UnitDelay: A UnitDelay struct
137+
138+ # Returns
139+ - nothing
140+ """
107141function on_timer(ud:: UnitDelay )
108142 ud. last_output = ud. last_input
143+ nothing
109144end
110145
146+ """
147+ reset(ud::UnitDelay)
148+
149+ Reset the `last_input` and `last_output` of the struct ud to zero.
150+
151+ # Parameters
152+ - ud::UnitDelay: A `UnitDelay` struct
153+
154+ # Returns
155+ - nothing
156+ """
111157function reset(ud:: UnitDelay )
112158 ud. last_input = 0.0
113159 ud. last_output = 0.0
160+ nothing
114161end
115162
116163"""
0 commit comments