class OroGen::Spec::Deployment

Instances of this class are used to define a deployment. The deployment is the part in which the TaskContext classes are instanciated and associated with specific Activity classes.

Constants

KNOWN_LOG_LEVELS

Attributes

connections[R]

The set of connections set up for this deployment. This is a set of [from, to] PortDeployment objects.

name[R]

The deployment name

peers[R]

The set of peer pairs set up for this deployment. This is a set of [a, b] TaskDeployment objects.

project[R]

The underlying Project object

task_activities[R]

The set of tasks that need to be deployed

Public Class Methods

new(project = nil, name = nil) click to toggle source
# File lib/orogen/spec/deployment.rb, line 532
def initialize(project = nil, name = nil)
    @project       = project
    @name            = name

    @install         = true
    @task_activities = Array.new
    @file_reporters  = Hash.new
    @loggers         = Hash.new
    @connections     = Array.new
    @tcp_reporters   = Hash.new
    @peers           = Set.new
    @corba_enabled   = nil
    @browse          = nil
    @loglevel        = nil
    @transports      = Array.new
    @manually_loaded_types = Set.new
    @lock_timeout_no_period = nil
    @lock_timeout_period_factor =  nil
end

Public Instance Methods

activity_ordered_tasks(ordered=Array.new) click to toggle source

handels theActivity creation order to be sure that all activities are created in the right order

# File lib/orogen/spec/deployment.rb, line 706
def activity_ordered_tasks(ordered=Array.new)
    oldsize = ordered.size()
    (task_activities - ordered).each do |task|
        if !task.master || ordered.include?(task.master)
            ordered << task
        end
    end
    if ordered.size == task_activities.size
        return ordered
    elsif oldsize == ordered.size()
        activities = task_activities.map do |task|
            "\n  #{task.name} (master: #{task.master ? task.master.name : "none"})"
        end
        raise ArgumentError, "I cannot find an order in which to create the deployed tasks of #{name} during deployment" <<
            "Did you created a loop among master and slave activities ?. The #{activities.size} deployed tasks are:#{activities.join("\n  ")}"
    else
        return activity_ordered_tasks(ordered)
    end
end
add_default_logger() click to toggle source
# File lib/orogen/spec/deployment.rb, line 736
def add_default_logger
    project.using_task_library "logger"
    task("#{name}_Logger", 'logger::Logger')
end
add_peers(a, b) click to toggle source

Declare that the given tasks are peers

# File lib/orogen/spec/deployment.rb, line 766
def add_peers(a, b)
    peers << [a, b]
    self
end
connect(from, to, policy = Hash.new) click to toggle source

Connects the two given ports or tasks

# File lib/orogen/spec/deployment.rb, line 750
def connect(from, to, policy = Hash.new)
    add_peers from.activity, to.activity

    if from.kind_of?(Port)
        if !from.kind_of?(OutputPort)
            raise ArgumentError, "in connect(a, b), 'a' must be a writer port"
        elsif !to.kind_of?(InputPort)
            raise ArgumentError, "in connect(a, b), 'b' must be a reader port"
        end
    end

    connections << [from, to, ConnPolicy.from_hash(policy)]
    self
end
corba_enabled?() click to toggle source

True if this deployment should export its tasks through CORBA.

It is true by default if the CORBA transport is enabled

# File lib/orogen/spec/deployment.rb, line 686
def corba_enabled?
    if @corba_enabled.nil?
        transports.include?('corba')
    else @corba_enabled
    end
end
disable_corba() click to toggle source

Force disabling CORBA support even though the CORBA transport is enabled in this deployment

See corba_enabled?

# File lib/orogen/spec/deployment.rb, line 697
def disable_corba; @corba_enabled = false end
disable_transport(transport_name) click to toggle source

Forbid the deployment from loading the given transport

# File lib/orogen/spec/deployment.rb, line 639
def disable_transport(transport_name)
    @transports.delete(transport_name.to_str)
end
do_not_install() click to toggle source

Do not install that deployment

# File lib/orogen/spec/deployment.rb, line 523
def do_not_install; @install = false end
each_task(&block) click to toggle source

Enumerates the tasks defined on this deployment

@yieldparam [TaskDeployment] task a deployed task

# File lib/orogen/spec/deployment.rb, line 671
def each_task(&block)
    task_activities.each(&block)
end
enable_corba() click to toggle source

Force enabling CORBA support even though the CORBA transport is not enabled in this deployment

See corba_enabled?

# File lib/orogen/spec/deployment.rb, line 703
def enable_corba; @corba_enabled = true end
enable_transport(transport_name) click to toggle source

Make the deployment load the given transport

# File lib/orogen/spec/deployment.rb, line 643
def enable_transport(transport_name)
    @transports << transport_name.to_str
end
find_task_by_name(name) click to toggle source

Returns the deployed task that has this name

@return [TaskDeployment,nil] the deployed task model, or nil if

none exists with that name
# File lib/orogen/spec/deployment.rb, line 679
def find_task_by_name(name)
    task_activities.find { |act| act.name == name }
end
get_lock_timeout_no_period() click to toggle source
# File lib/orogen/spec/deployment.rb, line 787
def get_lock_timeout_no_period
    @lock_timeout_no_period
end
get_lock_timeout_period_factor() click to toggle source
# File lib/orogen/spec/deployment.rb, line 797
def get_lock_timeout_period_factor
    @lock_timeout_period_factor
end
initialize_copy(old) click to toggle source
Calls superclass method
# File lib/orogen/spec/deployment.rb, line 552
def initialize_copy(old)
    super
    @task_activities = @task_activities.dup


    @transports = @transports.dup
    @peers = @peers.dup
    @manually_loaded_types = @manually_loaded_types.dup
end
inspect() click to toggle source
# File lib/orogen/spec/deployment.rb, line 571
def inspect
    to_s
end
install?() click to toggle source

True if this deployment should be installed

# File lib/orogen/spec/deployment.rb, line 525
def install?; !!@install end
linux?() click to toggle source

True if we are generating for Linux

# File lib/orogen/spec/deployment.rb, line 528
def linux?;     project.linux? end
load_type(typename) click to toggle source

Manually Request Loading of Types that are not Provided throught the task_contex typekit.

# File lib/orogen/spec/deployment.rb, line 580
def load_type(typename)
    if !project.imported_typekits_for(typename).map(&:name)[0]
        raise ArgumentError, "cannot find a typekit defining #{typename}"
    end
    @manually_loaded_types << typename
end
lock_timeout_no_period(timeout_in_s) click to toggle source

Set the lock timeout of a thread, which has no period if set, the minimum setting is 1s

# File lib/orogen/spec/deployment.rb, line 793
def lock_timeout_no_period(timeout_in_s)
    @lock_timeout_no_period = [1,timeout_in_s].max
end
lock_timeout_period_factor(factor) click to toggle source

Set the mutex timeout for a thread with a given period by a factor of its period if set, the minimum setting is factor 10 (times the period)

# File lib/orogen/spec/deployment.rb, line 804
def lock_timeout_period_factor(factor)
    @lock_timeout_period_factor = [10,factor.to_i].max
end
rtt_transports() click to toggle source

The set of transports loaded by this deployment for which a transport should be loaded on the RTT itself

# File lib/orogen/spec/deployment.rb, line 628
def rtt_transports
    result = self.transports
    result.delete('typelib')
    result
end
set_master_slave_activity(master, slave) click to toggle source

Define an master slave avtivity between tasks

# File lib/orogen/spec/deployment.rb, line 727
def set_master_slave_activity(master, slave)
    slave.slave_of(master)
    self
end
task name, task_context → task_deployment click to toggle source

Deploys a new task using the given task context type, and returns the corresponding TaskDeployment object. This instance can be used to configure the task further (for instance specifying the activity). See TaskDeployment documentation for available options.

# File lib/orogen/spec/deployment.rb, line 654
def task(name, klass)
    if klass.respond_to?(:to_str)
        task_context = project.task_model_from_name(klass)
    else task_context = klass
    end

    if find_task_by_name(name)
        raise ArgumentError, "there is already a task #{name} on the deployment #{self.name}"
    end
    deployment = TaskDeployment.new(name, task_context)
    task_activities << deployment
    deployment
end
to_s() click to toggle source
# File lib/orogen/spec/deployment.rb, line 567
def to_s
    "#<#{self.class} name=#{name} tasks=#{task_activities.map { |t| "#{t}" }.join(", ")}>"
end
transports() click to toggle source

The set of transports loaded by this deployment, as an array of names

# File lib/orogen/spec/deployment.rb, line 635
def transports
    @transports.to_a.sort
end
used_typekits() click to toggle source

Returns the set of typekits required by this particular deployment (i.e. the tasks that are deployed in it)

# File lib/orogen/spec/deployment.rb, line 589
def used_typekits
    task_typekits = task_activities.map do |deployed_task|
        deployed_task.task_model.used_typekits.
            map(&:name)
    end.flatten.to_set
   
    @manually_loaded_types.each do |type|
        tk = project.imported_typekits_for(type).map(&:name)[0]
        if !tk
            raise InternalError, "could not find manually loaded type \"#{type}\""
        end
        task_typekits << tk
    end

    task_typekits.sort.map do |used_name|
        this_tk = project.find_typekit(used_name)
        next if this_tk.virtual?
        if !this_tk
            raise InternalError, "#{used_name} is a typekit that is listed by one of the tasks of the #{name} deployment, but the oroGen project #{project.name} does not list it"
        end
        this_tk
    end.compact
end
uses_qt?() click to toggle source
# File lib/orogen/spec/deployment.rb, line 575
def uses_qt?
    task_activities.any?{|t| t.task_model.uses_qt?}
end
xenomai?() click to toggle source

True if we are generating for Xenomai

# File lib/orogen/spec/deployment.rb, line 530
def xenomai?;   project.xenomai? end