Class: Syskit::Models::ConfiguredDeployment

Inherits:
Object
  • Object
show all
Defined in:
lib/syskit/models/configured_deployment.rb

Overview

Representation of a deployment that is configured with name mappings and spawn options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_server_name, model, name_mappings = Hash.new, process_name = model.name, spawn_options = Hash.new) ⇒ ConfiguredDeployment

Returns a new instance of ConfiguredDeployment



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/syskit/models/configured_deployment.rb', line 20

def initialize(process_server_name, model, name_mappings = Hash.new, process_name = model.name, spawn_options = Hash.new)
    default_mappings = model.each_deployed_task_model.
        each_with_object(Hash.new) do |(deployed_task_name, _), result|
            result[deployed_task_name] = deployed_task_name
        end

    @process_server_name = process_server_name
    @model               = model
    @name_mappings       = default_mappings.merge(name_mappings)
    @process_name        = process_name
    @spawn_options       = spawn_options
end

Instance Attribute Details

#modelModel<Syskit::Deployment> (readonly)

Returns the deployment model

Returns:



12
13
14
# File 'lib/syskit/models/configured_deployment.rb', line 12

def model
  @model
end

#name_mappingsHash (readonly)

Returns the name mappings, e.g. the mapping from a task name in #model to the name this task should have while running

Returns:

  • (Hash)

    the name mappings, e.g. the mapping from a task name in #model to the name this task should have while running



18
19
20
# File 'lib/syskit/models/configured_deployment.rb', line 18

def name_mappings
  @name_mappings
end

#process_nameString (readonly)

Returns the process name

Returns:

  • (String)

    the process name



10
11
12
# File 'lib/syskit/models/configured_deployment.rb', line 10

def process_name
  @process_name
end

#process_server_nameString (readonly)

Returns the name of the process server this deployment should run on

Returns:

  • (String)

    the name of the process server this deployment should run on



8
9
10
# File 'lib/syskit/models/configured_deployment.rb', line 8

def process_server_name
  @process_server_name
end

#spawn_optionsHash (readonly)

Returns the options that should be passed at deployment startup

Returns:

  • (Hash)

    the options that should be passed at deployment startup



15
16
17
# File 'lib/syskit/models/configured_deployment.rb', line 15

def spawn_options
  @spawn_options
end

Instance Method Details

#==(other) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/syskit/models/configured_deployment.rb', line 114

def ==(other)
    return if !other.kind_of?(ConfiguredDeployment)
    return process_server_name == other.process_server_name &&
        process_name == other.process_name &&
        model == other.model &&
        spawn_options == other.spawn_options &&
        name_mappings == other.name_mappings
end

#command_line(loader: Roby.app.default_pkgconfig_loader, **options) ⇒ Object

Returns the command line information needed to start this deployment on the same machine than Syskit



45
46
47
48
49
# File 'lib/syskit/models/configured_deployment.rb', line 45

def command_line(loader: Roby.app.default_pkgconfig_loader, **options)
    model.command_line(process_name, name_mappings,
        loader: loader,
        **filter_command_line_options(options))
end

#each_deployed_task_model {|name, the| ... } ⇒ Object

Enumerate the tasks that are deployed by this configured deployment

Unlike #each_orogen_deployed_task_context_model, it enumerates the Syskit task context model

Yield Parameters:

  • name (String)

    the task name

  • the (Models::TaskCOntext)

    task model



79
80
81
82
83
84
# File 'lib/syskit/models/configured_deployment.rb', line 79

def each_deployed_task_model
    return enum_for(__method__) if !block_given?
    model.each_deployed_task_model do |name, model|
        yield(name_mappings[name], model)
    end
end

#each_orogen_deployed_task_context_model {|| ... } ⇒ Object

Enumerate the oroGen specification for the deployed tasks

Yield Parameters:

  • (OroGen::Spec::TaskDeployment)


89
90
91
92
93
94
95
96
# File 'lib/syskit/models/configured_deployment.rb', line 89

def each_orogen_deployed_task_context_model
    return enum_for(__method__) if !block_given?
    model.each_orogen_deployed_task_context_model do |deployed_task|
        task = deployed_task.dup
        task.name = name_mappings[task.name] || task.name
        yield(task)
    end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


127
# File 'lib/syskit/models/configured_deployment.rb', line 127

def eql?(other); self == other end

#filter_command_line_options(oro_logfile: nil, wait: nil, output: nil, **command_line_options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Filters out options that are part of the spawn options but not of the command-line generation options



37
38
39
40
# File 'lib/syskit/models/configured_deployment.rb', line 37

def filter_command_line_options(oro_logfile: nil, wait: nil, output: nil,
    **command_line_options)
    return command_line_options
end

#hashObject



123
124
125
# File 'lib/syskit/models/configured_deployment.rb', line 123

def hash
    [process_name, model].hash
end

#new(options = Hash.new) ⇒ Syskit::Deployment

Create a new deployment task that can represent self in a plan

Returns:



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/syskit/models/configured_deployment.rb', line 102

def new(options = Hash.new)
    options = options.merge(
        process_name: process_name,
        name_mappings: name_mappings,
        spawn_options: spawn_options,
        on: process_server_name)
    options.delete(:working_directory)
    options.delete(:output)
    options.delete(:wait)
    model.new(options)
end

#orogen_modelOroGen::Spec::Deployment

The oroGen model object that represents this configured deployment

It differs from model.orogen_model in that the #name_mappings are applied

Returns:

  • (OroGen::Spec::Deployment)


57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/syskit/models/configured_deployment.rb', line 57

def orogen_model
    if @orogen_model
        return @orogen_model
    end

    @orogen_model = model.orogen_model.dup
    orogen_model.task_activities.map! do |activity|
        activity = activity.dup
        activity.name = name_mappings[activity.name] || activity.name
        activity
    end
    @orogen_model
end

#pretty_print(pp) ⇒ Object



129
130
131
132
133
134
135
136
137
# File 'lib/syskit/models/configured_deployment.rb', line 129

def pretty_print(pp)
    pp.text "deployment #{model.orogen_model.name} with the following tasks"
    pp.nest(2) do
        each_orogen_deployed_task_context_model do |task|
            pp.breakable
            task.pretty_print(pp)
        end
    end
end