Module: RSMP::SiteProxy::Modules::Commands
- Included in:
- RSMP::SiteProxy
- Defined in:
- lib/rsmp/proxy/site/modules/commands.rb
Overview
Handles command requests and responses
Instance Method Summary collapse
- #command_collector_list(command_list) ⇒ Object
- #process_command_response(message) ⇒ Object
-
#send_command(command_list, component: nil, validate: true) ⇒ Object
Build and send a CommandRequest.
-
#send_command_and_collect(command_list, within:, component: nil, validate: true) ⇒ Object
Build, send a CommandRequest and collect the CommandResponse.
Instance Method Details
#command_collector_list(command_list) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rsmp/proxy/site/modules/commands.rb', line 38 def command_collector_list(command_list) list = JSON.parse(JSON.generate(command_list)) resolved = RSMP::Schema.resolve_sxl({ 'type' => 'CommandRequest', 'arg' => list }, schemas: schemas) return list unless resolved type, version = resolved list.each do |item| next unless item.key?('v') descriptor = RSMP::Schema.sxl_argument_descriptor(type, version, :commands, item['cCI'], item['n']) next unless descriptor encoded = RSMP::Message.encode_sxl_value(item['v'], descriptor) item['v'] = RSMP::Message.decode_sxl_value(encoded, descriptor) end list rescue RSMP::Schema::Error list end |
#process_command_response(message) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/rsmp/proxy/site/modules/commands.rb', line 58 def process_command_response() return reject_multiple_command_codes() if core_3_3? && multiple_command_codes?() log "Received #{.type}", message: , level: :log acknowledge end |
#send_command(command_list, component: nil, validate: true) ⇒ Object
Build and send a CommandRequest. Returns the CommandRequest message.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rsmp/proxy/site/modules/commands.rb', line 7 def send_command(command_list, component: nil, validate: true) validate_ready 'send command' component ||= main.c_id m_id = RSMP::Message.make_m_id = RSMP::CommandRequest.new({ 'cId' => component, 'arg' => command_list, 'mId' => m_id }) , validate: validate end |
#send_command_and_collect(command_list, within:, component: nil, validate: true) ⇒ Object
Build, send a CommandRequest and collect the CommandResponse. Returns the collector. Raises on NotAck or timeout if ok! is called on the result.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rsmp/proxy/site/modules/commands.rb', line 23 def send_command_and_collect(command_list, within:, component: nil, validate: true) validate_ready 'send command' component ||= main.c_id m_id = RSMP::Message.make_m_id collector_list = command_collector_list(command_list) = RSMP::CommandRequest.new({ 'cId' => component, 'arg' => command_list, 'mId' => m_id }) collector = CommandResponseCollector.new(self, collector_list, timeout: within, initiator: ) (, collector, validate: validate)[:collector] end |