-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenerator.py
91 lines (77 loc) · 3.11 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#from Part import parts
from yy1 import nozzle, Machine
class Generator:
def __init__(self, partlist, nozzle_changes):
self.machine = 'YY1'
self.panelized_length = 0
self.panelized_width = 0
self.panelized_rows = 1
self.panelized_columns = 1
self.fiducial_x = 5.0
self.fiducial_y = 5.0
self.overall_offset_x = 0
self.overall_offset_y = 0
self.parts = partlist
self.NozzleChange = nozzle_changes
while len(self.NozzleChange) < 4:
c1 = nozzle()
c1.use = False
c1.component = 1
c1.drop_station = 1
c1.pick_station = 1
self.NozzleChange.append(c1)
def generate(self, filepath):
f = open(filepath, "w")
f.write("NEODEN,YY1,P&P FILE,,,,,,,,,,,\n")
f.write(",,,,,,,,,,,,,\n")
f.write("PanelizedPCB,UnitLength,"+str(self.panelized_length)+",")
f.write("UnitWidth,"+str(self.panelized_width)+",")
f.write("Rows,"+str(self.panelized_rows)+",")
f.write("Columns,"+str(self.panelized_columns)+",\n")
f.write(",,,,,,,,,,,,,\n")
f.write("Fiducial,")
f.write("1-X,"+str(self.fiducial_x)+",")
f.write("1-Y,"+str(self.fiducial_y)+",")
f.write("OverallOffsetX,"+str(self.overall_offset_x)+",")
f.write("OverallOffsetY,"+str(self.overall_offset_y)+",\n")
f.write(",,,,,,,,,,,,,\n")
####################################
# Nozzle Change #
####################################
if len(self.NozzleChange) > 4:
print("Too much nozzle changes")
for change in self.NozzleChange:
f.write("NozzleChange,")
if change.use:
f.write("ON,")
else:
f.write("OFF,")
f.write("BeforeComponent,"+str(change.component)+",")
f.write("Head"+str(change.head)+",")
f.write("Drop,Station"+str(change.drop_station)+",")
f.write("PickUp,Station"+str(change.pick_station)+",")
f.write("\n")
f.write(",,,,,,,,,,,,,\n")
####################################
# Parts #
####################################
f.write("Designator,Comment,Footprint,Mid X(mm),Mid Y(mm) ,Rotation,Head ,FeederNo,Mount Speed(%),Pick Height(mm),Place Height(mm),Mode,Skip\n")
for part in self.parts:
f.write(str(part.designator) + ",")
f.write(str(part.comment) + ",")
f.write(str(part.footprint) + ",")
f.write(str(part.mid_x) + ",")
f.write(str(part.mid_y) + ",")
f.write(str(part.rotation) + ",")
f.write(str(part.head) + ",")
f.write(str(part.feeder) + ",")
f.write(str(part.speed) + ",")
f.write(str(part.pick_high) + ",")
f.write(str(part.place_high) + ",")
f.write(str(part.mode) + ",")
if(part.skip):
f.write("0")
else:
f.write("1")
f.write("\n")
f.close()