@@ -7,6 +7,30 @@ using Unitful
7
7
8
8
ENV [" MTK_ICONS_DIR" ] = " $(@__DIR__ ) /icons"
9
9
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
+
10
34
@connector RealInput begin
11
35
u (t), [input = true , unit = u " V" ]
12
36
end
28
52
@variables t [unit = u " s" ]
29
53
D = Differential (t)
30
54
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
-
37
55
@named p = Pin (; v = π)
38
56
@test getdefault (p. v) == π
39
57
@test Pin. isconnector == true
57
75
58
76
@test OnePort. isconnector == false
59
77
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
-
70
78
resistor_log = " $(@__DIR__ ) /logo/resistor.svg"
71
79
@mtkmodel Resistor begin
72
80
@extend v, i = oneport = OnePort ()
127
135
capacitor = Capacitor (; C = C_val)
128
136
source = Voltage ()
129
137
constant = Constant (; k = k_val)
130
- ground = Ground ()
138
+ ground = MyMockModule . Ground ()
131
139
end
132
140
133
141
@equations begin
0 commit comments