Class: Syskit::GUI::ComponentNetworkView

Inherits:
ComponentNetworkBaseView show all
Defined in:
lib/syskit/gui/component_network_view.rb

Overview

Generic component network visualization

It displays the task hierarchy as well as the dataflow network

Constant Summary

Constants inherited from ComponentNetworkBaseView

Syskit::GUI::ComponentNetworkBaseView::Button, Syskit::GUI::ComponentNetworkBaseView::DATA_SERVICE_WITHOUT_NAMES_TEMPLATE, Syskit::GUI::ComponentNetworkBaseView::DATA_SERVICE_WITH_NAMES_TEMPLATE

Instance Attribute Summary collapse

Attributes inherited from ComponentNetworkBaseView

#current_model, #page

Instance Method Summary collapse

Methods inherited from ComponentNetworkBaseView

#buttonClicked, #clear, common_graph_buttons, #compute_system_network, #disable, #enable, find_definition_place, graph_annotation_buttons, html_defined_in, #instanciate_model, #list_services, make_annotation_buttons, #push_plan, #render_data_services, #render_require_section, #save_svg, task_annotation_buttons

Constructor Details

#initialize(page) ⇒ ComponentNetworkView

Returns a new instance of ComponentNetworkView



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/syskit/gui/component_network_view.rb', line 34

def initialize(page)
    super
    @view_partial_plans = true
    @plan = Roby::Plan.new

    @hierarchy_options = Hash[
        title: 'Task Dependency Hierarchy',
        id: 'hierarchy',
        remove_compositions: false,
        annotations: ['task_info', 'port_details'].to_set,
        zoom: 1
    ]
    @dataflow_options = Hash[
        title: 'Dataflow',
        id: 'dataflow',
        remove_compositions: false,
        show_all_ports: false,
        annotations: ['task_info'].to_set,
        excluded_models: Set.new,
        zoom: 1
    ]

    buttons = []
    buttons << Button.new("dataflow/show_compositions",
                          on_text: 'Show compositions',
                          off_text: 'Hide compositions',
                          state: !dataflow_options[:remove_compositions])
    buttons << Button.new("dataflow/show_all_ports",
                          on_text: 'Show all ports',
                          off_text: 'Hide unused ports',
                          state: dataflow_options[:show_all_ports])

    if defined? OroGen::Logger::Logger
        dataflow_options[:excluded_models] << OroGen::Logger::Logger
        buttons << Button.new("dataflow/show_loggers",
                              on_text: 'Show loggers',
                              off_text: 'Hide loggers',
                              state: false)
    end

    buttons.concat(self.class.common_graph_buttons('dataflow'))
    buttons.concat(self.class.task_annotation_buttons('dataflow', dataflow_options[:annotations]))
    buttons.concat(self.class.graph_annotation_buttons('dataflow', dataflow_options[:annotations]))
    dataflow_options[:buttons] = buttons

    buttons = []
    buttons.concat(self.class.common_graph_buttons('hierarchy'))
    hierarchy_options[:buttons] = buttons
end

Instance Attribute Details

#dataflow_optionsObject (readonly)

Default rendering options for Syskit::GUI::ComponentNetworkBaseView#push_plan for the dataflow graph



18
19
20
# File 'lib/syskit/gui/component_network_view.rb', line 18

def dataflow_options
  @dataflow_options
end

#hierarchy_optionsObject (readonly)

Default rendering options for Syskit::GUI::ComponentNetworkBaseView#push_plan for the hierarchy graph



22
23
24
# File 'lib/syskit/gui/component_network_view.rb', line 22

def hierarchy_options
  @hierarchy_options
end

#planRoby::Plan (readonly)

The plan object that holds the network we render

Returns:

  • (Roby::Plan)


27
28
29
# File 'lib/syskit/gui/component_network_view.rb', line 27

def plan
  @plan
end

#taskSyskit::Component (readonly)

The toplevel task for the model we render

Returns:



32
33
34
# File 'lib/syskit/gui/component_network_view.rb', line 32

def task
  @task
end

Instance Method Details

#process_options(kind, model, options) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/syskit/gui/component_network_view.rb', line 157

def process_options(kind, model, options)
    options = Kernel.normalize_options options

    name = options[:name]
    if options[:id]
        options[:id] = options[:id] % "#{kind}-#{name}"
    end

    if externals = options.delete(:external_objects)
        options[:external_objects] = externals % "#{kind}-#{name}"
    end
    options
end

#render(model, method: :instanciate_model, name: nil, show_requirements: false, instanciate_options: Hash.new, dataflow: Hash.new, hierarchy: Hash.new, **render_options) ⇒ Object

Render a model on this view

Parameters:



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/syskit/gui/component_network_view.rb', line 102

def render(model,
           method: :instanciate_model,
           name: nil,
           show_requirements: false,
           instanciate_options: Hash.new,
           dataflow: Hash.new,
           hierarchy: Hash.new,
           **render_options)
    super

    plan.clear

    if show_requirements
        html = ModelViews.render_instance_requirements(page,
                model.to_instance_requirements,
                resolve_dependency_injection: true).join("\n")
        page.push("Resolved Requirements", "<pre>#{html}</pre>")
    end

    begin
        if method == :compute_system_network
            tic = Time.now
            @task = compute_system_network(model, plan)
            timing = Time.now - tic
        else
            @task = instanciate_model(model, plan, instanciate_options)
        end
    rescue Exception => e
        if view_partial_plans? then
            exception = e
        else raise
        end
    end

    render_options[:name] ||= model.object_id.to_s
    if timing
        page.push("", "<p>Network generated in %.3f</p>" % [timing], id: "timing-#{name}")
    end

    hierarchy_options = self.hierarchy_options.
        merge(render_options).
        merge(hierarchy)
    hierarchy_options = process_options('hierarchy', model, hierarchy_options)
    dataflow_options = self.dataflow_options.
        merge(render_options).
        merge(dataflow)
    dataflow_options = process_options('dataflow', model, dataflow_options)


    render_plan
    if exception
        raise exception
    end
end

#render_plan(hierarchy: Hash.new, dataflow: Hash.new, **options) ⇒ Object

Renders #plan

This renders the plan's hierarchy and dataflow

Syskit::GUI::ComponentNetworkBaseView#push_plan for both the hierarchy and dataflow graphs

Parameters:



183
184
185
186
187
188
189
190
191
192
# File 'lib/syskit/gui/component_network_view.rb', line 183

def render_plan(hierarchy: Hash.new, dataflow: Hash.new, **options)
    all_annotations = Syskit::Graphviz.available_annotations.to_set

    hierarchy_options = options.merge(self.hierarchy_options).merge(hierarchy)
    push_plan('hierarchy', plan, hierarchy_options)
    dataflow_options = Hash[annotations: all_annotations].
        merge(self.dataflow_options).merge(options).merge(dataflow)
    push_plan('dataflow', plan, dataflow_options)
    emit updated
end

#view_partial_plans=(flag) ⇒ Object

Whether the plan should be displayed regardless of errors during deployment or not. It defaults to true.



14
# File 'lib/syskit/gui/component_network_view.rb', line 14

attr_predicate :view_partial_plans?, true

#view_partial_plans?Object

Whether the plan should be displayed regardless of errors during deployment or not. It defaults to true.



14
# File 'lib/syskit/gui/component_network_view.rb', line 14

attr_predicate :view_partial_plans?, true