MINT-scxml 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +18 -0
- data/History.txt +4 -0
- data/MINT-scxml.gemspec +35 -0
- data/Manifest.txt +49 -0
- data/README.rdoc +50 -0
- data/Rakefile +31 -0
- data/lib/MINT-scxml.rb +5 -0
- data/lib/MINT-scxml/scxml-parser.rb +228 -0
- data/spec/atm_spec.rb +69 -0
- data/spec/parser_spec.rb +394 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/test_handgestures_spec.rb +53 -0
- data/spec/testmachines/atm_enhanced.rb +129 -0
- data/spec/testmachines/handgestures-scxmlgui.png +0 -0
- data/spec/testmachines/handgestures-scxmlgui.scxml +106 -0
- data/spec/testmachines/multiplestates.rb +25 -0
- data/spec/testmachines/traffic_light_enhanced.rb +56 -0
- data/spec/testmachines/vending_machine1.rb +18 -0
- data/spec/testmachines/vending_machine2.rb +42 -0
- data/spec/testmachines/vending_machine3.rb +48 -0
- data/spec/testmachines/vending_machine4.rb +29 -0
- data/spec_helper.rb +8 -0
- data/statemachines/AICommand_scxml_spec.rb +38 -0
- data/statemachines/AIO_scxml_spec.rb +36 -0
- data/statemachines/aui-scxml/AIC.scxml +26 -0
- data/statemachines/aui-scxml/AICommand.scxml +34 -0
- data/statemachines/aui-scxml/AICommand2.scxml +32 -0
- data/statemachines/aui-scxml/AIO.scxml +25 -0
- data/statemachines/aui/AIC.rb +29 -0
- data/statemachines/aui/AIChoiceElement.rb +32 -0
- data/statemachines/aui/AICommand.rb +34 -0
- data/statemachines/aui/AIIN.rb +7 -0
- data/statemachines/aui/AIINContinous.rb +41 -0
- data/statemachines/aui/AIMultiChoice.rb +46 -0
- data/statemachines/aui/AIMultiChoiceElement.rb +46 -0
- data/statemachines/aui/AIOUTContinous.rb +41 -0
- data/statemachines/aui/AISingleChoice.rb +42 -0
- data/statemachines/aui/AISingleChoiceElement.rb +45 -0
- data/statemachines/aui/aio.rb +28 -0
- data/statemachines/specs/AICommand_spec.rb +58 -0
- data/statemachines/specs/AIINContinous_spec.rb +61 -0
- data/statemachines/specs/AIMultiChoiceElement_spec.rb +70 -0
- data/statemachines/specs/AIMultiChoice_spec.rb +56 -0
- data/statemachines/specs/AIOUTContinous_spec.rb +71 -0
- data/statemachines/specs/AIO_spec.rb +53 -0
- data/statemachines/specs/AISingleChoiceElement_spec.rb +58 -0
- data/statemachines/specs/AISingleChoice_spec.rb +68 -0
- metadata +146 -0
data/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "AICommand" do
|
4
|
+
before (:each) do
|
5
|
+
parser = StatemachineParser.new
|
6
|
+
@statemachine = parser.build_from_scxml "aui-scxml/AICommand2.scxml"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it "should enter the nested superstate :focused" do
|
11
|
+
@statemachine.organize
|
12
|
+
@statemachine.present
|
13
|
+
@statemachine.focus
|
14
|
+
@statemachine.state.should == :deactivated
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should support transitions inside :focused" do
|
18
|
+
@statemachine.organize
|
19
|
+
@statemachine.present
|
20
|
+
@statemachine.focus
|
21
|
+
@statemachine.activate
|
22
|
+
@statemachine.state.should == :activated
|
23
|
+
@statemachine.deactivate
|
24
|
+
@statemachine.state.should == :deactivated
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should leave the superstate :focused and return to the same point it left" do
|
28
|
+
@statemachine.organize
|
29
|
+
@statemachine.present
|
30
|
+
@statemachine.focus
|
31
|
+
@statemachine.activate
|
32
|
+
@statemachine.state.should == :activated
|
33
|
+
@statemachine.defocus
|
34
|
+
@statemachine.state.should == :defocused
|
35
|
+
@statemachine.focus
|
36
|
+
@statemachine.state.should == :activated
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "AIO" do
|
4
|
+
before (:each) do
|
5
|
+
parser = StatemachineParser.new
|
6
|
+
@statemachine = parser.build_from_scxml "aui-scxml/AIO.scxml"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it "should start in :initialized" do
|
11
|
+
@statemachine.state.should == :initialized
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should enter the superstate :presenting" do
|
15
|
+
@statemachine.organize
|
16
|
+
@statemachine.state.should == :organized
|
17
|
+
@statemachine.present
|
18
|
+
@statemachine.state.should == :defocused
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should support transitions inside the superstate" do
|
22
|
+
@statemachine.organize
|
23
|
+
@statemachine.present
|
24
|
+
@statemachine.focus
|
25
|
+
@statemachine.state.should == :focused
|
26
|
+
@statemachine.defocus
|
27
|
+
@statemachine.state.should == :defocused
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should leave the superstate" do
|
31
|
+
@statemachine.organize
|
32
|
+
@statemachine.present
|
33
|
+
@statemachine.suspend
|
34
|
+
@statemachine.state.should == :suspended
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml">
|
2
|
+
<state id="AIC">
|
3
|
+
<state id="initialized">
|
4
|
+
<transition event="organize" target="organized"/>
|
5
|
+
</state>
|
6
|
+
<state id="organized">
|
7
|
+
<transition event="present" target="presenting"/>
|
8
|
+
</state>
|
9
|
+
<state id="suspended">
|
10
|
+
<transition event="organize" target="organized"/>
|
11
|
+
</state>
|
12
|
+
<state id="presenting">
|
13
|
+
<transition event="suspend" target="suspended"/>
|
14
|
+
<state id="defocused">
|
15
|
+
<transition event="focus" target="focused"/>
|
16
|
+
<transition event="next" target="focused"/>
|
17
|
+
<transition event="prev" target="focused"/>
|
18
|
+
<transition event="parent" target="focused"/>
|
19
|
+
<transition event="child" target="focused"/>
|
20
|
+
</state>
|
21
|
+
<state id="focused">
|
22
|
+
<transition event="defocus" target="defocused"/>
|
23
|
+
</state>
|
24
|
+
</state>
|
25
|
+
</state>
|
26
|
+
</scxml>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml">
|
2
|
+
<state id="AICommand">
|
3
|
+
<state id="initialized">
|
4
|
+
<transition event="organize" target="organized"/>
|
5
|
+
</state>
|
6
|
+
<state id="organized">
|
7
|
+
<transition event="present" target="presenting"/>
|
8
|
+
</state>
|
9
|
+
<state id="suspended">
|
10
|
+
<transition event="organize" target="organized"/>
|
11
|
+
</state>
|
12
|
+
<state id="presenting">
|
13
|
+
<transition event="suspend" target="suspended"/>
|
14
|
+
<state id="defocused">
|
15
|
+
<transition event="focus" target="focused"/>
|
16
|
+
<transition event="next" target="focused"/>
|
17
|
+
<transition event="prev" target="focused"/>
|
18
|
+
<transition event="parent" target="focused"/>
|
19
|
+
</state>
|
20
|
+
<state id="focused">
|
21
|
+
<transition event="defocus" target="defocused"/>
|
22
|
+
<state id="deactivated">
|
23
|
+
<transition event="activate" target="activated"/>
|
24
|
+
</state>
|
25
|
+
<state id="activated">
|
26
|
+
<transition event="deactivate" target="deactivated"/>
|
27
|
+
</state>
|
28
|
+
<history id="history" type="deep">
|
29
|
+
<transition target="deactivated"/>
|
30
|
+
</history>
|
31
|
+
</state>
|
32
|
+
</state>
|
33
|
+
</state>
|
34
|
+
</scxml>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0.0 y=0.0 w=299.19717193536917 h=692.0 -->
|
2
|
+
<state id="initialized"><!-- node-size-and-position x=118.75 y=43.0 w=70.0 h=20.0 -->
|
3
|
+
<transition event="organize" target="organized"></transition>
|
4
|
+
</state>
|
5
|
+
<state id="organized"><!-- node-size-and-position x=123.75 y=113.0 w=60.0 h=20.0 -->
|
6
|
+
<transition event="present" target="presenting"></transition>
|
7
|
+
</state>
|
8
|
+
<state id="presenting" initial="defocused"><!-- node-size-and-position x=20.0 y=183.0 w=161.5 h=356.0 -->
|
9
|
+
<transition event="suspend" target="suspended"></transition>
|
10
|
+
<state id="focused" initial="deactivated"><!-- node-size-and-position x=20.0 y=113.0 w=121.5 h=223.0 -->
|
11
|
+
<transition event="defocus" target="defocused"><!-- edge-path [defocused] x=78.78709972846912 y=98.06535407059803 --></transition>
|
12
|
+
<state id="deactivated"><!-- node-size-and-position x=29.0 y=113.0 w=70.0 h=20.0 -->
|
13
|
+
<transition event="activate" target="activated"><!-- edge-path [activated] x=70.0 y=158.0 pointx=0.0 pointy=19.0 offsetx=1.0 offsety=6.0 --></transition>
|
14
|
+
</state>
|
15
|
+
<state id="activated"><!-- node-size-and-position x=34.0 y=183.0 w=60.0 h=20.0 -->
|
16
|
+
<transition event="deactivate" target="deactivated"><!-- edge-path [deactivated] x=50.0 y=158.0 pointx=0.0 pointy=10.0 offsetx=-1.0 offsety=-1.0 --></transition>
|
17
|
+
</state>
|
18
|
+
<history id="history" type="deep"><!-- node-size-and-position x=39.0 y=43.0 w=50.0 h=20.0 -->
|
19
|
+
<transition target="deactivated"></transition>
|
20
|
+
</history>
|
21
|
+
</state>
|
22
|
+
<state id="defocused"><!-- node-size-and-position x=50.75 y=43.0 w=60.0 h=20.0 -->
|
23
|
+
<transition event="focus" target="focused"><!-- edge-path [focused] x=117.5 y=88.0 --></transition>
|
24
|
+
<transition event="next" target="focused"><!-- edge-path [focused] x=98.14354986423456 y=93.03267703529902 --></transition>
|
25
|
+
<transition event="prev" target="focused"><!-- edge-path [focused] x=136.85645013576544 y=82.96732296470098 --></transition>
|
26
|
+
<transition event="parent" target="focused"><!-- edge-path [focused] x=156.21290027153088 y=77.93464592940197 --></transition>
|
27
|
+
</state>
|
28
|
+
</state>
|
29
|
+
<state id="suspended"><!-- node-size-and-position x=125.75 y=589.0 w=60.0 h=20.0 -->
|
30
|
+
<transition event="organize" target="organized"><!-- edge-path [organized] x=211.75 y=361.0 --></transition>
|
31
|
+
</state>
|
32
|
+
</scxml>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<scxml id="SCXML" xmlns="http://www.w3.org/2005/07/scxml">
|
2
|
+
<state id="AIO">
|
3
|
+
<state id="initialized">
|
4
|
+
<transition event="organize" target="organized"/>
|
5
|
+
</state>
|
6
|
+
<state id="organized">
|
7
|
+
<transition event="present" target="presenting"/>
|
8
|
+
</state>
|
9
|
+
<state id="suspended">
|
10
|
+
<transition event="organize" target="organized"/>
|
11
|
+
</state>
|
12
|
+
<state id="presenting">
|
13
|
+
<transition event="suspend" target="suspended"/>
|
14
|
+
<state id="defocused">
|
15
|
+
<transition event="focus" target="focused"/>
|
16
|
+
<transition event="next" target="focused"/>
|
17
|
+
<transition event="prev" target="focused"/>
|
18
|
+
<transition event="parent" target="focused"/>
|
19
|
+
</state>
|
20
|
+
<state id="focused">
|
21
|
+
<transition event="defocus" target="defocused"/>
|
22
|
+
</state>
|
23
|
+
</state>
|
24
|
+
</state>
|
25
|
+
</scxml>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIC < AIO
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIC do
|
10
|
+
trans :initialized, :organize, :organized
|
11
|
+
trans :organized, :present, :presenting
|
12
|
+
trans :suspended, :organize, :organized
|
13
|
+
|
14
|
+
superstate :presenting do
|
15
|
+
event :suspend, :suspended
|
16
|
+
|
17
|
+
trans :defocused, :focus, :focused
|
18
|
+
trans :defocused, :next, :focused, :focus_next
|
19
|
+
trans :defocused, :prev, :focused, :focus_prev
|
20
|
+
trans :defocused, :parent, :focused, :focus_parent
|
21
|
+
trans :defocused, :child, :focused, :focus_child
|
22
|
+
trans :focused, :defocus, :defocused
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
# This code is only used in parallel with others
|
5
|
+
module MINT
|
6
|
+
class AIChoiceElement
|
7
|
+
def initialize_statemachine
|
8
|
+
if @statemachine.blank?
|
9
|
+
@statemachine = Statemachine.build do
|
10
|
+
superstate :AIChoiceElement do
|
11
|
+
trans :initialized, :organize, :organized
|
12
|
+
trans :organized, :present, :presenting
|
13
|
+
trans :suspended, :organize, :organized
|
14
|
+
|
15
|
+
superstate :presenting do
|
16
|
+
event :suspend, :suspended
|
17
|
+
|
18
|
+
trans :defocused, :focus, :focused
|
19
|
+
trans :defocused, :next, :focused, :focus_next
|
20
|
+
trans :defocused, :prev, :focused, :focus_prev
|
21
|
+
trans :defocused, :parent, :focused, :focus_parent
|
22
|
+
trans :focused, :defocus, :defocused
|
23
|
+
trans :focused, :drag, :dragging, :self_choose, In(:unchosen)
|
24
|
+
trans :focused, :drag, :dragging, nil, In(:chosen)
|
25
|
+
trans :dragging, :drop, :defocused
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AICommand < AIO
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AICommand do
|
10
|
+
trans :initialized, :organize, :organized
|
11
|
+
trans :organized, :present, :presenting
|
12
|
+
trans :suspended, :organize, :organized
|
13
|
+
|
14
|
+
superstate :presenting do
|
15
|
+
event :suspend, :suspended
|
16
|
+
|
17
|
+
trans :defocused, :focus, :focused_H
|
18
|
+
trans :defocused, :next, :focused_H, :focus_next
|
19
|
+
trans :defocused, :prev, :focused_H, :focus_prev
|
20
|
+
trans :defocused, :parent, :focused_H, :focus_parent
|
21
|
+
|
22
|
+
superstate :focused do
|
23
|
+
event :defocus, :defocused
|
24
|
+
|
25
|
+
trans :deactivated, :activate, :activated
|
26
|
+
trans :activated, :deactivate, :deactivated
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIINContinous < AIIN
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIINContinous do
|
10
|
+
trans :initialized, :organize, :organized
|
11
|
+
trans :organized, :present, :presenting
|
12
|
+
trans :suspended, :organize, :organized
|
13
|
+
|
14
|
+
superstate :presenting do
|
15
|
+
event :suspend, :suspended
|
16
|
+
|
17
|
+
trans :defocused, :focus, :focused
|
18
|
+
trans :defocused, :next, :focused, :focus_next
|
19
|
+
trans :defocused, :prev, :focused, :focus_prev
|
20
|
+
trans :defocused, :parent, :focused, :focus_parent
|
21
|
+
|
22
|
+
superstate :focused do
|
23
|
+
event :defocus, :defocused
|
24
|
+
|
25
|
+
# TODO how to implement the sensitivity condition?
|
26
|
+
trans :waiting, :decrease, :decreasing#, nil, (x1<x0-sensitivy)
|
27
|
+
trans :waiting, :increase, :increasing#, nil, (x1>x0-sensitivy)
|
28
|
+
trans :increasing, :decrease, :decreasing#, nil, (x1<x0-sensitivy)
|
29
|
+
trans :decreasing, :increase, :increasing#, nil, (x1>x0-sensitivy)
|
30
|
+
|
31
|
+
# TODO how to implement transitions without events
|
32
|
+
#trans :decreasing, nil, :waiting, nil, (Dt>tmax)
|
33
|
+
#trans :increasing, nil, :waiting, nil, (Dt>tmax)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIMultiChoice
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIMultiChoice do
|
10
|
+
trans :initialized, :organize, :organized
|
11
|
+
trans :organized, :present, :presenting
|
12
|
+
trans :suspended, :organize, :organized
|
13
|
+
|
14
|
+
superstate :presenting do
|
15
|
+
event :suspend, :suspended
|
16
|
+
|
17
|
+
parallel :p do
|
18
|
+
statemachine :s1 do
|
19
|
+
trans :listing, :drop, :dropped, :drop_all_dragging, In(:focused)
|
20
|
+
trans :listing, :choose_all, :choosing
|
21
|
+
trans :listing, :unchoose_all, :unchoosing
|
22
|
+
# TODO how to implement transitions without events
|
23
|
+
# trans :dropped, nil, :listing, :unfocus_self
|
24
|
+
# trans :choosing, nil, :listing, :choose_all_childs
|
25
|
+
# trans :unchoosing, nil, :listing, :unchoose_all_childs
|
26
|
+
end
|
27
|
+
statemachine :s2 do
|
28
|
+
superstate :presentingAIC do
|
29
|
+
event :suspend, :suspended
|
30
|
+
|
31
|
+
trans :defocused, :focus, :focused
|
32
|
+
trans :defocused, :next, :focused, :focus_next
|
33
|
+
trans :defocused, :prev, :focused, :focus_prev
|
34
|
+
trans :defocused, :parent, :focused, :focus_parent
|
35
|
+
trans :defocused, :child, :focused, :focus_child
|
36
|
+
trans :focused, :defocus, :defocused
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIMultiChoiceElement
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIMultiChoiceElement do
|
10
|
+
trans :initialized, :organize, :organized
|
11
|
+
trans :organized, :present, :presenting_H
|
12
|
+
trans :suspended, :organize, :organized
|
13
|
+
|
14
|
+
superstate :presenting do
|
15
|
+
event :suspend, :suspended
|
16
|
+
|
17
|
+
parallel :p do
|
18
|
+
statemachine :s1 do
|
19
|
+
superstate :selection do
|
20
|
+
trans :unchosen, :choose, :chosen, nil, In(:focused)
|
21
|
+
trans :chosen, :unchoose, :unchosen
|
22
|
+
end
|
23
|
+
end
|
24
|
+
statemachine :s2 do
|
25
|
+
superstate :presentingAIChoiceElement do
|
26
|
+
event :suspend, :suspended
|
27
|
+
|
28
|
+
trans :defocused, :focus, :focused
|
29
|
+
trans :defocused, :next, :focused, :focus_next
|
30
|
+
trans :defocused, :prev, :focused, :focus_prev
|
31
|
+
trans :defocused, :parent, :focused, :focus_parent
|
32
|
+
trans :focused, :defocus, :defocused
|
33
|
+
#would the implementation of "if" be like this?
|
34
|
+
trans :focused, :drag, :dragging, :self_choose, In(:unchosen)
|
35
|
+
trans :focused, :drag, :dragging, nil, In(:chosen)
|
36
|
+
trans :dragging, :drop, :defocused
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|