OSDN Git Service

Merge branch 'master' of ssh://192.168.5.213:/opt/git/vem
authoriwasaki <iwaaya@yasunaga-lab.bio.kyutech.ac.jp>
Thu, 14 Jan 2016 01:55:20 +0000 (10:55 +0900)
committeriwasaki <iwaaya@yasunaga-lab.bio.kyutech.ac.jp>
Thu, 14 Jan 2016 01:55:20 +0000 (10:55 +0900)
15 files changed:
lib/.cameraSocket.rb.un~
lib/.serialCamera.rb.un~
lib/cameraSocket.rb~
lib/serialCamera.rb
lib/serialCamera.rb~
vem/.feicontrol.rb.un~
vem/.test.rb.un~
vem/.vem.rb.un~
vem/feicontrol.rb
vem/feicontrol.rb~
vem/mock.rb~ [new file with mode: 0644]
vem/test.rb
vem/test.rb~
vem/vem.rb
vem/vem.rb~

index 6123b18..ccb6643 100644 (file)
Binary files a/lib/.cameraSocket.rb.un~ and b/lib/.cameraSocket.rb.un~ differ
index 472d4ef..f216c88 100644 (file)
Binary files a/lib/.serialCamera.rb.un~ and b/lib/.serialCamera.rb.un~ differ
index a2f7e6c..fd375d4 100644 (file)
@@ -29,6 +29,7 @@ class CameraSocket
                        end
 
                        ws.onmessage do |msg|
+                               sleep(0.5)
                                rec_buf = JSON.parse(msg)
                                if(rec_buf["type"]=="req")
                                        if(rec_buf["data"]=="img")
@@ -36,7 +37,6 @@ class CameraSocket
                                                @buf["data"] = @camera.get_image 
                                                @buf["count"] = @count
                                                ws.send(@buf.to_json)
-                                               puts @count
                                                @count = @count + 1
                                        end
                                end
index 93492b5..4397e60 100644 (file)
@@ -33,7 +33,7 @@ class SerialCamera
 
        def execute
                #puts "execute #{@count}"
-               sleep(0.2)
+               sleep(1)
                @origin_image = @vem.acquisition # 撮影
                converted_image = convert_256(@origin_image) # 256階調に変換
                @image = converted_image.to_json 
@@ -43,10 +43,15 @@ class SerialCamera
        end
 
        def get_image
+               if(@count==0) then
                @mutex.synchronize do
                        @cv.wait(@mutex) while (@complete == false)
                        @complete = false
                        return @image
                end
+               else
+               return @image
+               end
+               
        end
 end
index 93492b5..8596f09 100644 (file)
@@ -33,7 +33,7 @@ class SerialCamera
 
        def execute
                #puts "execute #{@count}"
-               sleep(0.2)
+               sleep(1.5)
                @origin_image = @vem.acquisition # 撮影
                converted_image = convert_256(@origin_image) # 256階調に変換
                @image = converted_image.to_json 
@@ -43,10 +43,15 @@ class SerialCamera
        end
 
        def get_image
+               if(@count==0) then
                @mutex.synchronize do
                        @cv.wait(@mutex) while (@complete == false)
                        @complete = false
                        return @image
                end
+               else
+               return @image
+               end
+               
        end
 end
index b506e59..d6a9ee5 100644 (file)
Binary files a/vem/.feicontrol.rb.un~ and b/vem/.feicontrol.rb.un~ differ
index 6200a01..06d0f43 100644 (file)
Binary files a/vem/.test.rb.un~ and b/vem/.test.rb.un~ differ
index adaa046..f221117 100644 (file)
Binary files a/vem/.vem.rb.un~ and b/vem/.vem.rb.un~ differ
index b77727d..2eadc46 100644 (file)
@@ -143,14 +143,17 @@ class FEIControl < VEM
                return @@params[:proj].to_json
        end
 
-       def set_image_shift(x, y)
+       def set_image_beam_shift(x, y)
                puts "FEI setImageShift"
 
                proj = @@tem.Projection
-               proj.imageshift.X = proj.imageshift.x + x
-               proj.imageshift.Y = proj.imageshift.y + y
-               @@params[:proj][:imageShift][:x] = proj.ImageShift.X
-               @@params[:proj][:imageShift][:y] = proj.ImageShift.Y
+               proj.ImageBeamShift.X = proj.ImageBeamShift.X
+               proj.ImageBeamShift.Y = proj.ImageBeamShift.Y
+
+               puts proj.ImageBeamShift.X
+               @@params[:proj][:imageShift][:x] = proj.ImageBeamShift.X
+               @@params[:proj][:imageShift][:y] = proj.ImageBeamShift.Y
+
        return @@params[:proj][:imageShift].to_json
        end
 
@@ -158,16 +161,16 @@ class FEIControl < VEM
                puts "FEI setFocus"
 
                proj = @@tem.Projection
-               proj.Focus = proj.Focus + params
+               #proj.Focus = proj.Focus
                @@params[:proj][:focus] = proj.Focus
                return @@params[:proj][:focus].to_json
        end
 
-       def set_defocus(params)
+       def set_defocusr(params)
                puts "FEI setDefocus"
 
                proj = @@tem.Projection
-               proj.Defocus = proj.Defocus + params
+               proj.Defocus = proj.Defocus + params*1e-9
                @@params[:proj][:defocus] = proj.Defocus
                return @@params[:proj][:defocus].to_json
        end
index 24ec2c6..94f488b 100644 (file)
@@ -29,8 +29,8 @@ class FEIControl < VEM
                                :a => 0,
                        },
                        :ccdCamera => {
-                               :binning    => 1,
-                               :expTime    => 1,
+                               :binning    => 4,
+                               :expTime    => 0.07,
                                :imageSize  => 0
                        },
                        :proj => {
@@ -143,14 +143,17 @@ class FEIControl < VEM
                return @@params[:proj].to_json
        end
 
-       def set_image_shift(x, y)
+       def set_image_beam_shift(x, y)
                puts "FEI setImageShift"
 
                proj = @@tem.Projection
-               proj.imageshift.X = proj.imageshift.x + x
-               proj.imageshift.Y = proj.imageshift.y + y
-               @@params[:proj][:imageShift][:x] = proj.ImageShift.X
-               @@params[:proj][:imageShift][:y] = proj.ImageShift.Y
+               proj.ImageBeamShift.X = proj.ImageBeamShift.X
+               proj.ImageBeamShift.Y = proj.ImageBeamShift.Y
+
+               puts proj.ImageBeamShift.X
+               @@params[:proj][:imageShift][:x] = proj.ImageBeamShift.X
+               @@params[:proj][:imageShift][:y] = proj.ImageBeamShift.Y
+
        return @@params[:proj][:imageShift].to_json
        end
 
@@ -158,16 +161,16 @@ class FEIControl < VEM
                puts "FEI setFocus"
 
                proj = @@tem.Projection
-               proj.Focus = proj.Focus + params
+               #proj.Focus = proj.Focus
                @@params[:proj][:focus] = proj.Focus
                return @@params[:proj][:focus].to_json
        end
 
-       def set_defocus(params)
+       def set_defocusr(params)
                puts "FEI setDefocus"
 
                proj = @@tem.Projection
-               proj.Defocus = proj.Defocus + params
+               proj.Defocus = proj.Defocus
                @@params[:proj][:defocus] = proj.Defocus
                return @@params[:proj][:defocus].to_json
        end
diff --git a/vem/mock.rb~ b/vem/mock.rb~
new file mode 100644 (file)
index 0000000..427190a
--- /dev/null
@@ -0,0 +1,99 @@
+$:.unshift(File.dirname(__FILE__))
+
+require "json"
+require "vem"
+require "singleton"
+
+
+class MockControl < VEM
+  include Singleton
+
+  def initialize
+    @params = {
+      :stage => {
+      :x => 0,
+      :y => 0,
+      :z => 0,
+      :a => 0,
+    },
+    :ccdCamera => {
+      :binning    => 1,
+      :expTime    => 1,
+      :imageSize  => 0
+    },
+      :proj => {
+      :magIndex => 0
+    },
+      :ill => {
+      :spotSizeIndex => 0
+    }
+    }
+    @send_size = 2048
+  end
+
+  def get_params
+    puts "MOCK get params"
+    return @params.to_json
+  end
+
+  def set_stageA(x, y, z, a)
+    puts "MOCK setStageA"
+
+    @params[:stage][:x] = x
+    @params[:stage][:y] = y
+    @params[:stage][:z] = z
+    @params[:stage][:a] = a
+
+    return @params[:stage].to_json
+  end
+
+  def set_stageR(x, y, z, a)
+    puts "MOCK setStageR"
+
+    @params[:stage][:x] = @params[:stage][:x].to_i + x
+    @params[:stage][:y] = @params[:stage][:y].to_i + y
+    @params[:stage][:z] = @params[:stage][:z].to_i + z
+    @params[:stage][:a] = @params[:stage][:a].to_i + a
+
+    return @params[:stage].to_json
+  end
+
+  def set_spotsize(spsize)
+    puts "MOCK setSpotSize"
+
+    @params[:ill][:spotSizeIndex] = spsize
+    return @params[:ill].to_json
+  end
+
+  def set_magnification(magsize)
+    puts "MOCK setMagnification"
+
+    @params[:proj][:magIndex] = magsize
+    return @params[:proj].to_json
+  end
+
+  def acquisition_init( binning, exp_time, image_size )
+    if(image_size==0)
+      @send_size = 2048/binning
+    elsif(image_size==1)
+      @send_size = 2048/(2*binning)
+    elsif(image_size==2)
+      @send_size = 2048/(4*binning)
+    end
+    @params[:ccdCamera][:binning]    = binning
+    @params[:ccdCamera][:expTime]   = exp_time
+    @params[:ccdCamera][:imageSize] = image_size
+    return @params[:ccdCamera].to_json
+  end
+
+  def acquisition
+    img_array = Array.new
+    # 画像ファイルをひらく
+    File.open("#{File.dirname(__FILE__)}/image/image#{@send_size}", "r") do |file|
+      img_array = JSON.load(file)
+    end
+    return img_array
+  end 
+
+end
+
index 9b4e068..c52601f 100644 (file)
@@ -30,16 +30,20 @@ class TEST
                @@vem.set_spotsizeR(1)
        end
 
-       def test_set_image_shift
-               puts @@vem.set_image_shift(0, 0)
+       def test_set_magnificationR
+               puts @@vem.set_magnificationR(1)
+       end
+
+       def test_set_image_beam_shift
+               puts @@vem.set_image_beam_shift(1, 0)
        end
 
        def test_set_focus
                puts @@vem.set_focus(0)
        end
 
-       def test_set_defocus
-               puts @@vem.set_defocus(0)
+       def test_set_defocusr
+               puts @@vem.set_defocusr(1)
        end
 
        def test_set_reset_defocus
@@ -75,9 +79,10 @@ test.test_acq_init
 test.test_acq
 =end
 
-test.test_set_image_shift
-test.test_set_focus
-test.test_set_defocus
-test.test_set_reset_defocus
-test.test_set_condenser_stg
-test.test_set_object_stg
+#test.test_set_magnificationR
+#test.test_set_image_beam_shift
+#test.test_set_focus
+test.test_set_defocusr
+#test.test_set_reset_defocus
+#test.test_set_condenser_stg
+#test.test_set_object_stg
index f394b50..65e3d9c 100644 (file)
@@ -30,16 +30,20 @@ class TEST
                @@vem.set_spotsizeR(1)
        end
 
-       def test_set_image_shift
-               puts @@vem.set_image_shift(0)
+       def test_set_magnificationR
+               puts @@vem.set_magnificationR(1)
+       end
+
+       def test_set_image_beam_shift
+               puts @@vem.set_image_beam_shift(1, 0)
        end
 
        def test_set_focus
                puts @@vem.set_focus(0)
        end
 
-       def test_set_defocus
-               puts @@vem.set_defocus(0)
+       def test_set_defocusr
+               puts @@vem.set_defocusr(1)
        end
 
        def test_set_reset_defocus
@@ -47,11 +51,11 @@ class TEST
        end
 
        def test_set_condenser_stg
-               puts @@vem.set_condenser_stg(0)
+               puts @@vem.set_condenser_stg(0, 0)
        end
 
        def test_set_object_stg
-               puts @@vem.set_object_stg(0)
+               puts @@vem.set_object_stg(0, 0)
        end
 
 
@@ -75,9 +79,10 @@ test.test_acq_init
 test.test_acq
 =end
 
-test.test_set_image_shift
-test.test_set_focus
+#test.test_set_magnificationR
+#test.test_set_image_beam_shift
+#test.test_set_focus
 test.test_set_defocus
-test.test_set_reset_defocus
-test.test_set_condenser_stg
-test.test_set_object_stg
+#test.test_set_reset_defocus
+#test.test_set_condenser_stg
+#test.test_set_object_stg
index a46b2df..ab4567b 100644 (file)
@@ -44,7 +44,7 @@ class VEM
        def set_focus(params)
        end
 
-       def set_defocus(params)
+       def set_defocusr(params)
        end
 
        def set_reset_defocus
index dd5010c..a46b2df 100644 (file)
@@ -38,7 +38,7 @@ class VEM
        def set_magnificationR(magsize)
        end
 
-       def set_image_shift(params)
+       def set_image_shift(x, y)
        end
 
        def set_focus(params)
@@ -50,10 +50,10 @@ class VEM
        def set_reset_defocus
        end
 
-       def set_condenser_stg
+       def set_condenser_stg(x, y)
        end
 
-       def set_object_stg
+       def set_object_stg(x, y)
        end
 
        def acquisition_init