kut 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/LICENSE.rdoc +6 -0
  2. data/README.rdoc +20 -0
  3. data/Rakefile.rb +63 -0
  4. data/bin/kut +27 -0
  5. data/doc-src/PINS.rdoc +18 -0
  6. data/examples/example_helper.rb +1 -0
  7. data/examples/net_list/print_cmp_list.rb +101 -0
  8. data/examples/pins/A3P1000_PQFP208.pins +216 -0
  9. data/examples/pins/AT32UC3A0512.pins +151 -0
  10. data/examples/pins/EMP7464S_TQFP100.pins +101 -0
  11. data/examples/pins/ata40conn.pins +44 -0
  12. data/examples/pins/full_sata.pins +25 -0
  13. data/examples/pins/jm20330.pins +85 -0
  14. data/lib/kut.rb +2 -0
  15. data/lib/kut/application.rb +56 -0
  16. data/lib/kut/commands/gost/bom2el_list.rb +171 -0
  17. data/lib/kut/commands/help-cmd.rb +32 -0
  18. data/lib/kut/commands/lib-gen-cmd.rb +88 -0
  19. data/lib/kut/commands/net_list2bom.rb +81 -0
  20. data/lib/kut/eeschema/wire.rb +3 -0
  21. data/lib/kut/kut_module.rb +18 -0
  22. data/lib/kut/library/components.rb +167 -0
  23. data/lib/kut/library/generator.rb +25 -0
  24. data/lib/kut/library/generator/default.rb +123 -0
  25. data/lib/kut/library/generator/gost-con.rb +116 -0
  26. data/lib/kut/library/generator/simple.rb +123 -0
  27. data/lib/kut/library/pins_reader.rb +47 -0
  28. data/lib/kut/library/regexp.rb +18 -0
  29. data/lib/kut/misc/matrix.rb +2 -0
  30. data/lib/kut/misc/point.rb +25 -0
  31. data/lib/kut/misc/rectangle.rb +20 -0
  32. data/lib/kut/net_list/concept.rb +20 -0
  33. data/lib/kut/net_list/kicad.rb +40 -0
  34. data/lib/kut/net_list/pcad.rb +69 -0
  35. data/lib/kut/tests/Rakefile.rb +0 -0
  36. data/lib/kut/tests/rectangle.rb +23 -0
  37. data/test/library_cmp_pin_test.rb +16 -0
  38. data/test/library_pins_reader_test.rb +40 -0
  39. data/test/point_test.rb +17 -0
  40. metadata +100 -0
data/LICENSE.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ Kut is copyrighted free software produced by Alexey Pavlyukov along with
2
+ community contributions.
3
+
4
+ Kut library distributed under GPL license.
5
+
6
+
data/README.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ = Kut: KiCAD utils & tools for generation, manipulation KiCAD files.
2
+
3
+ == Quick Start
4
+
5
+ === Installation:
6
+ git clone git://github.com/lexaficus/kut.git
7
+ cd kut
8
+ ruby ./bin/kut
9
+
10
+ === How to generate library components:
11
+
12
+ ruby bin/kut gen-lib -G simple -i examples/pins/jm20330.pins -o simple.lib --name JM_20330
13
+
14
+ link:images/lib-gen-simple.png
15
+
16
+ ruby bin/kut gen-lib -i examples/pins/jm20330.pins -o default.lib --name JM20330
17
+
18
+ link:images/lib-gen-default.png
19
+
20
+ ruby bin/kut gen-lib -i examples/pins/ata40conn.pins -o gost.lib --name ATA --ref X
data/Rakefile.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require "rake/rdoctask"
5
+ require "rake/gempackagetask"
6
+
7
+ KUT_VERSION = "0.1.0"
8
+
9
+ task :default => [:test]
10
+
11
+ desc "Run all tests"
12
+ Rake::TestTask.new do |test|
13
+ test.libs << "lib"
14
+ test.test_files = Dir[ "test/*_test.rb" ]
15
+ test.verbose = true
16
+ end
17
+
18
+ desc "genrates documentation"
19
+ Rake::RDocTask.new do |rdoc|
20
+ rdoc.rdoc_files.include( "README.rdoc",
21
+ "lib/",
22
+ Dir.glob("{doc-src,.}/*.rdoc"))
23
+ rdoc.main = "README.rdoc"
24
+ rdoc.rdoc_dir = "doc/html"
25
+ rdoc.title = "Kut Documentation"
26
+ rdoc.options = ['--charset=utf-8 --copy-local-images']
27
+ end
28
+
29
+ desc "run all examples"
30
+ task :examples do
31
+ examples = Dir["examples/**/*.rb"]
32
+ t = Time.now
33
+ puts "Running Examples"
34
+ examples.each { |file| `ruby -Ilib #{file}` }
35
+ puts "Ran in #{Time.now - t} s"
36
+ end
37
+
38
+ spec = Gem::Specification.new do |s|
39
+ s.name = 'kut'
40
+ s.version = KUT_VERSION
41
+ s.date = '2009-09-24'
42
+
43
+ s.summary = 'KiCAD utils & tools for generation, manipulation KiCAD files.'
44
+ s.email = 'lexaficus@list.ru'
45
+ s.authors = ['Alexey Pavlyukov']
46
+
47
+ s.bindir = "bin" # Use these for applications.
48
+ s.executables = ["kut"]
49
+ s.default_executable = "kut"
50
+
51
+ s.has_rdoc = false
52
+ s.rdoc_options = ["--main", "README.rdoc", "--title", "GostFrames Documentation"]
53
+ #s.extra_rdoc_files = ["README.rdoc", "LICENSE.rdoc"]
54
+ s.rdoc_options = ["--charset=utf-8"]
55
+ s.require_paths = ["lib"]
56
+ s.files = Dir.glob("{examples,lib,data}/**/**/*") + ["Rakefile.rb"] + Dir.glob("{doc-src,.}/*.rdoc")
57
+ s.test_files = Dir[ "test/*_test.rb" ]
58
+ end
59
+
60
+ Rake::GemPackageTask.new(spec) do |pkg|
61
+ pkg.need_zip = true
62
+ pkg.need_tar = true
63
+ end
data/bin/kut ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'kut'
5
+ rescue LoadError
6
+ begin
7
+ require 'rubygems'
8
+ require 'kut'
9
+ rescue LoadError
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ require 'kut'
12
+ end
13
+ end
14
+
15
+ require 'kut/commands/lib-gen-cmd'
16
+ require 'kut/commands/help-cmd'
17
+ require 'kut/commands/net_list2bom'
18
+ require 'kut/commands/gost/bom2el_list'
19
+
20
+ Kut.application.commands = [
21
+ Kut::HelpCommand.new,
22
+ Kut::LibraryGeneratorCommand.new,
23
+ Kut::NetList2Bom.new,
24
+ Kut::Bom2EL.new
25
+ ]
26
+
27
+ Kut.application.run
data/doc-src/PINS.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = pins file format
2
+
3
+ All strings in file starting with '#' is command for library generators.
4
+ All another strings in file must be contains: pin number, space, pin name.
5
+
6
+ pins file example:
7
+ #NAMES POWER_5V, POWER_3V
8
+ 1 VCC
9
+ 2 GND
10
+
11
+ Commands:
12
+ #NAMES - set component names
13
+ #REF - set component reference
14
+ #TOP - all pins enumerated after this command will be placed from the top of the component
15
+ #BOTTOM - all pins enumerated after this command will be placed under the bottom of the component
16
+ #LEFT - all pins enumerated after this command will be placed at the left of the component
17
+ #RIGHT - all pins enumerated after this command will be placed at the right of the component
18
+ #NO-PIN - insert space instead of the pin
@@ -0,0 +1 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -0,0 +1,101 @@
1
+ require "#{File.dirname(__FILE__)}/../example_helper.rb"
2
+ require 'kut/net_list/kicad'
3
+ require 'kut/net_list/pcad'
4
+
5
+ #net_list = Kut::NetList::KiCadNetList.new($stdin)
6
+ net_list = Kut::NetList::PCadNetList.new($stdin)
7
+
8
+ cmp_list = net_list.by_components()
9
+
10
+ cmp_by_value = {}
11
+
12
+ cmp_list.each { |cmp|
13
+ cmp_by_value[cmp.value] << cmp if cmp_by_value[cmp.value]
14
+ cmp_by_value[cmp.value] = [cmp] unless cmp_by_value[cmp.value]
15
+ #puts "#{cmp.reference} #{cmp.value}"
16
+ }
17
+
18
+ cmp_list = {}
19
+
20
+ def join_ref(ref_list)
21
+ return '' unless ref_list
22
+
23
+ ref_list.sort! { |a, b|
24
+ a =~ /(\D+)(\d+)/
25
+ a_n = $1
26
+ a_val = $2.to_i
27
+ b =~ /(\D+)(\d+)/
28
+ b_n = $1
29
+ b_val = $2.to_i
30
+
31
+ res = a_n <=> b_n
32
+ res = a_val <=> b_val if res == 0
33
+ }
34
+
35
+ ref_list.first =~ /(\D+)(\d+)/
36
+ prev_pref = $1
37
+ prev_num = $2.to_i
38
+ prev_ref = ref_list.first
39
+
40
+ result = ref_list.first
41
+ ref_list.delete_at(0)
42
+ counter = 0
43
+
44
+ # while ! ref_list.empty?
45
+ # ref = ref_list.first
46
+ # ref_list.delete_at(0)
47
+ # end
48
+
49
+ flag = false
50
+
51
+ ref_list.each { |ref|
52
+ ref =~ /(\D+)(\d+)/
53
+ pref = $1
54
+ num = $2.to_i
55
+
56
+ flag = (pref == prev_pref) && (num == (prev_num + 1))
57
+
58
+ if !flag then
59
+ if counter != 0 then
60
+ result += counter > 1 ? '..' : ','
61
+ result += prev_ref + ',' + ref
62
+ else
63
+ result += ',' + ref
64
+ end
65
+ end
66
+
67
+ #result += '..' + prev_ref + ',' + ref unless flag && counter != 0
68
+ #result += ',' + ref unless flag
69
+
70
+ counter += 1 if flag
71
+ counter = 0 unless flag
72
+
73
+ prev_pref = pref
74
+ prev_num = num
75
+ prev_ref = ref
76
+ }
77
+
78
+ if flag && counter != 0 then
79
+ result += counter > 1 ? '..' : ','
80
+ result += prev_ref
81
+ end
82
+
83
+ result
84
+ end
85
+
86
+ result = []
87
+
88
+ cmp_by_value.each { |key, cmps|
89
+ refs = []
90
+ count = 0
91
+ cmps.each { |cmp|
92
+ refs << cmp.reference
93
+ count += 1
94
+ }
95
+ refs = join_ref refs
96
+ result << ";#{refs};#{key};#{count};"
97
+ }
98
+
99
+ result.sort!
100
+
101
+ result.each{ |v| puts v }
@@ -0,0 +1,216 @@
1
+ #LEFT
2
+ 1 GND
3
+ 2 GAA2/IO225PDB3
4
+ 3 IO225NDB3
5
+ 4 GAB2/IO224PDB3
6
+ 5 IO224NDB3
7
+ 6 GAC2/IO223PDB3
8
+ 7 IO223NDB3
9
+ 8 IO222PDB3
10
+ 9 IO222NDB3
11
+ 10 IO220PDB3
12
+ 11 IO220NDB3
13
+ 12 IO218PDB3
14
+ 13 IO218NDB3
15
+ 14 IO216PDB3
16
+ 15 IO216NDB3
17
+ 16 VCC
18
+ 17 GND
19
+ 18 VCCIB3
20
+ 19 IO212PDB3
21
+ 20 IO212NDB3
22
+ 21 GFC1/IO209PDB3
23
+ 22 GFC0/IO209NDB3
24
+ 23 GFB1/IO208PDB3
25
+ 24 GFB0/IO208NDB3
26
+ 25 VCOMPLF
27
+ 26 GFA0/IO207NPB3
28
+ 27 VCCPLF
29
+ 28 GFA1/IO207PPB3
30
+ 29 GND
31
+ 30 GFA2/IO206PDB3
32
+ 31 IO206NDB3
33
+ 32 GFB2/IO205PDB3
34
+ 33 IO205NDB3
35
+ 34 GFC2/IO204PDB3
36
+ 35 IO204NDB3
37
+ 36 VCC
38
+ 37 IO199PDB3
39
+ 38 IO199NDB3
40
+ 39 IO197PSB3
41
+ 40 VCCIB3
42
+ 41 GND
43
+ 42 IO191PDB3
44
+ 43 IO191NDB3
45
+ 44 GEC1/IO190PDB3
46
+ 45 GEC0/IO190NDB3
47
+ 46 GEB1/IO189PDB3
48
+ 47 GEB0/IO189NDB3
49
+ 48 GEA1/IO188PDB3
50
+ 49 GEA0/IO188NDB3
51
+ 50 VMV3
52
+ 51 GNDQ
53
+
54
+ #BOTTOM
55
+ 52 GND
56
+ 53 VMV2
57
+ 54 GEA2/IO187RSB2
58
+ 55 GEB2/IO186RSB2
59
+ 56 GEC2/IO185RSB2
60
+ 57 IO184RSB2
61
+ 58 IO183RSB2
62
+ 59 IO182RSB2
63
+ 60 IO181RSB2
64
+ 61 IO180RSB2
65
+ 62 VCCIB2
66
+ 63 IO178RSB2
67
+ 64 IO176RSB2
68
+ 65 GND
69
+ 66 IO174RSB2
70
+ 67 IO172RSB2
71
+ 68 IO170RSB2
72
+ 69 IO168RSB2
73
+ 70 IO166RSB2
74
+ 71 VCC
75
+ 72 VCCIB2
76
+ 73 IO162RSB2
77
+ 74 IO160RSB2
78
+ 75 IO158RSB2
79
+ 76 IO156RSB2
80
+ 77 IO154RSB2
81
+ 78 IO152RSB2
82
+ 79 IO150RSB2
83
+ 80 IO148RSB2
84
+ 81 GND
85
+ 82 IO143RSB2
86
+ 83 IO141RSB2
87
+ 84 IO139RSB2
88
+ 85 IO137RSB2
89
+ 86 IO135RSB2TOP
90
+ 87 IO133RSB2
91
+ 88 VCC
92
+ 89 VCCIB2
93
+ 90 IO128RSB2
94
+ 91 IO126RSB2
95
+ 92 IO124RSB2
96
+ 93 IO122RSB2
97
+ 94 IO120RSB2
98
+ 95 IO118RSB2
99
+ 96 GDC2/IO116RSB2
100
+ 97 GND
101
+ 98 GDB2/IO115RSB2
102
+ 99 GDA2/IO114RSB2
103
+ 100 GNDQ
104
+ 101 TCK
105
+ 102 TDI
106
+ 103 TMS
107
+ 104 VMV2
108
+
109
+ #RIGHT
110
+ 105 GND
111
+ 106 VPUMP
112
+ 107 GNDQ
113
+ 108 TDO
114
+ 109 TRST
115
+ 110 VJTAG
116
+ 111 GDA0/IO113NDB1
117
+ 112 GDA1/IO113PDB1
118
+ 113 GDB0/IO112NDB1
119
+ 114 GDB1/IO112PDB1
120
+ 115 GDC0/IO111NDB1
121
+ 116 GDC1/IO111PDB1
122
+ 117 IO109NDB1
123
+ 118 IO109PDB1
124
+ 119 IO106NDB1
125
+ 120 IO106PDB1
126
+ 121 IO104PSB1
127
+ 122 GND
128
+ 123 VCCIB1
129
+ 124 IO99NDB1
130
+ 125 IO99PDB1
131
+ 126 NC
132
+ 127 IO96NDB1
133
+ 128 GCC2/IO96PDB1
134
+ 129 GCB2/IO95PSB1
135
+ 130 GND
136
+ 131 GCA2/IO94PSB1
137
+ 132 GCA1/IO93PDB1
138
+ 133 GCA0/IO93NDB1
139
+ 134 GCB0/IO92NDB1
140
+ 135 GCB1/IO92PDB1
141
+ 136 GCC0/IO91NDB1
142
+ 137 GCC1/IO91PDB1
143
+ 138 IO88NDB1
144
+ 139 IO88PDB1
145
+ 140 VCCIB1
146
+ 141 GND
147
+ 142 VCC
148
+ 143 IO86PSB1
149
+ 144 IO84NDB1
150
+ 145 IO84PDB1
151
+ 146 IO82NDB1
152
+ 147 IO82PDB1
153
+ 148 IO80NDB1
154
+ 149 GBC2/IO80PDB1
155
+ 150 IO79NDB1
156
+ 151 GBB2/IO79PDB1
157
+ 152 IO78NDB1
158
+ 153 GBA2/IO78PDB1
159
+ 154 VMV1
160
+ 155 GNDQ
161
+ 156 GND
162
+
163
+ #TOP
164
+ 157 VMV0
165
+ 158 GBA1/IO77RSB0
166
+ 159 GBA0/IO76RSB0
167
+ 160 GBB1/IO75RSB0
168
+ 161 GBB0/IO74RSB0
169
+ 162 GND
170
+ 163 GBC1/IO73RSB0
171
+ 164 GBC0/IO72RSB0
172
+ 165 IO70RSB0
173
+ 166 IO67RSB0
174
+ 167 IO63RSB0
175
+ 168 IO60RSB0
176
+ 169 IO57RSB0
177
+ 170 VCCIB0
178
+ 171 VCC
179
+ 172 IO54RSB0
180
+ 173 IO51RSB0
181
+ 174 IO48RSB0
182
+ 175 IO45RSB0
183
+ 176 IO42RSB0
184
+ 177 IO40RSB0
185
+ 178 GND
186
+ 179 IO38RSB0
187
+ 180 IO35RSB0
188
+ 181 IO33RSB0
189
+ 182 IO31RSB0
190
+ 183 IO29RSB0
191
+ 184 IO27RSB0
192
+ 185 IO25RSB0
193
+ 186 VCCIB0
194
+ 187 VCC
195
+ 188 IO22RSB0
196
+ 189 IO20RSB0
197
+ 190 IO18RSB0
198
+ 191 IO16RSB0
199
+ 192 IO15RSB0
200
+ 193 IO14RSB0
201
+ 194 IO13RSB0
202
+ 195 GND
203
+ 196 IO12RSB0
204
+ 197 IO11RSB0
205
+ 198 IO10RSB0
206
+ 199 IO09RSB0
207
+ 200 VCCIB0
208
+ 201 GAC1/IO05RSB0
209
+ 202 GAC0/IO04RSB0
210
+ 203 GAB1/IO03RSB0
211
+ 204 GAB0/IO02RSB0
212
+ 205 GAA1/IO01RSB0
213
+ 206 GAA0/IO00RSB0
214
+ 207 GNDQ
215
+ 208 VMV0
216
+