fhlow 1.91.0 → 1.91.1
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.
- data/bin/fhlow +58 -10
- data/lib/module_config/complexitem.rb +57 -0
- data/lib/module_config/config.rb +5 -3
- data/lib/module_config/item.rb +0 -4
- data/lib/module_config/items/complex.rb +44 -0
- data/lib/module_config/items/complexfreqencies.rb +59 -0
- data/lib/module_config/items/complexlibrary.rb +46 -0
- data/lib/module_config/items/complexpackage.rb +47 -0
- data/lib/module_config/items/complexpins.rb +59 -0
- data/lib/module_config/items/complexunit.rb +53 -0
- data/lib/module_config/items/simple.rb +29 -0
- data/lib/module_config/items/simplearchitecture.rb +34 -0
- data/lib/module_config/items/simplebindir.rb +31 -0
- data/lib/module_config/items/simplebool.rb +24 -0
- data/lib/module_config/items/simplepostlayoutsdf.rb +24 -0
- data/lib/module_config/items/simplesimulaterun.rb +25 -0
- data/lib/module_config/items/simpleverbose.rb +33 -0
- data/lib/module_config/section.rb +16 -4
- data/lib/module_config/simpleitem.rb +37 -0
- data/lib/module_config/test.flw +33 -12
- data/lib/module_config/test.rb +54 -4
- data/lib/module_config/unittests/config_test.rb +15 -12
- data/lib/module_fhlow/leaf.rb +28 -24
- data/lib/module_fhlow/leafs/Library.rb +60 -0
- data/lib/module_fhlow/leafs/Package.rb +4 -1
- data/lib/module_fhlow/leafs/Unit.rb +9 -1
- data/lib/module_fhlow/node.rb +4 -5
- data/lib/module_fhlow/plugin.rb +11 -0
- data/lib/module_fhlow/pluginpool.rb +17 -5
- data/lib/module_fhlow/rootnode.rb +4 -3
- data/lib/plugins/Modelsim.flw +18 -0
- data/lib/plugins/Modelsim.rb +331 -0
- data/lib/plugins/Quartus.flw +5 -0
- data/lib/plugins/Quartus.rb +237 -0
- data/tests/testsuite.rb +0 -0
- metadata +84 -79
- data/lib/module_config/configitems/complex.rb +0 -71
- data/lib/module_config/configitems/complexpackage.rb +0 -67
- data/lib/module_config/configitems/complexunit.rb +0 -76
- data/lib/module_config/configitems/simple.rb +0 -56
- data/lib/module_config/configitems/simplearchitecture.rb +0 -52
- data/lib/module_config/configitems/simplepackage.rb +0 -47
- data/lib/module_config/configitems/simpleunit.rb +0 -53
- data/lib/module_config/configs.test +0 -24
- data/lib/module_config/tmp +0 -3
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configexception_rb.html +0 -647
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complex_rb.html +0 -700
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexpackage_rb.html +0 -694
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-complexunit_rb.html +0 -704
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simple_rb.html +0 -685
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simplepackage_rb.html +0 -676
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-configitems-simpleunit_rb.html +0 -682
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-item_rb.html +0 -663
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-itemfactory_rb.html +0 -687
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-myconfig_rb.html +0 -687
- data/lib/module_config/unittests/coverage/-home-simon-tmp-fhlow_v2-flw-core-lib-module_config-section_rb.html +0 -692
- data/lib/module_config/unittests/coverage/index.html +0 -689
- data/lib/module_fhlow/leaf.rb~ +0 -202
- data/lib/module_fhlow/test.rb +0 -15
data/bin/fhlow
CHANGED
@@ -54,6 +54,8 @@ module Fhlow
|
|
54
54
|
# Initialization of some options and switches
|
55
55
|
opt_askexit = false
|
56
56
|
|
57
|
+
rn = nil
|
58
|
+
|
57
59
|
begin
|
58
60
|
####################################################################################################
|
59
61
|
|
@@ -65,7 +67,7 @@ module Fhlow
|
|
65
67
|
|
66
68
|
# create the logger
|
67
69
|
log = Log.new(RootNode.detectFhlowRootDir+"flw/var/log.flw", 1, pen)
|
68
|
-
log.info(self, "created logfile: "+RootNode.detectFhlowRootDir+"flw/var/log
|
70
|
+
log.info(self, "created logfile: "+RootNode.detectFhlowRootDir+"flw/var/fhlow.log")
|
69
71
|
|
70
72
|
####################################################################################################
|
71
73
|
|
@@ -73,7 +75,7 @@ module Fhlow
|
|
73
75
|
# create a CmdParser
|
74
76
|
cmd = CmdParse::CommandParser.new(false, true)
|
75
77
|
cmd.program_name = "fhlow"
|
76
|
-
cmd.program_version = [
|
78
|
+
cmd.program_version = [1, 91, 1]
|
77
79
|
|
78
80
|
# define the global options
|
79
81
|
cmd.options = CmdParse::OptionParserWrapper.new do |opt|
|
@@ -82,7 +84,6 @@ module Fhlow
|
|
82
84
|
opt.on("-c", "--nocolor", "Disable colorful output.") { pen.noColor }
|
83
85
|
|
84
86
|
opt.on("-a", "--askexit", "Asks to hit a key before exiting.") { opt_askexit = true }
|
85
|
-
# TODO: alternative actual child
|
86
87
|
end
|
87
88
|
|
88
89
|
# add two default cmds
|
@@ -108,7 +109,6 @@ module Fhlow
|
|
108
109
|
|
109
110
|
# print the header
|
110
111
|
pen.header
|
111
|
-
|
112
112
|
|
113
113
|
# tell the cmd-er to use our pen
|
114
114
|
cmd.pen = pen
|
@@ -116,17 +116,63 @@ module Fhlow
|
|
116
116
|
|
117
117
|
# fetch the default configurations
|
118
118
|
defaultconf = Config::Config.new(RootNode.detectFhlowRootDir+"flw/defaults.flw")
|
119
|
-
|
119
|
+
log.info(self, "Loaded settings from: "+RootNode.detectFhlowRootDir+"flw/defaults.flw.")
|
120
|
+
|
121
|
+
|
122
|
+
case RUBY_PLATFORM
|
123
|
+
when /ix/i, /ux/i, /gnu/i, /sysv/i, /solaris/i, /sunos/i, /bsd/i
|
124
|
+
if File.exist?("/etc/fhlow/system.flw")
|
125
|
+
defaultconf.merge(Config::Config.new("/etc/fhlow/system.flw"))
|
126
|
+
log.info(self, "Loaded settings from: /etc/fhlow/system.flw.")
|
127
|
+
end
|
128
|
+
|
129
|
+
if File.exist?("#{ENV['HOME']}/.fhlow/user.flw")
|
130
|
+
defaultconf.merge(Config::Config.new("#{ENV['HOME']}/.fhlow/user.flw"))
|
131
|
+
log.info(self, "Loaded settings from: #{ENV['HOME']}/.fhlow/user.flw.")
|
132
|
+
end
|
133
|
+
|
134
|
+
when /win/i, /ming/i
|
135
|
+
file = File.join(ENV['ALLUSERSPROFILE'], "Applicatoion Data", "fhlow", "user.flw")
|
136
|
+
if File.exist?(file)
|
137
|
+
defaultconf.merge(Config::Config.new(file))
|
138
|
+
log.info(self, "Loaded settings from: #{file}.")
|
139
|
+
end
|
140
|
+
|
141
|
+
file = File.join(ENV['APPDATA'], "fhlow", "user.flw")
|
142
|
+
if File.exist?(file)
|
143
|
+
defaultconf.merge(Config::Config.new(file))
|
144
|
+
log.info(self, "Loaded settings from: #{file}.")
|
145
|
+
end
|
146
|
+
|
147
|
+
else
|
148
|
+
raise Fhlow::FhlowException.new("fhlow"), "Your operating system (#{RUBY_PLATFORM}) is not supported!"
|
149
|
+
end
|
150
|
+
|
151
|
+
test = `gem contents fhlow`
|
152
|
+
pluginPath = ""
|
153
|
+
test.each do |s|
|
154
|
+
if s =~ /^.*plugins$/
|
155
|
+
pluginPath = s.chop + File::SEPARATOR
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
if pluginPath == ""
|
160
|
+
pluginPath = File.join(RootNode.detectFhlowRootDir, "flw", "plugins").chop + File::SEPARATOR
|
161
|
+
end
|
162
|
+
|
163
|
+
PluginPool.each_configfile(pluginPath) do |file|
|
164
|
+
defaultconf.merge(Config::Config.new(file))
|
165
|
+
log.info(self, "Loaded settings from: #{file}.")
|
166
|
+
end
|
120
167
|
|
121
168
|
# create the root node which initializes the whole tree structure
|
122
169
|
rn = RootNode.new(defaultconf, log, pen)
|
123
170
|
log.info(self, "successfully initialized the root object")
|
124
171
|
|
125
172
|
log.info(self, "sucessfully detected the actual child -> "+rn.getActualLeaf(Dir.pwd).name)
|
126
|
-
|
127
|
-
|
173
|
+
|
128
174
|
# create the plugin pool
|
129
|
-
pp =
|
175
|
+
pp = PluginPool.new(pluginPath, rn.getActualLeaf(Dir.pwd), pen, log)
|
130
176
|
log.info(self, "successfully included the plugins")
|
131
177
|
|
132
178
|
# register the plugins as cmds
|
@@ -148,8 +194,10 @@ module Fhlow
|
|
148
194
|
rescue FhlowException => e
|
149
195
|
pen.seperator
|
150
196
|
pen.puts "#{pen.lightred}Error:#{pen.clear} #{e.caller}\n #{e.message}"
|
151
|
-
log.error(e.caller, e.message)
|
152
|
-
pen.
|
197
|
+
log.error(e.caller, e.message) if log
|
198
|
+
pen.puts e.backtrace.join("\n") if $DEBUG
|
199
|
+
rn.getActualLeaf(Dir.pwd).conf.print if $DEBUG
|
200
|
+
|
153
201
|
|
154
202
|
rescue CmdParse::ParseError, OptionParser::ParseError => e
|
155
203
|
pen.puts "#{pen.lightred}Error while parsing command line:#{pen.clear}"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'item'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexItem < Item
|
8
|
+
attr_reader :name
|
9
|
+
attr_reader :value
|
10
|
+
attr_reader :overwrite
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def initialize(_str, _regex)
|
15
|
+
if _str =~ _regex
|
16
|
+
@name = $1
|
17
|
+
@overwrite = $2=="!"
|
18
|
+
@value = $3.split(/\s*;\s*/)
|
19
|
+
else
|
20
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration item <#{_str}> has wrong format."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
public
|
25
|
+
|
26
|
+
def merge(_complexitem)
|
27
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not fit! <#{_complexitem}> is not of type #{self.class.to_s}." unless _complexitem.instance_of?(self.class)
|
28
|
+
raise ConfigMergeException.new(self.class), "Merge: Configuration items do not have the same name! <#{_complexitem.name}> vs. <#{@name}>" unless _complexitem.name == @name
|
29
|
+
|
30
|
+
puts "------------------------"
|
31
|
+
$stdout.print "_complexitem: "
|
32
|
+
p _complexitem
|
33
|
+
$stdout.print "self: "
|
34
|
+
p self
|
35
|
+
puts "------------------------"
|
36
|
+
|
37
|
+
@value = _complexitem.value | @value unless @overwrite
|
38
|
+
end
|
39
|
+
|
40
|
+
def each(&block)
|
41
|
+
@value.each(&block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def print
|
45
|
+
puts " #{@name} = { # #{@self.class.to_s}"
|
46
|
+
$stdout.print " "
|
47
|
+
puts @value.join(";\n ")
|
48
|
+
puts " }"
|
49
|
+
end
|
50
|
+
|
51
|
+
def ComplexItem.getRegex(_nameregex, _valueregex)
|
52
|
+
/\s*(#{_nameregex})([!]?)\s*=\s*\{\s*(#{_valueregex})\s*\}/
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
data/lib/module_config/config.rb
CHANGED
@@ -7,9 +7,11 @@ module Config
|
|
7
7
|
|
8
8
|
@@factoriesloaded = false
|
9
9
|
|
10
|
+
attr_reader :filename
|
11
|
+
|
10
12
|
def initialize(_filename)
|
11
13
|
unless @@factoriesloaded
|
12
|
-
ItemFactory.load(File.join(File.dirname(__FILE__), "
|
14
|
+
ItemFactory.load(File.join(File.dirname(__FILE__), "items"))
|
13
15
|
@@factoriesloaded = true
|
14
16
|
end
|
15
17
|
|
@@ -22,8 +24,8 @@ module Config
|
|
22
24
|
while !file.strip.empty?
|
23
25
|
file = file.sub(Section.getRegex) do |match|
|
24
26
|
begin
|
25
|
-
@sections.push(Section.new(match))
|
26
|
-
"" # delete the proceded string (
|
27
|
+
@sections.push(Section.new(match, @filename))
|
28
|
+
"" # delete the proceded string (matched string will be sub'ed with the return value of this block)
|
27
29
|
rescue ConfigException => e
|
28
30
|
raise ConfigException.new(self.class), " File: #{_filename}\n#{e.message}"
|
29
31
|
end
|
data/lib/module_config/item.rb
CHANGED
@@ -25,10 +25,6 @@ module Config
|
|
25
25
|
raise NotImplementedError, "You have to implement value() in sublcasses inherited from Config::Item!"
|
26
26
|
end
|
27
27
|
|
28
|
-
def Item.getRegex()
|
29
|
-
raise NotImplementedError, "You have to implement getRegex() in sublcasses inherited from Config::Item!"
|
30
|
-
end
|
31
|
-
|
32
28
|
end
|
33
29
|
|
34
30
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'complexitem'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexFactory < ItemFactory
|
8
|
+
@@nameregex = /\w+/
|
9
|
+
@@valueregex = /(\s*.+[;][\s\n]*)*(\s*.+[;]*[\s\n]*)/
|
10
|
+
|
11
|
+
def ComplexFactory.match(_str)
|
12
|
+
_str.sub!(ComplexItem.getRegex(@@nameregex, @@valueregex), '')
|
13
|
+
return $&
|
14
|
+
end
|
15
|
+
|
16
|
+
def ComplexFactory.create(_str)
|
17
|
+
Complex.new(_str, ComplexItem.getRegex(@@nameregex, @@valueregex))
|
18
|
+
end
|
19
|
+
|
20
|
+
def ComplexFactory.priority
|
21
|
+
11
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Complex < ComplexItem
|
26
|
+
@@subitemregex = /\A.*\Z/
|
27
|
+
|
28
|
+
def initialize(_str, _regex)
|
29
|
+
super(_str, _regex)
|
30
|
+
@value.each do |item|
|
31
|
+
item.strip!
|
32
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration subitem <#{item}> of item <#{name}> has wrong format." unless item =~ @@subitemregex
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def print
|
37
|
+
puts " #{@name} = { ##{self.class.to_s}"
|
38
|
+
$stdout.print " "
|
39
|
+
puts @value.join(";\n ")
|
40
|
+
puts " }"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'complexitem'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexFreqenciesFactory < ItemFactory
|
8
|
+
@@nameregex = /Frequencies/
|
9
|
+
@@valueregex = /(\s*.*[;]\s*)*(\s*.*[;]*\s*)?/
|
10
|
+
|
11
|
+
def ComplexFreqenciesFactory.match(_str)
|
12
|
+
_str.sub!(ComplexItem.getRegex(@@nameregex, @@valueregex), '')
|
13
|
+
return $&
|
14
|
+
end
|
15
|
+
|
16
|
+
def ComplexFreqenciesFactory.create(_str)
|
17
|
+
ComplexFreqencies.new(_str, ComplexItem.getRegex(@@nameregex, @@valueregex))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ComplexFreqencies < ComplexItem
|
22
|
+
@@subitemregex = /\A([\w\(\)]+)\s*->\s*(\w+)\s*,\s*(\w+)\s*\Z/
|
23
|
+
|
24
|
+
def initialize(_str, _regex)
|
25
|
+
super(_str, _regex)
|
26
|
+
|
27
|
+
tmp = @value
|
28
|
+
@value = []
|
29
|
+
tmp.each do |item|
|
30
|
+
item.strip!
|
31
|
+
if item =~ @@subitemregex
|
32
|
+
item = Hash.new
|
33
|
+
item["signalname"] = $1
|
34
|
+
item["freqency"] = $2
|
35
|
+
item["clockname"] = $3
|
36
|
+
@value.push(item)
|
37
|
+
else
|
38
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration subitem <#{item}> of item <#{name}> has wrong format."
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def each(&_block)
|
45
|
+
@value.each do |subitem|
|
46
|
+
_block.call(subitem["signalname"], subitem["freqency"], subitem["clockname"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def print
|
51
|
+
puts " #{@name} = { ##{self.class.to_s}"
|
52
|
+
@value.each { |v| puts " #{v["signalname"]} -> #{v["freqency"]}, #{v["clockname"]};" }
|
53
|
+
puts " }"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'item'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexLibraryFactory < ItemFactory
|
8
|
+
@@nameregex = /\w*Librar\w*/
|
9
|
+
@@valueregex = /(\s*.*[;]\s*)*(\s*.*[;]?\s*)?/
|
10
|
+
|
11
|
+
def ComplexLibraryFactory.match(_str)
|
12
|
+
_str.sub!(ComplexItem.getRegex(@@nameregex, @@valueregex), '')
|
13
|
+
return $&
|
14
|
+
end
|
15
|
+
|
16
|
+
def ComplexLibraryFactory.create(_str)
|
17
|
+
ComplexLibrary.new(_str, ComplexItem.getRegex(@@nameregex, @@valueregex))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class ComplexLibrary < ComplexItem
|
23
|
+
@@subitemregex = /\A.+\Z/
|
24
|
+
|
25
|
+
def initialize(_str, _regex)
|
26
|
+
super(_str, _regex)
|
27
|
+
|
28
|
+
tmp = @value
|
29
|
+
@value = []
|
30
|
+
|
31
|
+
tmp.each do |item|
|
32
|
+
item.strip!
|
33
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration subitem \n -----\n #{item} \n -----\n of item <#{name}> has wrong format." unless item =~ @@subitemregex
|
34
|
+
@value.push(item.split(/,\s/))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def print
|
39
|
+
puts " #{@name} = { ##{self.class.to_s}"
|
40
|
+
@value.each { |v| puts " #{v};" }
|
41
|
+
puts " }"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'complexitem'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexPackageFactory < ItemFactory
|
8
|
+
@@nameregex = /\w*Package\w*/
|
9
|
+
@@valueregex = /((\s*[^\(\)]*[;]\s*)*(\s*[^\(\)\{]*[;]?\s*)?)/
|
10
|
+
|
11
|
+
def ComplexPackageFactory.match(_str)
|
12
|
+
_str.sub!(ComplexItem.getRegex(@@nameregex, @@valueregex), '')
|
13
|
+
return $&
|
14
|
+
end
|
15
|
+
|
16
|
+
def ComplexPackageFactory.create(_str)
|
17
|
+
ComplexPackage.new(_str, ComplexItem.getRegex(@@nameregex, @@valueregex))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class ComplexPackage < ComplexItem
|
23
|
+
@@subitemregex = /\A.+\Z/
|
24
|
+
|
25
|
+
def initialize(_str, _regex)
|
26
|
+
super(_str, _regex)
|
27
|
+
|
28
|
+
tmp = @value
|
29
|
+
@value = []
|
30
|
+
|
31
|
+
tmp.each do |item|
|
32
|
+
item.strip!
|
33
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration subitem \n -----\n #{item} \n -----\n of item <#{name}> has wrong format." unless item =~ @@subitemregex
|
34
|
+
@value.push(item.split(/,\s/))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def print
|
39
|
+
puts " #{@name} = { ##{self.class.to_s}"
|
40
|
+
@value.each { |v| puts " #{v.join(", ")};" }
|
41
|
+
puts " }"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'complexitem'
|
2
|
+
require 'itemfactory'
|
3
|
+
require 'configexception'
|
4
|
+
|
5
|
+
module Config
|
6
|
+
|
7
|
+
class ComplexPinsFactory < ItemFactory
|
8
|
+
@@nameregex = /Pins/
|
9
|
+
@@valueregex = /(\s*.*[;]\s*)*(\s*.*[;]*\s*)?/
|
10
|
+
|
11
|
+
def ComplexPinsFactory.match(_str)
|
12
|
+
_str.sub!(ComplexItem.getRegex(@@nameregex, @@valueregex), '')
|
13
|
+
return $&
|
14
|
+
end
|
15
|
+
|
16
|
+
def ComplexPinsFactory.create(_str)
|
17
|
+
ComplexPins.new(_str, ComplexItem.getRegex(@@nameregex, @@valueregex))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ComplexPins < ComplexItem
|
22
|
+
@@subitemregex = /\A([\w\(\)]+)\s*->\s*(\w+)\s*,\s*(true|false)\s*\Z/
|
23
|
+
|
24
|
+
def initialize(_str, _regex)
|
25
|
+
super(_str, _regex)
|
26
|
+
|
27
|
+
tmp = @value
|
28
|
+
@value = []
|
29
|
+
tmp.each do |item|
|
30
|
+
item.strip!
|
31
|
+
if item =~ @@subitemregex
|
32
|
+
item = Hash.new
|
33
|
+
item["signalname"] = $1
|
34
|
+
item["pinname"] = $2
|
35
|
+
item["pullup"] = $3
|
36
|
+
@value.push(item)
|
37
|
+
else
|
38
|
+
raise ConfigWrongFormatException.new(self.class), "Configuration subitem <#{item}> of item <#{name}> has wrong format."
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def each(&_block)
|
45
|
+
@value.each do |subitem|
|
46
|
+
_block.call(subitem["signalname"], subitem["pinname"], subitem["pullup"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def print
|
51
|
+
puts " #{@name} = { ##{self.class.to_s}"
|
52
|
+
@value.each { |v| puts " #{v["signalname"]} -> #{v["pinname"]}, #{v["pinnname"]};" }
|
53
|
+
puts " }"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|