Module: Motel::RJR

Includes:
Motel, Omega, Omega::Server::DSL
Defined in:
lib/motel/rjr/inspect.rb,
lib/motel/rjr/get.rb,
lib/motel/rjr/init.rb,
lib/motel/rjr/state.rb,
lib/motel/rjr/track.rb,
lib/motel/rjr/delete.rb,
lib/motel/rjr/create.rb,
lib/motel/rjr/update.rb

Overview

TODO

  • # times specified location was updated

  • location callbacks w/ their endpoints, callback params, and # of times invoked

Constant Summary collapse

GET_METHODS =
{ :get_location => get_location }
STATE_METHODS =
{ :save_state => save_state,
:restore_state => restore_state }
TRACK_METHODS =
{ :track_handler    => track_handler,
:remove_callbacks => remove_callbacks }
DELETE_METHODS =
{ :delete_location => delete_location }
CREATE_METHODS =
{ :create_location => create_location }
UPDATE_METHODS =
{ :update_location => update_location }
INSPECT_METHODS =
{ :get_status => get_status }

Constants included from Motel

CARTESIAN_NORMAL_VECTOR, CLOSE_ENOUGH, LOCATION_EVENTS, MAJOR_CARTESIAN_AXIS, MINOR_CARTESIAN_AXIS

Instance Attribute Summary

Attributes included from Omega::Server::DSL

#node

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Omega::Server::DSL

#check_attribute, #check_privilege, #cosmos_entity?, #current_session, #current_user, #delete_event_handler_for, #filter_properties, #filters_from_args, #from_valid_source?, #handle_node_closed, #in_subsystem, #is_cmd?, #is_node?, #login, #matching, #persistent_transport?, #remove_callbacks_for, #require_attribute, #require_persistent_transport!, #require_privilege, #require_state, #require_valid_source!, #subsystem, #subsystem_entity?, #subsystem_event?, #validate_session_source!, #with, #with_id

Methods included from Motel

angle_between, axis_angle, cross_product, dot_product, elliptical_path, gen_uuid, normalize, normalized?, orthogonal?, rand_vector, random_axis, rotate, rotated_angle

Class Method Details

.registryObject


25
26
27
# File 'lib/motel/rjr/init.rb', line 25

def self.registry
  @registry ||= Motel::Registry.new
end

.resetObject


33
34
35
# File 'lib/motel/rjr/init.rb', line 33

def self.reset
  Motel::RJR.registry.clear!
end

.user_registryObject


17
18
19
# File 'lib/motel/rjr/init.rb', line 17

def self.user_registry
  Users::RJR.registry
end

Instance Method Details

#cb_from_args(rjr_method, args) ⇒ Object

Helper to generate a new callback from the specified method & args. Will validate arguments in the context of their method


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/motel/rjr/track.rb', line 21

def cb_from_args(rjr_method, args)
  case rjr_method
  when "motel::track_movement"
    d = args.shift
    raise ArgumentError, "distance must be >0" unless d.numeric? && d.to_f > 0
    Callbacks::Movement.new(:min_distance => d.to_f,
                            :rjr_event    => 'motel::on_movement',
                            :event_type   => :movement)

  when 'motel::track_rotation'
    rt = args.shift
    raise ArgumentError,
      "#{rt} must >0 && <4*PI" unless rt.numeric? &&
                                      rt.to_f > 0 &&
                                      (0...4*Math::PI).include?(rt.to_f)

    ax = args.shift
    ay = args.shift
    az = args.shift
    raise ArgumentError,
      "rotation axis must be normalized" unless ax.nil? || ay.nil? || az.nil? ||
                                                Motel.normalized?(ax, ay, az)

    Callbacks::Rotation.new :rot_theta    => rt.to_f,
                            :axis_x       => ax,
                            :axis_y       => ay,
                            :axis_z       => az,
                            :rjr_event    => 'motel::on_rotation',
                            :event_type   => :rotation

  when 'motel::track_proximity'
    olid = args.shift
    oloc = registry.entity &with_id(olid)
    raise Omega::DataNotFound, "loc specified by #{olid} not found" if oloc.nil?

    pevent  = args.shift
    vevents = ['proximity', 'entered_proximity', 'left_proximity']
    raise ArgumentError,
      "event must be one of #{vevents.join(", ")}" unless vevents.include?(pevent)

    d = args.shift
    raise ArgumentError,
      "dist must be >0" unless d.numeric? && d.to_f > 0

    Callbacks::Proximity.new :max_distance => d.to_f,
                             :to_location  => oloc,
                             :rjr_event    => 'motel::on_proximity',
                             :event_type   => :proximity

  when 'motel::track_stops'
    Callbacks::Stopped.new :rjr_event   => 'motel::location_stopped',
                           :event_type  => :stopped

  when 'motel::track_strategy'
    Callbacks::ChangedStrategy.new :rjr_event  => 'motel::changed_strategy',
                                   :event_type => :changed_strategy

  end
end

#registryObject


29
30
31
# File 'lib/motel/rjr/init.rb', line 29

def registry
  Motel::RJR.registry
end

#user_registryObject


21
22
23
# File 'lib/motel/rjr/init.rb', line 21

def user_registry
  Motel::RJR.user_registry
end