Class: Syskit::ShellInterface

Inherits:
Roby::Interface::CommandLibrary
  • Object
show all
Defined in:
lib/syskit/shell_interface.rb

Overview

Definition of the syskit-specific interface commands

Defined Under Namespace

Classes: LoggingConfiguration, LoggingGroup, ShellDeploymentRestart

Instance Method Summary collapse

Instance Method Details

#disable_log_group(string) ⇒ Object



154
155
156
157
158
# File 'lib/syskit/shell_interface.rb', line 154

def disable_log_group(string)
    Syskit.conf.logs.disable_log_group(string)
    redeploy
    nil
end

#disable_logging_of(string) ⇒ Object

Deprecated.

use disable_log_group instead



163
164
165
# File 'lib/syskit/shell_interface.rb', line 163

def disable_logging_of(string)
    disable_log_group(string)
end

#dump_all_config(path, name = nil) ⇒ nil

Saves the configuration of all running tasks to disk

Parameters:

  • name (String) (defaults to: nil)

    the section name for the new configuration

  • path (String)

    the directory in which the files should be saved

Returns:

  • (nil)


30
31
32
33
# File 'lib/syskit/shell_interface.rb', line 30

def dump_all_config(path, name = nil)
    dump_task_config(Syskit::TaskContext, path, name)
    nil
end

#dump_task_config(task_model, path, name = nil) ⇒ nil

Save the configuration of all running tasks of the given model to disk

Parameters:

  • name (String, nil) (defaults to: nil)

    the section name for the new configuration. If nil, the task's orocos name will be used

  • path (String)

    the directory in which the files should be saved

Returns:

  • (nil)


12
13
14
15
16
17
18
19
# File 'lib/syskit/shell_interface.rb', line 12

def dump_task_config(task_model, path, name = nil)
    FileUtils.mkdir_p(path)
    plan.find_tasks(task_model).
        each do |t|
            Orocos.conf.save(t.orocos_task, path, name || t.orocos_task.name)
        end
    nil
end

#enable_log_group(string) ⇒ Object



141
142
143
144
145
# File 'lib/syskit/shell_interface.rb', line 141

def enable_log_group(string)
    Syskit.conf.logs.enable_log_group(string)
    redeploy
    nil
end

#enable_logging_of(string) ⇒ Object

Deprecated.

use enable_log_group instead



150
151
152
# File 'lib/syskit/shell_interface.rb', line 150

def enable_logging_of(string)
    enable_log_group(string)
end

#logging_confObject



169
170
171
172
173
174
175
176
177
# File 'lib/syskit/shell_interface.rb', line 169

def logging_conf
    conf = LoggingConfiguration.new(false, false, Hash.new)
    conf.port_logs_enabled = Syskit.conf.logs.port_logs_enabled?
    conf.conf_logs_enabled = Syskit.conf.logs.conf_logs_enabled?
    Syskit.conf.logs.groups.each_pair do |key, group|
        conf.groups[key] = LoggingGroup.new(key, group.enabled?)
    end
    conf
end

#pending_reloaded_configurationsObject



124
125
126
# File 'lib/syskit/shell_interface.rb', line 124

def pending_reloaded_configurations
    app.syskit_pending_reloaded_configurations
end

#redeployObject

Require the engine to redeploy the current network

It must be called after #reload_config to apply the new configuration(s)



134
135
136
137
# File 'lib/syskit/shell_interface.rb', line 134

def redeploy
    Runtime.apply_requirement_modifications(plan, force: true)
    nil
end

#reload_configObject



117
118
119
# File 'lib/syskit/shell_interface.rb', line 117

def reload_config
    app.syskit_reload_config
end

#restart_deployments(*models) ⇒ Object

Restarts deployment processes

Parameters:

  • models (Array<Model<Deployment>,Model<TaskContext>>)

    if non-empty, only the deployments matching this model or the deployments supporting tasks matching the models will be restarted, otherwise all deployments are restarted.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/syskit/shell_interface.rb', line 83

def restart_deployments(*models)
    protection = ShellDeploymentRestart.new
    plan.add(protection)
    protection.start!

    if models.empty?
        models << Syskit::Deployment
    end
    done = Roby::AndGenerator.new
    done.signals protection.redeploy_event

    models.each do |m|
        agents = plan.find_tasks(m).each_with_object(Set.new) do |task, result|
            if task.kind_of?(Syskit::TaskContext)
                result << task.execution_agent
            else
                result << task
            end
        end

        agents.each do |agent_task|
            agent_task.each_executed_task do |task|
                task.stop_event.handle_with(protection)
            end
            done << agent_task.stop_event
            agent_task.stop!
        end
    end
    nil
end

#stop_deployments(*models) ⇒ Object

Stops deployment processes

Parameters:

  • models (Array<Model<Deployment>>)

    if non-empty, only the deployments matching this model will be stopped, otherwise all deployments are stopped.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/syskit/shell_interface.rb', line 59

def stop_deployments(*models)
    if models.empty?
        models << Syskit::Deployment
    end
    models.each do |m|
        plan.find_tasks(m).
            each do |task|
                if task.kind_of?(Syskit::TaskContext)
                    task.execution_agent.stop!
                else
                    task.stop!
                end
            end
    end
end

#update_logging_conf(conf) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/syskit/shell_interface.rb', line 180

def update_logging_conf(conf)
    conf.port_logs_enabled ? Syskit.conf.logs.enable_port_logging :
                             Syskit.conf.logs.disable_port_logging

    conf.conf_logs_enabled ? Syskit.conf.logs.enable_conf_logging :
                             Syskit.conf.logs.disable_conf_logging

    conf.groups.each_pair do |name, group|
        begin
            Syskit.conf.logs.group_by_name(name).enabled = group.enabled
        rescue ArgumentError
            Syskit.warn "tried to update a group that does not exist: #{name}"
        end
    end
    redeploy
end