Skip to content

Commit 54a52aa

Browse files
committed
changed: preparestate! for SimModel now receives no additional arg.
The old method with `ym` and `d` arguments still works but it's now deprecated. The old method was not making sense since the two arguments were simply ignored. Moreover, it's now consistent with the `updatestate!` function, that is, it receive no measurement arguments for `SimModel`.
1 parent db9482c commit 54a52aa

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/sim_model.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ function initstate!(model::SimModel, u, d=model.buffer.empty)
208208
end
209209

210210
@doc raw"""
211-
preparestate!(model::SimModel, _ , _ ) -> x
211+
preparestate!(model::SimModel) -> x
212212
213213
Do nothing for [`SimModel`](@ref) and return the current model state ``\mathbf{x}(k)``.
214214
"""
215-
function preparestate!(model::SimModel, ::Any , ::Any=model.buffer.empty)
215+
function preparestate!(model::SimModel)
216+
x = model.buffer.x
217+
x .= model.x0 .+ model.xop
218+
return x
219+
end
220+
221+
@deprecate function preparestate!(model::SimModel, ::Any , ::Any=model.buffer.empty)
216222
x = model.buffer.x
217223
x .= model.x0 .+ model.xop
218224
return x

test/1_test_sim_model.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ end
107107
@test evaloutput(linmodel1, Float64[]) linmodel1(Float64[]) [50,30]
108108
x = initstate!(linmodel1, [10, 60])
109109
@test evaloutput(linmodel1) [50 + 19.0, 30 + 7.4]
110-
@test preparestate!(linmodel1, [10, 60]) x
110+
@test preparestate!(linmodel1) x # new method
111+
@test preparestate!(linmodel1, [10, 60]) x # deprecated method
111112
@test updatestate!(linmodel1, [10, 60]) x
112113
linmodel2 = LinModel(append(tf(1, [1, 0]), tf(2, [10, 1])), 1.0)
113114
x = initstate!(linmodel2, [10, 3])

0 commit comments

Comments
 (0)