summaryrefslogtreecommitdiff
path: root/gerber/excellon_statements.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2015-11-13 03:38:57 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2015-11-13 03:38:57 -0200
commit6d8b5377a8624ca35bcf93fb0751bc5ebebfd126 (patch)
tree131276ffbead64fb10b1dba8306bdf2f34e195f9 /gerber/excellon_statements.py
parent944c8329222b8c1166a4952df0ca553cbec71505 (diff)
parent9ca75f991a240b0ea233382ff23264a009b0324e (diff)
downloadgerbonara-6d8b5377a8624ca35bcf93fb0751bc5ebebfd126.tar.gz
gerbonara-6d8b5377a8624ca35bcf93fb0751bc5ebebfd126.tar.bz2
gerbonara-6d8b5377a8624ca35bcf93fb0751bc5ebebfd126.zip
Merge pull request #42 from curtacircuitos/add-some-missing-excellon-stmts
Improve Excellon parsing coverage
Diffstat (limited to 'gerber/excellon_statements.py')
-rw-r--r--gerber/excellon_statements.py109
1 files changed, 104 insertions, 5 deletions
diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py
index fa05e53..2be7a05 100644
--- a/gerber/excellon_statements.py
+++ b/gerber/excellon_statements.py
@@ -31,24 +31,27 @@ __all__ = ['ExcellonTool', 'ToolSelectionStmt', 'CoordinateStmt',
'CommentStmt', 'HeaderBeginStmt', 'HeaderEndStmt',
'RewindStopStmt', 'EndOfProgramStmt', 'UnitStmt',
'IncrementalModeStmt', 'VersionStmt', 'FormatStmt', 'LinkToolStmt',
- 'MeasuringModeStmt', 'RouteModeStmt', 'DrillModeStmt',
+ 'MeasuringModeStmt', 'RouteModeStmt', 'LinearModeStmt', 'DrillModeStmt',
'AbsoluteModeStmt', 'RepeatHoleStmt', 'UnknownStmt',
- 'ExcellonStatement',]
+ 'ExcellonStatement', 'ZAxisRoutPositionStmt',
+ 'RetractWithClampingStmt', 'RetractWithoutClampingStmt',
+ 'CutterCompensationOffStmt', 'CutterCompensationLeftStmt',
+ 'CutterCompensationRightStmt', 'ZAxisInfeedRateStmt']
class ExcellonStatement(object):
""" Excellon Statement abstract base class
"""
-
+
@classmethod
def from_excellon(cls, line):
raise NotImplementedError('from_excellon must be implemented in a '
'subclass')
-
+
def __init__(self, unit='inch', id=None):
self.units = unit
self.id = uuid.uuid4().int if id is None else id
-
+
def to_excellon(self, settings=None):
raise NotImplementedError('to_excellon must be implemented in a '
'subclass')
@@ -266,6 +269,34 @@ class ToolSelectionStmt(ExcellonStatement):
return stmt
+class ZAxisInfeedRateStmt(ExcellonStatement):
+
+ @classmethod
+ def from_excellon(cls, line, **kwargs):
+ """ Create a ZAxisInfeedRate from an excellon file line.
+
+ Parameters
+ ----------
+ line : string
+ Line from an Excellon file
+
+ Returns
+ -------
+ z_axis_infeed_rate : ToolSelectionStmt
+ ToolSelectionStmt representation of `line.`
+ """
+ rate = int(line[1:])
+
+ return cls(rate, **kwargs)
+
+ def __init__(self, rate, **kwargs):
+ super(ZAxisInfeedRateStmt, self).__init__(**kwargs)
+ self.rate = rate
+
+ def to_excellon(self, settings=None):
+ return 'F%02d' % self.rate
+
+
class CoordinateStmt(ExcellonStatement):
@classmethod
@@ -290,9 +321,14 @@ class CoordinateStmt(ExcellonStatement):
super(CoordinateStmt, self).__init__(**kwargs)
self.x = x
self.y = y
+ self.mode = None
def to_excellon(self, settings):
stmt = ''
+ if self.mode == "ROUT":
+ stmt += "G00"
+ if self.mode == "LINEAR":
+ stmt += "G01"
if self.x is not None:
stmt += 'X%s' % write_gerber_value(self.x, settings.format,
settings.zero_suppression)
@@ -431,6 +467,60 @@ class RewindStopStmt(ExcellonStatement):
return '%'
+class ZAxisRoutPositionStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(ZAxisRoutPositionStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'M15'
+
+
+class RetractWithClampingStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(RetractWithClampingStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'M16'
+
+
+class RetractWithoutClampingStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(RetractWithoutClampingStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'M17'
+
+
+class CutterCompensationOffStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(CutterCompensationOffStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'G40'
+
+
+class CutterCompensationLeftStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(CutterCompensationLeftStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'G41'
+
+
+class CutterCompensationRightStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(CutterCompensationRightStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'G42'
+
+
class EndOfProgramStmt(ExcellonStatement):
@classmethod
@@ -608,6 +698,15 @@ class RouteModeStmt(ExcellonStatement):
return 'G00'
+class LinearModeStmt(ExcellonStatement):
+
+ def __init__(self, **kwargs):
+ super(LinearModeStmt, self).__init__(**kwargs)
+
+ def to_excellon(self, settings=None):
+ return 'G01'
+
+
class DrillModeStmt(ExcellonStatement):
def __init__(self, **kwargs):