13
13
ODESystem (Equation[], t, [x], [p], defaults= Dict (x=> 1.0 , p=> 1.0 ))
14
14
end
15
15
16
- ModelingToolkit. connect (:: Type{<:Foo} , sys1, sys2) = [sys1. x ~ sys2. x]
16
+ function ModelingToolkit. connect (:: Type{<:Foo} , ss... )
17
+ n = length (ss)- 1
18
+ eqs = Vector {Equation} (undef, n)
19
+ for i in 1 : n
20
+ eqs[i] = ss[i]. x ~ ss[i+ 1 ]. x
21
+ end
22
+ eqs
23
+ end
24
+
17
25
@named f1 = Foo ()
18
26
@named f2 = Foo ()
27
+ @named f3 = Foo ()
28
+ @named f4 = Foo ()
19
29
@named g = Goo ()
20
30
21
31
@test isequal (connect (f1, f2), [f1. x ~ f2. x])
@@ -24,6 +34,9 @@ ModelingToolkit.connect(::Type{<:Foo}, sys1, sys2) = [sys1.x ~ sys2.x]
24
34
# Note that since there're overloadings, these tests are not re-runable.
25
35
ModelingToolkit. promote_connect_rule (:: Type{<:Foo} , :: Type{<:Goo} ) = Foo
26
36
@test isequal (connect (f1, g), [f1. x ~ g. x])
37
+ @test isequal (connect (f1, f2, g), [f1. x ~ f2. x; f2. x ~ g. x])
38
+ @test isequal (connect (f1, f2, g, f3), [f1. x ~ f2. x; f2. x ~ g. x; g. x ~ f3. x])
39
+ @test isequal (connect (f1, f2, g, f3, f4), [f1. x ~ f2. x; f2. x ~ g. x; g. x ~ f3. x; f3. x ~ f4. x])
27
40
ModelingToolkit. promote_connect_rule (:: Type{<:Goo} , :: Type{<:Foo} ) = Foo
28
41
@test isequal (connect (f1, g), [f1. x ~ g. x])
29
42
# test conflict
0 commit comments