Module: AUIControl
Class Method Summary collapse
- .find_common(tasks) ⇒ Object
-
.find_common_aic(tasks, activate = false, parents = { }) ⇒ String
Searches for the common root aic that contains all tasks of elements.
- .organize(aio, parent_aio = nil, layer = 0) ⇒ Object
-
.organize2(aio, parent_aio = nil, layer = 0) ⇒ Object
connects all aios on the same level.
- .organize_new(aio, prev = nil, layer = 0) ⇒ Object
-
.organize_sub(aio, parent_aio = nil, layer = 0) ⇒ Object
ensures that all prev/next relationships are setup properlyin one complete sequence.
-
.present_children(aisc) ⇒ Object
called from AISingleChoice mapping.
- .suspend_all ⇒ Object
- .suspend_others(ais) ⇒ Object
Methods included from MINT
#cache_coordinates, #cache_touched, #consume, #filter, #has_moved?, #restart_timeout, #start_one_time_tick, #start_timeout, #stop_timeout, #touch_changed?
Class Method Details
.find_common(tasks) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 152 def AUIControl.find_common(tasks) if tasks.length==1 return tasks[0] end parents ={ } tasks.each do |name| t = AIO.first(:name=>name) tname = t.name parents[tname] = [tname] while (t.parent) parents[tname].push t.parent.name t = t.parent end end lasttaskname = nil while 1==1 taskname = nil parents.keys.each_with_index do |k,i| if (i==0) taskname = parents[k].pop else comp = parents[k].pop if not comp.eql? taskname return lasttaskname end end end lasttaskname = taskname end end |
.find_common_aic(tasks, activate = false, parents = { }) ⇒ String
Searches for the common root aic that contains all tasks of elements. During the search towards the root it activates all relevant containters in the Layoutmodel in case activate is set to true.
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 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 113 def AUIControl.find_common_aic(tasks,activate=false, parents ={ }) if tasks.length==1 return tasks[0] end tasks.each do |e| p "processing #{e}" aio = AIO.first(:name=>e) if (aio==nil) throw ("AIO with name #{e} not found in AUI model!") end if (activate) aio.process_event("present") end if aio.parent and not parents[aio.parent.name] parents[aio.parent.name]=aio.name elsif aio.parent and parents[aio.parent.name] # already existing parent, thus all further saved parents of this task needs to be removed puts "parents #{parents.inspect}" parents.each {|k,v| if (v.eql? parents[aio.parent.name] or v.eql? aio.name) parents.delete(k) p "delete key #{k} value #{v}" end } parents[aio.parent.name]=aio.name # parents.delete(parents.invert[ parents[aio.parent.name]]) end end p "next step" if parents.length>0 return find_common_aic(parents.keys,activate,parents) else return tasks.first end end |
.organize(aio, parent_aio = nil, layer = 0) ⇒ Object
56 57 58 59 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 56 def AUIControl.organize(aio,parent_aio = nil, layer = 0) r= organize_sub(aio,parent_aio, layer ) r.process_event("organize") end |
.organize2(aio, parent_aio = nil, layer = 0) ⇒ Object
connects all aios on the same level
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 79 def AUIControl.organize2(aio,parent_aio = nil, layer = 0) # if layer == 0 # aio.next = aio # aio.previous = aio # end if (aio.kind_of? MINT::AIContainer) first = aio.children.first last = nil aio.children.each do |child| if last last.next = child.name child.previous = last.name end copy = child organize2(copy,nil,layer+1) last = child end aio.process_event!("organize") else aio.process_event!("organize") end p "organized #{aio.name}" end |
.organize_new(aio, prev = nil, layer = 0) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 61 def AUIControl.organize_new (aio,prev = nil, layer = 0) aio.previous=prev.name if prev if (aio.kind_of? MINT::AIContainer) prev_child = aio aio.children.each do |child| organize(child,prev_child) prev_child = child end if aio.children aio.next=aio.children[0].name end end aio.process_event "organize" end |
.organize_sub(aio, parent_aio = nil, layer = 0) ⇒ Object
ensures that all prev/next relationships are setup properlyin one complete sequence
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 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 29 def AUIControl.organize_sub(aio,parent_aio = nil, layer = 0) last_child = nil if (aio.kind_of? MINT::AIContainer) # aio.entry = aio.children[0] prev = aio aio.children.each do |child| if (child.instance_of? MINT::AIReference) # skip AIReferences for prev/next navigation child.process_event("organize") next end prev.next = child.name prev.process_event("organize") #if not prev.kind_of? MINT::AIContainer child.previous = prev.name prev = organize_sub(child,aio,layer+1) last_child = child end #prev.process_event("organize") return prev else return aio end end |
.present_children(aisc) ⇒ Object
called from AISingleChoice mapping
6 7 8 9 10 11 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 6 def AUIControl.present_children(aisc) sc = AISingleChoice.first(:name=>aisc['name']) sc.children.each do |aio| aio.process_event :present end end |
.suspend_all ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 13 def AUIControl.suspend_all aics = AIContainer.all(:parent =>nil) aics.each do |aic| p "Suspend AIC: #{aic.name}" aic.process_event :suspend end end |
.suspend_others(ais) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/MINT-core/agent/auicontrol.rb', line 21 def AUIControl.suspend_others(ais) ais = AISinglePresence.first(:name=>ais['name']) ais.children.each do |aio| aio.process_event :suspend if not aio.name.eql? ais.active_child.name end end |