Class: PlcUtil::Awl::AwlFile
- Inherits:
-
Object
- Object
- PlcUtil::Awl::AwlFile
- Defined in:
- lib/plcutil/siemens/awl/awl_file.rb
Instance Attribute Summary collapse
-
#symlist ⇒ Object
readonly
Returns the value of attribute symlist.
Instance Method Summary collapse
- #each_exploded(options = {}, &block) ⇒ Object
-
#initialize(filename, options = {}) ⇒ AwlFile
constructor
A new instance of AwlFile.
- #lookup_symlist(tag) ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ AwlFile
Returns a new instance of AwlFile.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/plcutil/siemens/awl/awl_file.rb', line 18 def initialize(filename, = {}) @symlist = [:symlist] && SymlistFile.new([:symlist]) || {} # parse file parser = PlcUtil::Awl::AwlGrammarParser.new awl_nodes = parser.parse File.read(filename) @awl = awl_nodes && awl_nodes.visit if !@awl raise [ "Unable to parse file: #{filename}", "Failure on line #{parser.failure_line} column #{parser.failure_column}", "Details:", parser.failure_reason.inspect, ].join("\n") end end |
Instance Attribute Details
#symlist ⇒ Object (readonly)
Returns the value of attribute symlist.
16 17 18 |
# File 'lib/plcutil/siemens/awl/awl_file.rb', line 16 def symlist @symlist end |
Instance Method Details
#each_exploded(options = {}, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/plcutil/siemens/awl/awl_file.rb', line 38 def each_exploded( = {}, &block) @awl[:dbs].each do |raw| db = create_struct raw name = if [:no_block] '' else raw[:id] end a = DbAddress.new 0, db_address(raw[:name]) db.each_exploded(a, name) do |addr, name, comment, type_name| yield addr, name, comment, type_name end end end |
#lookup_symlist(tag) ⇒ Object
34 35 36 |
# File 'lib/plcutil/siemens/awl/awl_file.rb', line 34 def lookup_symlist(tag) ([:blocks] && [:blocks][tag]) || (@symlist && @symlist[tag]) end |