circuitdata 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +25 -122
  3. data/Rakefile +4 -6
  4. data/lib/circuitdata.rb +32 -120
  5. data/lib/circuitdata/bury/bury.rb +61 -0
  6. data/lib/circuitdata/dereferencer.rb +49 -17
  7. data/lib/circuitdata/exposed_area.rb +84 -0
  8. data/lib/circuitdata/json_schema.rb +14 -0
  9. data/lib/circuitdata/json_validator.rb +56 -0
  10. data/lib/circuitdata/json_validator/json_schema_error_parser.rb +57 -0
  11. data/lib/circuitdata/material_validator.rb +40 -0
  12. data/lib/circuitdata/product.rb +125 -0
  13. data/lib/circuitdata/product_id_validator.rb +81 -0
  14. data/lib/circuitdata/profile.rb +31 -69
  15. data/lib/circuitdata/schema.rb +145 -0
  16. data/lib/circuitdata/schema_files/schema_v1_dereferenced.json +107155 -0
  17. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema.json +68 -5307
  18. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_generics.json +23 -0
  19. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_materials.json +99 -0
  20. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_products.json +779 -0
  21. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_profiles_and_capabilities.json +323 -0
  22. data/lib/circuitdata/summary.rb +96 -0
  23. data/lib/circuitdata/validator.rb +28 -0
  24. data/lib/circuitdata/version.rb +2 -1
  25. metadata +113 -20
  26. data/lib/circuitdata/bk_comparer.rb +0 -106
  27. data/lib/circuitdata/compatibility_checker.rb +0 -160
  28. data/lib/circuitdata/file_comparer.rb +0 -276
  29. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_schema_definitions.json +0 -1249
  30. data/lib/circuitdata/schema_files/v1/ottp_circuitdata_skeleton_schema.json +0 -94
  31. data/lib/circuitdata/schema_files/v1/ottp_schema_definitions.json +0 -102
  32. data/lib/circuitdata/tools.rb +0 -207
@@ -0,0 +1,323 @@
1
+ {
2
+ "version": {
3
+ "$ref": "ottp_circuitdata_schema_generics.json#/version"
4
+ },
5
+ "sections": {
6
+ "type": "object",
7
+ "required": [],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "count": { "type": "integer" },
11
+ "mm2": { "type": "number" }
12
+ }
13
+ },
14
+ "layers": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "properties": {
18
+ "none": {
19
+ "$ref": "#/layer_function"
20
+ },
21
+ "conductive": {
22
+ "$ref": "#/layer_function"
23
+ },
24
+ "dielectric": {
25
+ "$ref": "#/layer_function"
26
+ },
27
+ "soldermask": {
28
+ "$ref": "#/layer_function"
29
+ },
30
+ "stiffener": {
31
+ "$ref": "#/layer_function"
32
+ },
33
+ "plating": {
34
+ "$ref": "#/layer_function"
35
+ },
36
+ "adhesive": {
37
+ "$ref": "#/layer_function"
38
+ },
39
+ "thermal": {
40
+ "$ref": "#/layer_function"
41
+ },
42
+ "legend": {
43
+ "$ref": "#/layer_function"
44
+ },
45
+ "final_finish": {
46
+ "$ref": "#/layer_function"
47
+ },
48
+ "peelable_tape": {
49
+ "$ref": "#/layer_function"
50
+ },
51
+ "peelable_mask": {
52
+ "$ref": "#/layer_function"
53
+ },
54
+ "hard_gold": {
55
+ "$ref": "#/layer_function"
56
+ },
57
+ "solder_paste": {
58
+ "$ref": "#/layer_function"
59
+ }
60
+ }
61
+ },
62
+ "processes": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "properties": {
66
+ "edge_bevelling": {
67
+ "$ref": "#/process_function"
68
+ },
69
+ "depth_routing": {
70
+ "$ref": "#/process_function"
71
+ },
72
+ "counterboring": {
73
+ "$ref": "#/process_function"
74
+ },
75
+ "countersink": {
76
+ "$ref": "#/process_function"
77
+ },
78
+ "punching": {
79
+ "$ref": "#/process_function"
80
+ },
81
+ "plating": {
82
+ "$ref": "#/process_function"
83
+ },
84
+ "plated_edges": {
85
+ "$ref": "#/process_function"
86
+ },
87
+ "plated_slots": {
88
+ "$ref": "#/process_function"
89
+ },
90
+ "coin_attachment": {
91
+ "$ref": "#/process_function"
92
+ },
93
+ "holes": {
94
+ "$ref": "#/process_function"
95
+ }
96
+ }
97
+ },
98
+ "metrics": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "properties": {
102
+ "board": {
103
+ "type": "object",
104
+ "additionalProperties": false,
105
+ "properties": {
106
+ "size_x": { "type": "number" },
107
+ "size_y": { "type": "number" },
108
+ "breakaway_method": {
109
+ "type": "string",
110
+ "enum": ["routing", "punching"]
111
+ },
112
+ "thickness": { "type": "number" }
113
+ }
114
+ },
115
+ "array": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "properties": {
119
+ "size_x": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
120
+ "size_y": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
121
+ "boards_x": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
122
+ "boards_y": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
123
+ "boards_total": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
124
+ "border_left": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
125
+ "border_right": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
126
+ "border_top": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
127
+ "border_bottom": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
128
+ "board_spacing_x": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
129
+ "board_spacing_y": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
130
+ "fiducials_number": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
131
+ "fiducials_size": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
132
+ "fiducials_shape": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
133
+ "breakaway_method": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
134
+ "mouse_bites": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
135
+ "tooling_holes_number": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
136
+ "tooling_holes_size": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
137
+ "x_outs_allowed": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
138
+ "x_outs_max_percentage_on_array": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
139
+ "transplant_board_allowed": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
140
+ }
141
+ }
142
+ }
143
+ },
144
+ "logistical": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "properties": {
148
+ "inner_packaging": {
149
+ "type": "object",
150
+ "additionalProperties": false,
151
+ "properties": {
152
+ "ipc_1601_section_4_2_2_type": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
153
+ "hic": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
154
+ "esd": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
155
+ "desiccant": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
156
+ "vacuum": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
157
+ "maximum_number_of_arrays": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
158
+ }
159
+ }
160
+ }
161
+ },
162
+ "configuration": {
163
+ "type": "object",
164
+ "additionalProperties": false,
165
+ "properties": {
166
+ "markings": {
167
+ "type": "object",
168
+ "additionalProperties": false,
169
+ "properties": {
170
+ "layers": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
171
+ "date_code": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
172
+ "manufacturer_identification": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
173
+ "serial_number": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
174
+ "serial_number_format": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
175
+ }
176
+ },
177
+ "standards": {
178
+ "type": "object",
179
+ "additionalProperties": false,
180
+ "properties": {
181
+ "comply_with": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
182
+ "ipc_6010_class": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
183
+ "ipc_6010_compliance_level": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
184
+ "ipc_6010_copper_plating_thickness_level": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
185
+ "ipc_6010_annular_ring_level": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
186
+ "ipc_6010_conductor_spacing_level": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
187
+ "ipc_6010_conductor_width_level": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
188
+ "ipc_6012_class": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
189
+ "ipc_6013_class": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
190
+ "ipc_6018": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
191
+ }
192
+ },
193
+ "testing": {
194
+ "type": "object",
195
+ "additionalProperties": false,
196
+ "properties": {
197
+ "netlist": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
198
+ "allow_generate_netlist": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
199
+ "hipot": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
200
+ "4_wire": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
201
+ "ist": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
202
+ "impedance": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
203
+ }
204
+ },
205
+ "country_of_origin": {
206
+ "type": "object",
207
+ "additionalProperties": false,
208
+ "properties": {
209
+ "iso_3166_1_alpha_3": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
210
+ "iso_3166_1_alpha_2": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
211
+ "nato_member": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
212
+ "eu_member": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
213
+ }
214
+ },
215
+ "allowed_modifications": {
216
+ "type": "object",
217
+ "additionalProperties": false,
218
+ "properties": {
219
+ "dead_pad_removal": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
220
+ "add_copper_balancing": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
221
+ "add_copper_balancing_on_array": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
222
+ "add_tear_drops": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
223
+ "resize_vias": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
224
+ }
225
+ }
226
+ }
227
+ },
228
+ "layer_function": {
229
+ "type": "object",
230
+ "additionalProperties": false,
231
+ "properties": {
232
+ "flexible": {
233
+ "type": "object",
234
+ "additionalProperties": false,
235
+ "properties": {
236
+ "true": {
237
+ "$ref": "#/layer_flexibility"
238
+ },
239
+ "false": {
240
+ "$ref": "#/layer_flexibility"
241
+ }
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "process_function": {
247
+ "type": "object",
248
+ "additionalProperties": false,
249
+ "properties": {
250
+ "hole_type": {
251
+ "type": "object",
252
+ "properties": {
253
+ "through": {
254
+ "$ref": "#/hole_type"
255
+ },
256
+ "blind": {
257
+ "$ref": "#/hole_type"
258
+ },
259
+ "buried": {
260
+ "$ref": "#/hole_type"
261
+ },
262
+ "back_drill": {
263
+ "$ref": "#/hole_type"
264
+ },
265
+ "via": {
266
+ "$ref": "#/hole_type"
267
+ }
268
+ }
269
+ }
270
+ }
271
+ },
272
+ "hole_type": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": [],
276
+ "properties": {
277
+ "tool_size": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
278
+ "depth": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
279
+ "method": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
280
+ "minimum_designed_annular_ring": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
281
+ "press_fit": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
282
+ "plated": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
283
+ "capped": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
284
+ "filled": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
285
+ "covered": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
286
+ "staggered": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
287
+ "stacked": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
288
+ "alivh": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
289
+ "castellated": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
290
+ }
291
+ },
292
+ "layer_flexibility": {
293
+ "type": "object",
294
+ "required": ["material"],
295
+ "additionalProperties": false,
296
+ "properties": {
297
+ "material": {
298
+ "type": "object",
299
+ "additionalProperties": false,
300
+ "patternProperties": {
301
+ ".*": {
302
+ "type": "object",
303
+ "additionalProperties": false,
304
+ "properties": {
305
+ "count": { "type": "integer" },
306
+ "thickness": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
307
+ "tolerance_minus": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
308
+ "tolerance_plus": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
309
+ "minimum_track_width": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
310
+ "minimum_spacing_width": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
311
+ "function": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
312
+ "polarity": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
313
+ "color": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
314
+ "allow_touchups": { "type": "boolean" },
315
+ "heating_operations": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" },
316
+ "placement": { "$ref": "ottp_circuitdata_schema_generics.json#/profile_capability_layer_subelement" }
317
+ }
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }
@@ -0,0 +1,96 @@
1
+ require 'bigdecimal'
2
+ module Circuitdata
3
+ class Summary
4
+
5
+ SUMMARY_FIELDS = [
6
+ :base_materials,
7
+ :number_of_conductive_layers,
8
+ :board_outline,
9
+ :final_thickness,
10
+ :minimum_track,
11
+ :minimum_spacing,
12
+ :min_through_hole_size,
13
+ :max_aspect_ratio
14
+ ]
15
+
16
+ def initialize(product)
17
+ @product = product
18
+ end
19
+
20
+ def data
21
+ d = {}
22
+ SUMMARY_FIELDS.each do |key|
23
+ d[key] = send(key)
24
+ end
25
+ d
26
+ end
27
+
28
+ private
29
+
30
+ # helper functions
31
+ def conductive_layers
32
+ layers_with_function("conductive")
33
+ end
34
+
35
+ def board_area
36
+ # try adding up all sections
37
+ sizes = @product.sections.map{|section| section[:mm2]}
38
+ sizes.compact.inject(0, :+)
39
+ end
40
+
41
+ def layers_with_function(func)
42
+ @product.layers.select{ |layer| layer[:function] == func}
43
+ end
44
+
45
+ # mapping
46
+ def base_materials
47
+ dielectrics = layers_with_function("dielectric")
48
+ return nil if dielectrics.length == 0
49
+ flexes = dielectrics.map{|d| d.dig(:flexible)}.compact.uniq
50
+ return "Flexible" if flexes === [true]
51
+ return "Rigid" if flexes === [false]
52
+ return "Rigid Flex" if flexes.length == 2
53
+ return "Unknown" # dielectric is present, but does not have flex info.
54
+ end
55
+
56
+ # Return number of conductive layers
57
+ def number_of_conductive_layers
58
+ if conductive_layers.length > 0
59
+ return conductive_layers.length
60
+ end
61
+ end
62
+
63
+ def minimum_track
64
+ conductive_layers.map { |layer| layer.dig(:layer_attributes, :minimum_track_width)}.compact.min
65
+ end
66
+
67
+ def minimum_spacing
68
+ conductive_layers.map { |layer| layer.dig(:layer_attributes, :minimum_spacing_width)}.compact.min
69
+ end
70
+
71
+ def board_outline
72
+ array = @product.metrics.fetch(:board, {})
73
+ size_x = array[:size_x]
74
+ size_y = array[:size_y]
75
+ return size_x.to_s+" x "+size_y.to_s+" mm" if size_x && size_y
76
+ end
77
+
78
+ def final_thickness
79
+ @product.metrics.dig(:board, :thickness)
80
+ end
81
+
82
+ def min_through_hole_size
83
+ @product.processes.map{ |process| process.dig(:function_attributes,:finished_size)}.compact.min
84
+ end
85
+
86
+ def max_aspect_ratio
87
+ if final_thickness
88
+ if min_through_hole_size
89
+ th = BigDecimal(min_through_hole_size.to_s)/1000.0
90
+ ft = BigDecimal(final_thickness.to_s)
91
+ return (ft/th).truncate(2).to_s.to_f
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,28 @@
1
+ module Circuitdata
2
+ class Validator
3
+ attr_reader :errors
4
+
5
+ def initialize(data)
6
+ @data = data
7
+ end
8
+
9
+ def valid?
10
+ return @valid if defined? @valid
11
+ @valid = run_schema_checks && run_logic_checks
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :data, :schema
17
+
18
+ def run_schema_checks
19
+ @errors = JsonValidator.validate(Circuitdata.dereferenced_schema, data)
20
+ @errors.empty?
21
+ end
22
+
23
+ def run_logic_checks
24
+ @errors = ProductIdValidator.validate(data)
25
+ @errors.empty?
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,4 @@
1
1
  module Circuitdata
2
- VERSION = '0.6.4'
2
+ VERSION = "0.7.0"
3
+ SCHEMA_VERSION = 1.0
3
4
  end