@@ -147,6 +147,29 @@ Returns true if the expression or equation `O` contains [`Hold`](@ref) terms.
147
147
"""
148
148
hashold (O) = recursive_hasoperator (Hold, unwrap (O))
149
149
150
+ # ClockChange
151
+
152
+ """
153
+ $(TYPEDEF)
154
+
155
+ Change the clock of a discrete-time variable by sub or super sampling
156
+ ```
157
+ cont_x = ClockChange(from, to)(disc_x)
158
+ ```
159
+ """
160
+ @kwdef struct ClockChange <: Operator
161
+ from:: Any
162
+ to:: Any
163
+ end
164
+ (D:: ClockChange )(x) = Term {symtype(x)} (D, Any[x])
165
+ (D:: ClockChange )(x:: Num ) = Num (D (value (x)))
166
+ SymbolicUtils. promote_symtype (:: ClockChange , x) = x
167
+
168
+ function Base.:(== )(D1:: ClockChange , D2:: ClockChange )
169
+ isequal (D1. to, D2. to) && isequal (D1. from, D2. from)
170
+ end
171
+ Base. hash (D:: ClockChange , u:: UInt ) = hash (D. from, hash (D. to, xor (u, 0xa5b640d6d952f101 )))
172
+
150
173
# ShiftIndex
151
174
152
175
"""
@@ -242,10 +265,14 @@ function input_timedomain(h::Hold, arg = nothing)
242
265
end
243
266
output_timedomain (:: Hold , arg = nothing ) = Continuous ()
244
267
268
+ input_timedomain (cc:: ClockChange , arg = nothing ) = cc. from
269
+ output_timedomain (cc:: ClockChange , arg = nothing ) = cc. to
270
+
245
271
sampletime (op:: Sample , arg = nothing ) = sampletime (op. clock)
246
272
sampletime (op:: ShiftIndex , arg = nothing ) = sampletime (op. clock)
273
+ sampletime (op:: ClockChange , arg = nothing ) = sampletime (op. to)
247
274
248
- changes_domain (op) = isoperator (op, Union{Sample, Hold})
275
+ changes_domain (op) = isoperator (op, Union{Sample, Hold, ClockChange })
249
276
250
277
function output_timedomain (x)
251
278
if isoperator (x, Operator)
0 commit comments