MINT-core 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/Gemfile +22 -3
  2. data/Gemfile.lock +98 -22
  3. data/History.txt +262 -0
  4. data/LICENSE +30 -0
  5. data/MINT-core.gemspec +25 -80
  6. data/Manifest.txt +145 -30
  7. data/README.rdoc +6 -163
  8. data/Rakefile +16 -17
  9. data/bin/mint-aui +3 -3
  10. data/bin/mint-cui-gfx +3 -2
  11. data/bin/mint-juggernaut.sh +0 -0
  12. data/bin/mint-tuplespace +0 -0
  13. data/lib/MINT-core.rb +53 -15
  14. data/lib/MINT-core/agent/agent.rb +1 -1
  15. data/lib/MINT-core/agent/aui.rb +0 -14
  16. data/lib/MINT-core/agent/auicontrol.rb +91 -38
  17. data/lib/MINT-core/agent/cui-gfx.rb +3 -3
  18. data/lib/MINT-core/agent/cuicontrol.rb +94 -24
  19. data/lib/MINT-core/connector/redis_connector.rb +16 -0
  20. data/lib/MINT-core/manager/mapping_manager.rb +101 -0
  21. data/lib/MINT-core/manager/mapping_parser.rb +89 -0
  22. data/lib/MINT-core/manager/mapping_server.rb +99 -0
  23. data/lib/MINT-core/manager/position_updater.rb +33 -0
  24. data/lib/MINT-core/manager/scxml_client.rb +118 -0
  25. data/lib/MINT-core/manager/scxml_server.rb +86 -0
  26. data/lib/MINT-core/mapping/action/action.rb +32 -0
  27. data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
  28. data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
  29. data/lib/MINT-core/mapping/action/event_action.rb +40 -0
  30. data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
  31. data/lib/MINT-core/mapping/mapping.rb +170 -34
  32. data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
  33. data/lib/MINT-core/mapping/observation/observation.rb +219 -0
  34. data/lib/MINT-core/mapping/sequential.rb +1 -2
  35. data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
  36. data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
  37. data/lib/MINT-core/model/aui/AICommand.rb +7 -0
  38. data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
  39. data/lib/MINT-core/model/aui/AIContext.rb +12 -0
  40. data/lib/MINT-core/model/aui/AIIN.rb +8 -0
  41. data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
  42. data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
  43. data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
  44. data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
  45. data/lib/MINT-core/model/aui/AIO.rb +76 -123
  46. data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
  47. data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
  48. data/lib/MINT-core/model/aui/AIReference.rb +16 -0
  49. data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
  50. data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
  51. data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
  52. data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
  53. data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
  54. data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
  55. data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
  56. data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
  57. data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
  58. data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
  59. data/lib/MINT-core/model/aui/aio.scxml +18 -27
  60. data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
  61. data/lib/MINT-core/model/aui/aireference.scxml +28 -0
  62. data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
  63. data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
  64. data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
  65. data/lib/MINT-core/model/aui/model.rb +15 -38
  66. data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
  67. data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
  68. data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
  69. data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
  70. data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
  71. data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
  72. data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
  73. data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
  74. data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
  75. data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
  76. data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
  77. data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
  78. data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
  79. data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
  80. data/lib/MINT-core/model/interactor.rb +167 -46
  81. data/lib/MINT-core/model/interactor.scxml +3 -0
  82. data/lib/MINT-core/model/interactor_helpers.rb +25 -0
  83. data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
  84. data/lib/MINT-core/model/ir/body/body.rb +5 -0
  85. data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
  86. data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
  87. data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
  88. data/lib/MINT-core/model/ir/body/hand.rb +5 -0
  89. data/lib/MINT-core/model/ir/body/head.rb +102 -0
  90. data/lib/MINT-core/model/ir/body/head.scxml +92 -0
  91. data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
  92. data/lib/MINT-core/model/ir/body/pose.rb +99 -0
  93. data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
  94. data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
  95. data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
  96. data/lib/MINT-core/model/ir/ir.rb +5 -0
  97. data/lib/MINT-core/model/ir/irmedia.rb +5 -0
  98. data/lib/MINT-core/model/ir/irmode.rb +5 -0
  99. data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
  100. data/lib/MINT-core/model/ir/mouse.rb +44 -0
  101. data/lib/MINT-core/model/ir/mouse.scxml +35 -0
  102. data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
  103. data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
  104. data/lib/MINT-core/model/ir/pointer.scxml +19 -0
  105. data/lib/MINT-core/model/ir/screen.rb +5 -0
  106. data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
  107. data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
  108. data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
  109. data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
  110. data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
  111. data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
  112. data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
  113. data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
  114. data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
  115. data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
  116. data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
  117. data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
  118. data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  119. data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
  120. data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
  121. data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
  122. data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
  123. data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
  124. data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
  125. data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
  126. data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
  127. data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
  128. data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
  129. data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
  130. data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
  131. data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
  132. data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
  133. data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
  134. data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
  135. data/lib/MINT-core/model/mim/mim_default.xml +52 -0
  136. data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
  137. data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
  138. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
  139. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
  140. data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
  141. data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
  142. data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
  143. data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
  144. data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
  145. data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
  146. data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
  147. data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
  148. data/lib/MINT-core/model/task.rb +6 -6
  149. data/script/console +0 -0
  150. data/script/destroy +0 -0
  151. data/script/generate +0 -0
  152. data/spec/AICommand_spec.rb +20 -0
  153. data/spec/AIContainer_spec.rb +161 -0
  154. data/spec/AIINContinuous_spec.rb +92 -0
  155. data/spec/AIOUTContinuous_spec.rb +93 -0
  156. data/spec/AIO_spec.rb +73 -0
  157. data/spec/AIReference_spec.rb +105 -0
  158. data/spec/AISinglePresence_spec.rb +204 -60
  159. data/spec/Button_spec.rb +114 -0
  160. data/spec/CIO_spec.rb +145 -0
  161. data/spec/Interactor_spec.rb +95 -0
  162. data/spec/MappingManager_spec.rb +126 -0
  163. data/spec/Spontaneous_spec.rb +53 -0
  164. data/spec/aio_agent_spec.rb +215 -186
  165. data/spec/aisinglechoice_spec.rb +147 -88
  166. data/spec/aisinglechoiceelement_spec.rb +154 -70
  167. data/spec/complementary_mapping_spec.rb +158 -0
  168. data/spec/core_spec.rb +27 -15
  169. data/spec/cui_helper.rb +100 -0
  170. data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  171. data/spec/examples/mim_streaming_example.xml +9 -0
  172. data/spec/examples/mouse_highlight.xml +22 -0
  173. data/spec/examples/performance_mapping.xml +15 -0
  174. data/spec/examples/reset_click.xml +24 -0
  175. data/spec/interactor_test.scxml +32 -0
  176. data/spec/interactor_test_2.scxml +16 -0
  177. data/spec/mapping_performance_spec.rb +118 -0
  178. data/spec/mapping_server_spec.rb +161 -0
  179. data/spec/mapping_spec.rb +307 -0
  180. data/spec/music_spec.rb +301 -135
  181. data/spec/performance_counter.scxml +9 -0
  182. data/spec/sequential_mappings_spec.rb +69 -0
  183. data/spec/shared/aio_shared.rb +144 -0
  184. data/spec/spec_helper.rb +22 -3
  185. data/spec/spontaneous.scxml +11 -0
  186. data/spec/support/connection_helper.rb +19 -0
  187. data/spec/support/redis_connector_monkey_patch.rb +1 -0
  188. data/spec/support/statemachine_helper.rb +84 -0
  189. data/spec/sync_mappings_spec.rb +96 -0
  190. metadata +219 -354
  191. data/lib/MINT-core/mapping/complementary.rb +0 -100
  192. data/lib/MINT-core/mapping/on_state_change.rb +0 -65
  193. data/lib/MINT-core/model/aui/AIC.rb +0 -86
  194. data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
  195. data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
  196. data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
  197. data/lib/MINT-core/model/aui/aic.png +0 -0
  198. data/lib/MINT-core/model/aui/aic.scxml +0 -50
  199. data/lib/MINT-core/model/aui/aichoice.png +0 -0
  200. data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
  201. data/lib/MINT-core/model/aui/aio.png +0 -0
  202. data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
  203. data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
  204. data/lib/MINT-core/model/body/handgesture.rb +0 -279
  205. data/lib/MINT-core/model/body/head.png +0 -0
  206. data/lib/MINT-core/model/body/head.rb +0 -51
  207. data/lib/MINT-core/model/body/head.scxml +0 -28
  208. data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
  209. data/lib/MINT-core/overrides/rinda.rb +0 -34
  210. data/spec/AIC_spec.rb +0 -69
  211. data/spec/MINT-core_spec.rb +0 -11
  212. data/spec/aio_spec.rb +0 -144
  213. data/spec/cio_spec.rb +0 -369
  214. data/tasks/rspec.rake +0 -21
@@ -0,0 +1,12 @@
1
+ module MINT
2
+ class AIContext < AIOUT
3
+ #Todo check this
4
+ property :text, String
5
+ #has 1, :context, 'AIO'
6
+
7
+ def getSCXML
8
+ "#{File.dirname(__FILE__)}/aicontext.scxml"
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module MINT
2
+
3
+
4
+ class AIIN < AIO
5
+
6
+ end
7
+
8
+ end
@@ -0,0 +1,56 @@
1
+ module MINT
2
+
3
+
4
+ class AIINContinuous < AIIN
5
+
6
+ property :data, Integer
7
+ property :min, Integer,:default => 0
8
+ property :max, Integer,:default => 100
9
+
10
+ def getSCXML
11
+ "#{File.dirname(__FILE__)}/aiincontinuous.scxml"
12
+ end
13
+
14
+ # functions called from scxml
15
+
16
+ def publish(attribute)
17
+ channel_name = create_attribute_channel_name(attribute)
18
+
19
+ redis = RedisConnector.redis
20
+
21
+ fiber = Fiber.current
22
+
23
+ redis.pubsub.psubscribe('in_channel:Interactor.AIO.AIIN.AIINContinuous.'+self.name.to_s+":*") { |key,message|
24
+ sync_states
25
+ if message.eql? "stop"
26
+ process_event("halt")
27
+ else
28
+ d = attribute_get(:data)
29
+
30
+ if d
31
+ if message.to_i > d and not (is_in?(:progressing) or is_in?(:max))# state comparison just for performance
32
+ process_event("progress")
33
+ elsif message.to_i < d and not (is_in?(:regressing) or is_in?(:min))
34
+ process_event("regress")
35
+ end
36
+ else
37
+ # @statemachine.process_event("progress") # default progress TODO improve default handling for first data
38
+ process_event("progress")
39
+ end
40
+
41
+ attribute_set(:data,message.to_i)
42
+ RedisConnector.redis.publish channel_name,MultiJson.encode({:name=>self.name,:data => data})
43
+ end
44
+
45
+ }.callback { fiber.resume}
46
+ Fiber.yield
47
+
48
+
49
+ end
50
+
51
+ def halt(id)
52
+ RedisConnector.sub.unsubscribe(self.class.create_channel_name+".#{id}")
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,8 @@
1
+ module MINT
2
+
3
+
4
+ class AIINDiscrete < AIIN
5
+
6
+ end
7
+
8
+ end
@@ -1,5 +1,4 @@
1
1
  module MINT
2
- class AIMultiChoice < AIChoice
3
-
2
+ class AIMultiChoice < AISingleChoice
4
3
  end
5
4
  end
@@ -1,56 +1,9 @@
1
1
  module MINT
2
- class AIMultiChoiceElement < AIINChoose
3
- def initialize_statemachine
4
- if @statemachine.blank?
5
- @statemachine = Statemachine.build do
2
+ class AIMultiChoiceElement < AIChoiceElement
6
3
 
7
- # superstate :AIO do # TODO not supported so far!
8
- trans :initialized,:organize, :organized
9
- trans :organized, :present, :p
10
- trans :suspended,:present, :initialized
11
-
12
- parallel :p do
13
- statemachine :s1 do
14
- superstate :presenting do
15
- state :defocused do
16
- on_entry :sync_cio_to_displayed
17
- end
18
- state :focused do
19
- on_entry :sync_cio_to_highlighted
20
- end
21
- trans :defocused,:focus,:focused
22
- trans :focused,:defocus, :defocused
23
- trans :focused, :next, :defocused, :focus_next, Proc.new { exists_next}
24
- trans :focused, :prev, :defocused, :focus_previous, Proc.new { exists_prev}
25
- trans :focused, :parent, :defocused, :focus_parent
26
- event :suspend, :suspended
27
- end
28
- end
29
- statemachine :s2 do
30
- superstate :choice do
31
- trans :listed, :choose, :chosen
32
- # trans :chosen, :drag, :dragging
33
- # trans :dragging, :drop, :chosen
34
- trans :chosen, :unchoose, :listed
35
-
36
- trans :listed, :drag, :dragging
37
- trans :dragging, :drop, :listed
38
-
39
- state :chosen do
40
- on_entry :sync_cio_to_selected
41
- end
42
-
43
- state :listed do
44
- on_entry :sync_cio_to_listed
45
- end
46
-
47
- end
48
- end
49
- end
50
- #end
51
- end
52
- end
4
+ def getSCXML
5
+ "#{File.dirname(__FILE__)}/aimultichoiceelement.scxml"
53
6
  end
54
-
7
+
55
8
  end
56
9
  end
@@ -1,77 +1,78 @@
1
1
  module MINT
2
+ DataMapper::Model.raise_on_save_failure = true
2
3
 
4
+ class AIO < Interactor
3
5
 
4
- # An abstract
5
- class AIO < Element
6
- property :label, String
7
- property :description, Text, :lazy => false
8
- has 1, :next, self,
9
- :parent_key => [ :id ], # in the remote model (Blog)
10
- :child_key => [ :next_id ] # local to this model (Post)
11
- has 1, :previous, self,
12
- :parent_key => [ :id ], # in the remote model (Blog)
13
- :child_key => [ :prev_id ] # local to this model (Post)
14
-
15
-
16
- belongs_to :parent, 'AIC', # BUG figure out how to declare AIC
17
- :parent_key => [ :id ], # in the remote model (Blog)
18
- :child_key => [ :aic_id ], # local to this model (Post)
19
- :required => true
20
-
21
-
22
-
23
- def initialize_statemachine
24
- if @statemachine.blank?
25
- parser = StatemachineParser.new(self)
26
- @statemachine = parser.build_from_scxml "#{File.dirname(__FILE__)}/aio.scxml"
27
- =begin
28
- @statemachine = Statemachine.build do
29
-
30
- superstate :AIO do
31
- trans :initialized,:organize, :organized
32
- trans :organized, :present, :presenting
33
- trans :organized, :suspend, :suspended
34
- trans :suspended,:present, :presenting
35
- trans :suspended, :organize, :organized
36
- state :suspended do
37
- on_entry :sync_cio_to_hidden
38
- end
39
-
40
- superstate :presenting do
41
- on_entry :inform_parent_presenting
42
- event :suspend, :suspended
43
- state :defocused do
44
- on_entry :sync_cio_to_displayed
45
- end
46
- state :focused do
47
- on_entry :sync_cio_to_highlighted
48
- end
49
- trans :defocused,:focus,:focused
50
- trans :focused,:defocus, :defocused
51
- trans :focused, :next, :defocused, :focus_next, Proc.new { exists_next}
52
- trans :focused, :prev, :defocused, :focus_previous, Proc.new { exists_prev}
53
- trans :focused, :parent, :defocused, :focus_parent
54
-
55
- end
56
- end
57
- end
58
- =end
59
- @statemachine.reset
60
- #else
61
- #@statemachine.reset
6
+ # TODO Links are established without Datamapper's relations because of problems with cycles and self-references (AIContainer))
7
+ property :parent, String
8
+ property :previous, String
9
+ property :next, String
10
+
11
+ def self.getModel
12
+ "aui"
13
+ end
14
+
15
+
16
+ def getSCXML
17
+ "#{File.dirname(__FILE__)}/aio.scxml"
18
+ end
19
+
20
+ def parent
21
+ p = super
22
+ if p
23
+ r = AIContainer.get("aui",p)
24
+ return r
25
+ else
26
+ nil
27
+ end
28
+ end
29
+
30
+ def parent= (p)
31
+ if p.nil? or p.is_a? String
32
+ super(p)
33
+ else
34
+ super(p.name)
35
+ end
36
+ end
37
+
38
+ def parent2str
39
+ parent.name if self.parent
40
+ end
41
+
42
+ def next
43
+ p = super
44
+ if p
45
+ AIO.get("aui",p)
46
+ else
47
+ nil
48
+ end
49
+ end
50
+
51
+ def next2str
52
+ self.next.name if self.next
53
+ end
54
+
55
+
56
+ def previous
57
+ p = super
58
+ if p
59
+ AIO.get("aui",p)
60
+ else
61
+ nil
62
62
  end
63
63
  end
64
64
 
65
+ def previous2str
66
+ previous.name if self.previous
67
+ end
68
+
69
+
65
70
  # hook to inform parent about presenting state
66
71
  def inform_parent_presenting
67
72
  self.parent.child_to_presenting(self) if (self.parent)
68
73
  true
69
74
  end
70
75
 
71
- def sync_event(event)
72
- process_event(event, AIO_sync_callback.new)
73
- end
74
-
75
76
  # callbacks
76
77
 
77
78
  def exists_next
@@ -82,19 +83,10 @@ module MINT
82
83
  self.previous!=nil
83
84
  end
84
85
 
85
- def focus_next
86
- if (self.next)
87
- if self.next.process_event("focus")
88
- return true
89
- else
90
- puts "ERRROR #{self.next.name} could not execute focus event"
91
- return false
86
+ def exists_parent
87
+ self.parent!=nil
92
88
  end
93
- else
94
- puts "WARNING!! > no next element found!"
95
- return false
96
- end
97
- end
89
+
98
90
 
99
91
  def focus_previous
100
92
  if (self.previous)
@@ -112,59 +104,20 @@ module MINT
112
104
  end
113
105
  end
114
106
 
115
- def sync_cio_to_highlighted
116
- cio = MINT::CIO.first(:name=>self.name)
117
- if (cio and not cio.is_in? :highlighted)
118
- cio.sync_event(:highlight)
119
- # cio.states=[:highlighted]
120
- end
121
- true
122
- end
123
-
124
- def sync_cio_to_displayed
125
- cio = MINT::CIO.first(:name=>self.name)
126
- if (cio and not cio.is_in? :displayed)
127
- if (cio.is_in? :suspended or cio.is_in? :positioned)
128
- cio.sync_event(:display)
107
+ def focus_next
108
+ if (self.next)
109
+ if self.next.process_event("focus")
110
+ return true
129
111
  else
130
- cio.sync_event(:unhighlight)
112
+ puts "ERRROR #{self.next.name} could not execute focus event"
113
+ return false
131
114
  end
132
- #cio.states=[:displayed]
115
+ else
116
+ puts "WARNING!! > no next element found!"
117
+ return false
133
118
  end
134
- true
135
119
  end
136
120
 
137
- def sync_cio_to_hidden
138
- cio = MINT::CIO.first(:name=>self.name)
139
- if (cio and not cio.is_in? :hidden)
140
- cio.sync_event(:hide)
141
- end
142
- true
143
- end
144
121
  end
145
122
 
146
-
147
- class AIO_sync_callback
148
- def sync_cio_to_highlighted
149
- true
150
- end
151
-
152
- def sync_cio_to_displayed
153
- true
154
- end
155
-
156
- def sync_cio_to_suspended
157
- true
158
- end
159
- def inform_parent_presenting
160
- true
161
- end
162
- def present_first_child
163
- true
164
- end
165
-
166
- def present_children
167
- true
168
- end
169
- end
170
- end
123
+ end
@@ -0,0 +1,8 @@
1
+ module MINT
2
+
3
+
4
+ class AIOUT < AIO
5
+
6
+ end
7
+
8
+ end
@@ -0,0 +1,61 @@
1
+ module MINT
2
+ class AIOUTContinuous < AIOUT
3
+
4
+ property :data, Integer, :default => 0
5
+ property :min, Integer,:default => 0
6
+ property :max, Integer,:default => 100
7
+
8
+ def getSCXML
9
+ "#{File.dirname(__FILE__)}/aioutcontinuous.scxml"
10
+ end
11
+
12
+ PUBLISH_ATTRIBUTES += [:data]
13
+
14
+ # functions called from scxml
15
+
16
+ def data=(value)
17
+ super # use original method instead of accessing @ivar directly
18
+ publish_update_new
19
+ end
20
+
21
+ def publish_update_new
22
+ RedisConnector.redis.publish create_attribute_channel_name('data'), self.to_json(:only => self.class::PUBLISH_ATTRIBUTES)
23
+ end
24
+
25
+
26
+ def consume(attribute)
27
+ @d = 0
28
+
29
+ channel_name = create_attribute_channel_name(attribute)
30
+ p "subscribed #{channel_name}"
31
+
32
+ redis = RedisConnector.redis
33
+
34
+ fiber = Fiber.current
35
+
36
+ redis.pubsub.subscribe(channel_name) { |message|
37
+ found=MultiJson.decode message
38
+
39
+ if self.name.eql? found['name']
40
+ if found['data']
41
+ @d = found['data'].to_i
42
+ @data = attribute_get(:data)
43
+
44
+ process_event "move"
45
+ restart_timeout(1,:halt)
46
+
47
+ attribute_set(:data,@d)
48
+ RedisConnector.redis.publish("out_channel:#{create_channel_w_name}:testuser",@data)
49
+ end
50
+ end
51
+ }.callback { fiber.resume}
52
+ Fiber.yield
53
+ @d
54
+ end
55
+
56
+ def halt(id)
57
+ RedisConnector.sub.unsubscribe(self.class.create_channel_name+".#{id}")
58
+ end
59
+ end
60
+
61
+ end