Class: Syskit::GUI::Instanciate
- Defined in:
- lib/syskit/gui/instanciate.rb
Instance Attribute Summary collapse
-
#apply_btn ⇒ Object
readonly
Returns the value of attribute apply_btn.
-
#display ⇒ Object
readonly
Returns the value of attribute display.
-
#exception_view ⇒ Object
readonly
Returns the value of attribute exception_view.
-
#instance_txt ⇒ Object
readonly
Returns the value of attribute instance_txt.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#permanent ⇒ Object
readonly
Returns the value of attribute permanent.
-
#rendering ⇒ Object
readonly
Returns the value of attribute rendering.
Class Method Summary collapse
- .compute(plan, passes, compute_policies, compute_deployments, validate_network, display_timepoints = false, permanent = []) ⇒ Object
- .parse_passes(remaining) ⇒ Object
Instance Method Summary collapse
- #compute ⇒ Object
- #create_toolbar ⇒ Object
-
#initialize(parent = nil, arguments = "", permanent = []) ⇒ Instanciate
constructor
A new instance of Instanciate.
- #plan ⇒ Object
Constructor Details
#initialize(parent = nil, arguments = "", permanent = []) ⇒ Instanciate
Returns a new instance of Instanciate
25 26 27 28 29 30 31 32 33 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 |
# File 'lib/syskit/gui/instanciate.rb', line 25 def initialize(parent = nil, arguments = "", permanent = []) super(parent) main_layout = Qt::VBoxLayout.new(self) = main_layout.add_layout() splitter = Qt::Splitter.new(self) main_layout.(splitter) # Add the main view @display = Qt::WebView.new @page = HTMLPage.new(@display.page) main_layout.(@display) @rendering = Syskit::GUI::ComponentNetworkView.new(@page) rendering.enable # Add the exception view @exception_view = MetaRuby::GUI::ExceptionView.new splitter.orientation = Qt::Vertical splitter. display splitter.set_stretch_factor 0, 3 splitter. exception_view splitter.set_stretch_factor 1, 1 @apply_btn.connect(SIGNAL('clicked()')) do Roby.app.clear_exceptions Roby.app.reload_models compute end @permanent = permanent @instance_txt.text = arguments end |
Instance Attribute Details
#apply_btn ⇒ Object (readonly)
Returns the value of attribute apply_btn
10 11 12 |
# File 'lib/syskit/gui/instanciate.rb', line 10 def apply_btn @apply_btn end |
#display ⇒ Object (readonly)
Returns the value of attribute display
13 14 15 |
# File 'lib/syskit/gui/instanciate.rb', line 13 def display @display end |
#exception_view ⇒ Object (readonly)
Returns the value of attribute exception_view
17 18 19 |
# File 'lib/syskit/gui/instanciate.rb', line 17 def exception_view @exception_view end |
#instance_txt ⇒ Object (readonly)
Returns the value of attribute instance_txt
11 12 13 |
# File 'lib/syskit/gui/instanciate.rb', line 11 def instance_txt @instance_txt end |
#page ⇒ Object (readonly)
Returns the value of attribute page
14 15 16 |
# File 'lib/syskit/gui/instanciate.rb', line 14 def page @page end |
#permanent ⇒ Object (readonly)
Returns the value of attribute permanent
19 20 21 |
# File 'lib/syskit/gui/instanciate.rb', line 19 def permanent @permanent end |
#rendering ⇒ Object (readonly)
Returns the value of attribute rendering
15 16 17 |
# File 'lib/syskit/gui/instanciate.rb', line 15 def rendering @rendering end |
Class Method Details
.compute(plan, passes, compute_policies, compute_deployments, validate_network, display_timepoints = false, permanent = []) ⇒ Object
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/instanciate.rb', line 104 def self.compute(plan, passes, compute_policies, compute_deployments, validate_network, display_timepoints = false, permanent = []) Scripts.start_profiling Scripts.pause_profiling if passes.empty? && !permanent.empty? passes << [] end passes.each do |actions| requirement_tasks = actions.map do |action_name| action_name = action_name.gsub(/!$/, '') begin _, act = ::Robot.action_from_name(action_name) rescue ArgumentError act = eval(action_name).to_action end # Instanciate the action, and find out if it is actually # a syskit-centric action or not task = act.instanciate(plan) if !(planner = task.planning_task) || !planner.respond_to?(:requirements) raise ArgumentError, "#{action_name} is not an action created from a Syskit definition or device" end plan.add_mission_task(task) task end permanent.each do |req| plan.add_mission_task(task = req.as_plan) requirement_tasks << task end requirement_tasks = requirement_tasks.map(&:planning_task) Scripts.resume_profiling Scripts.tic engine = Syskit::NetworkGeneration::Engine.new(plan) engine.resolve(requirement_tasks: requirement_tasks, compute_policies: compute_policies, compute_deployments: compute_deployments, validate_generated_network: validate_network, validate_deployed_network: validate_network, validate_final_network: validate_network, on_error: :commit) plan.static_garbage_collect do |task| plan.remove_task(task) end Scripts.toc_tic "computed deployment in %.3f seconds" if display_timepoints pp engine.format_timepoints end Scripts.pause_profiling end Scripts.end_profiling end |
.parse_passes(remaining) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/syskit/gui/instanciate.rb', line 87 def self.parse_passes(remaining) passes = [] current = [] while name = remaining.shift if name == "/" passes << current current = [] else current << name end end if !current.empty? passes << current end passes end |
Instance Method Details
#compute ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/syskit/gui/instanciate.rb', line 70 def compute passes = Instanciate.parse_passes(instance_txt.text.split(" ")) plan.clear exception_view.clear begin Instanciate.compute(plan, passes, true, true, true, false, permanent) rescue Exception => e Roby.app.registered_exceptions.each do |loading_error, reason| exception_view.push(loading_error, reason) end exception_view.push(e) end rendering.render_plan end |
#create_toolbar ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/syskit/gui/instanciate.rb', line 61 def = Qt::HBoxLayout.new @apply_btn = Qt::PushButton.new("Reload && Apply", self) @instance_txt = Qt::LineEdit.new(self) .(@apply_btn) .(@instance_txt) end |
#plan ⇒ Object
21 22 23 |
# File 'lib/syskit/gui/instanciate.rb', line 21 def plan rendering.plan end |