MINT-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/.gemtest +0 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +69 -0
  4. data/History.txt +3 -0
  5. data/MINT-core.gemspec +58 -0
  6. data/Manifest.txt +77 -0
  7. data/PostInstall.txt +7 -0
  8. data/README.rdoc +63 -0
  9. data/Rakefile +29 -0
  10. data/bin/mint-aui +40 -0
  11. data/bin/mint-cui-gfx +47 -0
  12. data/bin/mint-juggernaut.sh +4 -0
  13. data/bin/mint-tuplespace +12 -0
  14. data/lib/MINT-core.rb +42 -0
  15. data/lib/MINT-core/agent/agent.rb +28 -0
  16. data/lib/MINT-core/agent/aui.rb +52 -0
  17. data/lib/MINT-core/agent/auicontrol.rb +135 -0
  18. data/lib/MINT-core/agent/cui-gfx.rb +160 -0
  19. data/lib/MINT-core/agent/cuicontrol.rb +46 -0
  20. data/lib/MINT-core/mapping/complementary.rb +100 -0
  21. data/lib/MINT-core/mapping/mapping.rb +47 -0
  22. data/lib/MINT-core/mapping/on_state_change.rb +65 -0
  23. data/lib/MINT-core/mapping/sequential.rb +87 -0
  24. data/lib/MINT-core/model/aui/AIC.rb +86 -0
  25. data/lib/MINT-core/model/aui/AIChoice.rb +65 -0
  26. data/lib/MINT-core/model/aui/AIINChoose.rb +54 -0
  27. data/lib/MINT-core/model/aui/AIMultiChoice.rb +5 -0
  28. data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +56 -0
  29. data/lib/MINT-core/model/aui/AIO.rb +170 -0
  30. data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +43 -0
  31. data/lib/MINT-core/model/aui/AISingleChoice.rb +9 -0
  32. data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +69 -0
  33. data/lib/MINT-core/model/aui/AISinglePresence.rb +100 -0
  34. data/lib/MINT-core/model/aui/aic.png +0 -0
  35. data/lib/MINT-core/model/aui/aic.scxml +50 -0
  36. data/lib/MINT-core/model/aui/aichoice.png +0 -0
  37. data/lib/MINT-core/model/aui/aichoice.scxml +60 -0
  38. data/lib/MINT-core/model/aui/aio.png +0 -0
  39. data/lib/MINT-core/model/aui/aio.scxml +43 -0
  40. data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
  41. data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +71 -0
  42. data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
  43. data/lib/MINT-core/model/aui/aisinglepresence.scxml +58 -0
  44. data/lib/MINT-core/model/aui/model.rb +50 -0
  45. data/lib/MINT-core/model/body/gesture_button.rb +26 -0
  46. data/lib/MINT-core/model/body/handgesture.rb +279 -0
  47. data/lib/MINT-core/model/body/head.png +0 -0
  48. data/lib/MINT-core/model/body/head.rb +51 -0
  49. data/lib/MINT-core/model/body/head.scxml +28 -0
  50. data/lib/MINT-core/model/cui/gfx/CIC.rb +266 -0
  51. data/lib/MINT-core/model/cui/gfx/CIO.rb +381 -0
  52. data/lib/MINT-core/model/cui/gfx/model.rb +204 -0
  53. data/lib/MINT-core/model/cui/gfx/screen.rb +18 -0
  54. data/lib/MINT-core/model/device/button.rb +20 -0
  55. data/lib/MINT-core/model/device/joypad.rb +30 -0
  56. data/lib/MINT-core/model/device/mouse.rb +171 -0
  57. data/lib/MINT-core/model/device/pointer.rb +85 -0
  58. data/lib/MINT-core/model/device/wheel.rb +51 -0
  59. data/lib/MINT-core/model/interactor.rb +167 -0
  60. data/lib/MINT-core/model/task.rb +71 -0
  61. data/lib/MINT-core/overrides/rinda.rb +34 -0
  62. data/script/console +10 -0
  63. data/script/destroy +14 -0
  64. data/script/generate +14 -0
  65. data/spec/AIC_spec.rb +69 -0
  66. data/spec/AISinglePresence_spec.rb +94 -0
  67. data/spec/MINT-core_spec.rb +11 -0
  68. data/spec/aio_agent_spec.rb +234 -0
  69. data/spec/aio_spec.rb +144 -0
  70. data/spec/aisinglechoice_spec.rb +152 -0
  71. data/spec/aisinglechoiceelement_spec.rb +106 -0
  72. data/spec/cio_spec.rb +369 -0
  73. data/spec/core_spec.rb +29 -0
  74. data/spec/music_spec.rb +179 -0
  75. data/spec/rcov.opts +2 -0
  76. data/spec/spec.opts +4 -0
  77. data/spec/spec_helper.rb +7 -0
  78. data/tasks/rspec.rake +21 -0
  79. metadata +227 -0
@@ -0,0 +1,54 @@
1
+ module MINT
2
+ class AIINChoose_sync_callback < AIO_sync_callback
3
+ def initialize(element)
4
+ @element=element
5
+ end
6
+ def sync_cio_to_listed
7
+ true
8
+ end
9
+
10
+ def sync_cio_to_selected
11
+ true
12
+ end
13
+
14
+
15
+
16
+ def unchoose_others
17
+ aios = @element.parent.childs.all(:states=>/\bchosen\b/)
18
+ aios.each do |aio|
19
+ aio.process_event("unchoose") if aio.is_in? :chosen
20
+ end
21
+ true
22
+ end
23
+ end
24
+
25
+ class AIINChoose < AIINDiscrete
26
+
27
+ def sync_event(event)
28
+ process_event(event, AIINChoose_sync_callback.new(self))
29
+ end
30
+ def sync_cio_to_selected
31
+ cio = MINT::Selectable.first(:name=>self.name)
32
+ if (cio and not cio.is_in? :selected)
33
+ cio.sync_event(:select)
34
+ end
35
+ true
36
+ end
37
+
38
+ def sync_cio_to_listed
39
+ cio = MINT::Selectable.first(:name=>self.name)
40
+ if (cio and not cio.is_in? :listed)
41
+ cio.sync_event(:listed)
42
+ end
43
+ true
44
+ end
45
+
46
+ def unchoose_others
47
+ aios = self.parent.childs.all(:states=>/\bchosen\b/)
48
+ aios.each do |aio|
49
+ aio.process_event("unchoose")
50
+ end
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,5 @@
1
+ module MINT
2
+ class AIMultiChoice < AIChoice
3
+
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ module MINT
2
+ class AIMultiChoiceElement < AIINChoose
3
+ def initialize_statemachine
4
+ if @statemachine.blank?
5
+ @statemachine = Statemachine.build do
6
+
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
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,170 @@
1
+ module MINT
2
+
3
+
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
62
+ end
63
+ end
64
+
65
+ # hook to inform parent about presenting state
66
+ def inform_parent_presenting
67
+ self.parent.child_to_presenting(self) if (self.parent)
68
+ true
69
+ end
70
+
71
+ def sync_event(event)
72
+ process_event(event, AIO_sync_callback.new)
73
+ end
74
+
75
+ # callbacks
76
+
77
+ def exists_next
78
+ self.next!=nil
79
+ end
80
+
81
+ def exists_prev
82
+ self.previous!=nil
83
+ end
84
+
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
92
+ end
93
+ else
94
+ puts "WARNING!! > no next element found!"
95
+ return false
96
+ end
97
+ end
98
+
99
+ def focus_previous
100
+ if (self.previous)
101
+ self.previous.process_event("focus")
102
+ else
103
+ return false # TODO not working, find abbruchbedingung!!!
104
+ end
105
+ end
106
+
107
+ def focus_parent
108
+ if (self.parent)
109
+ self.parent.process_event("focus")
110
+ else
111
+ return false # TODO not working, find abbruchbedingung!!!
112
+ end
113
+ end
114
+
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)
129
+ else
130
+ cio.sync_event(:unhighlight)
131
+ end
132
+ #cio.states=[:displayed]
133
+ end
134
+ true
135
+ end
136
+
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
+ end
145
+
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
@@ -0,0 +1,43 @@
1
+ module MINT
2
+
3
+ class AIOUTDiscrete < AIOUT
4
+ def initialize_statemachine
5
+ if @statemachine.blank?
6
+ @statemachine = Statemachine.build do
7
+ trans :initialized,:organize, :organized
8
+ trans :organized, :present, :p
9
+ trans :suspended,:present, :p, :present_children
10
+ state :suspended do
11
+ on_entry :sync_cio_to_hidden
12
+ end
13
+
14
+ superstate :p_t do # TODO artificial superstate required to get following event working!
15
+ event :suspend, :suspended, :hide_children
16
+ parallel :p do
17
+ statemachine :s1 do
18
+ superstate :presenting do
19
+ state :defocused do
20
+ on_entry :sync_cio_to_displayed
21
+ end
22
+ state :focused do
23
+ on_entry :sync_cio_to_highlighted
24
+ end
25
+ trans :defocused,:focus,:focused
26
+ trans :focused, :defocus, :defocused
27
+ trans :focused, :next, :defocused, :focus_next, Proc.new { exists_next}
28
+ trans :focused, :prev, :defocused, :focus_previous, Proc.new { exists_prev}
29
+ trans :focused, :parent, :defocused, :focus_parent
30
+ end
31
+ end
32
+ statemachine :s2 do
33
+ superstate :l do
34
+ trans :listing, :update, :listing, :sync_cio_to_updated
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ module MINT
2
+ class AISingleChoice < AIChoice
3
+
4
+ end
5
+
6
+ class ARContainer < AISingleChoice
7
+
8
+ end
9
+ end
@@ -0,0 +1,69 @@
1
+ module MINT
2
+ class AISingleChoiceElement < AIINChoose
3
+ def initialize_statemachine
4
+ p "enter init"
5
+ if @statemachine.blank?
6
+ parser = StatemachineParser.new(self)
7
+ p "after parsing"
8
+ # @statemachine = parser.build_from_scxml "#{File.dirname(__FILE__)}/aisinglechoiceelement.scxml"
9
+ @statemachine = Statemachine.build do
10
+
11
+ # superstate :AIO do # TODO not supported so far!
12
+ trans :initialized,:organize, :organized
13
+ trans :organized, :present, :p_t
14
+ trans :organized, :suspend, :suspended
15
+ trans :suspended, :present, :p_t
16
+ trans :suspended, :organize, :organized
17
+ state :suspended do
18
+ on_entry :sync_cio_to_hidden
19
+ end
20
+
21
+ superstate :p_t do
22
+ event :suspend, :suspended
23
+ parallel :p do
24
+ statemachine :s1 do
25
+ superstate :presenting do
26
+ state :defocused do
27
+ on_entry :sync_cio_to_displayed
28
+ end
29
+ state :focused do
30
+ on_entry :sync_cio_to_highlighted
31
+ end
32
+ trans :defocused,:focus,:focused
33
+ trans :focused, :defocus, :defocused
34
+ trans :focused, :next, :defocused, :focus_next, Proc.new { exists_next}
35
+ trans :focused, :prev, :defocused, :focus_previous, Proc.new { exists_prev}
36
+ trans :focused, :parent, :defocused, :focus_parent
37
+ trans :focused, :drag, :dragging, :choose
38
+ trans :dragging, :drop, :defocused
39
+ end
40
+ end
41
+ statemachine :s2 do
42
+ superstate :selection_H do
43
+ state :unchosen do
44
+ on_entry :sync_cio_to_listed
45
+ event :choose, :chosen
46
+ end
47
+ state :chosen do
48
+ on_entry [:sync_cio_to_selected,:unchoose_others]
49
+ event :unchoose, :unchosen
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ def remove_from_origin
59
+ self.parent.childs.get(self.id).destroy
60
+ end
61
+
62
+ def choose
63
+ if self.is_in? :unchosen
64
+ self.process_event(:choose)
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,100 @@
1
+ module MINT
2
+ class AISinglePresence < AIC
3
+ def initialize_statemachine
4
+ if @statemachine.blank?
5
+ parser = StatemachineParser.new(self)
6
+ @statemachine = parser.build_from_scxml "#{File.dirname(__FILE__)}/aisinglepresence.scxml"
7
+ =begin
8
+ @statemachine = Statemachine.build do
9
+ trans :initialized,:organize, :organized
10
+ trans :organized, :present, :presenting
11
+ trans :suspended, :present, :presenting
12
+ state :suspended do
13
+ on_entry [:sync_cio_to_hidden]
14
+ end
15
+
16
+ superstate :presenting do
17
+ on_entry :present_first_child
18
+ on_exit :hide_children
19
+ event :suspend, :suspended
20
+
21
+ state :defocused do
22
+ on_entry :sync_cio_to_displayed
23
+ event :focus, :focused
24
+ end
25
+ superstate :focused do
26
+ event :defocus, :defocused
27
+ state :waiting do
28
+ on_entry :sync_cio_to_highlighted
29
+ event :enter, :entered
30
+ event :next, :defocused, :focus_next, Proc.new { exists_next}
31
+ event :prev, :defocused, :focus_previous, Proc.new { exists_prev}
32
+ event :parent, :defocused, :focus_parent
33
+ end
34
+ state :entered do
35
+ event :leave, :waiting
36
+ event :next, :entered, :present_next_child, Proc.new { exists_next_child}
37
+ event :prev, :entered, :present_previous_child, Proc.new { exists_prev_child}
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ =end
44
+ end
45
+ end
46
+
47
+ # hook that is called from a child if it enters presenting state
48
+ def child_to_presenting(child)
49
+ childs.all.each do |e|
50
+ e.process_event(:suspend) if e.id != child.id and not e.is_in? :suspended
51
+ end
52
+ end
53
+
54
+ def present_first_child
55
+ childs[0].process_event :present
56
+ end
57
+
58
+ def present_next_child
59
+ active = false
60
+ childs.each do |c|
61
+ if active
62
+ c.process_event(:present)
63
+ active = false
64
+ else
65
+ active = true if c.states!=[:suspended]
66
+ end
67
+ end
68
+ end
69
+
70
+ def present_previous_child
71
+ active = false
72
+ childs.reverse_each do |c|
73
+ if active
74
+ c.process_event(:present)
75
+ active = false
76
+ else
77
+ active = true if c.states!=[:suspended]
78
+ end
79
+ end
80
+ end
81
+
82
+ def add_element
83
+ f = AISingleChoiceElement.first(:new_states=> /#{Regexp.quote("dragging")}/)
84
+ self.childs << f
85
+ self.childs.save
86
+ f.process_event(:drop)
87
+ f.destroy
88
+ end
89
+
90
+ def exists_next_child
91
+ self.childs.next!=nil
92
+ end
93
+
94
+ def exists_prev_child
95
+ self.childs.previous!=nil
96
+ end
97
+
98
+ end
99
+
100
+ end