lib/runner.rb in tg-can-controls-gateway-0.1.2 vs lib/runner.rb in tg-can-controls-gateway-0.1.3

- old
+ new

@@ -13,21 +13,22 @@ :port => nil, :valve => :closed, } include OAttr - oattr :incoming_osc_port, :device, :valve + oattr :incoming_osc_port, :device, :valve, :logfile def self.instance @@instance end def initialize path, options = {} @@instance = self @path = path @options = Defaults.merge(gnode @path).merge(options) puts "options: #{@options.inspect}" + (Ccg::logger logfile) # FIXIT: legacy! pushing config values from GOM to global variable!!! STATION['port'] = Integer(incoming_osc_port) STATION['device'] = device STATION['rci_uri'] = device_rci_uri @@ -46,14 +47,14 @@ port = Integer(incoming_osc_port) if port.nil? raise "NOT Starting servers since port cannot be determined" end - puts "#{Time.now.iso8601} | ++ Starting servers" + Ccg.logger.info "Starting servers" EventMachine::threadpool_size = 20 EventMachine::run do - puts "#{Time.now.iso8601} | ++ * UdpServer (port: #{port}) ..." + Ccg.logger.info "UdpServer (port: #{port}) ..." EventMachine::open_datagram_socket('0.0.0.0', port, UdpServer) # TODO place http server component for GNP callbacks here... end end @@ -69,28 +70,5 @@ def valve_update _, attribute @options[:valve] = attribute["value"].to_sym puts " -- can-controls-valve now: #{valve}" end end - -__END__ - - def _fill_settings - CcgLogger::LOGGER.info "#{Time.now.iso8601} | ++ Initializing settings ..." - my_gom = RestFs::Client.new GOM_ROOT - - my_res = my_gom.retrieve("#{STATION['device']}:rci_uri") - if my_res - STATION['rci_uri'] = my_res['attribute']['value'] - CcgLogger::LOGGER.info "#{Time.now.iso8601} | ++ setting rci_uri for station #{STATION['device']} => #{STATION['rci_uri'].inspect}" - - my_port_res = my_gom.retrieve("#{STATION['device']}/hid:port") - if my_port_res - STATION['port'] = my_port_res['attribute']['value'] - else - CcgLogger::LOGGER.info "#{Time.now.iso8601} | ++ device's hid:port #{STATION['device']}/hid:port not found in gom" - end - else - CcgLogger::LOGGER.info "#{Time.now.iso8601} | ++ device's rci_uri #{STATION['device']}:rci_uri not found in gom" - end - end -