Skip to content

Commit b82ca64

Browse files
refactor: change ::TimeDomain methods to ::Clocks.Type, add fallbacks
1 parent 4d2af81 commit b82ca64

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/clock.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,29 @@ discrete-time systems that assume a fixed sample time, such as PID controllers a
4747
filters.
4848
""" SolverStepClock
4949

50-
isclock(c::TimeDomain) = @match c begin
50+
isclock(c::Clocks.Type) = @match c begin
5151
PeriodicClock() => true
5252
_ => false
5353
end
54+
isclock(::TimeDomain) = false
5455

55-
issolverstepclock(c::TimeDomain) = @match c begin
56+
issolverstepclock(c::Clocks.Type) = @match c begin
5657
SolverStepClock() => true
5758
_ => false
5859
end
60+
issolverstepclock(::TimeDomain) = false
5961

60-
iscontinuous(c::TimeDomain) = @match c begin
62+
iscontinuous(c::Clocks.Type) = @match c begin
6163
ContinuousClock() => true
6264
_ => false
6365
end
66+
iscontinuous(::TimeDomain) = false
6467

65-
iseventclock(c::TimeDomain) = @match c begin
68+
iseventclock(c::Clocks.Type) = @match c begin
6669
EventClock() => true
6770
_ => false
6871
end
72+
iseventclock(::TimeDomain) = false
6973

7074
is_discrete_time_domain(c::TimeDomain) = !iscontinuous(c)
7175

@@ -77,7 +81,7 @@ iseventclock(::Any) = false
7781
is_discrete_time_domain(::Any) = false
7882

7983
# public
80-
function first_clock_tick_time(c, t0)
84+
function first_clock_tick_time(c::Clocks.Type, t0)
8185
@match c begin
8286
PeriodicClock(dt) => ceil(t0 / dt) * dt
8387
SolverStepClock() => t0
@@ -87,6 +91,10 @@ function first_clock_tick_time(c, t0)
8791
end
8892
end
8993

94+
function first_clock_tick_time(c::TimeDomain, _)
95+
error("Unimplemented for clock $c")
96+
end
97+
9098
# public
9199
"""
92100
$(TYPEDEF)

0 commit comments

Comments
 (0)