roby 0.7
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 +29 -0
- data/History.txt +4 -0
- data/License-fr.txt +519 -0
- data/License.txt +515 -0
- data/Manifest.txt +245 -0
- data/NOTES +4 -0
- data/README.txt +163 -0
- data/Rakefile +161 -0
- data/TODO.txt +146 -0
- data/app/README.txt +24 -0
- data/app/Rakefile +8 -0
- data/app/config/ROBOT.rb +5 -0
- data/app/config/app.yml +91 -0
- data/app/config/init.rb +7 -0
- data/app/config/roby.yml +3 -0
- data/app/controllers/.gitattributes +0 -0
- data/app/controllers/ROBOT.rb +2 -0
- data/app/data/.gitattributes +0 -0
- data/app/planners/ROBOT/main.rb +6 -0
- data/app/planners/main.rb +5 -0
- data/app/scripts/distributed +3 -0
- data/app/scripts/generate/bookmarks +3 -0
- data/app/scripts/replay +3 -0
- data/app/scripts/results +3 -0
- data/app/scripts/run +3 -0
- data/app/scripts/server +3 -0
- data/app/scripts/shell +3 -0
- data/app/scripts/test +3 -0
- data/app/tasks/.gitattributes +0 -0
- data/app/tasks/ROBOT/.gitattributes +0 -0
- data/bin/roby +210 -0
- data/bin/roby-log +168 -0
- data/bin/roby-shell +25 -0
- data/doc/images/event_generalization.png +0 -0
- data/doc/images/exception_propagation_1.png +0 -0
- data/doc/images/exception_propagation_2.png +0 -0
- data/doc/images/exception_propagation_3.png +0 -0
- data/doc/images/exception_propagation_4.png +0 -0
- data/doc/images/exception_propagation_5.png +0 -0
- data/doc/images/replay_handler_error.png +0 -0
- data/doc/images/replay_handler_error_0.png +0 -0
- data/doc/images/replay_handler_error_1.png +0 -0
- data/doc/images/roby_cycle_overview.png +0 -0
- data/doc/images/roby_replay_02.png +0 -0
- data/doc/images/roby_replay_03.png +0 -0
- data/doc/images/roby_replay_04.png +0 -0
- data/doc/images/roby_replay_event_representation.png +0 -0
- data/doc/images/roby_replay_first_state.png +0 -0
- data/doc/images/roby_replay_relations.png +0 -0
- data/doc/images/roby_replay_startup.png +0 -0
- data/doc/images/task_event_generalization.png +0 -0
- data/doc/papers.rdoc +11 -0
- data/doc/styles/allison.css +314 -0
- data/doc/styles/allison.js +316 -0
- data/doc/styles/allison.rb +276 -0
- data/doc/styles/jamis.rb +593 -0
- data/doc/tutorials/01-GettingStarted.rdoc +86 -0
- data/doc/tutorials/02-GoForward.rdoc +220 -0
- data/doc/tutorials/03-PlannedPath.rdoc +268 -0
- data/doc/tutorials/04-EventPropagation.rdoc +236 -0
- data/doc/tutorials/05-ErrorHandling.rdoc +319 -0
- data/doc/tutorials/06-Overview.rdoc +40 -0
- data/doc/videos.rdoc +69 -0
- data/ext/droby/dump.cc +175 -0
- data/ext/droby/extconf.rb +3 -0
- data/ext/graph/algorithm.cc +746 -0
- data/ext/graph/extconf.rb +7 -0
- data/ext/graph/graph.cc +529 -0
- data/ext/graph/graph.hh +183 -0
- data/ext/graph/iterator_sequence.hh +102 -0
- data/ext/graph/undirected_dfs.hh +226 -0
- data/ext/graph/undirected_graph.hh +421 -0
- data/lib/roby.rb +41 -0
- data/lib/roby/app.rb +870 -0
- data/lib/roby/app/rake.rb +56 -0
- data/lib/roby/app/run.rb +14 -0
- data/lib/roby/app/scripts/distributed.rb +13 -0
- data/lib/roby/app/scripts/generate/bookmarks.rb +162 -0
- data/lib/roby/app/scripts/replay.rb +31 -0
- data/lib/roby/app/scripts/results.rb +15 -0
- data/lib/roby/app/scripts/run.rb +26 -0
- data/lib/roby/app/scripts/server.rb +18 -0
- data/lib/roby/app/scripts/shell.rb +88 -0
- data/lib/roby/app/scripts/test.rb +40 -0
- data/lib/roby/basic_object.rb +151 -0
- data/lib/roby/config.rb +5 -0
- data/lib/roby/control.rb +747 -0
- data/lib/roby/decision_control.rb +17 -0
- data/lib/roby/distributed.rb +32 -0
- data/lib/roby/distributed/base.rb +440 -0
- data/lib/roby/distributed/communication.rb +871 -0
- data/lib/roby/distributed/connection_space.rb +592 -0
- data/lib/roby/distributed/distributed_object.rb +206 -0
- data/lib/roby/distributed/drb.rb +62 -0
- data/lib/roby/distributed/notifications.rb +539 -0
- data/lib/roby/distributed/peer.rb +550 -0
- data/lib/roby/distributed/protocol.rb +529 -0
- data/lib/roby/distributed/proxy.rb +343 -0
- data/lib/roby/distributed/subscription.rb +311 -0
- data/lib/roby/distributed/transaction.rb +498 -0
- data/lib/roby/event.rb +897 -0
- data/lib/roby/exceptions.rb +234 -0
- data/lib/roby/executives/simple.rb +30 -0
- data/lib/roby/graph.rb +166 -0
- data/lib/roby/interface.rb +390 -0
- data/lib/roby/log.rb +3 -0
- data/lib/roby/log/chronicle.rb +303 -0
- data/lib/roby/log/console.rb +72 -0
- data/lib/roby/log/data_stream.rb +197 -0
- data/lib/roby/log/dot.rb +279 -0
- data/lib/roby/log/event_stream.rb +151 -0
- data/lib/roby/log/file.rb +340 -0
- data/lib/roby/log/gui/basic_display.ui +83 -0
- data/lib/roby/log/gui/chronicle.rb +26 -0
- data/lib/roby/log/gui/chronicle_view.rb +40 -0
- data/lib/roby/log/gui/chronicle_view.ui +70 -0
- data/lib/roby/log/gui/data_displays.rb +172 -0
- data/lib/roby/log/gui/data_displays.ui +155 -0
- data/lib/roby/log/gui/notifications.rb +26 -0
- data/lib/roby/log/gui/relations.rb +248 -0
- data/lib/roby/log/gui/relations.ui +123 -0
- data/lib/roby/log/gui/relations_view.rb +185 -0
- data/lib/roby/log/gui/relations_view.ui +149 -0
- data/lib/roby/log/gui/replay.rb +327 -0
- data/lib/roby/log/gui/replay_controls.rb +200 -0
- data/lib/roby/log/gui/replay_controls.ui +259 -0
- data/lib/roby/log/gui/runtime.rb +130 -0
- data/lib/roby/log/hooks.rb +185 -0
- data/lib/roby/log/logger.rb +202 -0
- data/lib/roby/log/notifications.rb +244 -0
- data/lib/roby/log/plan_rebuilder.rb +470 -0
- data/lib/roby/log/relations.rb +1056 -0
- data/lib/roby/log/server.rb +550 -0
- data/lib/roby/log/sqlite.rb +47 -0
- data/lib/roby/log/timings.rb +164 -0
- data/lib/roby/plan-object.rb +247 -0
- data/lib/roby/plan.rb +762 -0
- data/lib/roby/planning.rb +13 -0
- data/lib/roby/planning/loops.rb +302 -0
- data/lib/roby/planning/model.rb +906 -0
- data/lib/roby/planning/task.rb +151 -0
- data/lib/roby/propagation.rb +562 -0
- data/lib/roby/query.rb +619 -0
- data/lib/roby/relations.rb +583 -0
- data/lib/roby/relations/conflicts.rb +70 -0
- data/lib/roby/relations/ensured.rb +20 -0
- data/lib/roby/relations/error_handling.rb +23 -0
- data/lib/roby/relations/events.rb +9 -0
- data/lib/roby/relations/executed_by.rb +193 -0
- data/lib/roby/relations/hierarchy.rb +239 -0
- data/lib/roby/relations/influence.rb +10 -0
- data/lib/roby/relations/planned_by.rb +63 -0
- data/lib/roby/robot.rb +7 -0
- data/lib/roby/standard_errors.rb +218 -0
- data/lib/roby/state.rb +5 -0
- data/lib/roby/state/events.rb +221 -0
- data/lib/roby/state/information.rb +55 -0
- data/lib/roby/state/pos.rb +110 -0
- data/lib/roby/state/shapes.rb +32 -0
- data/lib/roby/state/state.rb +353 -0
- data/lib/roby/support.rb +92 -0
- data/lib/roby/task-operations.rb +182 -0
- data/lib/roby/task.rb +1618 -0
- data/lib/roby/test/common.rb +399 -0
- data/lib/roby/test/distributed.rb +214 -0
- data/lib/roby/test/tasks/empty_task.rb +9 -0
- data/lib/roby/test/tasks/goto.rb +36 -0
- data/lib/roby/test/tasks/simple_task.rb +23 -0
- data/lib/roby/test/testcase.rb +519 -0
- data/lib/roby/test/tools.rb +160 -0
- data/lib/roby/thread_task.rb +87 -0
- data/lib/roby/transactions.rb +462 -0
- data/lib/roby/transactions/proxy.rb +292 -0
- data/lib/roby/transactions/updates.rb +139 -0
- data/plugins/fault_injection/History.txt +4 -0
- data/plugins/fault_injection/README.txt +37 -0
- data/plugins/fault_injection/Rakefile +18 -0
- data/plugins/fault_injection/TODO.txt +0 -0
- data/plugins/fault_injection/app.rb +52 -0
- data/plugins/fault_injection/fault_injection.rb +89 -0
- data/plugins/fault_injection/test/test_fault_injection.rb +84 -0
- data/plugins/subsystems/README.txt +40 -0
- data/plugins/subsystems/Rakefile +18 -0
- data/plugins/subsystems/app.rb +171 -0
- data/plugins/subsystems/test/app/README +24 -0
- data/plugins/subsystems/test/app/Rakefile +8 -0
- data/plugins/subsystems/test/app/config/app.yml +71 -0
- data/plugins/subsystems/test/app/config/init.rb +9 -0
- data/plugins/subsystems/test/app/config/roby.yml +3 -0
- data/plugins/subsystems/test/app/planners/main.rb +20 -0
- data/plugins/subsystems/test/app/scripts/distributed +3 -0
- data/plugins/subsystems/test/app/scripts/replay +3 -0
- data/plugins/subsystems/test/app/scripts/results +3 -0
- data/plugins/subsystems/test/app/scripts/run +3 -0
- data/plugins/subsystems/test/app/scripts/server +3 -0
- data/plugins/subsystems/test/app/scripts/shell +3 -0
- data/plugins/subsystems/test/app/scripts/test +3 -0
- data/plugins/subsystems/test/app/tasks/services.rb +15 -0
- data/plugins/subsystems/test/test_subsystems.rb +71 -0
- data/test/distributed/test_communication.rb +178 -0
- data/test/distributed/test_connection.rb +282 -0
- data/test/distributed/test_execution.rb +373 -0
- data/test/distributed/test_mixed_plan.rb +341 -0
- data/test/distributed/test_plan_notifications.rb +238 -0
- data/test/distributed/test_protocol.rb +516 -0
- data/test/distributed/test_query.rb +102 -0
- data/test/distributed/test_remote_plan.rb +491 -0
- data/test/distributed/test_transaction.rb +463 -0
- data/test/mockups/tasks.rb +27 -0
- data/test/planning/test_loops.rb +380 -0
- data/test/planning/test_model.rb +427 -0
- data/test/planning/test_task.rb +106 -0
- data/test/relations/test_conflicts.rb +42 -0
- data/test/relations/test_ensured.rb +38 -0
- data/test/relations/test_executed_by.rb +149 -0
- data/test/relations/test_hierarchy.rb +158 -0
- data/test/relations/test_planned_by.rb +54 -0
- data/test/suite_core.rb +24 -0
- data/test/suite_distributed.rb +9 -0
- data/test/suite_planning.rb +3 -0
- data/test/suite_relations.rb +8 -0
- data/test/test_bgl.rb +508 -0
- data/test/test_control.rb +399 -0
- data/test/test_event.rb +894 -0
- data/test/test_exceptions.rb +592 -0
- data/test/test_interface.rb +37 -0
- data/test/test_log.rb +114 -0
- data/test/test_log_server.rb +132 -0
- data/test/test_plan.rb +584 -0
- data/test/test_propagation.rb +210 -0
- data/test/test_query.rb +266 -0
- data/test/test_relations.rb +180 -0
- data/test/test_state.rb +414 -0
- data/test/test_support.rb +16 -0
- data/test/test_task.rb +938 -0
- data/test/test_testcase.rb +122 -0
- data/test/test_thread_task.rb +73 -0
- data/test/test_transactions.rb +569 -0
- data/test/test_transactions_proxy.rb +198 -0
- metadata +570 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
== Directories
|
|
2
|
+
A basic Roby application has the following directories:
|
|
3
|
+
config:: configuration files. config/init.rb is the main configuration file (loaded
|
|
4
|
+
by all robots). Robot-specific configuration is in config/ROBOTNAME.rb.
|
|
5
|
+
The main Roby configuration file is config/roby.yml. The default file
|
|
6
|
+
describes all available configuration options.
|
|
7
|
+
planners:: planner models. Global planners (shared by all robots) are in
|
|
8
|
+
planners/. Robot-specific planners are in planners/ROBOTNAME/
|
|
9
|
+
controllers:: robot controllers. These files are supposed to start the basic robot
|
|
10
|
+
services, to make the robot ready. A robot shall have a controllers/ROBOTNAME.rb
|
|
11
|
+
file which does that.
|
|
12
|
+
tasks:: task models
|
|
13
|
+
data:: where all data files are. See #find_data.
|
|
14
|
+
scripts:: various scripts needed to run and debug a Roby application
|
|
15
|
+
|
|
16
|
+
The basic directory structure, and the global files, are installed by <tt>roby init</tt>. Basic
|
|
17
|
+
robot files can be added by <tt>roby robot ROBOTNAME</tt>
|
|
18
|
+
|
|
19
|
+
== Genom/Pocosim integration
|
|
20
|
+
An application can use the Genom/Pocosim integration by calling <tt>roby init --module genom</tt>.
|
|
21
|
+
The following files and directories are added:
|
|
22
|
+
config/ROBOTNAME-genom.rb:: Genom-specific configuration for ROBOTNAME
|
|
23
|
+
tasks/genom/:: per-Genom module tasks
|
|
24
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# dRoby neighbour discovery
|
|
2
|
+
discovery:
|
|
3
|
+
# The host:port at which we can connect to a discovery tuplespace
|
|
4
|
+
# (default: no discovery tuplespace)
|
|
5
|
+
# tuplespace: "localhost:29568"
|
|
6
|
+
# The port at which we do ring discovery (default: disabled)
|
|
7
|
+
# ring: 42865
|
|
8
|
+
|
|
9
|
+
# dRoby host configuration
|
|
10
|
+
droby:
|
|
11
|
+
# How many errors are allowed before disconnecting from a peer
|
|
12
|
+
# (default: 10)
|
|
13
|
+
# max_errors: 1
|
|
14
|
+
# The ring discovery period if we do ring discovery (default: 0.5)
|
|
15
|
+
# period: 0.5
|
|
16
|
+
|
|
17
|
+
# Pocosim configuration
|
|
18
|
+
pocosim:
|
|
19
|
+
# The host of the GDHE display
|
|
20
|
+
# display: localhost
|
|
21
|
+
|
|
22
|
+
# An initialization script to display the scene on GDHE. The file is searched
|
|
23
|
+
# in the data/ director
|
|
24
|
+
# gdhe: lousa.gdhe
|
|
25
|
+
|
|
26
|
+
# The Gazebo world file for pocosim/gazebo simulations. The file is searched
|
|
27
|
+
# in the data/ directory
|
|
28
|
+
# gazebo: lousa.world
|
|
29
|
+
|
|
30
|
+
# Logging configuration
|
|
31
|
+
log:
|
|
32
|
+
# Log system events (default: false)
|
|
33
|
+
# events: true
|
|
34
|
+
|
|
35
|
+
# Disables the log server (default: enabled)
|
|
36
|
+
# server: false
|
|
37
|
+
#
|
|
38
|
+
# ... or configure it
|
|
39
|
+
# server:
|
|
40
|
+
# # The port to listen on (for service discovery)
|
|
41
|
+
# port: 48933
|
|
42
|
+
# # The discovery period
|
|
43
|
+
# period: 10
|
|
44
|
+
|
|
45
|
+
# Logging levels. It is a hash of Component: level (where level
|
|
46
|
+
# is one of DEBUG, INFO, WARN and FATAL).
|
|
47
|
+
# levels:
|
|
48
|
+
# Roby: INFO
|
|
49
|
+
# Genom: INFO
|
|
50
|
+
|
|
51
|
+
# Control configuration
|
|
52
|
+
control:
|
|
53
|
+
# Abort if a task/event exception is not caught (default: false)
|
|
54
|
+
# abort_on_exception: true
|
|
55
|
+
# Abort if an application exception occurs (default: false)
|
|
56
|
+
# abort_on_application_exception: true
|
|
57
|
+
|
|
58
|
+
# If the GC should be run at each control loop (default: false)
|
|
59
|
+
# WARNING: for now, the performance hit for GCing at each control loop
|
|
60
|
+
# WARNING: is too high
|
|
61
|
+
# control_gc: false
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Per-robot configuration. In these, you can override global options, or set
|
|
65
|
+
# new options.
|
|
66
|
+
# dala:
|
|
67
|
+
# droby:
|
|
68
|
+
# # The host:port at which this robot listens
|
|
69
|
+
# host: "localhost:1287"
|
|
70
|
+
|
|
71
|
+
# vim: sw=2
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file is called to do application-global configuration. For configuration
|
|
2
|
+
# specific to a robot, edit config/NAME.rb, where NAME is the robot name.
|
|
3
|
+
|
|
4
|
+
# Require Roby components
|
|
5
|
+
#
|
|
6
|
+
# Roby.app.using 'planning'
|
|
7
|
+
# Roby.app.using 'distributed'
|
|
8
|
+
# Roby.app.using 'genom'
|
|
9
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# The main planner. A planner of this model is automatically added in the
|
|
2
|
+
# Interface planner list.
|
|
3
|
+
class MainPlanner < Roby::Planning::Planner
|
|
4
|
+
method(:navigation, :returns => Services::Navigation)
|
|
5
|
+
method(:localization, :returns => Services::Localization)
|
|
6
|
+
|
|
7
|
+
method(:localization, :id => 'test') do
|
|
8
|
+
Services::Localization.new(:id => 'localization')
|
|
9
|
+
end
|
|
10
|
+
method(:localization, :id => 'another') do
|
|
11
|
+
Services::Localization.new(:id => 'another_localization')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
method(:navigation, :id => 'test') do
|
|
15
|
+
root = Services::Navigation.new
|
|
16
|
+
root.realized_by(loc = localization)
|
|
17
|
+
root
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'roby/test/tasks/simple_task'
|
|
2
|
+
SimpleTask = Roby::Test::SimpleTask
|
|
3
|
+
|
|
4
|
+
module Services
|
|
5
|
+
class Navigation < SimpleTask; end
|
|
6
|
+
class Localization < SimpleTask
|
|
7
|
+
event :ready, :command => true
|
|
8
|
+
on :start => :ready
|
|
9
|
+
|
|
10
|
+
def update_localization(state)
|
|
11
|
+
state.pos += 1
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'roby'
|
|
3
|
+
require 'roby/app'
|
|
4
|
+
require 'roby/test/common'
|
|
5
|
+
require 'roby/test/tasks/simple_task'
|
|
6
|
+
|
|
7
|
+
APP_DIR = File.expand_path('app', File.dirname(__FILE__))
|
|
8
|
+
require "#{APP_DIR}/tasks/services"
|
|
9
|
+
require "#{APP_DIR}/planners/main"
|
|
10
|
+
Roby.app.using :subsystems
|
|
11
|
+
|
|
12
|
+
State = Roby::State
|
|
13
|
+
Robot = Roby
|
|
14
|
+
|
|
15
|
+
class TC_Subsystems < Test::Unit::TestCase
|
|
16
|
+
include Roby::Test
|
|
17
|
+
include Roby::Subsystems
|
|
18
|
+
|
|
19
|
+
def setup
|
|
20
|
+
super
|
|
21
|
+
DRb.start_service
|
|
22
|
+
State.pos = 0
|
|
23
|
+
State.services do |s|
|
|
24
|
+
s.localization = 'test'
|
|
25
|
+
s.navigation = 'test'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def nav_loc
|
|
30
|
+
tasks = plan.known_tasks.to_a
|
|
31
|
+
assert_equal(2, tasks.size, tasks)
|
|
32
|
+
if tasks.first.kind_of?(Services::Navigation)
|
|
33
|
+
tasks
|
|
34
|
+
else tasks.reverse
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_initialize_plan
|
|
39
|
+
start_with, ready = Application.initialize_plan
|
|
40
|
+
|
|
41
|
+
nav, loc = nav_loc
|
|
42
|
+
assert(plan.permanent?(nav))
|
|
43
|
+
assert(plan.permanent?(loc))
|
|
44
|
+
assert(nav.realized_by?(loc))
|
|
45
|
+
|
|
46
|
+
assert_equal([loc.event(:start)], start_with.child_objects(EventStructure::Signal).to_a)
|
|
47
|
+
|
|
48
|
+
and_gen = loc.event(:ready).child_objects(EventStructure::Signal).to_a.first
|
|
49
|
+
assert_equal([nav.event(:start)], and_gen.child_objects(EventStructure::Signal).to_a)
|
|
50
|
+
|
|
51
|
+
assert_equal([nav.event(:start), loc.event(:ready)].to_set, ready.parent_objects(EventStructure::Signal).to_set)
|
|
52
|
+
|
|
53
|
+
rescue Roby::Planning::NotFound
|
|
54
|
+
STDERR.puts $!.full_message
|
|
55
|
+
raise
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_start_subsystems
|
|
59
|
+
Roby.logger.level = Logger::FATAL
|
|
60
|
+
Roby.control.run :detach => true
|
|
61
|
+
|
|
62
|
+
Application.run(Roby.app) { }
|
|
63
|
+
nav, loc = nav_loc
|
|
64
|
+
assert(nav.running?)
|
|
65
|
+
assert(loc.running?)
|
|
66
|
+
|
|
67
|
+
sleep(0.5)
|
|
68
|
+
assert(State.pos > 0)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'roby/distributed'
|
|
3
|
+
require 'roby/test/distributed'
|
|
4
|
+
require 'flexmock'
|
|
5
|
+
|
|
6
|
+
class TC_DistributedCommunication < Test::Unit::TestCase
|
|
7
|
+
include Roby
|
|
8
|
+
include Roby::Distributed::Test
|
|
9
|
+
|
|
10
|
+
attr_reader :local_peer
|
|
11
|
+
module FakePeerServerMethods
|
|
12
|
+
def reply(mock, value)
|
|
13
|
+
mock.method_called(value) if mock
|
|
14
|
+
value
|
|
15
|
+
end
|
|
16
|
+
def reply_error(count)
|
|
17
|
+
@error_count ||= count
|
|
18
|
+
if @error_count == 0
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@error_count -= 1
|
|
23
|
+
raise
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def reply_with_callback(mock, value)
|
|
27
|
+
peer.disable_tx
|
|
28
|
+
mock.method_called(value)
|
|
29
|
+
peer.transmit(:reply, mock, value + 1)
|
|
30
|
+
mock.method_called(value + 2)
|
|
31
|
+
peer.enable_tx
|
|
32
|
+
value
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def recursive_callbacks
|
|
36
|
+
peer.transmit(:recursive_callbacks)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def setup(server); peer.setup(server) end
|
|
40
|
+
def peer_drb_object; DRbObject.new(peer) end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def setup
|
|
44
|
+
super
|
|
45
|
+
|
|
46
|
+
peer2peer(true) do |remote|
|
|
47
|
+
def remote.install_fake_methods
|
|
48
|
+
local_peer.local_server.extend FakePeerServerMethods
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
remote_peer.local_server.extend FakePeerServerMethods
|
|
53
|
+
remote.install_fake_methods
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_transmit
|
|
57
|
+
FlexMock.use do |mock|
|
|
58
|
+
# Check that nothing is sent while the link is not alive
|
|
59
|
+
remote_peer.disable_tx
|
|
60
|
+
remote_peer.transmit(:reply, DRbObject.new(mock), 42) do |result|
|
|
61
|
+
mock.block_called(result)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
remote_peer.transmit(:reply, DRbObject.new(mock), 24)
|
|
65
|
+
remote_peer.transmit(:reply, DRbObject.new(mock), 24) do |result|
|
|
66
|
+
mock.block_called(result)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
mock.should_receive(:link_alive).once.ordered
|
|
70
|
+
mock.should_receive(:method_called).with(42).once.ordered(:first_call)
|
|
71
|
+
mock.should_receive(:method_called).with(24).twice.ordered(:second_calls)
|
|
72
|
+
mock.should_receive(:block_called).with(42).once.ordered(:second_calls)
|
|
73
|
+
mock.should_receive(:block_called).with(24).once.ordered
|
|
74
|
+
|
|
75
|
+
mock.link_alive
|
|
76
|
+
remote_peer.enable_tx
|
|
77
|
+
remote_peer.synchro_point
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_transmit_error
|
|
82
|
+
FlexMock.use do |mock|
|
|
83
|
+
remote_peer.disable_tx
|
|
84
|
+
remote_peer.transmit(:reply_error, 2) do |result|
|
|
85
|
+
mock.block_called
|
|
86
|
+
end
|
|
87
|
+
mock.should_receive(:block_called).never
|
|
88
|
+
remote_peer.enable_tx
|
|
89
|
+
assert_raises(Roby::Distributed::DisconnectedError) { remote_peer.synchro_point }
|
|
90
|
+
|
|
91
|
+
assert(!remote_peer.connected?)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_call(value = 42)
|
|
96
|
+
FlexMock.use do |mock|
|
|
97
|
+
mock.should_receive(:method_called).with(value).once
|
|
98
|
+
assert_equal(value, remote_peer.call(:reply, DRbObject.new(mock), value))
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_concurrent_calls
|
|
103
|
+
remote_peer.disable_tx
|
|
104
|
+
|
|
105
|
+
t1 = Thread.new { test_call(42) }
|
|
106
|
+
# wait for the TX thread to notice the new entry in the queue and
|
|
107
|
+
# wake up
|
|
108
|
+
sleep(0.5)
|
|
109
|
+
|
|
110
|
+
t2 = Thread.new { test_call(21) }
|
|
111
|
+
# Wait for +t2+ to insert its entry in the TX queue
|
|
112
|
+
sleep(0.5)
|
|
113
|
+
|
|
114
|
+
remote_peer.enable_tx
|
|
115
|
+
t1.value
|
|
116
|
+
t2.value
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_call_raises
|
|
120
|
+
Roby.logger.level = Logger::FATAL
|
|
121
|
+
assert_raises(RuntimeError) do
|
|
122
|
+
remote_peer.call(:reply_error, 2)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_call_disconnects
|
|
127
|
+
Roby.logger.level = Logger::FATAL
|
|
128
|
+
remote_peer.disable_tx
|
|
129
|
+
|
|
130
|
+
remote_peer.transmit(:reply_error, 2)
|
|
131
|
+
sleep(0.5)
|
|
132
|
+
|
|
133
|
+
Thread.new do
|
|
134
|
+
sleep(0.5)
|
|
135
|
+
remote_peer.enable_tx
|
|
136
|
+
end
|
|
137
|
+
assert_raises(DisconnectedError) { remote_peer.call(:reply, nil, 42) }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def test_callback
|
|
141
|
+
FlexMock.use do |mock|
|
|
142
|
+
# Check that nothing is sent while the link is not alive
|
|
143
|
+
mock.should_receive(:method_called).with(42).once.ordered
|
|
144
|
+
mock.should_receive(:method_called).with(44).once.ordered
|
|
145
|
+
mock.should_receive(:method_called).with(43).once.ordered
|
|
146
|
+
|
|
147
|
+
assert_equal(42, remote_peer.call(:reply_with_callback, DRbObject.new(mock), 42))
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def test_recursive_callbacks
|
|
152
|
+
Roby.logger.level = Logger::FATAL
|
|
153
|
+
assert_raises(DisconnectedError) { remote_peer.call(:recursive_callbacks) }
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_synchro_point
|
|
157
|
+
remote_peer.disable_tx
|
|
158
|
+
remote.send_local_peer(:disable_tx)
|
|
159
|
+
FlexMock.use do |mock|
|
|
160
|
+
remote_peer.transmit(:reply, DRbObject.new(mock), 42)
|
|
161
|
+
remote_peer.transmit(:reply, DRbObject.new(mock), 21)
|
|
162
|
+
remote.send_local_peer(:transmit, :reply, DRbObject.new(mock), 42)
|
|
163
|
+
remote.send_local_peer(:transmit, :reply, DRbObject.new(mock), 21)
|
|
164
|
+
|
|
165
|
+
Thread.current.priority = 10
|
|
166
|
+
sleep(0.5)
|
|
167
|
+
mock.should_receive(:method_called).times(4)
|
|
168
|
+
|
|
169
|
+
remote_peer.enable_tx
|
|
170
|
+
remote.send_local_peer(:enable_tx)
|
|
171
|
+
remote_peer.synchro_point
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
ensure
|
|
175
|
+
Thread.current.priority = 0
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|