diff options
-rw-r--r-- | lib/evendoors/board.rb | 2 | ||||
-rw-r--r-- | lib/evendoors/door.rb | 2 | ||||
-rw-r--r-- | lib/evendoors/room.rb | 17 | ||||
-rw-r--r-- | lib/evendoors/space.rb | 3 | ||||
-rw-r--r-- | lib/evendoors/twirl.rb | 5 | ||||
-rw-r--r-- | spec/evendoors_spec.rb | 17 | ||||
-rw-r--r-- | test/test_evendoors.rb | 16 |
7 files changed, 36 insertions, 26 deletions
diff --git a/lib/evendoors/board.rb b/lib/evendoors/board.rb index 24b028a..3cc2240 100644 --- a/lib/evendoors/board.rb +++ b/lib/evendoors/board.rb @@ -23,7 +23,7 @@ module EvenDoors @saved = p receive_p p if not @saved.nil? - puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug + puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR release_p @saved @saved = nil diff --git a/lib/evendoors/door.rb b/lib/evendoors/door.rb index c87bfcd..6118a27 100644 --- a/lib/evendoors/door.rb +++ b/lib/evendoors/door.rb @@ -28,7 +28,7 @@ module EvenDoors @saved = p receive_p p if not @saved.nil? - puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug + puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR release_p @saved @saved = nil diff --git a/lib/evendoors/room.rb b/lib/evendoors/room.rb index 729e66c..71c8971 100644 --- a/lib/evendoors/room.rb +++ b/lib/evendoors/room.rb @@ -28,21 +28,22 @@ module EvenDoors end # def start! - puts " * start #{path}" if EvenDoors::Twirl.debug + puts " * start #{path}" if EvenDoors::Twirl.debug_routing @spots.values.each do |spot| spot.start! if spot.respond_to? :start! end end # def stop! - puts " * stop #{path}" if EvenDoors::Twirl.debug + puts " * stop #{path}" if EvenDoors::Twirl.debug_routing @spots.values.each do |spot| spot.stop! if spot.respond_to? :stop! end end # def space - ( @parent.nil? ? self : @parent.space ) + return @space if @space + @space = ( @parent.nil? ? self : @parent.space ) end # def try_links p - puts " -> try_links ..." if EvenDoors::Twirl.debug + puts " -> try_links ..." if EvenDoors::Twirl.debug_routing links = @links[p.src.name] return false if links.nil? pending_link = nil @@ -86,7 +87,7 @@ module EvenDoors end # def send_p p - puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug + puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing if p.src.nil? # do not route orphan particles !! p.error! EvenDoors::ERROR_ROUTE_NS, space @@ -103,12 +104,12 @@ module EvenDoors else p.error! EvenDoors::ERROR_ROUTE_NDNL end - puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug + puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing EvenDoors::Twirl.send_p p end # def send_sys_p p - puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug + puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing if p.next_dst p.split_dst! if p.door @@ -121,7 +122,7 @@ module EvenDoors else p.error! EvenDoors::ERROR_ROUTE_SND end - puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug + puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing EvenDoors::Twirl.send_sys_p p end # diff --git a/lib/evendoors/space.rb b/lib/evendoors/space.rb index 22b9910..da13065 100644 --- a/lib/evendoors/space.rb +++ b/lib/evendoors/space.rb @@ -8,7 +8,8 @@ module EvenDoors # def initialize n, args={} super n, nil - EvenDoors::Twirl.debug = args[:debug] || false + EvenDoors::Twirl.debug_errors = args[:debug_errors] || false + EvenDoors::Twirl.debug_routing = args[:debug_routing] || false end # def twirl! diff --git a/lib/evendoors/twirl.rb b/lib/evendoors/twirl.rb index 1ddf490..cb01618 100644 --- a/lib/evendoors/twirl.rb +++ b/lib/evendoors/twirl.rb @@ -6,7 +6,8 @@ module EvenDoors # class Twirl # - @debug = false + @debug_routing = false + @debug_errors = false @pool = {} # per particle class free list @sys_fifo = [] # system particles fifo list @app_fifo = [] # application particles fifo list @@ -15,7 +16,7 @@ module EvenDoors # class << self # - attr_accessor :debug, :run + attr_accessor :run, :debug_routing, :debug_errors # def release_p p # hope there is no circular loop diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb index 6bde8f2..4923fd4 100644 --- a/spec/evendoors_spec.rb +++ b/spec/evendoors_spec.rb @@ -328,12 +328,19 @@ describe EvenDoors do describe EvenDoors::Space do # it "does really little for now" do - EvenDoors::Twirl.debug.should be false - space = EvenDoors::Space.new 'dom0', :debug=>true - EvenDoors::Twirl.debug.should be true + EvenDoors::Twirl.debug_routing.should be false + space = EvenDoors::Space.new 'dom0', :debug_routing=>true + EvenDoors::Twirl.debug_routing.should be true space.twirl! - EvenDoors::Twirl.debug = false - EvenDoors::Twirl.debug.should be false + EvenDoors::Twirl.debug_routing = false + EvenDoors::Twirl.debug_routing.should be false + # + EvenDoors::Twirl.debug_errors.should be false + space = EvenDoors::Space.new 'dom0', :debug_errors=>true + EvenDoors::Twirl.debug_errors.should be true + space.twirl! + EvenDoors::Twirl.debug_errors = false + EvenDoors::Twirl.debug_errors.should be false end # end diff --git a/test/test_evendoors.rb b/test/test_evendoors.rb index 18073d4..2e8a732 100644 --- a/test/test_evendoors.rb +++ b/test/test_evendoors.rb @@ -7,7 +7,7 @@ require 'evendoors' class InputDoor < EvenDoors::Door # def start! - puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug + puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing @lines = [ "#{name} says : hello", "world ( from #{path} )" ] p = require_p EvenDoors::Particle p.set_dst! EvenDoors::ACT_GET, path @@ -15,11 +15,11 @@ class InputDoor < EvenDoors::Door end # # def stop! - # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug + # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing # end # def receive_p p - puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug + puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug_routing if p.action==EvenDoors::ACT_GET p.reset! p.set_data 'line', @lines.shift @@ -43,7 +43,7 @@ end class ConcatBoard < EvenDoors::Board # def receive_p p - puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug + puts " * #{self.class.name} receive_p : #{p.action}" if EvenDoors::Twirl.debug_routing if p.action==EvenDoors::ACT_ERROR # else @@ -63,15 +63,15 @@ end class OutputDoor < EvenDoors::Door # # def start! - # puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug + # puts " * start #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing # end # # def stop! - # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug + # puts " * stop #{self.class.name} #{@path}" if EvenDoors::Twirl.debug_routing # end # def receive_p p - if EvenDoors::Twirl.debug + if EvenDoors::Twirl.debug_routing puts " * #{self.class.name} receive_p : #{@path} : DATA #{p.get_data('line')}" else puts p.get_data 'line' @@ -81,7 +81,7 @@ class OutputDoor < EvenDoors::Door # end # -space = EvenDoors::Space.new 'space', :debug=>true +space = EvenDoors::Space.new 'space', :debug_routing=>false, :debug_errors=>true # room0 = EvenDoors::Room.new 'room0', space room1 = space.add_spot EvenDoors::Room.new 'room1' |