Commits

saar drimer committed 55936ce

re-defined meandering definitions

  • Participants
  • Parent commits 322e3f4

Comments (0)

Files changed (3)

File utils/extract.py

     for layer in utils.get_surface_layers(cfg):
         routing[layer] = {}
         for i, path in enumerate(svg_in.xpath(xpath_expr % layer, namespaces={'inkscape':cfg['namespace']['inkscape'], 'svg':cfg['namespace']['svg']})):
+
+            generated_path = None
+
             routing[layer][str(i)] = {}
             rd = svg.absolute_to_relative_path(path.get('d'))
             gerber_lp = path.get('gerber_lp')
             if path_style is not None:
                 routing[layer][str(i)]['style'] = path_style
 
+            print pcbmode_params
+
             if pcbmode_params is not None:
-                pt = re.match('^\s*([^:]*)', pcbmode_params)
-                if pt.group(0).lower() == 'meander':
-                    # creates a meander SVG path
-                    meander_params = utils.process_meander_type(pcbmode_params)
-                    generated_path = svg.create_meandering_path(meander_params)
+                print 'XXX', pcbmode_params
+                trace_type = re.match('type\s*:\s*([^;]*)', pcbmode_params)
+                trace_type = trace_type.group(1).lower()
+                meander_params = utils.process_meander_type(pcbmode_params, trace_type)
+                generated_path = svg.create_meandering_path(meander_params)
                 routing[layer][str(i)]['pcbmode'] = pcbmode_params
 
 
                             generated_paths[inkparam.lstrip('#')] = generated_path
 
 
-            generated_path = None
+
 
     # add path-effects to routing file
     path_effects = svg_in.xpath("//inkscape:path-effect", namespaces={'inkscape':cfg['namespace']['inkscape']})

File utils/svg.py

 
     deg_to_rad = 2 * pi / 360
 
-    radius = params.get('radius')
+    radius = params.get('radius') 
     theta = params.get('theta')
-    width = params.get('width')
-    number = params.get('number') or 1
-    if number is None:
-        number = 1
-    pitch = params.get('pitch')
+    width = params.get('trace-width')
+    number = params.get('bus-width') or 1
+    pitch = params.get('pitch') or 0
 
     coords = []
     coords.append(Point(0, -(number-1)*pitch/2))
-    for n in range(1,int(number)):
+    for n in range(1, int(number)):
         coords.append(Point(2*radius*cos(theta*deg_to_rad), pitch))
 
     path = ''
 
     for coord in coords:
-        path += create_meander(radius, theta, coord)
+        path += create_round_meander(radius, theta, coord)
 
     return path
 
 
 
 
-def create_meander(radius, theta=0, offset=Point()):
+def create_round_meander(radius, theta=0, offset=Point()):
     """
     Returns a single period of a meandering path based on radius
     and angle theta

File utils/utils.py

 
 
 
-def process_meander_type(type_string):
+def process_meander_type(type_string, meander_type):
     """
     Extract meander path type parameters and return them as a dict
     """
 
-    look_for = ['radius', 'theta', 'width', 'number', 'pitch']
+    if (meander_type == 'meander-round'):
+        look_for = ['radius', 'theta', 'bus-width', 'pitch']
+    elif (meander_type == 'meander-sawtooth'):
+        look_for = ['base-length', 'amplitude', 'bus-width', 'pitch']
+    else:
+        print "ERROR: unrecognised meander type"
+        reaise
 
     meander = {}
 
+    regex = '\s*%s\s*:\s*(?P<v>[^;]*)'
+
     for param in look_for:
-        tmp = re.search('\s*%s\s*=\s*(?P<v>[^;]*)' % param, type_string)
+        tmp = re.search(regex % param, type_string)
         if tmp is not None:
             meander[param] = float(tmp.group('v'))