@@ -7,6 +7,30 @@ using Unitful
77
88ENV [" MTK_ICONS_DIR" ] = " $(@__DIR__ ) /icons"
99
10+ # Mock module used to test if the `@mtkmodel` macro works with fully-qualified names as well.
11+ module MyMockModule
12+ using .. ModelingToolkit, .. Unitful
13+
14+ export Pin
15+ @connector Pin begin
16+ v (t), [unit = u " V" ] # Potential at the pin [V]
17+ i (t), [connect = Flow, unit = u " A" ] # Current flowing into the pin [A]
18+ @icon " pin.png"
19+ end
20+
21+ @mtkmodel Ground begin
22+ @components begin
23+ g = Pin ()
24+ end
25+ @icon read (abspath (ENV [" MTK_ICONS_DIR" ], " ground.svg" ), String)
26+ @equations begin
27+ g. v ~ 0
28+ end
29+ end
30+ end
31+
32+ using . MyMockModule
33+
1034@connector RealInput begin
1135 u (t), [input = true , unit = u " V" ]
1236end
2852@variables t [unit = u " s" ]
2953D = Differential (t)
3054
31- @connector Pin begin
32- v (t), [unit = u " V" ] # Potential at the pin [V]
33- i (t), [connect = Flow, unit = u " A" ] # Current flowing into the pin [A]
34- @icon " pin.png"
35- end
36-
3755@named p = Pin (; v = π)
3856@test getdefault (p. v) == π
3957@test Pin. isconnector == true
5775
5876@test OnePort. isconnector == false
5977
60- @mtkmodel Ground begin
61- @components begin
62- g = Pin ()
63- end
64- @icon read (abspath (ENV [" MTK_ICONS_DIR" ], " ground.svg" ), String)
65- @equations begin
66- g. v ~ 0
67- end
68- end
69-
7078resistor_log = " $(@__DIR__ ) /logo/resistor.svg"
7179@mtkmodel Resistor begin
7280 @extend v, i = oneport = OnePort ()
127135 capacitor = Capacitor (; C = C_val)
128136 source = Voltage ()
129137 constant = Constant (; k = k_val)
130- ground = Ground ()
138+ ground = MyMockModule . Ground ()
131139 end
132140
133141 @equations begin
0 commit comments