OSDN Git Service

commit by fei
[vem/vem.git] / lib / cameraSocket.rb~
diff --git a/lib/cameraSocket.rb~ b/lib/cameraSocket.rb~
deleted file mode 100644 (file)
index 09bcefc..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby -I c://Users/iwasaki/gem/sinatra-master/lib -I lib
-
-$:.unshift(File.dirname(__FILE__))
-
-require 'em-websocket'
-require 'json'
-require 'benchmark'
-require 'serialCamera'
-
-class CameraSocket
-       def initialize(ip, port)
-               @ip = ip
-               @port = port
-               @camera = SerialCamera.instance
-               @buf = {"type"=>nil, "data"=>nil}
-               @count = 0
-               @start_time = 0
-       end
-
-       def run!
-               EM::WebSocket.start(host: @ip, port: @port) do |ws|
-
-                       ws.onopen do
-                               puts "ws open"
-                               @buf["type"] = "connection"
-                               @buf["data"] = "open"
-                               @camera.on_flag
-                               ws.send(@buf.to_json)
-                       end
-
-                       ws.onmessage do |msg|
-                               rec_buf = JSON.parse(msg)
-                               if(rec_buf["type"]=="req")
-                                       if(rec_buf["data"]=="img")
-                                               @buf["type"] = "img"
-                                               @camera.unlock_acq
-                                               @buf["data"] = @camera.get_image 
-                                               @buf["count"] = @count
-                                               ws.send(@buf.to_json)
-                                               @count = @count + 1
-                                       end
-                               end
-                       end
-
-                       ws.onclose do
-                               @camera.off_flag
-                       end
-
-               end
-       end
-end