Class: CcgRunner

Inherits:
Gom::Remote::Entry
  • Object
show all
Includes:
OAttr
Defined in:
lib/runner.rb

Constant Summary collapse

Defaults =
{
  :logfile => '-',
  :port => nil,
  :valve => :closed,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ CcgRunner

Returns a new instance of CcgRunner.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/runner.rb', line 24

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
  puts " -- STATION info: #{STATION.inspect}"

  @options[:valve] = valve.to_sym # type fixing the GOM string
  init_gnp
end

Class Method Details

.instanceObject



20
21
22
# File 'lib/runner.rb', line 20

def self.instance
  @@instance
end

Instance Method Details

#device_rci_uriObject



41
42
43
# File 'lib/runner.rb', line 41

def device_rci_uri
  @device_rci_uri ||= connection.read "#{device}:rci_uri.txt"
end

#runObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runner.rb', line 45

def run
  #fill_settings
  port = Integer(incoming_osc_port)
  if port.nil?
    raise "NOT Starting servers since port cannot be determined"
  end

  Ccg.logger.info "Starting servers"
  EventMachine::threadpool_size = 20
  EventMachine::run do
    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