Class: MINT::AIINContinuous
- Inherits:
-
AIIN
- Object
- Interactor
- AIO
- AIIN
- MINT::AIINContinuous
- Defined in:
- lib/MINT-core/model/aui/AIINContinuous.rb
Constant Summary
Constants inherited from Interactor
Interactor::PUBLISH_ATTRIBUTES
Instance Method Summary collapse
- #getSCXML ⇒ Object
- #halt(id) ⇒ Object
-
#publish(attribute) ⇒ Object
functions called from scxml.
Methods inherited from AIO
#exists_next, #exists_parent, #exists_prev, #focus_next, #focus_parent, #focus_previous, getModel, #inform_parent_presenting, #next, #next2str, #parent, #parent2str, #parent=, #previous, #previous2str
Methods inherited from Interactor
class_from_channel_name, #create_attribute_channel_name, create_channel_name, #create_channel_w_name, get, getModel, get_dm, #init_statemachine, #is_in?, #new_states, notify, #process_event, #process_event!, #process_event_vars, #publish_update, #states, #states=, #sync_event, #sync_states, #to_dot, wait
Methods included from InteractorHelpers
#restart_timeout, #start_timeout, #stop_timeout
Instance Method Details
#getSCXML ⇒ Object
10 11 12 |
# File 'lib/MINT-core/model/aui/AIINContinuous.rb', line 10 def getSCXML "#{File.dirname(__FILE__)}/aiincontinuous.scxml" end |
#halt(id) ⇒ Object
51 52 53 |
# File 'lib/MINT-core/model/aui/AIINContinuous.rb', line 51 def halt(id) RedisConnector.sub.unsubscribe(self.class.create_channel_name+".#{id}") end |
#publish(attribute) ⇒ Object
functions called from scxml
16 17 18 19 20 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 |
# File 'lib/MINT-core/model/aui/AIINContinuous.rb', line 16 def publish(attribute) channel_name = create_attribute_channel_name(attribute) redis = RedisConnector.redis fiber = Fiber.current redis.pubsub.psubscribe('in_channel:Interactor.AIO.AIIN.AIINContinuous.'+self.name.to_s+":*") { |key,| sync_states if .eql? "stop" process_event("halt") else d = attribute_get(:data) if d if .to_i > d and not (is_in?(:progressing) or is_in?(:max))# state comparison just for performance process_event("progress") elsif .to_i < d and not (is_in?(:regressing) or is_in?(:min)) process_event("regress") end else # @statemachine.process_event("progress") # default progress TODO improve default handling for first data process_event("progress") end attribute_set(:data,.to_i) RedisConnector.redis.publish channel_name,MultiJson.encode({:name=>self.name,:data => data}) end }.callback { fiber.resume} Fiber.yield end |