diff options
Diffstat (limited to 'lib/iotas')
| -rw-r--r-- | lib/iotas/door.rb | 2 | ||||
| -rw-r--r-- | lib/iotas/iota.rb (renamed from lib/iotas/spot.rb) | 6 | ||||
| -rw-r--r-- | lib/iotas/particle.rb | 4 | ||||
| -rw-r--r-- | lib/iotas/room.rb | 34 | ||||
| -rw-r--r-- | lib/iotas/spin.rb | 14 | 
5 files changed, 30 insertions, 30 deletions
diff --git a/lib/iotas/door.rb b/lib/iotas/door.rb index 8474b09..a5ffb97 100644 --- a/lib/iotas/door.rb +++ b/lib/iotas/door.rb @@ -21,7 +21,7 @@  #  module Iotas      # -    class Door < Spot +    class Door < Iota          #          def initialize n, p              super n, p diff --git a/lib/iotas/spot.rb b/lib/iotas/iota.rb index aca0c2b..e26bf4f 100644 --- a/lib/iotas/spot.rb +++ b/lib/iotas/iota.rb @@ -21,7 +21,7 @@  #  module Iotas      # -    class Spot +    class Iota          #          def initialize n, p              @name   = n     # unique in it's room @@ -29,8 +29,8 @@ module Iotas              @viewer = nil   # particle going through that position will be sent there readonly              @path = ( @parent ? @parent.path+Iotas::PATH_SEP : '') + @name              @spin = ( @parent ? @parent.spin : self ) -            @parent.add_spot self if @parent -            raise Iotas::Exception.new "Spot name #{name} is not valid" if @name.include? Iotas::PATH_SEP +            @parent.add_iota self if @parent +            raise Iotas::Exception.new "Iota name #{name} is not valid" if @name.include? Iotas::PATH_SEP          end          #          attr_reader :name, :path, :spin diff --git a/lib/iotas/particle.rb b/lib/iotas/particle.rb index ffb141b..4141953 100644 --- a/lib/iotas/particle.rb +++ b/lib/iotas/particle.rb @@ -26,8 +26,8 @@ module Iotas          #          def initialize o={}              @ts = Time.now      # creation time -            @src = nil          # Spot where it's originated from -            @dst = nil          # Spot where it's heading to +            @src = nil          # Iota where it's originated from +            @dst = nil          # Iota where it's heading to              @room = nil         # Room path part of the current destination              @door = nil         # Door path part of the current destination              @action = nil       # action part of the current destination diff --git a/lib/iotas/room.rb b/lib/iotas/room.rb index 569c921..203b74c 100644 --- a/lib/iotas/room.rb +++ b/lib/iotas/room.rb @@ -21,11 +21,11 @@  #  module Iotas      # -    class Room < Spot +    class Room < Iota          #          def initialize n, p              super n, p -            @spots = {} +            @iotas = {}              @links = {}          end          # @@ -33,7 +33,7 @@ module Iotas              {                  'kls'   => self.class.name,                  'name'  => @name, -                'spots' => @spots, +                'iotas' => @iotas,                  'links' => @links              }.to_json *a          end @@ -41,8 +41,8 @@ module Iotas          def self.json_create o              raise Iotas::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name              room = self.new o['name'], o['parent'] -            o['spots'].each do |name,spot| -                eval( spot['kls'] ).json_create(spot.merge!('parent'=>room)) +            o['iotas'].each do |name,iota| +                eval( iota['kls'] ).json_create(iota.merge!('parent'=>room))              end              o['links'].each do |src,links|                  links.each do |link| @@ -52,35 +52,35 @@ module Iotas              room          end          # -        def add_spot s -            raise Iotas::Exception.new "Spot #{s.name} already has #{s.parent.name} as parent" if not s.parent.nil? and s.parent!=self -            raise Iotas::Exception.new "Spot #{s.name} already exists in #{path}" if @spots.has_key? s.name +        def add_iota s +            raise Iotas::Exception.new "Iota #{s.name} already has #{s.parent.name} as parent" if not s.parent.nil? and s.parent!=self +            raise Iotas::Exception.new "Iota #{s.name} already exists in #{path}" if @iotas.has_key? s.name              s.parent = self if s.parent.nil? -            @spots[s.name]=s +            @iotas[s.name]=s          end          #          def add_link l -            l.door = @spots[l.src] +            l.door = @iotas[l.src]              raise Iotas::Exception.new "Link source #{l.src} does not exist in #{path}" if l.door.nil?              (@links[l.src] ||= [])<< l          end          #          def start!              puts " * start #{path}" if @spin.debug_routing -            @spots.values.each do |spot| spot.start! end +            @iotas.values.each do |iota| iota.start! end          end          #          def stop!              puts " * stop #{path}" if @spin.debug_routing -            @spots.values.each do |spot| spot.stop! end +            @iotas.values.each do |iota| iota.stop! end          end          #          def search_down spath              return self if spath==path              return nil if (spath=~/^#{path}\/(\w+)\/?/)!=0 -            if spot = @spots[$1] -                return spot if spot.path==spath    # needed as Door doesn't implement #search_down -                return spot.search_down spath +            if iota = @iotas[$1] +                return iota if iota.path==spath    # needed as Door doesn't implement #search_down +                return iota.search_down spath              end              nil          end @@ -114,14 +114,14 @@ module Iotas          #          def route_p p              if p.room.nil? or p.room==path -                if door = @spots[p.door] +                if door = @iotas[p.door]                      p.dst_routed! door                  else                      p.error! Iotas::ERROR_ROUTE_RRWD                  end              elsif (p.room=~/^#{path}\/(.*)/)==0                  room, *more = $1.split Iotas::PATH_SEP -                if child=@spots[room] +                if child=@iotas[room]                      child.route_p p                  else                      p.error! Iotas::ERROR_ROUTE_DDWR diff --git a/lib/iotas/spin.rb b/lib/iotas/spin.rb index 03c0141..4c8e238 100644 --- a/lib/iotas/spin.rb +++ b/lib/iotas/spin.rb @@ -37,9 +37,9 @@ module Iotas              @debug_routing  = o[:debug_routing]||o['debug_routing']||false              #              if not o.empty? -                o['spots'].each do |name,spot| -                    Iotas::Room.json_create(spot.merge!('parent'=>self)) -                end if o['spots'] +                o['iotas'].each do |name,iota| +                    Iotas::Room.json_create(iota.merge!('parent'=>self)) +                end if o['iotas']                  o['app_fifo'].each do |particle|                      @app_fifo << Iotas::Particle.json_create(particle.merge!('spin'=>self))                  end if o['app_fifo'] @@ -57,7 +57,7 @@ module Iotas                  'timestamp'     => Time.now,                  'name'          => @name,                  'hibernation'   => @hibernation, -                'spots'         => @spots, +                'iotas'         => @iotas,                  'sys_fifo'      => @sys_fifo,                  'app_fifo'      => @app_fifo,                  'debug_errors'  => @debug_errors, @@ -71,7 +71,7 @@ module Iotas          end          #          def clear! -            @spots.clear +            @iotas.clear              @pool.clear              @sys_fifo.clear              @app_fifo.clear @@ -113,7 +113,7 @@ module Iotas          end          #          def spin! -            @spots.values.each do |spot| spot.start! end unless @hibernation +            @iotas.values.each do |iota| iota.start! end unless @hibernation              @run = true              @hibernation = false              while @run and (@sys_fifo.length>0 or @app_fifo.length>0) @@ -127,7 +127,7 @@ module Iotas                      break                  end              end -            @spots.values.each do |spot| spot.stop! end unless @hibernation +            @iotas.values.each do |iota| iota.stop! end unless @hibernation          end          #          def stop!  | 
