Top Level Namespace

Defined Under Namespace

Modules: ApplicationHelper, CanControlsGateway, Ccg, CcgLogger, UdpServer Classes: ApplicationController, CcgRunner

Constant Summary collapse

SERVER =
"localhost"
PORT =
6567
STATIONS =
1
EVENTS =

GOM_ROOT = “gom” GOM_ROOT = “localhost:3080

{ "swipeDown"  => "down",
"swipeUp"    => "up",
"swipeLeft"  => "left",
"swipeRight" => "right",
"zoomIn"     => "in",
"zoomOut"    => "out",
"cancel"     => "cancel",
"mouseDown"  => "confirm",
"bigSwipe"   => 'start'}
XML_EVENT_TEMPLATE =
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<trackingdata ts="" station_id="%s">
  <event type="%s">
   <position type="vec3f" coordinate_system="plane">%s, %s, 0</position>
  </event>
</trackingdata>
XML
XML_MOVE_EVENT_TEMPLATE =
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<trackingdata ts="" station_id="%s">
  <event type="mouseMove">
   <position type="vec3f" coordinate_system="plane">%s, %s, 0</position>
  </event>
  <event type="%s"></event>
</trackingdata>
XML
XML_EVENT_TEMPLATE_NO_DATA =
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<trackingdata ts="" station_id="%s">
  <event type="%s">
  </event>
</trackingdata>
XML
XML_NO_EVENT_TEMPLATE =
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<trackingdata ts="" station_id="%s">
</trackingdata>
XML
STATION =
{
  'device' => '/areas/home/tv',
  'target' => 'input_dispatcher',
}
ADDR =

host, port

['0.0.0.0', 33333]
UDPSock =
UDPSocket.new

Instance Method Summary collapse

Instance Method Details

#generate_payloadObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ping.rb', line 50

def generate_payload
  if [true].choice
    my_event = EVENTS.choice
    puts "event >>>>>> #{my_event}"
    my_now   = Time.now
    if ['mouseMove', 'mouseDown', 'mouseUp'].include? my_event
      sprintf(XML_EVENT_TEMPLATE, (rand*STATIONS).to_i, my_event, Math.sin(my_now), Math.cos(my_now))
    else
      sprintf(XML_MOVE_EVENT_TEMPLATE, (rand*STATIONS).to_i, Math.sin(my_now), Math.cos(my_now), my_event)
    end
  else
    puts "no event"
    sprintf(XML_NO_EVENT_TEMPLATE, (rand*STATIONS).to_i)
  end
end

#rca_commandObject

require ‘osc_package’



5
# File 'lib/dispatcher.rb', line 5

require 'rca_command'

#send_gesture(server_addr, server_port, payload) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ping.rb', line 66

def send_gesture(server_addr, server_port, payload)
  resp, sock = nil, nil
  begin
    sock = UDPSocket.open
    puts payload
    sock.send("#{payload}", 0, server_addr, server_port)
    resp = ["sent"]
  rescue IOError, SystemCallError
  ensure
    sock.close if sock
  end
  resp ? resp[0] : nil
end