class Orocos::Async::RemoteNameService

Base class for name services that are accessed remotely (e.g. over the network)

Public Class Methods

new(name_service,options = Hash.new) click to toggle source
Calls superclass method Orocos::Async::NameServiceBase.new
# File lib/orocos/async/name_service.rb, line 270
def initialize(name_service,options = Hash.new)
    options = Kernel.validate_options options,
        :reconnect => true,
        :known_errors => Array.new
    
    @reconnect = options.delete(:reconnect)
    options[:known_errors].concat([Orocos::ComError,Orocos::NotFound])
    super(name_service,options)
    @namespace = name_service.namespace
end

Public Instance Methods

get(name,options=Hash.new,&block) click to toggle source
# File lib/orocos/async/name_service.rb, line 313
def get(name,options=Hash.new,&block)
    async_options,other_options = Kernel.filter_options options, 
        :sync_key => nil,:raise => nil,:event_loop => @event_loop,
        :period => nil,:wait => nil

    if block
        p = proc do |task,error|
            async_options[:use] = task
            atask = if !error
                        task.to_async(async_options)
                    end
            if block.arity == 2
                block.call atask,error
            elsif !error
                block.call atask
            end
        end 
        orig_get name,other_options,&p
    else
        task = orig_get name,other_options
        task.to_async(Hash[:use => task].merge(async_options))
    end
end
name() click to toggle source
# File lib/orocos/async/name_service.rb, line 309
def name
    @delegator_obj.name
end
reconnect?() click to toggle source

True if this name service should automatically reconnect @return [Boolean]

# File lib/orocos/async/name_service.rb, line 283
def reconnect?; @reconnect end
unreachable!(options = Hash.new) click to toggle source
Calls superclass method
# File lib/orocos/async/name_service.rb, line 285
def unreachable!(options = Hash.new)
    @watchdog_timer.stop
    if !valid_delegator?
        raise "This should never happen. There must be always a valid delegator obj"
    end

    if reconnect? && options.has_key?(:error)
        obj = @delegator_obj
        obj.reset
        timer = @event_loop.async_every obj.method(:names),:period => 1.0,:sync_key => nil,:known_errors => [Orocos::NotFound,Orocos::ComError] do |names,error|
            if error
                obj.reset
            else
                reachable!(obj)
                @watchdog_timer.start
                timer.stop
            end
        end
        timer.doc = "NameService #{name} reconnect"
    else
    end
    super
end