MINT-core 1.0.1 → 2.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.
- data/Gemfile +22 -3
- data/Gemfile.lock +98 -22
- data/History.txt +262 -0
- data/LICENSE +30 -0
- data/MINT-core.gemspec +25 -80
- data/Manifest.txt +145 -30
- data/README.rdoc +6 -163
- data/Rakefile +16 -17
- data/bin/mint-aui +3 -3
- data/bin/mint-cui-gfx +3 -2
- data/bin/mint-juggernaut.sh +0 -0
- data/bin/mint-tuplespace +0 -0
- data/lib/MINT-core.rb +53 -15
- data/lib/MINT-core/agent/agent.rb +1 -1
- data/lib/MINT-core/agent/aui.rb +0 -14
- data/lib/MINT-core/agent/auicontrol.rb +91 -38
- data/lib/MINT-core/agent/cui-gfx.rb +3 -3
- data/lib/MINT-core/agent/cuicontrol.rb +94 -24
- data/lib/MINT-core/connector/redis_connector.rb +16 -0
- data/lib/MINT-core/manager/mapping_manager.rb +101 -0
- data/lib/MINT-core/manager/mapping_parser.rb +89 -0
- data/lib/MINT-core/manager/mapping_server.rb +99 -0
- data/lib/MINT-core/manager/position_updater.rb +33 -0
- data/lib/MINT-core/manager/scxml_client.rb +118 -0
- data/lib/MINT-core/manager/scxml_server.rb +86 -0
- data/lib/MINT-core/mapping/action/action.rb +32 -0
- data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
- data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
- data/lib/MINT-core/mapping/action/event_action.rb +40 -0
- data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
- data/lib/MINT-core/mapping/mapping.rb +170 -34
- data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
- data/lib/MINT-core/mapping/observation/observation.rb +219 -0
- data/lib/MINT-core/mapping/sequential.rb +1 -2
- data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
- data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
- data/lib/MINT-core/model/aui/AICommand.rb +7 -0
- data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
- data/lib/MINT-core/model/aui/AIContext.rb +12 -0
- data/lib/MINT-core/model/aui/AIIN.rb +8 -0
- data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
- data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
- data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
- data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
- data/lib/MINT-core/model/aui/AIO.rb +76 -123
- data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
- data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
- data/lib/MINT-core/model/aui/AIReference.rb +16 -0
- data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
- data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
- data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
- data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
- data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
- data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
- data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
- data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
- data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
- data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
- data/lib/MINT-core/model/aui/aio.scxml +18 -27
- data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
- data/lib/MINT-core/model/aui/aireference.scxml +28 -0
- data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
- data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
- data/lib/MINT-core/model/aui/model.rb +15 -38
- data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
- data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
- data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
- data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
- data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
- data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
- data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
- data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
- data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
- data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
- data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
- data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
- data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
- data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
- data/lib/MINT-core/model/interactor.rb +167 -46
- data/lib/MINT-core/model/interactor.scxml +3 -0
- data/lib/MINT-core/model/interactor_helpers.rb +25 -0
- data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
- data/lib/MINT-core/model/ir/body/body.rb +5 -0
- data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
- data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
- data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
- data/lib/MINT-core/model/ir/body/hand.rb +5 -0
- data/lib/MINT-core/model/ir/body/head.rb +102 -0
- data/lib/MINT-core/model/ir/body/head.scxml +92 -0
- data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
- data/lib/MINT-core/model/ir/body/pose.rb +99 -0
- data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
- data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
- data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
- data/lib/MINT-core/model/ir/ir.rb +5 -0
- data/lib/MINT-core/model/ir/irmedia.rb +5 -0
- data/lib/MINT-core/model/ir/irmode.rb +5 -0
- data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
- data/lib/MINT-core/model/ir/mouse.rb +44 -0
- data/lib/MINT-core/model/ir/mouse.scxml +35 -0
- data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
- data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
- data/lib/MINT-core/model/ir/pointer.scxml +19 -0
- data/lib/MINT-core/model/ir/screen.rb +5 -0
- data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
- data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
- data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
- data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
- data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
- data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
- data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
- data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
- data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
- data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
- data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
- data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
- data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
- data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
- data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
- data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
- data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
- data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
- data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
- data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
- data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
- data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
- data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/mim_default.xml +52 -0
- data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
- data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
- data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
- data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
- data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
- data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
- data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
- data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
- data/lib/MINT-core/model/task.rb +6 -6
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/spec/AICommand_spec.rb +20 -0
- data/spec/AIContainer_spec.rb +161 -0
- data/spec/AIINContinuous_spec.rb +92 -0
- data/spec/AIOUTContinuous_spec.rb +93 -0
- data/spec/AIO_spec.rb +73 -0
- data/spec/AIReference_spec.rb +105 -0
- data/spec/AISinglePresence_spec.rb +204 -60
- data/spec/Button_spec.rb +114 -0
- data/spec/CIO_spec.rb +145 -0
- data/spec/Interactor_spec.rb +95 -0
- data/spec/MappingManager_spec.rb +126 -0
- data/spec/Spontaneous_spec.rb +53 -0
- data/spec/aio_agent_spec.rb +215 -186
- data/spec/aisinglechoice_spec.rb +147 -88
- data/spec/aisinglechoiceelement_spec.rb +154 -70
- data/spec/complementary_mapping_spec.rb +158 -0
- data/spec/core_spec.rb +27 -15
- data/spec/cui_helper.rb +100 -0
- data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
- data/spec/examples/mim_streaming_example.xml +9 -0
- data/spec/examples/mouse_highlight.xml +22 -0
- data/spec/examples/performance_mapping.xml +15 -0
- data/spec/examples/reset_click.xml +24 -0
- data/spec/interactor_test.scxml +32 -0
- data/spec/interactor_test_2.scxml +16 -0
- data/spec/mapping_performance_spec.rb +118 -0
- data/spec/mapping_server_spec.rb +161 -0
- data/spec/mapping_spec.rb +307 -0
- data/spec/music_spec.rb +301 -135
- data/spec/performance_counter.scxml +9 -0
- data/spec/sequential_mappings_spec.rb +69 -0
- data/spec/shared/aio_shared.rb +144 -0
- data/spec/spec_helper.rb +22 -3
- data/spec/spontaneous.scxml +11 -0
- data/spec/support/connection_helper.rb +19 -0
- data/spec/support/redis_connector_monkey_patch.rb +1 -0
- data/spec/support/statemachine_helper.rb +84 -0
- data/spec/sync_mappings_spec.rb +96 -0
- metadata +219 -354
- data/lib/MINT-core/mapping/complementary.rb +0 -100
- data/lib/MINT-core/mapping/on_state_change.rb +0 -65
- data/lib/MINT-core/model/aui/AIC.rb +0 -86
- data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
- data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
- data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
- data/lib/MINT-core/model/aui/aic.png +0 -0
- data/lib/MINT-core/model/aui/aic.scxml +0 -50
- data/lib/MINT-core/model/aui/aichoice.png +0 -0
- data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
- data/lib/MINT-core/model/aui/aio.png +0 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
- data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
- data/lib/MINT-core/model/body/handgesture.rb +0 -279
- data/lib/MINT-core/model/body/head.png +0 -0
- data/lib/MINT-core/model/body/head.rb +0 -51
- data/lib/MINT-core/model/body/head.scxml +0 -28
- data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
- data/lib/MINT-core/overrides/rinda.rb +0 -34
- data/spec/AIC_spec.rb +0 -69
- data/spec/MINT-core_spec.rb +0 -11
- data/spec/aio_spec.rb +0 -144
- data/spec/cio_spec.rb +0 -369
- data/tasks/rspec.rake +0 -21
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "em-spec/rspec"
|
|
3
|
+
require 'perftools'
|
|
4
|
+
|
|
5
|
+
describe "MappingPerformance" do
|
|
6
|
+
include EventMachine::SpecHelper
|
|
7
|
+
|
|
8
|
+
before :all do
|
|
9
|
+
connection_options = { :adapter => "redis"}
|
|
10
|
+
DataMapper.setup(:default, connection_options)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
connect do |redis|
|
|
14
|
+
require "MINT-core"
|
|
15
|
+
class InteractorTest < MINT::Interactor
|
|
16
|
+
def getSCXML
|
|
17
|
+
"#{File.dirname(__FILE__)}/interactor_test.scxml"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class PerformanceCounter < MINT::Interactor
|
|
22
|
+
property :counter, Integer, :default => 0
|
|
23
|
+
property :amount, Integer, :default => 10
|
|
24
|
+
|
|
25
|
+
def inc_counter
|
|
26
|
+
counter = attribute_get(:counter)
|
|
27
|
+
attribute_set(:counter, counter + 1)
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
def getSCXML
|
|
31
|
+
"#{File.dirname(__FILE__)}/performance_counter.scxml"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
|
|
36
|
+
DataMapper.finalize
|
|
37
|
+
DataMapper::Model.raise_on_save_failure = true
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
it "should run as quickly as possible for one mapping" do
|
|
43
|
+
connect true do |redis|
|
|
44
|
+
parser = MINT::MappingParser.new
|
|
45
|
+
m = parser.build_from_scxml File.dirname(__FILE__) +"/examples/performance_mapping.xml"
|
|
46
|
+
m.start
|
|
47
|
+
|
|
48
|
+
check_result = Proc.new {
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
done
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
test_complex_state_flow_w_name redis,[["Interactor.PerformanceCounter","counter" ,["initialized","finished"]]],check_result do |count|
|
|
55
|
+
counter = PerformanceCounter.create(:name=>"counter",:amount =>1)
|
|
56
|
+
trigger = InteractorTest.create(:name=>"test")
|
|
57
|
+
trigger.process_event :organize
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should run as quickly as possible for two mappings" do
|
|
65
|
+
connect true do |redis|
|
|
66
|
+
parser = MINT::MappingParser.new
|
|
67
|
+
m = parser.build_from_scxml File.dirname(__FILE__) +"/examples/performance_mapping.xml"
|
|
68
|
+
m.start
|
|
69
|
+
|
|
70
|
+
m = parser.build_from_scxml File.dirname(__FILE__) +"/examples/performance_mapping.xml"
|
|
71
|
+
m.start
|
|
72
|
+
|
|
73
|
+
check_result = Proc.new {
|
|
74
|
+
done
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
test_complex_state_flow_w_name redis,[["Interactor.PerformanceCounter","counter" ,["initialized","initialized","finished"]]],check_result do |count|
|
|
78
|
+
counter = PerformanceCounter.create(:name=>"counter",:amount =>2)
|
|
79
|
+
trigger = InteractorTest.create(:name=>"test")
|
|
80
|
+
trigger.process_event :organize
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should run as quickly as possible for 1000 mappings" do
|
|
88
|
+
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do
|
|
89
|
+
connect(true,30) do |redis|
|
|
90
|
+
parser = MINT::MappingParser.new
|
|
91
|
+
|
|
92
|
+
obs_array =[]
|
|
93
|
+
|
|
94
|
+
for i in 1..500 do
|
|
95
|
+
m = parser.build_from_scxml File.dirname(__FILE__) +"/examples/performance_mapping.xml"
|
|
96
|
+
m.start
|
|
97
|
+
obs_array << "initialized"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
obs_array << "finished"
|
|
101
|
+
|
|
102
|
+
p obs_array
|
|
103
|
+
|
|
104
|
+
check_result = Proc.new {
|
|
105
|
+
done
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
test_complex_state_flow_w_name redis,[["Interactor.PerformanceCounter","counter" ,obs_array]],check_result do |count|
|
|
109
|
+
counter = PerformanceCounter.create(:name=>"counter",:amount =>500)
|
|
110
|
+
trigger = InteractorTest.create(:name=>"test")
|
|
111
|
+
trigger.process_event :organize
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
require "em-spec/rspec"
|
|
4
|
+
|
|
5
|
+
class FakeMappingServerClient < EventMachine::Connection
|
|
6
|
+
include EM::Protocols::LineText2
|
|
7
|
+
|
|
8
|
+
attr_writer :onopen, :onclose, :onmessage, :onregistered
|
|
9
|
+
attr_reader :data
|
|
10
|
+
|
|
11
|
+
def post_init
|
|
12
|
+
@state = :new
|
|
13
|
+
@data = []
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def set_expectations(mapping_name,detail_level,expected_data)
|
|
18
|
+
@mapping_name = mapping_name
|
|
19
|
+
@expected_data = expected_data
|
|
20
|
+
@detail_level = detail_level
|
|
21
|
+
end
|
|
22
|
+
def receive_line(rd)
|
|
23
|
+
@data << rd
|
|
24
|
+
if @state == :new
|
|
25
|
+
@onopen.call if @onopen
|
|
26
|
+
@state = :open
|
|
27
|
+
end
|
|
28
|
+
p "received #{rd}"
|
|
29
|
+
if rd.eql? "READY"
|
|
30
|
+
@state = :ready
|
|
31
|
+
send_data("REGISTER%#{@mapping_name}%#{@detail_level}\r\n")
|
|
32
|
+
elsif rd.eql? "REGISTERED%#{@mapping_name}%#{@detail_level}"
|
|
33
|
+
@state = :registered
|
|
34
|
+
@onregistered.call if @onregistered
|
|
35
|
+
|
|
36
|
+
else
|
|
37
|
+
d = rd.split("%")
|
|
38
|
+
if d.length ==3
|
|
39
|
+
if d[1].eql? @mapping_name and (d[0].eql? "INFO" or d[0].eql? @detail_level)
|
|
40
|
+
MultiJson.decode(d[2]).should == @expected_data.shift
|
|
41
|
+
|
|
42
|
+
EM::stop if @expected_data.length == 0
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
p "Unknown command received:#{rd}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
def unbind
|
|
52
|
+
@onclose.call if @onclose
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "Mapping server" do
|
|
57
|
+
include EventMachine::SpecHelper
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
before :all do
|
|
61
|
+
connection_options = { :adapter => "redis"}
|
|
62
|
+
DataMapper.setup(:default, connection_options)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
connect do |redis|
|
|
66
|
+
require "MINT-core"
|
|
67
|
+
class Logging
|
|
68
|
+
def self.log(mapping,data)
|
|
69
|
+
p "log: #{mapping} #{data}"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
DataMapper.finalize
|
|
73
|
+
DataMapper::Model.raise_on_save_failure = true
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
before(:each) do
|
|
78
|
+
Redis.new(:db => 15).flushdb
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should open connection and accept register command" do
|
|
82
|
+
connect true do |redis|
|
|
83
|
+
CUIControl.clearHighlighted
|
|
84
|
+
|
|
85
|
+
server = MappingServer.new(:host => '0.0.0.0', :port => 12345)
|
|
86
|
+
server.start
|
|
87
|
+
|
|
88
|
+
# opens the socket client connection
|
|
89
|
+
socket = EM.connect('0.0.0.0', 12345, FakeMappingServerClient)
|
|
90
|
+
socket.set_expectations("Mouse Interactor Highlighting","INFO",[])
|
|
91
|
+
# assigning the onopen client callback directly
|
|
92
|
+
socket.onopen = lambda {
|
|
93
|
+
|
|
94
|
+
server.connections.size.should == 1
|
|
95
|
+
socket.data.last.chomp.should == "READY"
|
|
96
|
+
EM.stop
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should return all information about mapping states after registration with DETAIL" do
|
|
103
|
+
connect true do |redis|
|
|
104
|
+
CUIControl.clearHighlighted
|
|
105
|
+
server = MappingServer.new(:host => '0.0.0.0', :port => 12345)
|
|
106
|
+
server.start
|
|
107
|
+
|
|
108
|
+
# opens the socket client connection
|
|
109
|
+
socket = EM.connect('0.0.0.0', 12345, FakeMappingServerClient )
|
|
110
|
+
socket.set_expectations("Mouse Interactor Highlighting","DETAIL",[{"id"=>"33113", "mapping_state"=>"loaded"},
|
|
111
|
+
{"id"=>"33113", "mapping_state"=>"started"},
|
|
112
|
+
{"id"=>"111", "state"=>"activated"},
|
|
113
|
+
{"id"=>"111", "element"=>"Interactor.IR.IRMode.Pointer.Mouse", "result"=>{}, "state"=>"false"},
|
|
114
|
+
{"id"=>"111", "element"=>"Interactor.IR.IRMode.Pointer.Mouse", "result"=>{"p"=>{"classtype"=>"MINT::Mouse", "mint_model"=>"core", "name"=>"mouse", "states"=>["left_released", "stopped", "right_released"], "abstract_states"=>"Mouse|root|connected|leftbutton|pointer|rightbutton", "new_states"=>["connected", "leftbutton", "pointer", "rightbutton", "left_released", "stopped", "right_released"], "x"=>-1, "y"=>-1}}, "state"=>"true", "name"=>"mouse"},
|
|
115
|
+
{"id"=>"2222", "state"=>"activated"},
|
|
116
|
+
{"id"=>"2222", "state"=>"succeeded"},
|
|
117
|
+
{"id"=>"33113", "mapping_state"=>"succeeded"},
|
|
118
|
+
{"id"=>"33113", "mapping_state"=>"restarted"},
|
|
119
|
+
{"id"=>"111", "state"=>"activated"}])
|
|
120
|
+
m = server.manager
|
|
121
|
+
|
|
122
|
+
socket.onregistered= lambda {
|
|
123
|
+
m.load(File.dirname(__FILE__) +"/examples/mim_streaming_example.xml").started {
|
|
124
|
+
mouse = MINT::Mouse.create(:name =>"mouse") # previously activated observation should be false
|
|
125
|
+
mouse.process_event :connect # observation should be true
|
|
126
|
+
#mouse.process_event :move
|
|
127
|
+
#mouse.process_event :stop
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
it "should return all information about mapping states after registration with DETAIL" do
|
|
135
|
+
connect true do |redis|
|
|
136
|
+
CUIControl.clearHighlighted
|
|
137
|
+
server = MappingServer.new(:host => '0.0.0.0', :port => 12345)
|
|
138
|
+
server.start
|
|
139
|
+
|
|
140
|
+
# opens the socket client connection
|
|
141
|
+
socket = EM.connect('0.0.0.0', 12345, FakeMappingServerClient )
|
|
142
|
+
socket.set_expectations("Mouse Interactor Highlighting","INFO",[#{"id"=>"33113", "mapping_state"=>"loaded"},
|
|
143
|
+
# {"id"=>"33113", "mapping_state"=>"started"},
|
|
144
|
+
{"id"=>"33113", "mapping_state"=>"succeeded", "name"=>"mouse"}
|
|
145
|
+
#{"id"=>"33113", "mapping_state"=>"restarted"}
|
|
146
|
+
])
|
|
147
|
+
m = server.manager
|
|
148
|
+
|
|
149
|
+
socket.onregistered= lambda {
|
|
150
|
+
m.load(File.dirname(__FILE__) +"/examples/mim_streaming_example.xml").started {
|
|
151
|
+
mouse = MINT::Mouse.create(:name =>"mouse") # previously activated observation should be false
|
|
152
|
+
mouse.process_event :connect # observation should be true
|
|
153
|
+
#mouse.process_event :move
|
|
154
|
+
#mouse.process_event :stop
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
require "em-spec/rspec"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe 'Mapping' do
|
|
7
|
+
include EventMachine::SpecHelper
|
|
8
|
+
|
|
9
|
+
before :all do
|
|
10
|
+
|
|
11
|
+
connection_options = { :adapter => "redis"}
|
|
12
|
+
DataMapper.setup(:default, connection_options)
|
|
13
|
+
|
|
14
|
+
connect do |redis|
|
|
15
|
+
require "MINT-core"
|
|
16
|
+
require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
|
|
17
|
+
include MINT
|
|
18
|
+
|
|
19
|
+
class InteractorTest < MINT::Interactor
|
|
20
|
+
|
|
21
|
+
def show_states c
|
|
22
|
+
puts "States #{c['states']}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def getSCXML
|
|
26
|
+
"#{File.dirname(__FILE__)}/interactor_test.scxml"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
class InteractorTest_2 <InteractorTest
|
|
30
|
+
end
|
|
31
|
+
class InteractorTest2 <InteractorTest
|
|
32
|
+
def getSCXML
|
|
33
|
+
"#{File.dirname(__FILE__)}/interactor_test_2.scxml"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Logging
|
|
38
|
+
def self.log(mapping,data)
|
|
39
|
+
p "log: #{mapping} #{data}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
DataMapper.finalize
|
|
43
|
+
DataMapper::Model.raise_on_save_failure = true
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe 'without Parser' do
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
describe 'Sequential' do
|
|
51
|
+
describe 'with EventAction' do
|
|
52
|
+
it 'should fire event if all observations have been true' do
|
|
53
|
+
connect true do |redis|
|
|
54
|
+
o1 = Observation.new(:element =>"Interactor.InteractorTest",:name => "test_1", :states =>[:organized],:process=> :onchange)
|
|
55
|
+
o2 = Observation.new(:element =>"Interactor.InteractorTest.InteractorTest_2",:name => "test_2", :states =>[:initialized], :result => "p",:process=> :continuous )
|
|
56
|
+
a = EventAction.new(:event => :organize, :target => "p")
|
|
57
|
+
m = MINT::SequentialMapping.new(:name=>"Interactor.InteractorTest Observation", :observations => [o1,o2],:actions =>[a])
|
|
58
|
+
m.start
|
|
59
|
+
|
|
60
|
+
test_state_flow redis,"Interactor.InteractorTest.InteractorTest_2.test_2" ,["initialized", "organized"] do
|
|
61
|
+
test_1 = InteractorTest.create(:name => "test_1")
|
|
62
|
+
test_1.process_event :organize
|
|
63
|
+
test_2 = InteractorTest_2.create(:name => "test_2")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "sync mapping" do
|
|
69
|
+
it 'should support name selector and not observations for sync mappings' do
|
|
70
|
+
connect true do |redis|
|
|
71
|
+
o1 = Observation.new(:element =>"Interactor.AIO", :states =>[:presenting],:result=>"aio")
|
|
72
|
+
o2 = NegationObservation.new(:element =>"Interactor.CIO", :name =>"aio.name" ,:states =>[:displaying], :result => "cio", :process => :continuous )
|
|
73
|
+
a = EventAction.new(:event => :display, :target => "cio")
|
|
74
|
+
m = MINT::SequentialMapping.new(:name=>"Sync CIO to display", :observations => [o1,o2],:actions =>[a])
|
|
75
|
+
m.start
|
|
76
|
+
|
|
77
|
+
test_state_flow redis,"Interactor.CIO.test" ,[["displaying", "init_js"],"displayed"] do
|
|
78
|
+
aio = MINT::AIO.create(:name => "test", :states => [:organized])
|
|
79
|
+
cio = MINT::CIO.create(:name => "test", :states=>[:positioned])
|
|
80
|
+
aio.process_event :present
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
it 'should support not end up in cycles for sync mappings' do
|
|
86
|
+
connect true do |redis|
|
|
87
|
+
o1 = Observation.new(:element =>"Interactor.AIO", :states =>[:presenting],:result=>"aio",:process => :onchange)
|
|
88
|
+
o2 = NegationObservation.new(:element =>"Interactor.CIO", :name =>"aio.name" ,:states =>[:displaying], :result => "cio",:process => :instant )
|
|
89
|
+
a = EventAction.new(:event => :display, :target => "cio")
|
|
90
|
+
m = MINT::SequentialMapping.new(:name=>"Sync CIO to display", :observations => [o1,o2],:actions =>[a])
|
|
91
|
+
m.state_callback = Logging.method(:log)
|
|
92
|
+
m.start
|
|
93
|
+
|
|
94
|
+
o3 = Observation.new(:element =>"Interactor.CIO", :states =>[:displaying],:result=>"cio",:process => :onchange)
|
|
95
|
+
o4 = NegationObservation.new(:element =>"Interactor.AIO", :name =>"cio.name" ,:states =>[:presenting], :result => "aio",:process => :instant)
|
|
96
|
+
a1 = EventAction.new(:event => :present, :target => "aio")
|
|
97
|
+
m1 = MINT::SequentialMapping.new(:name=>"Sync CIO display to AIO presenting", :observations => [o3,o4],:actions =>[a1])
|
|
98
|
+
m1.state_callback = Logging.method(:log)
|
|
99
|
+
m1.start
|
|
100
|
+
|
|
101
|
+
test_state_flow redis,"Interactor.AIO.test" ,[["presenting", "defocused"]] do
|
|
102
|
+
aio = MINT::AIO.create(:name => "test", :states => [:organized])
|
|
103
|
+
cio = MINT::CIO.create(:name => "test", :states=>[:positioned])
|
|
104
|
+
cio.process_event :display
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
describe 'Complementary' do
|
|
118
|
+
describe 'with EventAction' do
|
|
119
|
+
it 'should fire event if the observation is true' do
|
|
120
|
+
connect true do |redis|
|
|
121
|
+
o = Observation.new(:element =>"Interactor.InteractorTest", :name => "test", :result => "p", :states =>[:initialized], :process=>"onchange")
|
|
122
|
+
a = EventAction.new(:event => :organize,:target => "p")
|
|
123
|
+
m = MINT::ComplementaryMapping.new(:name=>"Interactor.InteractorTest Observation", :observations => [o],:actions =>[a])
|
|
124
|
+
m.start
|
|
125
|
+
|
|
126
|
+
test_state_flow redis,"Interactor.InteractorTest.test" ,["initialized", "organized"] do
|
|
127
|
+
@a = InteractorTest.create(:name => "test")
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'should fire event if both observations are true' do
|
|
133
|
+
connect true do |redis|
|
|
134
|
+
o1 = Observation.new(:element =>"Interactor.InteractorTest",:name => "test_1", :states =>[:organized], :process=>"onchange")
|
|
135
|
+
o2 = Observation.new(:element =>"Interactor.InteractorTest.InteractorTest_2",:name => "test_2", :states =>[:initialized], :result => "p",:process=>"instant")
|
|
136
|
+
a = EventAction.new(:event => :organize, :target => "p")
|
|
137
|
+
m = MINT::ComplementaryMapping.new(:name=>"Interactor.InteractorTest Observation", :observations => [o1,o2],:actions =>[a])
|
|
138
|
+
m.start
|
|
139
|
+
|
|
140
|
+
test_state_flow redis,"Interactor.InteractorTest.InteractorTest_2.test_2" ,["initialized", "organized"] do
|
|
141
|
+
test_1 = InteractorTest.create(:name => "test_1")
|
|
142
|
+
test_2 = InteractorTest_2.create(:name => "test_2")
|
|
143
|
+
test_1.process_event :organize
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'should handle a continuous observation' do
|
|
149
|
+
pending "rethink if step 3 really should happen"
|
|
150
|
+
connect true do |redis|
|
|
151
|
+
o1 = Observation.new(:element =>"Interactor.InteractorTest.InteractorTest2",:name => "test", :states =>[:presenting], :result => "p",:process => :onchange)
|
|
152
|
+
a = EventAction.new(:event => :step, :target => "p")
|
|
153
|
+
m = MINT::ComplementaryMapping.new(:name=>"Interactor.InteractorTest Observation", :observations => [o1],:actions =>[a])
|
|
154
|
+
m.start
|
|
155
|
+
|
|
156
|
+
test_state_flow redis,"Interactor.InteractorTest.InteractorTest2.test" ,["initialized", ["presenting", "step1"],"step2","step3","initialized"] do
|
|
157
|
+
test = InteractorTest2.create(:name => "test")
|
|
158
|
+
test.process_event :present
|
|
159
|
+
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'should handle a non continuous observation' do
|
|
166
|
+
connect true do |redis|
|
|
167
|
+
o1 = Observation.new(:element =>"Interactor.InteractorTest.InteractorTest2",:name => "test", :states =>[:presenting], :result => "p", :process=>"onchange")
|
|
168
|
+
a = EventAction.new(:event => :step, :target => "p")
|
|
169
|
+
m = MINT::ComplementaryMapping.new(:name=>"Interactor.InteractorTest Observation", :observations => [o1],:actions =>[a])
|
|
170
|
+
m.start
|
|
171
|
+
|
|
172
|
+
test_state_flow redis,"Interactor.InteractorTest.InteractorTest2.test" ,["initialized", ["presenting", "step1"],"step2"] do
|
|
173
|
+
test = InteractorTest2.create(:name => "test")
|
|
174
|
+
test.process_event :present
|
|
175
|
+
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe 'with BackendAction' do
|
|
184
|
+
it 'should call the Backend Action if observation is true' do
|
|
185
|
+
connect true do |redis|
|
|
186
|
+
b = InteractorTest.new
|
|
187
|
+
o = Observation.new(:element =>"Interactor.InteractorTest",:name => "test", :states =>[:organized], :result => "c", :process=>"onchange")
|
|
188
|
+
a = BackendAction.new(:call => b.method(:show_states), :parameter => "c")
|
|
189
|
+
m = MINT::ComplementaryMapping.new(:name=>"BackendAction test",:observations => [o],:actions =>[a])
|
|
190
|
+
m.start
|
|
191
|
+
|
|
192
|
+
test_state_flow redis,"Interactor.InteractorTest.test" ,["initialized", "organized"] do
|
|
193
|
+
test = InteractorTest.create(:name => "test")
|
|
194
|
+
test.process_event :organize
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
describe 'with Parser' do
|
|
204
|
+
describe 'Complementary' do
|
|
205
|
+
describe 'with EventAction' do
|
|
206
|
+
it 'should fire event if the observation is true' do
|
|
207
|
+
connect true do |redis|
|
|
208
|
+
parser = MINT::MappingParser.new
|
|
209
|
+
scxml = <<EOS
|
|
210
|
+
<mapping name="Interactor.InteractorTest Observation" xmlns="http://www.multi-access.de"
|
|
211
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
212
|
+
xsi:schemaLocation="http://www.multi-access.de mint-mappings.xsd">
|
|
213
|
+
<operator type="complementary">
|
|
214
|
+
<observations>
|
|
215
|
+
<observation interactor="Interactor.InteractorTest" name="test" states="initialized" result="p" process="onchange"/>
|
|
216
|
+
</observations>
|
|
217
|
+
<actions>
|
|
218
|
+
<event type="organize" target="p"/>
|
|
219
|
+
</actions>
|
|
220
|
+
</operator>
|
|
221
|
+
|
|
222
|
+
</mapping>
|
|
223
|
+
EOS
|
|
224
|
+
m = parser.build_from_scxml_string scxml
|
|
225
|
+
m.start
|
|
226
|
+
|
|
227
|
+
test_state_flow redis,"Interactor.InteractorTest.test" ,["initialized", "organized"] do
|
|
228
|
+
@a = InteractorTest.create(:name => "test")
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it 'should fire event if both observations are true' do
|
|
234
|
+
connect true do |redis|
|
|
235
|
+
parser = MINT::MappingParser.new
|
|
236
|
+
scxml = <<EOS
|
|
237
|
+
<mapping name="Interactor.InteractorTest Observation" xmlns="http://www.multi-access.de"
|
|
238
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
239
|
+
xsi:schemaLocation="http://www.multi-access.de mint-mappings.xsd">
|
|
240
|
+
<operator type="sequential">
|
|
241
|
+
<observations>
|
|
242
|
+
<observation interactor="Interactor.InteractorTest" name="test_1" states="organized" process="onchange"/>
|
|
243
|
+
<observation interactor="Interactor.InteractorTest.InteractorTest_2" name="test_2" states="initialized" process="instant" result="p"/>
|
|
244
|
+
</observations>
|
|
245
|
+
<actions>
|
|
246
|
+
<event type="organize" target="p"/>
|
|
247
|
+
</actions>
|
|
248
|
+
</operator>
|
|
249
|
+
|
|
250
|
+
</mapping>
|
|
251
|
+
EOS
|
|
252
|
+
m = parser.build_from_scxml_string scxml
|
|
253
|
+
m.start
|
|
254
|
+
|
|
255
|
+
test_state_flow redis,"Interactor.InteractorTest.InteractorTest_2.test_2" ,["initialized", "organized"] do
|
|
256
|
+
test_1 = InteractorTest.create(:name => "test_1")
|
|
257
|
+
test_2 = InteractorTest_2.create(:name => "test_2")
|
|
258
|
+
test_1.process_event :organize
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
=begin
|
|
265
|
+
describe 'with BindAction' do
|
|
266
|
+
it 'should bind if both observation are true' do
|
|
267
|
+
connect true do |redis|
|
|
268
|
+
o1 = Observation.new(:element =>"Interactor.InteractorTest",:name => "test", :states =>[:organized])
|
|
269
|
+
o2 = Observation.new(:element =>"Interactor.InteractorTest.InteractorTest_2",:name=>"test_2", :states =>[:presenting])
|
|
270
|
+
a = BindAction.new(:elementIn => "Interactor.InteractorTest",:nameIn => "test", :attrIn =>"data",:attrOut=>"data",
|
|
271
|
+
:elementOut =>"Interactor.InteractorTest.InteractorTest_2", :nameOut=>"test_2" )
|
|
272
|
+
m = ComplementaryMapping.new(:name => "BindAction test", :observations => [o1,o2],:actions =>[a])
|
|
273
|
+
m.start
|
|
274
|
+
|
|
275
|
+
test_state_flow redis,"Interactor.InteractorTest" ,["initialized", "organized"] do
|
|
276
|
+
test_1 = InteractorTest.create(:name => "test")
|
|
277
|
+
test_2 = InteractorTest_2.create(:name => "test_2")
|
|
278
|
+
test_1.process_event :organize
|
|
279
|
+
test_2.process_event :organize
|
|
280
|
+
test_2.process_event :present
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
describe 'with BackendAction' do
|
|
288
|
+
it 'should call the Backend Action if observation is true' do
|
|
289
|
+
connect true do |redis|
|
|
290
|
+
b = InteractorTest.new
|
|
291
|
+
o = Observation.new(:element =>"Interactor.InteractorTest",:name => "test", :states =>[:organized], :result => "c")
|
|
292
|
+
a = BackendAction.new(:call => b.method(:show_states), :parameter => "c")
|
|
293
|
+
m = ComplementaryMapping.new(:name=>"BackendAction test",:observations => [o],:actions =>[a])
|
|
294
|
+
m.start
|
|
295
|
+
|
|
296
|
+
test_state_flow redis,"Interactor.InteractorTest" ,["initialized", "organized"] do
|
|
297
|
+
test = InteractorTest.create(:name => "test")
|
|
298
|
+
test.process_event :organize
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
=end
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
end
|