Skip to content

Commit b60be79

Browse files
BenChungAayushSabharwal
authored andcommitted
Redefine the discrete_compile interface a bit
1 parent c081a34 commit b60be79

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/systems/systemstructure.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,9 @@ function mtkcompile!(state::TearingState; simplify = false,
897897
inputs = Any[], outputs = Any[],
898898
disturbance_inputs = Any[],
899899
kwargs...)
900+
# split_system returns one or two systems and the inputs for each
901+
# mod clock inference to be binary
902+
# if it's continous keep going, if not then error unless given trait impl in additional passes
900903
ci = ModelingToolkit.ClockInference(state)
901904
ci = ModelingToolkit.infer_clocks!(ci)
902905
time_domains = merge(Dict(state.fullvars .=> ci.var_domain),
@@ -910,7 +913,7 @@ function mtkcompile!(state::TearingState; simplify = false,
910913
discrete_pass_idx = findfirst(discrete_compile_pass, additional_passes)
911914
discrete_compile = additional_passes[discrete_pass_idx]
912915
deleteat!(additional_passes, discrete_pass_idx)
913-
return discrete_compile(tss, clocked_inputs)
916+
return discrete_compile(tss, clocked_inputs, ci)
914917
end
915918
throw(HybridSystemNotSupportedException("""
916919
Discrete systems with multiple clocks are not supported with the standard \
@@ -931,7 +934,7 @@ function mtkcompile!(state::TearingState; simplify = false,
931934
deleteat!(additional_passes, discrete_pass_idx)
932935
# in the case of a hybrid system, the discrete_compile pass should take the currents of sys.discrete_subsystems
933936
# and modifies discrete_subsystems to bea tuple of the io and anything else, while adding or manipulating the rest of sys as needed
934-
return discrete_compile(sys, tss[2:end], inputs)
937+
return discrete_compile(sys, tss[[i for i in eachindex(tss) if i != continuous_id]], clocked_inputs, ci)
935938
end
936939
throw(HybridSystemNotSupportedException("""
937940
Hybrid continuous-discrete systems are currently not supported with \

0 commit comments

Comments
 (0)