Skip to content

Commit d0b4c5a

Browse files
BenChungAayushSabharwal
authored andcommitted
Redefine the discrete_compile interface a bit
1 parent 25fb131 commit d0b4c5a

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
@@ -899,6 +899,9 @@ function mtkcompile!(state::TearingState; simplify = false,
899899
inputs = Any[], outputs = Any[],
900900
disturbance_inputs = Any[],
901901
kwargs...)
902+
# split_system returns one or two systems and the inputs for each
903+
# mod clock inference to be binary
904+
# if it's continous keep going, if not then error unless given trait impl in additional passes
902905
ci = ModelingToolkit.ClockInference(state)
903906
ci = ModelingToolkit.infer_clocks!(ci)
904907
time_domains = merge(Dict(state.fullvars .=> ci.var_domain),
@@ -912,7 +915,7 @@ function mtkcompile!(state::TearingState; simplify = false,
912915
discrete_pass_idx = findfirst(discrete_compile_pass, additional_passes)
913916
discrete_compile = additional_passes[discrete_pass_idx]
914917
deleteat!(additional_passes, discrete_pass_idx)
915-
return discrete_compile(tss, clocked_inputs)
918+
return discrete_compile(tss, clocked_inputs, ci)
916919
end
917920
throw(HybridSystemNotSupportedException("""
918921
Discrete systems with multiple clocks are not supported with the standard \
@@ -933,7 +936,7 @@ function mtkcompile!(state::TearingState; simplify = false,
933936
deleteat!(additional_passes, discrete_pass_idx)
934937
# in the case of a hybrid system, the discrete_compile pass should take the currents of sys.discrete_subsystems
935938
# and modifies discrete_subsystems to bea tuple of the io and anything else, while adding or manipulating the rest of sys as needed
936-
return discrete_compile(sys, tss[2:end], inputs)
939+
return discrete_compile(sys, tss[[i for i in eachindex(tss) if i != continuous_id]], clocked_inputs, ci)
937940
end
938941
throw(HybridSystemNotSupportedException("""
939942
Hybrid continuous-discrete systems are currently not supported with \

0 commit comments

Comments
 (0)