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
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIOUTContinous
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIOUTContinous 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
|
+
trans :waiting, :progress, :progressing
|
26
|
+
trans :waiting, :regress, :regressing
|
27
|
+
|
28
|
+
superstate :moving do
|
29
|
+
event :halt, :waiting
|
30
|
+
|
31
|
+
trans :progressing, :regress, :regressing
|
32
|
+
trans :regressing, :progress, :progressing
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AISingleChoice
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AISingleChoice 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
|
+
# TODO how to implement transitions without events
|
21
|
+
# trans :dropped, nil , :listing, :unfocus_self
|
22
|
+
end
|
23
|
+
statemachine :s2 do
|
24
|
+
superstate :presentingAIC do
|
25
|
+
event :suspend, :suspended
|
26
|
+
|
27
|
+
trans :defocused, :focus, :focused
|
28
|
+
trans :defocused, :next, :focused, :focus_next
|
29
|
+
trans :defocused, :prev, :focused, :focus_prev
|
30
|
+
trans :defocused, :parent, :focused, :focus_parent
|
31
|
+
trans :defocused, :child, :focused, :focus_child
|
32
|
+
trans :focused, :defocus, :defocused
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AISingleChoiceElement
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AISingleChoiceElement 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, :all_unchoose, 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
|
+
trans :focused, :drag, :dragging, :self_choose, In(:unchosen)
|
34
|
+
trans :focused, :drag, :dragging, nil, In(:chosen)
|
35
|
+
trans :dragging, :drop, :defocused
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'statemachine'
|
3
|
+
|
4
|
+
module MINT
|
5
|
+
class AIO
|
6
|
+
def initialize_statemachine
|
7
|
+
if @statemachine.blank?
|
8
|
+
@statemachine = Statemachine.build do
|
9
|
+
superstate :AIO 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 :focused, :defocus, :defocused
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "AICommand" do
|
4
|
+
before (:each) do
|
5
|
+
@statemachine = Statemachine.build do
|
6
|
+
superstate :AICommand do
|
7
|
+
trans :initialized, :organize, :organized
|
8
|
+
trans :organized, :present, :presenting
|
9
|
+
trans :suspended, :organize, :organized
|
10
|
+
|
11
|
+
superstate :presenting do
|
12
|
+
event :suspend, :suspended
|
13
|
+
|
14
|
+
trans :defocused, :focus, :focused_H
|
15
|
+
trans :defocused, :next, :focused_H#, :focus_next
|
16
|
+
trans :defocused, :prev, :focused_H#, :focus_prev
|
17
|
+
trans :defocused, :parent, :focused_H#, :focus_parent
|
18
|
+
|
19
|
+
superstate :focused do
|
20
|
+
event :defocus, :defocused
|
21
|
+
|
22
|
+
trans :deactivated, :activate, :activated
|
23
|
+
trans :activated, :deactivate, :deactivated
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should enter the nested superstate :focused" do
|
31
|
+
@statemachine.organize
|
32
|
+
@statemachine.present
|
33
|
+
@statemachine.focus
|
34
|
+
@statemachine.state.should == :deactivated
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should support transitions inside :focused" do
|
38
|
+
@statemachine.organize
|
39
|
+
@statemachine.present
|
40
|
+
@statemachine.focus
|
41
|
+
@statemachine.activate
|
42
|
+
@statemachine.state.should == :activated
|
43
|
+
@statemachine.deactivate
|
44
|
+
@statemachine.state.should == :deactivated
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should leave the superstate :focused and return to the same point it left" do
|
48
|
+
@statemachine.organize
|
49
|
+
@statemachine.present
|
50
|
+
@statemachine.focus
|
51
|
+
@statemachine.activate
|
52
|
+
@statemachine.state.should == :activated
|
53
|
+
@statemachine.defocus
|
54
|
+
@statemachine.state.should == :defocused
|
55
|
+
@statemachine.focus
|
56
|
+
@statemachine.state.should == :activated
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "AIINContinous" do
|
4
|
+
before (:each) do
|
5
|
+
@statemachine = Statemachine.build do
|
6
|
+
superstate :AIINContinous do
|
7
|
+
trans :initialized, :organize, :organized
|
8
|
+
trans :organized, :present, :presenting
|
9
|
+
trans :suspended, :organize, :organized
|
10
|
+
|
11
|
+
superstate :presenting do
|
12
|
+
event :suspend, :suspended
|
13
|
+
|
14
|
+
trans :defocused, :focus, :focused
|
15
|
+
trans :defocused, :next, :focused, :focus_next
|
16
|
+
trans :defocused, :prev, :focused, :focus_prev
|
17
|
+
trans :defocused, :parent, :focused, :focus_parent
|
18
|
+
|
19
|
+
superstate :focused do
|
20
|
+
event :defocus, :defocused
|
21
|
+
|
22
|
+
# TODO how to implement the sensitivity condition?
|
23
|
+
trans :waiting, :decrease, :decreasing#, nil, (x1<x0-sensitivy)
|
24
|
+
trans :waiting, :increase, :increasing#, nil, (x1>x0-sensitivy)
|
25
|
+
trans :increasing, :decrease, :decreasing#, nil, (x1<x0-sensitivy)
|
26
|
+
trans :decreasing, :increase, :increasing#, nil, (x1>x0-sensitivy)
|
27
|
+
|
28
|
+
# TODO how to implement transitions without events
|
29
|
+
#trans :decreasing, nil, :waiting, nil, (Dt>tmax)
|
30
|
+
#trans :increasing, nil, :waiting, nil, (Dt>tmax)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
it "should enter the nested superstate :focused" do
|
39
|
+
@statemachine.organize
|
40
|
+
@statemachine.present
|
41
|
+
@statemachine.focus
|
42
|
+
@statemachine.state.should == :waiting
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should support transitions inside :focused" do
|
46
|
+
@statemachine.organize
|
47
|
+
@statemachine.present
|
48
|
+
@statemachine.focus
|
49
|
+
@statemachine.increase
|
50
|
+
@statemachine.state.should == :increasing
|
51
|
+
@statemachine.decrease
|
52
|
+
@statemachine.state.should == :decreasing
|
53
|
+
end
|
54
|
+
|
55
|
+
#TODO implement test for spontaneous transitions
|
56
|
+
=begin
|
57
|
+
it "should support spontaneous transitions" do
|
58
|
+
end
|
59
|
+
=end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "AIMultiChoiceElement" do
|
4
|
+
before (:each) do
|
5
|
+
@statemachine = Statemachine.build do
|
6
|
+
superstate :AIMultiChoiceElement do
|
7
|
+
trans :initialized, :organize, :organized
|
8
|
+
trans :organized, :present, :presenting_H
|
9
|
+
trans :suspended, :organize, :organized
|
10
|
+
|
11
|
+
superstate :presenting do
|
12
|
+
event :suspend, :suspended
|
13
|
+
parallel :p do
|
14
|
+
statemachine :s1 do
|
15
|
+
superstate :selection do
|
16
|
+
# TODO make In() work
|
17
|
+
trans :unchosen, :choose, :chosen#, nil, In(:focused)
|
18
|
+
trans :chosen, :unchoose, :unchosen
|
19
|
+
end
|
20
|
+
end
|
21
|
+
statemachine :s2 do
|
22
|
+
superstate :presentingAIChoiceElement do
|
23
|
+
event :suspend, :suspended
|
24
|
+
|
25
|
+
trans :defocused, :focus, :focused
|
26
|
+
trans :defocused, :next, :focused, :focus_next
|
27
|
+
trans :defocused, :prev, :focused, :focus_prev
|
28
|
+
trans :defocused, :parent, :focused, :focus_parent
|
29
|
+
trans :focused, :defocus, :defocused
|
30
|
+
#would the implementation of "if" be like this?
|
31
|
+
# TODO make In() work
|
32
|
+
trans :focused, :drag, :dragging#, :self_choose, In(:unchosen)
|
33
|
+
trans :focused, :drag, :dragging#, nil, In(:chosen)
|
34
|
+
trans :dragging, :drop, :defocused
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should enter :presenting" do
|
44
|
+
@statemachine.organize
|
45
|
+
@statemachine.present
|
46
|
+
@statemachine.states_id.should == [:unchosen, :defocused]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should support parallel transitions" do
|
50
|
+
@statemachine.organize
|
51
|
+
@statemachine.present
|
52
|
+
@statemachine.focus
|
53
|
+
@statemachine.choose
|
54
|
+
@statemachine.states_id.should == [:chosen, :focused]
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should leave :presenting and return to the proper states" do
|
58
|
+
@statemachine.organize
|
59
|
+
@statemachine.present
|
60
|
+
@statemachine.focus
|
61
|
+
@statemachine.choose
|
62
|
+
@statemachine.states_id.should == [:chosen, :focused]
|
63
|
+
@statemachine.suspend
|
64
|
+
@statemachine.state.should == :suspended
|
65
|
+
@statemachine.organize
|
66
|
+
@statemachine.present
|
67
|
+
end
|
68
|
+
|
69
|
+
#TODO implement test to check if In() is working
|
70
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "AIMultiChoice" do
|
4
|
+
before (:each) do
|
5
|
+
@statemachine = Statemachine.build do
|
6
|
+
superstate :AIMultiChoice do
|
7
|
+
trans :initialized, :organize, :organized
|
8
|
+
trans :organized, :present, :presenting
|
9
|
+
trans :suspended, :organize, :organized
|
10
|
+
|
11
|
+
superstate :presenting do
|
12
|
+
event :suspend, :suspended
|
13
|
+
parallel :p do
|
14
|
+
statemachine :s1 do
|
15
|
+
# TODO make In() work
|
16
|
+
trans :listing, :drop, :dropped#, nil, In(:focused)#, :drop_all_dragging, In(:focused)
|
17
|
+
trans :listing, :choose_all, :choosing
|
18
|
+
trans :listing, :unchoose_all, :unchoosing
|
19
|
+
# TODO how to implement transitions without events
|
20
|
+
# trans :dropped, nil, :listing, :unfocus_self
|
21
|
+
# trans :choosing, nil, :listing, :choose_all_childs
|
22
|
+
# trans :unchoosing, nil, :listing, :unchoose_all_childs
|
23
|
+
end
|
24
|
+
statemachine :s2 do
|
25
|
+
superstate :presentingAIC 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 :defocused, :child, :focused#, :focus_child
|
33
|
+
trans :focused, :defocus, :defocused
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should support parallel transitions" do
|
43
|
+
@statemachine.organize
|
44
|
+
@statemachine.present
|
45
|
+
@statemachine.states_id.should == [:listing, :defocused]
|
46
|
+
@statemachine.choose_all
|
47
|
+
@statemachine.focus
|
48
|
+
@statemachine.states_id.should == [:choosing, :focused]
|
49
|
+
@statemachine.defocus
|
50
|
+
@statemachine.states_id.should == [:choosing, :defocused]
|
51
|
+
end
|
52
|
+
|
53
|
+
# TODO implement test to check if In() is working
|
54
|
+
# TODO implement test for spontaneous transitions
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "AIINContinous" do
|
4
|
+
before (:each) do
|
5
|
+
@statemachine = Statemachine.build do
|
6
|
+
superstate :AIOUTContinous do
|
7
|
+
trans :initialized, :organize, :organized
|
8
|
+
trans :organized, :present, :presenting
|
9
|
+
trans :suspended, :organize, :organized
|
10
|
+
|
11
|
+
superstate :presenting do
|
12
|
+
event :suspend, :suspended
|
13
|
+
|
14
|
+
trans :defocused, :focus, :focused
|
15
|
+
trans :defocused, :next, :focused, :focus_next
|
16
|
+
trans :defocused, :prev, :focused, :focus_prev
|
17
|
+
trans :defocused, :parent, :focused, :focus_parent
|
18
|
+
|
19
|
+
superstate :focused do
|
20
|
+
event :defocus, :defocused
|
21
|
+
|
22
|
+
trans :waiting, :progress, :progressing
|
23
|
+
trans :waiting, :regress, :regressing
|
24
|
+
|
25
|
+
superstate :moving do
|
26
|
+
event :halt, :waiting
|
27
|
+
|
28
|
+
trans :progressing, :regress, :regressing
|
29
|
+
trans :regressing, :progress, :progressing
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
it "should enter the nested superstate :focused" do
|
39
|
+
@statemachine.organize
|
40
|
+
@statemachine.present
|
41
|
+
@statemachine.focus
|
42
|
+
@statemachine.state.should == :waiting
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should support transitions inside :focused" do
|
46
|
+
@statemachine.organize
|
47
|
+
@statemachine.present
|
48
|
+
@statemachine.focus
|
49
|
+
@statemachine.progress
|
50
|
+
@statemachine.state.should == :progressing
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should support transitions inside :moving" do
|
54
|
+
@statemachine.organize
|
55
|
+
@statemachine.present
|
56
|
+
@statemachine.focus
|
57
|
+
@statemachine.progress
|
58
|
+
@statemachine.state.should == :progressing
|
59
|
+
@statemachine.regress
|
60
|
+
@statemachine.state.should == :regressing
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should leave :moving" do
|
64
|
+
@statemachine.organize
|
65
|
+
@statemachine.present
|
66
|
+
@statemachine.focus
|
67
|
+
@statemachine.progress
|
68
|
+
@statemachine.halt
|
69
|
+
@statemachine.state.should == :waiting
|
70
|
+
end
|
71
|
+
end
|