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,204 @@
1
+ module MINT
2
+ require "MINT-core/model/cui/gfx/CIO"
3
+
4
+ require "MINT-core/model/cui/gfx/CIC"
5
+ class Button < CIO
6
+ end
7
+
8
+ class Image < CIO
9
+ property :path, String
10
+ end
11
+
12
+ class Selectable_sync_callback < CIO_sync_callback
13
+ def sync_aio_to_unchosen
14
+ true
15
+ end
16
+
17
+ def sync_aio_to_chosen
18
+ true
19
+ end
20
+ end
21
+ # Abstract class to handle objects that can be selected
22
+ class Selectable < CIO
23
+ def initialize_statemachine
24
+ if @statemachine.blank?
25
+
26
+ @statemachine = Statemachine.build do
27
+
28
+ superstate :CIO do
29
+ trans :initialized,:position,:positioning
30
+ trans :positioning,:calculated,:positioned, :store_calculated_values_in_model
31
+ trans :positioned, :display, :presenting
32
+ trans :disabled, :hide, :hidden
33
+ trans :hidden,:display, :presenting
34
+
35
+
36
+ parallel :p do
37
+ statemachine :s1 do
38
+ superstate :presenting do
39
+ on_entry :sync_aio_to_presented
40
+
41
+ event :hide, :hidden
42
+
43
+ state :displayed do
44
+ on_entry :sync_aio_to_defocus
45
+ end
46
+
47
+ state :highlighted do
48
+ on_entry :sync_aio_to_focused
49
+ end
50
+
51
+ trans :displayed, :highlight, :highlighted
52
+ trans :highlighted,:unhighlight, :displayed
53
+ trans :highlighted, :up, :displayed, :highlight_up
54
+ trans :highlighted, :down, :displayed, :highlight_down
55
+ trans :highlighted, :left, :displayed, :highlight_left
56
+ trans :highlighted, :right, :displayed, :highlight_right
57
+
58
+ event :disable, :disabled
59
+
60
+ end
61
+ end
62
+ statemachine :s2 do
63
+ superstate :selection do
64
+ trans :listed, :select, :selected
65
+ trans :selected, :select, :listed
66
+
67
+ state :listed do
68
+ on_entry :sync_aio_to_unchosen
69
+ end
70
+
71
+ state :selected do
72
+ on_entry :sync_aio_to_chosen
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def sync_event(event)
83
+ process_event(event, Selectable_sync_callback.new)
84
+ end
85
+
86
+ def sync_aio_to_unchosen
87
+ aio = MINT::AIINChoose.first(:name=>self.name)
88
+ if (aio and not aio.is_in? :unchosen)
89
+ aio.sync_event(:unchoose)
90
+ end
91
+ true
92
+ end
93
+
94
+ def sync_aio_to_chosen
95
+ aio = MINT::AIINChoose.first(:name=>self.name)
96
+ if (aio and not aio.is_in? :chosen)
97
+ aio.sync_event(:choose)
98
+ end
99
+ true
100
+ end
101
+ end
102
+
103
+ class FurnitureItem < Selectable
104
+ property :title, String
105
+ property :price, String
106
+ property :image, String
107
+ property :description, String
108
+ end
109
+
110
+ class SingleHighlight < CIC
111
+ end
112
+
113
+
114
+ class ARFrame < CIO
115
+
116
+ end
117
+
118
+ class CheckBox < Selectable
119
+ end
120
+
121
+ class CheckBoxGroup < CIC
122
+ end
123
+
124
+ class RadioButton < Selectable
125
+ end
126
+
127
+ class MarkableRadioButton < RadioButton
128
+ def initialize_statemachine
129
+ if @statemachine.blank?
130
+
131
+ @statemachine = Statemachine.build do
132
+
133
+ superstate :CIO do
134
+ trans :initialized,:position,:positioning
135
+ trans :positioning,:calculated,:positioned, :store_calculated_values_in_model
136
+ trans :positioned, :display, :presenting
137
+ trans :disabled, :hide, :hidden
138
+ trans :hidden,:display, :presenting
139
+
140
+
141
+ parallel :p do
142
+ statemachine :s1 do
143
+ superstate :presenting do
144
+ on_entry :sync_aio_to_presented
145
+
146
+ state :displayed do
147
+ on_entry :sync_aio_to_defocus
148
+ end
149
+
150
+ state :highlighted do
151
+ on_entry :sync_aio_to_focused
152
+ end
153
+
154
+ trans :displayed, :highlight, :highlighted
155
+ trans :highlighted,:unhighlight, :displayed
156
+ trans :highlighted, :up, :displayed, :highlight_up
157
+ trans :highlighted, :down, :displayed, :highlight_down
158
+ trans :highlighted, :left, :displayed, :highlight_left
159
+ trans :highlighted, :right, :displayed, :highlight_right
160
+
161
+ event :disable, :disabled
162
+ event :hide, :hidden
163
+
164
+ end
165
+ end
166
+ statemachine :s2 do
167
+ superstate :selection do
168
+ trans :listed, :select, :selected
169
+ trans :selected, :select, :listed
170
+
171
+ state :listed do
172
+ on_entry :sync_aio_to_unchosen
173
+ end
174
+
175
+ state :selected do
176
+ on_entry :sync_aio_to_chosen
177
+ end
178
+ end
179
+ end
180
+ statemachine :s3 do
181
+ superstate :marker do
182
+ trans :unmarked, :mark, :marked
183
+ trans :marked, :unmark, :unmarked
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ class RadioButtonGroup < CIC
194
+ end
195
+
196
+ class BasicText < CIO
197
+ end
198
+
199
+ class Label <CIO
200
+ end
201
+
202
+ require "MINT-core/model/cui/gfx/screen"
203
+
204
+ end
@@ -0,0 +1,18 @@
1
+ module MINT
2
+ class Screen < Element
3
+ property :root, String
4
+
5
+
6
+ protected
7
+ def initialize_statemachine
8
+ if @statemachine.blank?
9
+ @statemachine = Statemachine.build do
10
+ trans :initialized, :calculate, :calculating
11
+ trans :calculating, :done, :finished
12
+ trans :finished, :calculate, :calculating
13
+ end
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module MINT
2
+
3
+ class HWButton < Element
4
+
5
+ def initialize_statemachine
6
+ if @statemachine.blank?
7
+ @statemachine = Statemachine.build do
8
+
9
+ trans :disconnected,:connect, :connected
10
+ trans :connected, :disconnect, :disconnected
11
+
12
+ superstate :connected do
13
+ trans :released, :press, :pressed
14
+ trans :pressed, :release, :released
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ module MINT
2
+
3
+ class Joypad < Element
4
+ def initialize_statemachine
5
+ if @statemachine.blank?
6
+ @statemachine = Statemachine.build do
7
+
8
+ trans :disconnected,:connect, :connected
9
+ trans :connected, :disconnect, :disconnected
10
+
11
+ superstate :connected do
12
+ state :released
13
+ superstate :pressed do
14
+ state :left
15
+ state :right
16
+ state :down
17
+ state :up
18
+ event :release, :released
19
+ end
20
+ event :press_left, :left
21
+ event :press_right, :right
22
+ event :press_up, :up
23
+ event :press_down, :down
24
+ event :disconnect, :disconnected
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,171 @@
1
+ require "eventmachine"
2
+ module MINT
3
+
4
+ class MouseMode < Element
5
+ def initialize_statemachine
6
+ if @statemachine.blank?
7
+ @statemachine = Statemachine.build do
8
+ trans :selecting,:drag, :dragging
9
+ trans :dragging, :select, :selecting
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ class Mouse < Pointer
16
+
17
+ class CoordinateTracker
18
+ include EventMachine::Deferrable
19
+ def initialize(mouse)
20
+ @mouse = mouse
21
+ p "handling juggernait"
22
+ Redis.new.subscribe("juggernaut") do |on|
23
+ on.mon.message do |msg|
24
+ r = msg.parseJSON
25
+ if (r["channels"].eql? "pointer")
26
+ @x,@y = r["data"].split
27
+ end
28
+ end
29
+ end
30
+ end
31
+ def save(state)
32
+ @mouse.x=@x
33
+ @mouse.y=@y
34
+ @mouse.process_event(state)
35
+ p "stopped"
36
+ end
37
+ end
38
+
39
+ # property :x, Integer, :default => -1
40
+ # property :y, Integer, :default => -1
41
+ property :z, Integer, :default => 0
42
+
43
+ def cache_coordinates(x,y)
44
+ @x = x
45
+ @y = y
46
+ end
47
+
48
+ def initialize_statemachine
49
+ if @statemachine.blank?
50
+
51
+ @pointer_timer = nil
52
+ @wheel_timer = nil
53
+
54
+ @statemachine = Statemachine.build do
55
+
56
+ trans :disconnected,:connect, :connected
57
+ trans :connected, :disconnect, :disconnected
58
+
59
+ superstate :connected do
60
+ parallel :p do
61
+ statemachine :s1 do
62
+ superstate :pointer do
63
+ on_entry :start_coordinates_tracker
64
+ on_exit :stop_coordinates_tracker
65
+
66
+
67
+ trans :stopped, :move, :moving
68
+ trans :moving,:move, :moving
69
+ trans :moving,:stop,:stopped
70
+
71
+ state :moving do
72
+ on_entry :start_timeout_pointer # TODO no support for varibles in on_entry on_exit
73
+ on_exit :stop_timeout_pointer
74
+ end
75
+ end
76
+ end
77
+ statemachine :s2 do
78
+ superstate :right_button do # TODO we still not have name spaces :-(
79
+ trans :right_released, :right_press, :right_pressed
80
+ trans :right_pressed, :right_release, :right_released
81
+ end
82
+ end
83
+ statemachine :s3 do
84
+ superstate :left_button do # TODO we still not have name spaces :-(
85
+ trans :left_released, :left_press, :left_pressed
86
+ trans :left_pressed, :left_release, :left_released
87
+ end
88
+ end
89
+ statemachine :s4 do
90
+ superstate :middle_button do # TODO we still not have name spaces :-(
91
+ trans :middle_released, :middle_press, :middle_pressed
92
+ trans :middle_pressed, :middle_release, :middle_released
93
+ end
94
+ end
95
+ statemachine :s5 do
96
+ superstate :wheel do
97
+ trans :wheel_stopped,:regress, :regressing
98
+ trans :wheel_stopped,:progress, :progressing
99
+
100
+ trans :regressing, :regress, :regressing
101
+ trans :regressing, :stop_wheel, :wheel_stopped
102
+ trans :regressing, :progress, :progressing
103
+
104
+ trans :progressing, :progress, :progressing
105
+ trans :progressing, :stop_wheel, :wheel_stopped
106
+ trans :progressing, :regress, :regressing
107
+
108
+ state :regressing do
109
+ on_entry :start_timeout_wheel
110
+ on_exit :stop_timeout_wheel
111
+ end
112
+ state :progressing do
113
+ on_entry :start_timeout_wheel
114
+ on_exit :stop_timeout_wheel
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+
123
+ def start_timeout_wheel
124
+ if not @wheel_timer
125
+ @wheel_timer = EventMachine::Timer.new(0.3) do
126
+ process_event("stop_wheel")
127
+ end
128
+ else
129
+ puts "wheel timer already started!!!"
130
+ end
131
+ end
132
+
133
+ def stop_timeout_wheel
134
+ stop_timeout(@wheel_timer)
135
+ end
136
+
137
+ def start_timeout_pointer
138
+ # @tracker = CoordinateTracker.new(self)
139
+ # @tracker.callback do |x|
140
+ # @tracker.save(state)
141
+ # end
142
+
143
+ if not @pointer_timer
144
+ @pointer_timer = EventMachine::Timer.new(0.3) do
145
+ @mouse.x=@x
146
+ @mouse.y=@y
147
+ @mouse.process_event("stop")
148
+
149
+ # @tracker.set_deferred_status :succeeded, "stop"
150
+ end
151
+ else
152
+ puts "pointer timer already started!!!"
153
+ end
154
+ end
155
+
156
+
157
+ def stop_timeout_pointer
158
+ stop_timeout(@pointer_timer)
159
+ end
160
+
161
+ def stop_timeout(timer)
162
+ if timer
163
+ timer.cancel
164
+ timer = nil
165
+ end
166
+ end
167
+ end
168
+
169
+ end
170
+
171
+ end