Class: MINT::ComplementaryMapping

Inherits:
Mapping
  • Object
show all
Defined in:
lib/MINT-core/mapping/complementary_mapping.rb

Direct Known Subclasses

SequentialMapping

Instance Attribute Summary

Attributes inherited from Mapping

#state_callback

Instance Method Summary collapse

Methods inherited from Mapping

#actions, #actions_succeeded_callback, #activated_callback, #call_actions_succeeded_callbacks, #call_activated_callbacks, #cb_activate_action, #id, #initialize, #mapping_name, #observations, #startAction, #stop_observations

Constructor Details

This class inherits a constructor from MINT::Mapping

Instance Method Details

#restartObject



9
10
11
12
13
# File 'lib/MINT-core/mapping/complementary_mapping.rb', line 9

def restart
  @state_callback.call(@mapping[:name], {:id => @mapping[:id], :mapping_state => :restarted}) if @state_callback
  start_observations
  self
end

#startObject



3
4
5
6
7
# File 'lib/MINT-core/mapping/complementary_mapping.rb', line 3

def start
  @state_callback.call(@mapping[:name], {:id => @mapping[:id], :mapping_state => :started}) if @state_callback
  start_observations
  self
end

#start_observationsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/MINT-core/mapping/complementary_mapping.rb', line 15

def start_observations
  @observation_init = 0
  observations.each do |observation|
    @observation_init += 1
    observation.start(@observation_results,self.method(:cb_activate_action)).is_subscribed_callback { |observation|
      @observation_state[observation.element] = false
      @state_callback.call(@mapping[:name], {:id => observation.id, :state => :activated}) if @state_callback
      @observation_init -= 1
      if @observation_init == 0
        @mapping_activated = true
        call_activated_callbacks
      end
    }
  end
end