Module: RSMP::SiteProxy::Modules::Status
- Included in:
- RSMP::SiteProxy
- Defined in:
- lib/rsmp/proxy/site/modules/status.rb
Overview
Handles status requests, responses, subscriptions and updates
Instance Method Summary collapse
- #ensure_subscription_path(component_id, code, name) ⇒ Object
- #process_status_response(message) ⇒ Object
- #process_status_update(message) ⇒ Object
- #remove_subscription_item(component_id, code, name) ⇒ Object
- #request_status(component, status_list, options = {}) ⇒ Object
- #subscribe_to_status(component_id, status_list, options = {}) ⇒ Object
- #unsubscribe_to_status(component_id, status_list, options = {}) ⇒ Object
- #update_subscription(component_id, subscribe_list) ⇒ Object
Instance Method Details
#ensure_subscription_path(component_id, code, name) ⇒ Object
36 37 38 39 40 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 36 def ensure_subscription_path(component_id, code, name) @status_subscriptions[component_id] ||= {} @status_subscriptions[component_id][code] ||= {} @status_subscriptions[component_id][code][name] ||= {} end |
#process_status_response(message) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 29 def process_status_response() component = find_component .attribute('cId') component.store_status log "Received #{message.type}", message: , level: :log acknowledge end |
#process_status_update(message) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 100 def process_status_update() component = find_component .attribute('cId') component.check_repeat_values , @status_subscriptions component.store_status log "Received #{message.type}", message: , level: :log acknowledge end |
#remove_subscription_item(component_id, code, name) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 76 def remove_subscription_item(component_id, code, name) return unless @status_subscriptions.dig(component_id, code, name) @status_subscriptions[component_id][code].delete name @status_subscriptions[component_id].delete(code) if @status_subscriptions[component_id][code].empty? @status_subscriptions.delete(component_id) if @status_subscriptions[component_id].empty? end |
#request_status(component, status_list, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 6 def request_status(component, status_list, = {}) validate_ready 'request status' m_id = [:m_id] || RSMP::Message.make_m_id # additional items can be used when verifying the response, # but must be removed from the request request_list = status_list.map { |item| item.slice('sCI', 'n') } = RSMP::StatusRequest.new({ 'cId' => component, 'sS' => request_list, 'mId' => m_id }) send_and_optionally_collect , do || StatusCollector.new( self, status_list, .merge(task: @task, m_id: m_id) ) end end |
#subscribe_to_status(component_id, status_list, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 52 def subscribe_to_status(component_id, status_list, = {}) validate_ready 'subscribe to status' m_id = [:m_id] || RSMP::Message.make_m_id subscribe_list = status_list.map { |item| item.slice('sCI', 'n', 'uRt', 'sOc') } update_subscription(component_id, subscribe_list) find_component component_id = RSMP::StatusSubscribe.new({ 'cId' => component_id, 'sS' => subscribe_list, 'mId' => m_id }) send_and_optionally_collect , do || StatusCollector.new( self, status_list, .merge(task: @task, m_id: m_id) ) end end |
#unsubscribe_to_status(component_id, status_list, options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 84 def unsubscribe_to_status(component_id, status_list, = {}) validate_ready 'unsubscribe to status' status_list.each do |item| remove_subscription_item(component_id, item['sCI'], item['n']) end = RSMP::StatusUnsubscribe.new({ 'cId' => component_id, 'sS' => status_list }) , validate: [:validate] end |
#update_subscription(component_id, subscribe_list) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/rsmp/proxy/site/modules/status.rb', line 42 def update_subscription(component_id, subscribe_list) subscribe_list.each do |item| code = item['sCI'] name = item['n'] sub = ensure_subscription_path(component_id, code, name) sub['uRt'] = item['uRt'] sub['sOc'] = item['sOc'] end end |