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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/class/Wire_helper.rb', line 14
def initialize(chip, api)
super()
@wire_helper_gui = Ui_Wire_helper.new
centerWindow(self)
@wire_helper_gui.setupUi(self)
@chip = chip
@api = api
api.setWiringLeds(0x0000000000000000)
scene = Qt::GraphicsScene.new
@wire_helper_gui.lbl_chip.setText("Your chip (#{chip.chip_reference}):")
total_pin_nbr = Pin.where(pin_chip: @chip.chip_id).count
if Package.find_by(package_id: chip.chip_package).package_shape == 0
pin_by_side = total_pin_nbr / 4
cHeight = 14*(pin_by_side + 4)
scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
y = 32
y2 = cHeight - 38
x = 32
x2 = cHeight - 38
(1..total_pin_nbr).each do |i|
if i <= pin_by_side
ySig = y
yNum = y
UniqPin.new(scene, i, @chip.chip_id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false, api)
y = y + 14
elsif i > pin_by_side && i <= total_pin_nbr / 2
xSig2 = x
xNum2 = x
UniqPin.new(scene, i, @chip.chip_id, xSig2 - 12, cHeight + 55, xNum2 - 12, cHeight, x, cHeight, 6, 20, true, api)
x = x + 14
elsif i > total_pin_nbr / 2 && i <= (total_pin_nbr - (pin_by_side))
xSig = cHeight + 24
ySig = y2
yNum = y2
if i < 10
xNum = cHeight - 20
elsif i >= 10 && i < 100
xNum = cHeight - 25
else
xNum = cHeight - 35
end
UniqPin.new(scene, i, @chip.chip_id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false, api)
y2 = y2 - 14
else
xSig2 = x2
xNum2 = x2
if i < 10
yNum2 = 20
elsif i >= 10 && i < 100
yNum2 = 30
else
yNum2 = 40
end
UniqPin.new(scene, i, @chip.chip_id, xSig2 - 12, -20, xNum2 - 12, yNum2, x2, 0, 6, -20, true, api)
x2 = x2 - 14
end
end
else
pin_by_side = total_pin_nbr / 2
cHeight = 14 * (pin_by_side + 2)
scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
y = 18
y2 = cHeight - 24
(1..total_pin_nbr).each do |i|
if i <= total_pin_nbr / 2
ySig = y
yNum = y
UniqPin.new(scene, i, @chip.chip_id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false, api)
y = y + 14
else
xSig = cHeight + 24
ySig = y2
yNum = y2
if i < 10
xNum = cHeight - 20
elsif i >= 10 && i < 100
xNum = cHeight - 25
else
xNum = cHeight - 35
end
UniqPin.new(scene, i, @chip.chip_id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false, api)
y2 = y2 - 14
end
end
end
@wire_helper_gui.gView.setScene(scene)
rescue Exception => msg
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while drawing the chip. Consult the logs for more details').exec
logger = Logger.new($logFilePath)
logger.error msg
end
|