Sha256: f1a27580a21a26d4d5651cb3201c00c8b48785fb91879217f2f4191cf36d68cb
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
require 'osc' require 'rca_command' module CanControlsGateway class OscToRcaDispatcher attr_reader :event, :raw_data, :osc_packet, :osc_message def initialize data @raw_data = data @osc_packet = OSC::Packet.decode @raw_data rescue @osc_packet = nil @osc_message = @osc_packet[0][1] rescue @osc_message = nil @event = extract_event @osc_message end def dispatch_rca return true if @event.nil? my_args = { 'action' => @event } CcgLogger::LOGGER.info "#{Time.now.iso8601} | >> OscToRcaDispatcher: sending command : rci_uri: #{STATION['rci_uri']}, target: #{STATION['target']}, args: #{my_args.inspect}" my_command = CanControlsGateway::RcaCommand.new STATION['rci_uri'], STATION['target'], my_args CcgLogger::LOGGER.info "#{Time.now.iso8601} #{my_command.send_command}" end private def extract_event omsg return nil if omsg.nil? if omsg[0].kind_of?(OSC::OSCString) #s EVENTS[omsg[0].to_s] elsif omsg[2].kind_of?(OSC::OSCString) # ffs EVENTS[omsg[2].to_s] else nil # something else, e.g. ff end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tg-can-controls-gateway-0.1.2 | lib/osc_to_rca_dispatcher.rb |
tg-can-controls-gateway-0.1.1 | lib/osc_to_rca_dispatcher.rb |