@@ -130,13 +130,13 @@ Generate sine signal.
130
130
- `output`
131
131
"""
132
132
@component function Sine (; name,
133
- frequency,
134
- amplitude = 1 ,
135
- phase = 0 ,
136
- offset = 0 ,
137
- start_time = 0 ,
138
- smooth = false ,
139
- output__unit = nothing )
133
+ frequency,
134
+ amplitude = 1 ,
135
+ phase = 0 ,
136
+ offset = 0 ,
137
+ start_time = 0 ,
138
+ smooth = false ,
139
+ output__unit = nothing )
140
140
@named output = RealOutput (; unit = output__unit)
141
141
pars = @parameters offset= offset start_time= start_time amplitude= amplitude frequency= frequency phase= phase
142
142
equation = if smooth == false
@@ -174,13 +174,13 @@ Cosine signal.
174
174
"""
175
175
176
176
@component function Cosine (; name,
177
- frequency,
178
- amplitude = 1 ,
179
- phase = 0 ,
180
- offset = 0 ,
181
- start_time = 0 ,
182
- smooth = false ,
183
- output__unit = nothing )
177
+ frequency,
178
+ amplitude = 1 ,
179
+ phase = 0 ,
180
+ offset = 0 ,
181
+ start_time = 0 ,
182
+ smooth = false ,
183
+ output__unit = nothing )
184
184
@named output = RealOutput (; unit = output__unit)
185
185
pars = @parameters offset= offset start_time= start_time amplitude= amplitude frequency= frequency phase= phase
186
186
equation = if smooth == false
@@ -240,12 +240,12 @@ Generate ramp signal.
240
240
- `output`
241
241
"""
242
242
@component function Ramp (; name,
243
- height = 1 ,
244
- duration = 1 ,
245
- offset = 0 ,
246
- start_time = 0 ,
247
- smooth = false ,
248
- output__unit = nothing )
243
+ height = 1 ,
244
+ duration = 1 ,
245
+ offset = 0 ,
246
+ start_time = 0 ,
247
+ smooth = false ,
248
+ output__unit = nothing )
249
249
@named output = RealOutput (; unit = output__unit)
250
250
pars = @parameters offset= offset start_time= start_time height= height duration= duration
251
251
equation = if smooth == false
@@ -283,8 +283,8 @@ Generate smooth square signal.
283
283
- `output`
284
284
"""
285
285
@component function Square (; name, frequency = 1.0 , amplitude = 1.0 ,
286
- offset = 0.0 , start_time = 0.0 , smooth = false ,
287
- output__unit = nothing )
286
+ offset = 0.0 , start_time = 0.0 , smooth = false ,
287
+ output__unit = nothing )
288
288
@named output = RealOutput (; unit = output__unit)
289
289
pars = @parameters begin
290
290
frequency = frequency
@@ -326,7 +326,7 @@ Generate step signal.
326
326
- `output`
327
327
"""
328
328
@component function Step (; name, height = 1 , offset = 0 , start_time = 0 , duration = Inf ,
329
- smooth = 1e-5 , output__unit = nothing )
329
+ smooth = 1e-5 , output__unit = nothing )
330
330
@named output = RealOutput (; unit = output__unit)
331
331
duration_numeric = duration
332
332
pars = @parameters offset= offset start_time= start_time height= height duration= duration
@@ -370,14 +370,14 @@ Exponentially damped sine signal.
370
370
- `output`
371
371
"""
372
372
@component function ExpSine (; name,
373
- frequency,
374
- amplitude = 1 ,
375
- damping = 0.1 ,
376
- phase = 0 ,
377
- offset = 0 ,
378
- start_time = 0 ,
379
- smooth = false ,
380
- output__unit = nothing )
373
+ frequency,
374
+ amplitude = 1 ,
375
+ damping = 0.1 ,
376
+ phase = 0 ,
377
+ offset = 0 ,
378
+ start_time = 0 ,
379
+ smooth = false ,
380
+ output__unit = nothing )
381
381
@named output = RealOutput (; unit = output__unit)
382
382
pars = @parameters offset= offset start_time= start_time amplitude= amplitude frequency= frequency phase= phase damping= damping
383
383
@@ -418,8 +418,8 @@ Generate smooth triangular signal for frequencies less than or equal to 25 Hz
418
418
- `output`
419
419
"""
420
420
@component function Triangular (; name, amplitude = 1.0 , frequency = 1.0 ,
421
- offset = 0.0 , start_time = 0.0 , smooth = false ,
422
- output__unit = nothing )
421
+ offset = 0.0 , start_time = 0.0 , smooth = false ,
422
+ output__unit = nothing )
423
423
@named output = RealOutput (; unit = output__unit)
424
424
pars = @parameters begin
425
425
amplitude = amplitude
@@ -569,9 +569,9 @@ function first_order_backwards_difference(t, buffer, Δt, circular_buffer)
569
569
end
570
570
571
571
function get_sampled_data (t,
572
- buffer:: Vector{T} ,
573
- dt:: T ,
574
- circular_buffer = true ) where {T <: Real }
572
+ buffer:: Vector{T} ,
573
+ dt:: T ,
574
+ circular_buffer = true ) where {T <: Real }
575
575
if t < 0
576
576
t = zero (t)
577
577
end
@@ -630,7 +630,12 @@ function Symbolics.derivative(::typeof(get_sampled_data), args::NTuple{4, Any},
630
630
circular_buffer = @inbounds args[4 ]
631
631
first_order_backwards_difference (t, buffer, sample_time, circular_buffer)
632
632
end
633
- function ChainRulesCore. frule ((_, ẋ, _), :: typeof (get_sampled_data), t, buffer, sample_time, circular_buffer)
633
+ function ChainRulesCore. frule ((_, ẋ, _),
634
+ :: typeof (get_sampled_data),
635
+ t,
636
+ buffer,
637
+ sample_time,
638
+ circular_buffer)
634
639
first_order_backwards_difference (t, buffer, sample_time, circular_buffer) * ẋ
635
640
end
636
641
@@ -655,7 +660,11 @@ data input component.
655
660
# Connectors:
656
661
- `output`
657
662
"""
658
- @component function SampledData (:: Val{SampledDataType.vector_based} ; name, buffer, sample_time, circular_buffer= true )
663
+ @component function SampledData (:: Val{SampledDataType.vector_based} ;
664
+ name,
665
+ buffer,
666
+ sample_time,
667
+ circular_buffer = true )
659
668
pars = @parameters begin
660
669
buffer = buffer # ::Vector{Real}
661
670
sample_time = sample_time # ::Real
@@ -704,16 +713,19 @@ SampledData(x::SampledDataType.Option; kwargs...) = SampledData(Val(x); kwargs..
704
713
SampledData (T:: Type , circular_buffer = true ; name) = SampledData (SampledDataType. struct_based; name, buffer = Parameter (T[], zero (T), circular_buffer))
705
714
706
715
# vector_based
707
- SampledData (sample_time:: T , circular_buffer = true ; name) where {T <: Real } = SampledData (SampledDataType. vector_based; name, buffer= T[], sample_time, circular_buffer)
708
- SampledData (buffer:: Vector{<:Real} , sample_time:: Real , circular_buffer = true ; name) = SampledData (SampledDataType. vector_based; name, buffer, sample_time, circular_buffer)
709
- SampledData (; name, buffer, sample_time, circular_buffer) = SampledData (SampledDataType. vector_based; name, buffer, sample_time, circular_buffer)
710
-
711
-
712
-
713
-
714
-
715
-
716
-
717
-
718
-
719
-
716
+ function SampledData (sample_time:: T , circular_buffer = true ; name) where {T <: Real }
717
+ SampledData (SampledDataType. vector_based;
718
+ name,
719
+ buffer = T[],
720
+ sample_time,
721
+ circular_buffer)
722
+ end
723
+ function SampledData (buffer:: Vector{<:Real} ,
724
+ sample_time:: Real ,
725
+ circular_buffer = true ;
726
+ name)
727
+ SampledData (SampledDataType. vector_based; name, buffer, sample_time, circular_buffer)
728
+ end
729
+ function SampledData (; name, buffer, sample_time, circular_buffer)
730
+ SampledData (SampledDataType. vector_based; name, buffer, sample_time, circular_buffer)
731
+ end
0 commit comments