pyedb 0.42.0__py3-none-any.whl → 0.43.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyedb might be problematic. Click here for more details.

@@ -50,9 +50,126 @@ class CfgLayer(CfgBase):
50
50
 
51
51
 
52
52
  class CfgStackup:
53
+ class Grpc:
54
+ def __init__(self, parent):
55
+ self.parent = parent
56
+ self._pedb = parent._pedb
57
+
58
+ def apply(self):
59
+ """Apply configuration settings to the current design"""
60
+ if len(self.parent.materials):
61
+ self.__apply_materials()
62
+
63
+ input_signal_layers = [i for i in self.parent.layers if i.type.lower() == "signal"]
64
+
65
+ if len(self.parent.layers):
66
+ if len(self._pedb.stackup.signal_layers) == 0:
67
+ self.__create_stackup()
68
+ elif not len(input_signal_layers) == len(self._pedb.stackup.signal_layers):
69
+ raise Exception(f"Input signal layer count do not match.")
70
+ else:
71
+ self.__apply_layers()
72
+
73
+ def __create_stackup(self):
74
+ layers = list()
75
+ layers.extend(self.parent.layers)
76
+ for l_attrs in layers:
77
+ attrs = l_attrs.get_attributes()
78
+ self._pedb.stackup.add_layer_bottom(**attrs)
79
+
80
+ def __apply_layers(self):
81
+ """Apply layer settings to the current design"""
82
+ layers = list()
83
+ layers.extend(self.parent.layers)
84
+
85
+ removal_list = []
86
+ lc_signal_layers = []
87
+ for name, obj in self._pedb.stackup.all_layers.items():
88
+ if obj.type == "dielectric":
89
+ removal_list.append(name)
90
+ elif obj.type == "signal":
91
+ lc_signal_layers.append(obj.id)
92
+ for l in removal_list:
93
+ self._pedb.stackup.remove_layer(l)
94
+
95
+ # update all signal layers
96
+ id_name = {i[0]: i[1] for i in self._pedb.stackup.layers_by_id}
97
+ signal_idx = 0
98
+ for l in layers:
99
+ if l.type == "signal":
100
+ layer_id = lc_signal_layers[signal_idx]
101
+ layer_name = id_name[layer_id]
102
+ attrs = l.get_attributes()
103
+ self._pedb.stackup.layers[layer_name].update(**attrs)
104
+ signal_idx = signal_idx + 1
105
+
106
+ # add all dielectric layers. Dielectric layers must be added last. Otherwise,
107
+ # dielectric layer will occupy signal and document layer id.
108
+ prev_layer_clone = None
109
+ l = layers.pop(0)
110
+ if l.type == "signal":
111
+ prev_layer_clone = self._pedb.stackup.layers[l.name]
112
+ else:
113
+ attrs = l.get_attributes()
114
+ prev_layer_clone = self._pedb.stackup.add_layer_top(**attrs)
115
+ for idx, l in enumerate(layers):
116
+ if l.type == "dielectric":
117
+ attrs = l.get_attributes()
118
+ prev_layer_clone = self._pedb.stackup.add_layer_below(
119
+ base_layer_name=prev_layer_clone.name, **attrs
120
+ )
121
+ elif l.type == "signal":
122
+ prev_layer_clone = self._pedb.stackup.layers[l.name]
123
+
124
+ def __apply_materials(self):
125
+ """Apply material settings to the current design"""
126
+ materials_in_db = {i.lower(): i for i, _ in self._pedb.materials.materials.items()}
127
+ for mat_in_cfg in self.parent.materials:
128
+ if mat_in_cfg.name.lower() in materials_in_db:
129
+ self._pedb.materials.delete_material(materials_in_db[mat_in_cfg.name.lower()])
130
+
131
+ attrs = mat_in_cfg.get_attributes()
132
+ mat = self._pedb.materials.add_material(**attrs)
133
+
134
+ def get_materials_from_db(self):
135
+ materials = []
136
+ for name, p in self._pedb.materials.materials.items():
137
+ mat = {}
138
+ for p_name in CfgMaterial().__dict__:
139
+ mat[p_name] = getattr(p, p_name)
140
+ materials.append(mat)
141
+ return materials
142
+
143
+ def get_layers_from_db(self):
144
+ layers = []
145
+ for name, obj in self._pedb.stackup.all_layers.items():
146
+ layers.append(obj.properties)
147
+ return layers
148
+
149
+ def get_data_from_db(self):
150
+ """Get configuration data from layout.
151
+
152
+ Returns
153
+ -------
154
+ dict
155
+ """
156
+ stackup = {}
157
+ materials = self.get_materials_from_db()
158
+ stackup["materials"] = materials
159
+ layers = self.get_layers_from_db()
160
+ stackup["layers"] = layers
161
+ return stackup
162
+
163
+ class DotNet(Grpc):
164
+ def __init__(self, parent):
165
+ super().__init__(parent)
166
+
53
167
  def __init__(self, pedb: Edb, data):
54
168
  self._pedb = pedb
55
-
169
+ if self._pedb.grpc:
170
+ self.api = self.Grpc(self)
171
+ else:
172
+ self.api = self.DotNet(self)
56
173
  self.materials = [CfgMaterial(**mat) for mat in data.get("materials", [])]
57
174
  self.layers = [CfgLayer(**lay) for lay in data.get("layers", [])]
58
175
 
@@ -77,93 +194,13 @@ class CfgStackup:
77
194
  materials.append(i.material)
78
195
 
79
196
  def apply(self):
80
- """Apply configuration settings to the current design"""
81
- if len(self.materials):
82
- self.__apply_materials()
83
-
84
- input_signal_layers = [i for i in self.layers if i.type.lower() == "signal"]
85
-
86
- if len(self.layers):
87
- if len(self._pedb.stackup.signal_layers) == 0:
88
- self.__create_stackup()
89
- elif not len(input_signal_layers) == len(self._pedb.stackup.signal_layers):
90
- raise Exception(f"Input signal layer count do not match.")
91
- else:
92
- self.__apply_layers()
93
-
94
- def __create_stackup(self):
95
- layers = list()
96
- layers.extend(self.layers)
97
- for l_attrs in layers:
98
- attrs = l_attrs.get_attributes()
99
- self._pedb.stackup.add_layer_bottom(**attrs)
100
-
101
- def __apply_layers(self):
102
- """Apply layer settings to the current design"""
103
- layers = list()
104
- layers.extend(self.layers)
105
-
106
- removal_list = []
107
- lc_signal_layers = []
108
- for name, obj in self._pedb.stackup.all_layers.items():
109
- if obj.type == "dielectric":
110
- removal_list.append(name)
111
- elif obj.type == "signal":
112
- lc_signal_layers.append(obj.id)
113
- for l in removal_list:
114
- self._pedb.stackup.remove_layer(l)
115
-
116
- # update all signal layers
117
- id_name = {i[0]: i[1] for i in self._pedb.stackup.layers_by_id}
118
- signal_idx = 0
119
- for l in layers:
120
- if l.type == "signal":
121
- layer_id = lc_signal_layers[signal_idx]
122
- layer_name = id_name[layer_id]
123
- attrs = l.get_attributes()
124
- self._pedb.stackup.layers[layer_name].update(**attrs)
125
- signal_idx = signal_idx + 1
126
-
127
- # add all dielectric layers. Dielectric layers must be added last. Otherwise,
128
- # dielectric layer will occupy signal and document layer id.
129
- prev_layer_clone = None
130
- l = layers.pop(0)
131
- if l.type == "signal":
132
- prev_layer_clone = self._pedb.stackup.layers[l.name]
133
- else:
134
- attrs = l.get_attributes()
135
- prev_layer_clone = self._pedb.stackup.add_layer_top(**attrs)
136
- for idx, l in enumerate(layers):
137
- if l.type == "dielectric":
138
- attrs = l.get_attributes()
139
- prev_layer_clone = self._pedb.stackup.add_layer_below(base_layer_name=prev_layer_clone.name, **attrs)
140
- elif l.type == "signal":
141
- prev_layer_clone = self._pedb.stackup.layers[l.name]
142
-
143
- def __apply_materials(self):
144
- """Apply material settings to the current design"""
145
- materials_in_db = {i.lower(): i for i, _ in self._pedb.materials.materials.items()}
146
- for mat_in_cfg in self.materials:
147
- if mat_in_cfg.name.lower() in materials_in_db:
148
- self._pedb.materials.delete_material(materials_in_db[mat_in_cfg.name.lower()])
149
-
150
- attrs = mat_in_cfg.get_attributes()
151
- mat = self._pedb.materials.add_material(**attrs)
197
+ self.api.apply()
152
198
 
153
199
  def get_materials_from_db(self):
154
- materials = []
155
- for name, p in self._pedb.materials.materials.items():
156
- mat = {}
157
- for p_name in CfgMaterial().__dict__:
158
- mat[p_name] = getattr(p, p_name)
159
- materials.append(mat)
160
- return materials
200
+ return self.api.get_materials_from_db()
161
201
 
162
202
  def get_layers_from_db(self):
163
- layers = []
164
- for name, obj in self._pedb.stackup.all_layers.items():
165
- layers.append(obj.properties)
166
- return layers
203
+ return self.api.get_layers_from_db()
167
204
 
168
205
  def get_data_from_db(self):
169
206
  """Get configuration data from layout.
@@ -172,9 +209,4 @@ class CfgStackup:
172
209
  -------
173
210
  dict
174
211
  """
175
- stackup = {}
176
- materials = self.get_materials_from_db()
177
- stackup["materials"] = materials
178
- layers = self.get_layers_from_db()
179
- stackup["layers"] = layers
180
- return stackup
212
+ return self.api.get_data_from_db()