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,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CcgRunner.



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

def initialize path, options = {}
  @@instance = self
  @path = path
  @options = Defaults.merge(gnode @path).merge(options)
  puts "options: #{@options.inspect}"

  # 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}"

  init_gnp
end

Instance Attribute Details

#valveObject (readonly)

Returns the value of attribute valve.



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

def valve
  @valve
end

Class Method Details

.instanceObject



22
23
24
# File 'lib/runner.rb', line 22

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

  puts "#{Time.now.iso8601} |  ++ Starting servers"
  EventMachine::threadpool_size = 20
  EventMachine::run do
    puts "#{Time.now.iso8601} |  ++   * UdpServer (port: #{port}) ..."
    EventMachine::open_datagram_socket('0.0.0.0', port, UdpServer)
    # TODO place http server component for GNP callbacks here...
  end
end