omf_ec 6.0.0.pre.2
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +7 -0
- data/bin/omf_test +161 -0
- data/config/ec.yml +164 -0
- data/exp_repo/system/exp/eventlib.rb +96 -0
- data/exp_repo/system/exp/imageNode.rb +283 -0
- data/exp_repo/system/exp/reset.rb +21 -0
- data/exp_repo/system/exp/saveNode.rb +99 -0
- data/exp_repo/system/exp/stat.rb +49 -0
- data/exp_repo/system/exp/stdlib.rb +122 -0
- data/exp_repo/system/exp/tell.rb +53 -0
- data/exp_repo/system/exp/testlib.rb +12 -0
- data/exp_repo/system/exp/winlib.rb +154 -0
- data/exp_repo/system/topo/active.rb +9 -0
- data/exp_repo/system/topo/all.rb +10 -0
- data/exp_repo/system/topo/circle.rb +23 -0
- data/exp_repo/test/app/aodvd.rb +73 -0
- data/exp_repo/test/app/appDef1.rb +102 -0
- data/exp_repo/test/app/athstats.rb +76 -0
- data/exp_repo/test/app/echo.rb +36 -0
- data/exp_repo/test/app/gennyReceiverAppDef.rb +100 -0
- data/exp_repo/test/app/gennySenderAppDef.rb +106 -0
- data/exp_repo/test/app/itgdec.rb +79 -0
- data/exp_repo/test/app/itgr.rb +77 -0
- data/exp_repo/test/app/itgs.rb +105 -0
- data/exp_repo/test/app/nop.rb +36 -0
- data/exp_repo/test/app/otg2.rb +68 -0
- data/exp_repo/test/app/otg2_mp.rb +56 -0
- data/exp_repo/test/app/otr2.rb +56 -0
- data/exp_repo/test/app/otr2_mp.rb +51 -0
- data/exp_repo/test/app/trace_oml2.rb +62 -0
- data/exp_repo/test/app/wlanconfig_oml2.rb +42 -0
- data/exp_repo/test/exp/conf-room-demo.rb +118 -0
- data/exp_repo/test/exp/planetlab.rb +82 -0
- data/exp_repo/test/exp/test01.rb +42 -0
- data/exp_repo/test/exp/test02.rb +60 -0
- data/exp_repo/test/exp/test03.rb +95 -0
- data/exp_repo/test/exp/test04.rb +105 -0
- data/exp_repo/test/exp/test05.rb +87 -0
- data/exp_repo/test/exp/test06.rb +71 -0
- data/exp_repo/test/exp/tutorial/hello-world-wired.rb +79 -0
- data/exp_repo/test/exp/tutorial/hello-world-wireless.rb +87 -0
- data/exp_repo/test/exp/tutorial/using-filters.rb +69 -0
- data/exp_repo/test/exp/tutorial/using-groups.rb +64 -0
- data/exp_repo/test/exp/tutorial/using-properties.rb +93 -0
- data/exp_repo/test/exp/tutorial/using-prototypes.rb +111 -0
- data/exp_repo/test/proto/aodvrouter.rb +55 -0
- data/exp_repo/test/proto/driverqueryapp.rb +59 -0
- data/exp_repo/test/proto/forwarder.rb +73 -0
- data/exp_repo/test/proto/itgcbrsender.rb +70 -0
- data/exp_repo/test/proto/itgdecoder.rb +64 -0
- data/exp_repo/test/proto/itgreceiver.rb +55 -0
- data/exp_repo/test/proto/itgvoipsender.rb +64 -0
- data/exp_repo/test/proto/listener2.rb +62 -0
- data/exp_repo/test/proto/nop.rb +47 -0
- data/exp_repo/test/proto/probelink.rb +48 -0
- data/exp_repo/test/proto/raw_receiver.rb +64 -0
- data/exp_repo/test/proto/receiver2_mp.rb +48 -0
- data/exp_repo/test/proto/sender2_mp.rb +54 -0
- data/exp_repo/test/proto/udp_receiver.rb +55 -0
- data/exp_repo/test/proto/udp_sender.rb +61 -0
- data/lib/omf_ec/version.rb +3 -0
- data/lib/omf_ec.rb +5 -0
- data/omf_ec.gemspec +24 -0
- metadata +145 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/omf_test
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require 'omf_common'
|
5
|
+
$stdout.sync = true
|
6
|
+
|
7
|
+
options = {
|
8
|
+
dsl: 'xmpp_blather',
|
9
|
+
pubsub_host: 'pubsub',
|
10
|
+
}
|
11
|
+
|
12
|
+
executable_name = File.basename($PROGRAM_NAME)
|
13
|
+
|
14
|
+
option_parser = OptionParser.new do |opts|
|
15
|
+
opts.banner = "usage: #{executable_name} [options]"
|
16
|
+
|
17
|
+
opts.on("-u USER", "Username") do |user|
|
18
|
+
options[:user] = user
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-p PASSWORD", "Password") do |password|
|
22
|
+
options[:password] = password
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-s SERVER", "XMPP server") do |server|
|
26
|
+
options[:server] = server
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-n NODE", "PubSub node to subscribe") do |node|
|
30
|
+
options[:uid] = node
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-d", "--debug", "Debug mode") do
|
34
|
+
options[:debug] = true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
option_parser.parse!
|
40
|
+
rescue => e
|
41
|
+
puts e.message
|
42
|
+
puts ""
|
43
|
+
puts option_parser.help
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless options[:server] && options[:user] && options[:server]
|
48
|
+
puts option_parser.help
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
Logging.logger.root.level = :debug if options[:debug]
|
53
|
+
Blather.logger = logger
|
54
|
+
|
55
|
+
comm = OmfCommon::Comm.new(options[:dsl])
|
56
|
+
host = nil
|
57
|
+
|
58
|
+
# Create a resource of type mock
|
59
|
+
create_msg = OmfCommon::Message.create { |v| v.property('type', 'mock') }.sign
|
60
|
+
|
61
|
+
create_wifi_msg = OmfCommon::Message.create do |v|
|
62
|
+
v.property('hrn', 'wlan0')
|
63
|
+
v.property('type', 'wifi')
|
64
|
+
end.sign
|
65
|
+
|
66
|
+
# A request message to be sent to mock
|
67
|
+
request_mock_property = OmfCommon::Message.request do |v|
|
68
|
+
v.property('available_properties')
|
69
|
+
v.property('kernel_version')
|
70
|
+
v.property('resource_proxy_list')
|
71
|
+
v.property('resource_utility_list')
|
72
|
+
v.property('bob')
|
73
|
+
end.sign
|
74
|
+
|
75
|
+
request_wifi_property = OmfCommon::Message.request do |v|
|
76
|
+
v.property('link')
|
77
|
+
v.property('available_properties')
|
78
|
+
end.sign
|
79
|
+
|
80
|
+
# A request message to be sent to node
|
81
|
+
request_node_property = OmfCommon::Message.request do |v|
|
82
|
+
v.property('available_properties')
|
83
|
+
v.property('proxies')
|
84
|
+
end
|
85
|
+
|
86
|
+
# A configure message to be sent to mock
|
87
|
+
configure_mock_property = OmfCommon::Message.configure do |v|
|
88
|
+
v.property('hrn', 'human_readable_name')
|
89
|
+
end.sign
|
90
|
+
|
91
|
+
# Simple release message
|
92
|
+
release_message = OmfCommon::Message.release.sign
|
93
|
+
|
94
|
+
# For simplicity, use comm instance directly
|
95
|
+
comm.when_ready do
|
96
|
+
logger.info "CONNECTED: #{comm.jid.inspect}"
|
97
|
+
host = "#{options[:pubsub_host]}.#{comm.jid.domain}"
|
98
|
+
|
99
|
+
# We assume the node where RC runs started already
|
100
|
+
comm.subscribe(options[:uid], host) do |e|
|
101
|
+
if e.error?
|
102
|
+
comm.disconnect(host)
|
103
|
+
else
|
104
|
+
# Publish the create message to RC's pubsub node
|
105
|
+
comm.publish(options[:uid], request_node_property, host)
|
106
|
+
comm.publish(options[:uid], create_wifi_msg, host)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Fired when messages published to the nodes I subscribed to
|
112
|
+
comm.node_event do |e|
|
113
|
+
e.items.each do |item|
|
114
|
+
begin
|
115
|
+
# Parse the message (pubsub item payload)
|
116
|
+
message = OmfCommon::Message.parse(item.payload)
|
117
|
+
context_id = message.read_content("context_id")
|
118
|
+
|
119
|
+
# We are only interested in inform messages for the moment
|
120
|
+
if message.operation == :inform
|
121
|
+
inform_type = message.read_content("inform_type")
|
122
|
+
|
123
|
+
case inform_type
|
124
|
+
when 'CREATED'
|
125
|
+
resource_id = message.read_content("resource_id")
|
126
|
+
logger.info "Resource #{resource_id} created"
|
127
|
+
|
128
|
+
comm.subscribe(resource_id, host) do |m|
|
129
|
+
EM.add_periodic_timer(2) do
|
130
|
+
comm.publish(resource_id, request_wifi_property, host)
|
131
|
+
#comm.publish(resource_id, request_mock_property, host)
|
132
|
+
#comm.publish(resource_id, configure_mock_property, host)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
when 'STATUS'
|
137
|
+
message.read_element("//property").each do |p|
|
138
|
+
logger.info "#{p.attr('key')} => #{p.content.strip}"
|
139
|
+
end
|
140
|
+
when 'RELEASED'
|
141
|
+
logger.info "Resource #{message.read_content("resource_id")} released"
|
142
|
+
when 'FAILED'
|
143
|
+
logger.error message.read_content("error_message")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
rescue => e
|
147
|
+
logger.error "#{e.message}\n#{e.backtrace.join("\n")}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
trap(:INT) { comm.disconnect(host) }
|
153
|
+
trap(:TERM) { comm.disconnect(host) }
|
154
|
+
|
155
|
+
EM.run do
|
156
|
+
comm.connect(options[:user], options[:password], options[:server])
|
157
|
+
|
158
|
+
EM.add_timer(5) do
|
159
|
+
comm.publish(options[:uid], release_message, host)
|
160
|
+
end
|
161
|
+
end
|
data/config/ec.yml
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2009 National ICT Australia (NICTA), Australia
|
3
|
+
#
|
4
|
+
# Copyright (c) 2004-2009 WINLAB, Rutgers University, USA
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# This is the config file for the OMF Experiment Controller
|
26
|
+
#
|
27
|
+
# NOTE: use only 'spaces' to indent !
|
28
|
+
# ('tab' indents are not supported by the ruby yaml parser, which is used to
|
29
|
+
# read this file)
|
30
|
+
#
|
31
|
+
---
|
32
|
+
:econtroller:
|
33
|
+
|
34
|
+
:config:
|
35
|
+
|
36
|
+
# Config Parameter for the "default" profile
|
37
|
+
# IMPORTANT: There has to be a default entry. It should contain a complete
|
38
|
+
# set of parameters, so other profiles can fall back to it
|
39
|
+
:default:
|
40
|
+
|
41
|
+
# This is the domain name of the testbed
|
42
|
+
# You need a corresponding entry in the testbed table of your inventory
|
43
|
+
# that has this name set in the 'node_domain' column
|
44
|
+
:domain: 'norbit'
|
45
|
+
:slice: 'default_slice'
|
46
|
+
|
47
|
+
# This is the Path where EC should look for its repository of built-in
|
48
|
+
# experiments (e.g. example experiments, maintenance experiments, etc...)
|
49
|
+
:repository:
|
50
|
+
:path: ["../share/repository", "/usr/share/omf-expctl-5.4/repository"]
|
51
|
+
|
52
|
+
# URI to the OML server to use for this EC
|
53
|
+
# (can be overwritten on the EC command line)
|
54
|
+
:omluri: 'tcp:norbit.npc.nicta.com.au:3003'
|
55
|
+
|
56
|
+
# This should be the IP address of the local interface that is accessible
|
57
|
+
# from the nodes. This address will be given to the nodes so they can
|
58
|
+
# retrieve applications from the EC via HTTP.
|
59
|
+
:web:
|
60
|
+
:host: '10.0.0.200'
|
61
|
+
:resource_dir: ["../../omf-common/share/htdocs", "/usr/share/omf-common-5.4/share/htdocs"]
|
62
|
+
|
63
|
+
:communicator:
|
64
|
+
|
65
|
+
# set this to false if you want to disable signature checks and message signing
|
66
|
+
:authenticate_messages: false
|
67
|
+
# your RSA/DSA SSH private key file
|
68
|
+
:private_key: '~/.ssh/id_rsa'
|
69
|
+
# directory holding the public keys of your OMF peers
|
70
|
+
:public_key_dir: '~/.omf-expctl/peer_keys'
|
71
|
+
|
72
|
+
:type: 'xmpp'
|
73
|
+
:xmpp:
|
74
|
+
# Address of the server to use as gateway for PubSub communication
|
75
|
+
:pubsub_gateway: 'norbit.npc.nicta.com.au'
|
76
|
+
#:pubsub_port: 5222
|
77
|
+
# The 'pubsub_domain' is the hostname of the pubsub server on which
|
78
|
+
# you would like to host your slice's communications. Leave this
|
79
|
+
# commented if you wish to host them on the 'pubsub_gateway' server
|
80
|
+
# which you selected above.
|
81
|
+
#:pubsub_domain: 'norbit.npc.nicta.com.au'
|
82
|
+
# The following 'pubsub_user' and 'pubsub_pwd' are optional
|
83
|
+
# EC will create a unique user/pwd for itself if this is not provided
|
84
|
+
# In a typical OMF install, you should not uncomment these lines
|
85
|
+
# (do so only if you need to manually set user/password for
|
86
|
+
# your client to connect to your pubsub server)
|
87
|
+
#:pubsub_user: 'my_EC_name'
|
88
|
+
#:pubsub_pwd: 'my_EC_password'
|
89
|
+
# set this to "true" if you have a DNS SRV record pointing to the
|
90
|
+
# real pubsub server hostname
|
91
|
+
:pubsub_use_dnssrv: false
|
92
|
+
|
93
|
+
# AM contact details. By default, the AM is contacted through the EC's XMPP
|
94
|
+
# connection as specified in the ':communicator:' section above. In this
|
95
|
+
# ':services:' section, you can specify additional AM contact details.
|
96
|
+
# Supported protocols are XMPP and HTTP for legacy services.
|
97
|
+
:services:
|
98
|
+
-
|
99
|
+
:type: :http
|
100
|
+
:uri: 'http://norbit.npc.nicta.com.au:5054'
|
101
|
+
# -
|
102
|
+
# :type: :xmpp
|
103
|
+
# :uri: 'norbit.npc.nicta.com.au'
|
104
|
+
# :user: 'joe'
|
105
|
+
# :password: 'fluffy'
|
106
|
+
|
107
|
+
|
108
|
+
##########################
|
109
|
+
# config parameters for the "p2p" profile
|
110
|
+
:p2p:
|
111
|
+
:domain: 'planetlab'
|
112
|
+
:repository:
|
113
|
+
:path: [".", "../share/repository", "/usr/share/omf-expctl-5.4/repository"]
|
114
|
+
:inventory:
|
115
|
+
:url: 'http://planetlab-europe-07.ipv6.lip6.fr:5054/inventory'
|
116
|
+
# :web:
|
117
|
+
# :host: 'your_hostname_or_ip_here'
|
118
|
+
:result:
|
119
|
+
:url: 'http://planetlab-europe-07.ipv6.lip6.fr:5054/result/'
|
120
|
+
:communicator:
|
121
|
+
:type: 'xmpp'
|
122
|
+
:xmpp:
|
123
|
+
:server: planetlab-europe-07.ipv6.lip6.fr
|
124
|
+
:password: '123'
|
125
|
+
####
|
126
|
+
:planetlab:
|
127
|
+
:domain: 'planetlab'
|
128
|
+
:slice: 'ost_securexmpp'
|
129
|
+
:repository:
|
130
|
+
:path: ["../share/repository", "/usr/share/omf-expctl-5.4/repository"]
|
131
|
+
:inventory:
|
132
|
+
:url: 'http://mytestbed.net:5054/inventory'
|
133
|
+
|
134
|
+
:web:
|
135
|
+
:host: '10.0.0.200'
|
136
|
+
:resource_dir: ["../../omf-common/share/htdocs", "/usr/share/omf-common-5.4/share/htdocs"]
|
137
|
+
|
138
|
+
:communicator:
|
139
|
+
|
140
|
+
:authenticate_messages: true
|
141
|
+
:private_key: '~/.ssh/id_rsa'
|
142
|
+
:public_key_dir: '~/.omf-expctl/peer_keys'
|
143
|
+
|
144
|
+
:type: 'xmpp'
|
145
|
+
:xmpp:
|
146
|
+
:pubsub_gateway: 'mytestbed.net'
|
147
|
+
|
148
|
+
##########################
|
149
|
+
# config parameters for the "p2p" profile
|
150
|
+
#
|
151
|
+
# To use this testbed, call EC with the option PRINT_ONLY or "-d debug"
|
152
|
+
# Any parameter settings within this section will override the settings
|
153
|
+
# done in the "default" section. The EC first loads the "default"
|
154
|
+
# settings, then it uses the "debug" specific settings to override the
|
155
|
+
# relevant parameters
|
156
|
+
:debug:
|
157
|
+
:repository:
|
158
|
+
:path: ['.', '../share/repository']
|
159
|
+
:communicator:
|
160
|
+
:type: 'mock'
|
161
|
+
:log: '../etc/omf-expctl/debug_log.xml'
|
162
|
+
:inventory:
|
163
|
+
:url: 'http://norbit.npc.nicta.com.au:5054/inventory'
|
164
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2010 National ICT Australia (NICTA), Australia
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# = eventlib.rb
|
24
|
+
#
|
25
|
+
# == Description
|
26
|
+
#
|
27
|
+
# This Ruby file contains various common Event declarations, which the EC will
|
28
|
+
# load before the user's experiment file
|
29
|
+
#
|
30
|
+
|
31
|
+
#
|
32
|
+
# This provide some default Event definition that the user may use in his
|
33
|
+
# experiment, without having to worry about how to define them.
|
34
|
+
# To start one of the event monitoring defined here, the user need to associate
|
35
|
+
# at least one block of tasks to it, using the onEvent() OEDL call.
|
36
|
+
# See the OEDL documentation for more info and a tutorial
|
37
|
+
#
|
38
|
+
|
39
|
+
defEvent(:ALL_UP_AND_INSTALLED) do |event|
|
40
|
+
node_status = allGroups.state("status/@value")
|
41
|
+
app_status = allGroups.state("apps/app/status/@value")
|
42
|
+
if allEqual(node_status, "UP") && allEqual(app_status, "INSTALLED.OK")
|
43
|
+
event.fire
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
defEvent(:ALL_UP) do |event|
|
48
|
+
node_status = allGroups.state("status/@value")
|
49
|
+
event.fire if allEqual(node_status, "UP")
|
50
|
+
end
|
51
|
+
|
52
|
+
defEvent(:ALL_INTERFACE_UP) do |event|
|
53
|
+
iface_status = allGroups.state("net/*/*/current/@status")
|
54
|
+
#info "TDEBUG - #{if_status.join(" ")}"
|
55
|
+
event.fire if allEqual(iface_status, "CONFIGURED.OK")
|
56
|
+
end
|
57
|
+
|
58
|
+
defEvent(:EXPERIMENT_DONE) do |event|
|
59
|
+
exp_status = Experiment.state("status/text()")
|
60
|
+
event.fire if allEqual(exp_status, "DONE")
|
61
|
+
end
|
62
|
+
|
63
|
+
onEvent(:EXPERIMENT_DONE, true) do |event|
|
64
|
+
Experiment.close
|
65
|
+
end
|
66
|
+
|
67
|
+
defEvent(:INTERRUPT, 1) do |event|
|
68
|
+
exp_status = Experiment.state("status/text()")
|
69
|
+
event.fire if allEqual(exp_status, "INTERRUPTED")
|
70
|
+
end
|
71
|
+
|
72
|
+
onEvent(:INTERRUPT) do |event|
|
73
|
+
MObject.info(:INTERRUPT, "\n\nUser issued an Interruption. Stopping the experiment now! Please wait...\n")
|
74
|
+
Experiment.done
|
75
|
+
end
|
76
|
+
|
77
|
+
defEvent(:NO_USER_DEFINED_EVENTS) do |event|
|
78
|
+
if Experiment.running? && !Experiment.disconnection_allowed?
|
79
|
+
if Event.empty?(:ignore => [:EXPERIMENT_DONE, :NO_USER_DEFINED_EVENTS])
|
80
|
+
event.fire
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
onEvent(:NO_USER_DEFINED_EVENTS) do |event|
|
86
|
+
warn " "
|
87
|
+
warn "Warning!!! Your experiment has no user-defined events!"
|
88
|
+
warn "It is likely that nothing will happen from now one..."
|
89
|
+
warn "Press CTRL-C only ONCE to stop your experiment.\n"
|
90
|
+
# An alternative... not sure what is the best here, for now use the above
|
91
|
+
# warn "Closing down your experiment now..."
|
92
|
+
# Experiment.done
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|