Commit 1f5aa39
authored
Add module to easily create component graphs (#606)
This adds a module that allows the easy creation of component graphs.
Here is a simple example:
```python
gen = GraphGenerator()
# Pre-create a battery component to refer to it later or to use it in multiple
# places in the graph.
special_bat = gen.component(ComponentCategory.BATTERY)
graph = gen.to_graph(
(
ComponentCategory.METER, # grid side meter
[ # list of components connected to grid side meter
(
ComponentCategory.METER, # Meter in front of battery->inverter
( # A tuple, first is connected to parent, second is the child of the first
# Inverter in front of battery, type will be
# set to InverterType.BATTERY
ComponentCategory.INVERTER,
ComponentCategory.BATTERY, # Battery
),
),
(
ComponentCategory.METER,
(
# Inverter in front of battery, type will be
# set to InverterType.BATTERY
ComponentCategory.INVERTER,
special_bat, # Pre-created battery
),
),
],
)
)
```
it's not actually used yet, but I plan to do that for the n:m
battery:inverter
issue.
It also updates the MockMicrogrid to accept such graphs as parameter.
I suspect that part will receive some more udpates and fixes as I use it
more.2 files changed
+392
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | | - | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | | - | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
79 | 94 | | |
80 | | - | |
81 | | - | |
| 95 | + | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
96 | 146 | | |
97 | 147 | | |
98 | 148 | | |
| |||
0 commit comments