tallakt-plcutil 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/bin/symlist +32 -19
  2. data/lib/plcutil.rb +1 -1
  3. metadata +2 -3
data/bin/symlist CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  require 'dbf'
4
4
 
5
- symlists_file = ARGV.shift
6
-
7
- raise "Please specify the name of the project's SYMLISTS.DBF file as parameter" unless symlists_file && symlists_file.match(/SYMLISTS[.]DBF/i)
8
-
9
5
  class Tag
10
6
  attr_reader :name, :address, :comment, :type
11
7
 
@@ -14,23 +10,40 @@ class Tag
14
10
  end
15
11
  end
16
12
 
17
- symlists = DBF::Table.new symlists_file
18
- files = symlists.map {|record| [record['_UNAME'], record['_DBPATH']] unless record['_DELETED'] }.compact
19
13
 
20
- tags = []
21
- files.each do |uname, dbpath|
22
- fn = File.join(File.dirname(symlists_file), dbpath, 'SYMLIST.DBF')
23
- symlist = DBF::Table.new fn
24
- symlist.each do |rec|
25
- tags << Tag.new(rec['_SKZ'], rec['_DATATYP'], rec['_OPIEC'], rec['_COMMENT']) if rec
14
+ def print_symlist(symlists_file)
15
+ symlists = DBF::Table.new symlists_file
16
+ files = symlists.map {|record| [record['_UNAME'], record['_DBPATH']] unless record['_DELETED'] }.compact
17
+
18
+ tags = []
19
+ files.each do |uname, dbpath|
20
+ fn = File.join(File.dirname(symlists_file), dbpath, 'SYMLIST.DBF')
21
+ symlist = DBF::Table.new fn
22
+ symlist.each do |rec|
23
+ tags << Tag.new(rec['_SKZ'], rec['_DATATYP'], rec['_OPIEC'], rec['_COMMENT']) if rec
24
+ end
25
+ end
26
+
27
+ tags.each do |t|
28
+ typ = if t.type == t.address
29
+ ''
30
+ else
31
+ t.type
32
+ end
33
+ puts '%-24s%-12s%-13s%s' % [t.name, typ, t.address, t.comment]
26
34
  end
27
35
  end
28
36
 
29
- tags.each do |t|
30
- typ = if t.type == t.address
31
- ''
32
- else
33
- t.type
34
- end
35
- puts '%-24s%-12s%-13s%s' % [t.name, typ, t.address, t.comment]
37
+ s7_folder = ARGV.shift || '.'
38
+ symlists_files = Dir::glob(File.join(s7_folder, '**', 'SYMLISTS.DBF'))
39
+
40
+ if symlists_files.size == 1
41
+ print_symlist symlists_files.first
42
+ else
43
+ STDERR.puts "Please specify the Step 7 project folder"
44
+ if symlists_files.any?
45
+ STDERR.puts 'Possible options:'
46
+ symlists_files.each {|f| STDERR.puts " #{File.dirname(File.dirname f)}" }
47
+ end
36
48
  end
49
+
data/lib/plcutil.rb CHANGED
@@ -3,6 +3,6 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
4
 
5
5
  module PlcUtil
6
- VERSION = '0.2.10'
6
+ VERSION = '0.2.11'
7
7
  end
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tallakt-plcutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 1.8.24
142
+ rubygems_version: 1.8.23
143
143
  signing_key:
144
144
  specification_version: 3
145
145
  summary: Ruby PLC file library
@@ -147,4 +147,3 @@ test_files:
147
147
  - test/input_files/step7_v5.4/00000001.AWL
148
148
  - test/input_files/step7_v5.4/S7_pro2.zip
149
149
  - test/input_files/step7_v5.4/SYMLIST.DBF
150
- has_rdoc: