OSDN Git Service

20140826WITs
authorMurakamiMaiko <k238071m@pc18.lan.yasunaga-lab.bio.kyutech.ac.jp>
Tue, 26 Aug 2014 06:06:31 +0000 (15:06 +0900)
committerMurakamiMaiko <k238071m@pc18.lan.yasunaga-lab.bio.kyutech.ac.jp>
Tue, 26 Aug 2014 06:06:31 +0000 (15:06 +0900)
25 files changed:
CSS/vemclient.css
CSS/vemclient.css~ [new file with mode: 0755]
File/log.txt
JS/Currentcondition.js [new file with mode: 0644]
JS/Currentcondition.js~ [new file with mode: 0644]
JS/TemControl.js~ [new file with mode: 0755]
JS/ajax.js~ [new file with mode: 0755]
JS/filecontrol.js~ [new file with mode: 0755]
JS/filedownload.js~ [new file with mode: 0755]
JS/mscontrol.js [new file with mode: 0644]
JS/mscontrol.js~ [new file with mode: 0644]
JS/stagecontrol.js [new file with mode: 0644]
JS/stagecontrol.js~ [new file with mode: 0644]
cgi-bin/activetem.rb
cgi-bin/activetem.rb~ [new file with mode: 0755]
cgi-bin/implementation.rb
cgi-bin/implementation.rb~ [new file with mode: 0755]
cgi-bin/settem.rb
cgi-bin/settem.rb~ [new file with mode: 0755]
cgi-bin/vemclient.rb
cgi-bin/vemclient.rb~ [new file with mode: 0755]
vem.html
vem.html~ [new file with mode: 0755]
vemserver.rb
vemserver.rb~ [new file with mode: 0755]

index becc73b..9bc732e 100755 (executable)
@@ -31,7 +31,6 @@ body{
   width:1000px;
   margin-left:auto;
   margin-right:auto;
-
 }
 
 #leftside{
@@ -49,7 +48,8 @@ body{
 div#left{
   float:left;
   position:absolute;
-  left:100px;
+  left:200px;
+  text-align:left;
 }
 div#right{
   position:relative;
diff --git a/CSS/vemclient.css~ b/CSS/vemclient.css~
new file mode 100755 (executable)
index 0000000..20d2e20
--- /dev/null
@@ -0,0 +1,65 @@
+body{
+  background-color:#F5FFFA;
+  margin-left:auto;
+  margin-right:auto;
+  text-align:center;
+  width:90%;
+}
+
+#HITACHI {
+  border:0px;
+  height:141px;
+  width:300px;
+  background:url(icon/TEM1icon.png) left top no-repeat;
+}
+
+#FEI {
+  border:0px;
+  height:141px;
+  width:300px;
+  background:url(icon/TEM2icon.png) left top no-repeat;
+}
+
+#JEOL {
+  border:0px;
+  height:141px;
+  width:300px;
+  background:url(icon/TEM3icon.png) left top no-repeat;
+}
+
+#container{
+  width:1000px;
+  margin-left:auto;
+  margin-right:auto;
+}
+
+#leftside{
+  width:580px;
+  float:left;
+  margin: 10px;
+}
+
+#rightside{
+  width:380px;
+  float:left;
+  margin: 10px;
+}
+
+div#left{
+  float:left;
+  position:absolute;
+  left:150px;
+  text-align:left;
+}
+div#right{
+  position:relative;
+  left:80px;
+}
+.clearRight{
+  clear:left;
+}
+.box{
+  position:absolute;
+  text-align:left;
+  left:60px;
+}
index 9bca002..fa01f9d 100755 (executable)
@@ -163,3 +163,21 @@ Connect HITACHI
 Connect FEI
 Connect FEI
 Connect JEOL
+Accepted!
+Connect HITACHI
+Connect HITACHI
+Connect FEI
+Connect HITACHI
+Connect FEI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect FEI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
+Connect HITACHI
diff --git a/JS/Currentcondition.js b/JS/Currentcondition.js
new file mode 100644 (file)
index 0000000..34d49e5
--- /dev/null
@@ -0,0 +1,56 @@
+function Currentcondition() {
+
+ var ajax=getAjax();
+ if(command == "require"){
+       var position1 = document.getElementById("position");
+       var magnificant = document.getElementById("Magnificant");
+       var brightness = document.getElementById("Brightness");
+       var contrast = document.getElementById("Contrast");
+       var forcus = document.getElementById("Forcus");
+       var voltage = document.getElementById("Voltage");
+  }else {
+       var position1 = document.anchorsgetElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      position1.innerHTML="Onreadystate change error.";         
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(require),true);
+
+        }catch(e){
+      position1.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      position1.innerHTML ="send error";
+    }
+    
+  }else {
+       position1.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+                    var resultjson = ajax.responseText;
+                    position1.innerHTML = "x="+resultjson[Current_stargeX]+" y="+resultjson[Current_stargeY]+" z="+resultjson[Current_stargeZ]+" a="+resultjson[Current_stargeA];
+               magnificant.innerHTML = resultjson[Magnificant];
+               brightness.innerHTML = resultjson[Brightness];
+               contrast.innerHTML = resultjson[Contrast];
+               forcus.innerHTML = resultjson[Forcus];
+               voltage.innerHTML = resultjson[Voltage];                     
+               result.innerHTML = ajax.responseText; 
+             }else {
+               position1.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
diff --git a/JS/Currentcondition.js~ b/JS/Currentcondition.js~
new file mode 100644 (file)
index 0000000..936320f
--- /dev/null
@@ -0,0 +1,56 @@
+function Currentcondition() {
+
+ var ajax=getAjax();
+ if(command == "require"){
+       var position1 = document.getElementById("position");
+       var magnificant = document.getElementById("Magnificant");
+       var brightness = document.getElementById("Brightness");
+       var contrast = document.getElementById("Contrast");
+       var forcus = document.getElementById("Forcus");
+       var voltage = document.getElementById("Voltage");
+  }else {
+       var position1 = document.anchorsgetElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      position1.innerHTML="Onreadystate change error.";         
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(require),true);
+      //document.getElementById("mid").innerHTML="absolutex="+absolutex+" absolutey="+absolutey;        
+        }catch(e){
+      position1.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      position1.innerHTML ="send error";
+    }
+    
+  }else {
+       position1.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+                    var resultjson = ajax.responseText;
+                    position1.innerHTML = "x="+resultjson[Current_stargeX]+" y="+resultjson[Current_stargeY]+" z="+resultjson[Current_stargeZ]+" a="+resultjson[Current_stargeA];
+               magnificant.innerHTML = resultjson[Magnificant];
+               brightness.innerHTML = resultjson[Brightness];
+               contrast.innerHTML = resultjson[Contrast];
+               forcus.innerHTML = resultjson[Forcus];
+               voltage.innerHTML = resultjson[Voltage];                     
+               result.innerHTML = ajax.responseText; 
+             }else {
+               position1.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
diff --git a/JS/TemControl.js~ b/JS/TemControl.js~
new file mode 100755 (executable)
index 0000000..3f61145
--- /dev/null
@@ -0,0 +1,49 @@
+function TemControl(command,parameter){
+
+  var ajax = getAjax();
+
+  if(command == "Connect"){
+    var result = document.getElementById("connection");
+  }else{
+    var result = document.getElementById("result");
+  }
+
+  if(ajax){
+    try{
+      ajax.onreadystatechange = getData;
+    }catch(e){
+      result.innerHTML = "onreadystate change error";
+    }
+
+    try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&parameter="+encodeURIComponent(parameter),true);
+    }catch(e){
+      result.innerHTML = "ajax open error";
+    }
+
+    try{
+      ajax.send(null);
+    }catch(e){
+      result.innerHTML = "send error";
+    }
+  }else{
+    result.innerHTML = "you cannot use ajax...";
+  }
+
+  function getData(){
+    if(ajax.readyState == 4){
+      if(ajax.status == 200){
+       result.innerHTML = ajax.responseText;
+       if(ajax.responseText.match(/Control/i)){
+         a = ajax.responseText.split(" ");
+         alert(a[1]+a[2]);
+       }
+      }else{
+       result.innerHTML = "HTTP error";
+      }
+    }else{
+      result.innerHTML = "HTTP Transmission...";
+    }
+  }
+
+}
diff --git a/JS/ajax.js~ b/JS/ajax.js~
new file mode 100755 (executable)
index 0000000..0843b4f
--- /dev/null
@@ -0,0 +1,17 @@
+function getAjax(){
+       var ajax = null;
+       try{
+               ajax = new XMLHttpRequest();
+       }catch(e){
+               try{
+                       ajax = new ActiveXObject("Msxml2.XMLHTTP");
+               }catch(e){
+                       try{
+                               ajax = new ActiveXObject("Microsoft.XMLHTTP");
+                       }catch(e){
+                               alert("Not Init");
+                       }
+               }
+       }
+       return ajax;
+}
diff --git a/JS/filecontrol.js~ b/JS/filecontrol.js~
new file mode 100755 (executable)
index 0000000..fa62f37
--- /dev/null
@@ -0,0 +1,101 @@
+function fileListDialog(files){
+  var name = new Array();
+  var urn = new Array();
+  var type = new Array();
+  var size = new Array();
+  var latest = new Array();
+
+  
+    i=0
+    name[i] = files[i].name;
+    urn[i] = files[i].urn;
+    type[i] = files[i].type;
+    size[i] = files[i].size;
+    latest[i] = files[i].lastModifiedDate;
+
+  //display file status
+  var output = "<hr>The number of files is "+files.length+"<br><hr/>";
+    output+="Name:"+name[i]+"<br>"+"URN:"+urn[i]+"<br>"+"Type:"+type[i]+"<br>"+"Size:"+size[i]+"<br>"+"Date:"+latest[i]+"<br><hr>"
+  document.getElementById("filestatus").innerHTML = output;
+
+    document.getElementById("filecontent").innerHTML = "";
+  //get file contents
+  fileread(files,"filecontent","file");
+
+}
+
+function fileread(blob,place,variable){
+    var f = blob[i];
+    var reader = new FileReader();
+
+    if(f.type.match("text.*")){
+      reader.onload = function(e){
+       document.getElementById(place).innerHTML = reader.result;
+       document.getElementById(variable).value = reader.result;
+       document.getElementById("flag").value = "text";
+      }
+      reader.readAsText(f,"utf-8");
+    }
+    
+    if(f.type.match("image.*")){
+      reader.onload = function(e){
+       var img = document.createElement("img");
+       img.src = reader.result;
+       document.getElementById(place).appendChild(img);
+        document.getElementById(variable).value = reader.result;
+       document.getElementById("flag").value = "image";
+      }
+      reader.readAsDataURL(f);
+    }
+  
+}
+
+
+function onDrop(event){
+  var files = event.dataTransfer.files;
+  var disp = document.getElementById("disp");
+  disp.innerHTML = "";
+
+  for(i=0;i<files.length;i++){
+    var f = files[i];
+    var reader = new FileReader();
+
+    if(!f.type.match('image.*')&&!f.type.match('text.*')){
+      alert("Drag and Drop Image or Text file!");
+      continue;
+    }
+
+    reader.onerror = function(event){
+      disp.innerHTML = "read error!";
+    }
+    
+    if(f.type.match('text.*')){
+      reader.onload = function(event){
+       disp.innerHTML = event.target.result;
+       document.getElementById("file").value = reader.result;
+      }
+      reader.readAsText(f,"utf-8");
+    }
+
+    if(f.type.match('image.*')){
+      reader.onload = function(event){
+       var img = document.createElement("img");
+       img.src = event.target.result;
+       disp.appendChild(img);
+       document.getElementById("file").value = reader.result;
+      }
+      reader.readAsDataURL(f);
+    }
+  }
+
+  reader.addEventListener('progress',function(event){
+   document.getElementById("progress").innerHTML = Math.floor((event.loaded / event.total)*100);
+  },true);
+
+      event.preventDefault();
+}
+
+function onDragOver(event){
+  event.preventDefault();
+}
+
diff --git a/JS/filedownload.js~ b/JS/filedownload.js~
new file mode 100755 (executable)
index 0000000..e468aee
--- /dev/null
@@ -0,0 +1,43 @@
+function filewrite(){
+  var ajax = getAjax();
+  var result = document.getElementById("link");
+
+  if(ajax){
+    try{
+      ajax.onreadystatechange = getData;
+    }catch(e){
+      result.innerHTML = "onreadystatechange error!"
+    }
+
+    try{
+      ajax.open("GET","//localhost:8000/images/"+document.cameracontrol.input.value+".tif",true);
+      ajax.responseType = 'blob'
+    }catch(e){
+      result.innerHTML = "ajax open error!";
+    }
+
+    try{
+      ajax.send(null);
+    }catch(e){
+      result.innerHTML = "send error!";
+    }
+  }else{
+    result.innerHTML = "you cannot use ajax...";
+  }
+
+  function getData(){
+    if(ajax.readyState == 4){
+      if(ajax.status == 200){
+       var url = window.URL.createObjectURL(this.response)
+         dl_name = document.cameracontrol.dlname.value+"_"+document.cameracontrol.mode.value;
+       result.innerHTML = '<a href="'+url+'" download='+dl_name+'>download_link</a>';
+      }else{
+       result.innerHTML = "HTTP error!";
+      }
+    }else{
+      result.innerHTML = "HTTP Transmission!";
+    }
+  }
+
+}
+
diff --git a/JS/mscontrol.js b/JS/mscontrol.js
new file mode 100644 (file)
index 0000000..c1143f2
--- /dev/null
@@ -0,0 +1,45 @@
+function mscontrol(command,catchvalue) {
+ var ajax=getAjax();
+  if(command == "Brightnessset"){
+       var result = document.getElementById("Brightness");
+       }else if (command == "Voltageset") {
+       var result = document.getElementById("Voltage");
+  }else {
+       var result = document.getElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      result.innerHTML="Onreadystate change error.";    
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&catchvalue="+encodeURIComponent(catchvalue),true);         
+        }catch(e){
+      result.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      result.innerHTML ="send error";
+    }
+    
+  }else {
+       result.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+               result.innerHTML = ajax.responseText; 
+             }else {
+               result.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
diff --git a/JS/mscontrol.js~ b/JS/mscontrol.js~
new file mode 100644 (file)
index 0000000..3b51dbd
--- /dev/null
@@ -0,0 +1,45 @@
+function mscontrol(command,catchvalue) {
+ var ajax=getAjax();
+ if(command == "Brightnessset"){
+       var result = document.getElementById("Brightness");
+       }else if (command == "Voltageset") {
+       var result = document.getElementById("Voltage");
+  }else {
+       var result = document.getElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      result.innerHTML="Onreadystate change error.";    
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&catchvalue="+encodeURIComponent(catchvalue),true);         
+        }catch(e){
+      result.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      result.innerHTML ="send error";
+    }
+    
+  }else {
+       result.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+               result.innerHTML = ajax.responseText; 
+             }else {
+               result.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
diff --git a/JS/stagecontrol.js b/JS/stagecontrol.js
new file mode 100644 (file)
index 0000000..26ab173
--- /dev/null
@@ -0,0 +1,45 @@
+
+function stagecontrol(command,absolutex,absolutey,absolutez,absolutea) {
+ var ajax=getAjax();
+ if(command == "detailcatch"){
+       var result = document.getElementById("detail");
+  }else {
+       var result = document.getElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      result.innerHTML="Onreadystate change error.";    
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&x="+encodeURIComponent(absolutex)+"&y="+encodeURIComponent(absolutey)+"&z="+encodeURIComponent(absolutez)+"&a="+encodeURIComponent(absolutea),true);
+      //document.getElementById("mid").innerHTML="absolutex="+absolutex+" absolutey="+absolutey;        
+        }catch(e){
+      result.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      result.innerHTML ="send error";
+    }
+    
+  }else {
+       result.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+               result.innerHTML = ajax.responseText; 
+             }else {
+               result.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
diff --git a/JS/stagecontrol.js~ b/JS/stagecontrol.js~
new file mode 100644 (file)
index 0000000..7568b1a
--- /dev/null
@@ -0,0 +1,45 @@
+
+function stagecontrol(command,absolutex,absolutey,absolutez,absolutea) {
+ var ajax=getAjax();
+ if(command == "detailcatch"){
+       var result = document.getElementById("detail");
+  }else {
+       var result = document.anchorsgetElementById("result");
+  }
+  
+  if (ajax) {
+        try{
+          ajax.onreadystatechange = getData;
+        }catch(e){
+      result.innerHTML="Onreadystate change error.";    
+        }
+        
+        try{
+      ajax.open("GET","//localhost:8000/cgi-bin/vemclient.rb?command="+encodeURIComponent(command)+"&x="+encodeURIComponent(absolutex)+"&y="+encodeURIComponent(absolutey)+"&z="+encodeURIComponent(absolutez)+"&a="+encodeURIComponent(absolutea),true);
+      //document.getElementById("mid").innerHTML="absolutex="+absolutex+" absolutey="+absolutey;        
+        }catch(e){
+      result.innerHTML = "ajax open error";
+        }
+
+    try {
+        ajax.send(null);
+    }catch (e) {
+      result.innerHTML ="send error";
+    }
+    
+  }else {
+       result.innerHTML = "you cannot use ajax....";
+  }
+  
+  function getData() { 
+      if (ajax.readyState==4) {
+          if (ajax.status==200) {
+               result.innerHTML = ajax.responseText; 
+             }else {
+               result.innerHTML = "HTTP transmission....";
+            }
+       }
+  }
+ }
\ No newline at end of file
index 0f652a7..3b68e2d 100755 (executable)
@@ -1,2 +1,2 @@
-$activehost = '192.168.4.114'
-$activeport = '33333'
+$activehost = '192.168.4.218'
+$activeport = '11111'
diff --git a/cgi-bin/activetem.rb~ b/cgi-bin/activetem.rb~
new file mode 100755 (executable)
index 0000000..24305d4
--- /dev/null
@@ -0,0 +1,2 @@
+$activehost = '192.168.4.218'
+$activeport = '22222'
index be9b16c..8953b2c 100755 (executable)
@@ -1,18 +1,18 @@
-#!/usr/bin/ruby
+#!/usr/local/bin/ruby
 
 $tem = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc)}
 
 $tem = {
   'HITACHI' => {
-    'host' => '192.168.4.114',
+    'host' => '192.168.4.218',
     'port' => '11111'
   },
   'FEI' => {
-    'host' => '192.168.4.114',
+    'host' => '192.168.4.218',
     'port' => '22222'
   },
   'JEOL' => {
-    'host' => '192.168.4.114',
+    'host' => '192.168.4.218',
     'port' => '33333'
   }
 }
diff --git a/cgi-bin/implementation.rb~ b/cgi-bin/implementation.rb~
new file mode 100755 (executable)
index 0000000..c808d73
--- /dev/null
@@ -0,0 +1,19 @@
+#!/ruby/bin/ruby
+
+$tem = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc)}
+
+$tem = {
+  'HITACHI' => {
+    'host' => '192.168.4.218',
+    'port' => '11111'
+  },
+  'FEI' => {
+    'host' => '192.168.4.218',
+    'port' => '22222'
+  },
+  'JEOL' => {
+    'host' => '192.168.4.218',
+    'port' => '33333'
+  }
+}
+
index 41dccef..377b9c0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby
+#!/usr/local/bin/ruby
 
 require "socket"
 require "./cgi-bin/implementation"
diff --git a/cgi-bin/settem.rb~ b/cgi-bin/settem.rb~
new file mode 100755 (executable)
index 0000000..d71bef9
--- /dev/null
@@ -0,0 +1,41 @@
+#!/ruby/bin/ruby
+
+require "socket"
+require "./cgi-bin/implementation"
+require "./cgi-bin/activetem"
+
+class SetTem
+
+  def initialize(activetem)
+    @@tem = activetem
+    #get TEM_Instrument info
+    @@host = $tem["#{activetem}"]["host"]
+    @@port = $tem["#{activetem}"]["port"]
+
+    #set TEM_instrument info
+    tem = File.open("./cgi-bin/activetem.rb","w")
+    tem.write "$activehost = '#{@@host}'\n$activeport = '#{@@port}'\n"
+    
+    tem.close
+
+  end
+
+  def connect
+    
+    log = File.open("./File/log.txt","a")
+    socket = TCPSocket.open($activehost,$activeport)
+    socket.puts "Connect:#{@@tem}"
+    socket.flush
+
+    output = socket.gets
+    log.write output
+
+    log.close
+    socket.close
+
+    return output
+
+  end
+  
+end
+
index 0abff7d..5f5d633 100755 (executable)
@@ -1,10 +1,12 @@
-#!/usr/bin/ruby
+#!/usr/local/bin/ruby
 
 require "cgi"
 require "socket"
 require "./cgi-bin/settem"
 require "./cgi-bin/activetem"
+require "rubygems"
 require "systemu"
+require "json"
 
 cgi = CGI.new
 
@@ -14,6 +16,7 @@ command = CGI.unescapeHTML(command)
 parameter = cgi['parameter']
 parameter = CGI.unescapeHTML(parameter)
 
+
 case command
 
 when "Connect" then
@@ -24,12 +27,12 @@ when "StageSet", "MagnificationSet", "ImageShift" then
   socket = TCPSocket.open($activehost,$activeport)
   socket.puts parameter
 
+  
   result = socket.gets.chomp
   if result == "Accepted!" then
     tiff2gif = "source Eos/env/Eos_env;tiff2mrc -i images/download.tif -o images/download.mrc;mrc2gif -i images/download.mrc -o images/download.gif"
     systemu tiff2gif
   end
-
   result = "<img src = 'images/download.gif' height=200 width=400><br>"
 
 
@@ -40,8 +43,39 @@ when "StageSet", "MagnificationSet", "ImageShift" then
 when "Control" then
   socket = TCPSocket.open($activehost,$activeport)
   socket.puts "Control:#{parameter}"
-
   result = socket.gets
+  
+when "detailcatch" then
+
+  socket = TCPSocket.open($activehost,$activeport)
+     
+  movex=cgi['x']
+  movex=CGI.unescapeHTML(movex)
+  movey=cgi['y'] 
+  movey=CGI.unescapeHTML(movey)
+  movez=cgi['z'] 
+  movez=CGI.unescapeHTML(movez)
+  tilta=cgi['a'] 
+  tilta=CGI.unescapeHTML(tilta)
+
+  position={"Command"=>"Control","Parameter"=>"StargesetA","GonionXA"=>movex.to_i,"GonionYA"=>movey.to_i,"GonionZA"=>movez.to_i,"GonionAA"=>tilta.to_i}
+
+=begin .to_json not use!
+  socket.puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
+  puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
+=end
+
+  positionj=position.to_json
+  socket.puts   positionj
+  puts positionj
+
+  result = "move x ="+movex.to_s+" move y ="+movey.to_s+" move z ="+movez.to_s+" tilt a ="+tilta.to_s+"<br>"
+
+when "currentcondition" then
+ socket = TCPsocket.open($activehost,$activeport)
+ sosket.puts '{"Command":"Require"}'
+ result = socket.gets 
+  
 
 when "TakePhoto" then
   filename = parameter.split(":")
@@ -50,6 +84,33 @@ when "TakePhoto" then
 
   result = "<img src = 'images/#{filename[1]}.gif' height=400 width=400><br>"
 
+when "Brightnessset" then
+   
+   socket = TCPSocket.open($activehost,$activeport)
+   Bv=cgi['catchvalue']
+   Bv=CGI.unescapeHTML(Bv)
+   
+   brightinfo={"Command"=>"Control","Parameter"=>"Brightnessset","Brightvalue"=>Bv.to_i}
+   
+   brightinfoj=brightinfo.to_json
+   socket.puts brightinfoj
+   puts brightinfoj  
+   result = "Brightness: "+Bv.to_s
+
+when "Voltageset" then
+
+   socket = TCPSocket.open($activehost,$activeport)
+   Voltagevalue=cgi['catchvalue']
+   Voltagevalue=CGI.unescapeHTML(Voltagevalue)
+   
+   voltageinfo={"Command"=>"Control","Parameter"=>"Voltageset","Voltagevalue"=>Voltagevalue.to_i}
+   
+   voltageinfoj=voltageinfo.to_json
+   socket.puts voltageinfoj
+   puts voltageinfoj
+   
+   result = "Volatege : "+Voltagevalue.to_s+"<br>"
+
 else
   #do_something_other
 end
diff --git a/cgi-bin/vemclient.rb~ b/cgi-bin/vemclient.rb~
new file mode 100755 (executable)
index 0000000..a0e5429
--- /dev/null
@@ -0,0 +1,124 @@
+#!/usr/local/bin/ruby
+
+require "cgi"
+require "socket"
+require "./cgi-bin/settem"
+require "./cgi-bin/activetem"
+require "rubygems"
+require "systemu"
+require "json"
+
+cgi = CGI.new
+
+command = cgi['command']
+command = CGI.unescapeHTML(command)
+
+parameter = cgi['parameter']
+parameter = CGI.unescapeHTML(parameter)
+
+
+case command
+
+when "Connect" then
+  temset = SetTem.new(parameter)
+  result = temset.connect
+
+when "StageSet", "MagnificationSet", "ImageShift" then
+  socket = TCPSocket.open($activehost,$activeport)
+  socket.puts parameter
+
+  
+  result = socket.gets.chomp
+  if result == "Accepted!" then
+    tiff2gif = "source Eos/env/Eos_env;tiff2mrc -i images/download.tif -o images/download.mrc;mrc2gif -i images/download.mrc -o images/download.gif"
+    systemu tiff2gif
+  end
+  result = "<img src = 'images/download.gif' height=200 width=400><br>"
+
+
+#when something then
+  #do_something
+  #
+  #
+when "Control" then
+  socket = TCPSocket.open($activehost,$activeport)
+  socket.puts "Control:#{parameter}"
+  result = socket.gets
+  
+when "detailcatch" then
+
+  socket = TCPSocket.open($activehost,$activeport)
+     
+  movex=cgi['x']
+  movex=CGI.unescapeHTML(movex)
+  movey=cgi['y'] 
+  movey=CGI.unescapeHTML(movey)
+  movez=cgi['z'] 
+  movez=CGI.unescapeHTML(movez)
+  tilta=cgi['a'] 
+  tilta=CGI.unescapeHTML(tilta)
+
+  position={"Command"=>"Control","Parameter"=>"StargesetA","GonionXA"=>movex.to_i,"GonionYA"=>movey.to_i,"GonionZA"=>movez.to_i,"GonionAA"=>tilta.to_i}
+
+=begin .to_json not use!
+  socket.puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
+  puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
+=end
+
+  positionj=position.to_json
+  socket.puts   positionj
+  puts positionj
+
+  result = "move x ="+movex.to_s+" move y ="+movey.to_s+" move z ="+movez.to_s+" tilt a ="+tilta.to_s+"<br>"
+
+when "currentcondition" then
+ socket = TCPsocket.open($activehost,$activeport)
+ sosket.puts '{"Command":"Require"}'
+ result = socket.gets 
+  
+
+when "TakePhoto" then
+  filename = parameter.split(":")
+  tiff2gif = "source Eos/env/Eos_env;tiff2mrc -i images/#{filename[0]}.tif -o images/#{filename[0]}.mrc;mrc2gif -i images/#{filename[0]}.mrc -o images/#{filename[1]}.gif"
+  systemu tiff2gif
+
+  result = "<img src = 'images/#{filename[1]}.gif' height=400 width=400><br>"
+
+when "Brightnessset" then
+   
+   socket = TCPSocket.open($activehost,$activeport)
+   Bv=cgi['catchvalue']
+   Bv=CGI.unescapeHTML(Bv)
+   
+   brightinfo={"Command"=>"Control","Parameter"=>"Brightnessset","Brightvalue"=>Bv.to_i}
+   
+   brightinfoj=brightinfo.to_json
+   socket.puts brightinfoj
+   puts brightinfoj
+   
+   result = Bv.to_s
+
+when "Voltageset" then
+
+   socket = TCPSocket.open($activehost,$activeport)
+   Voltagevalue=cgi['catchvalue']
+   Voltagevalue=CGI.unescapeHTML(Voltagevalue)
+   
+   voltageinfo={"Command"=>"Control","Parameter"=>"Voltageset","Voltagevalue"=>Voltagevalue.to_i}
+   
+   voltageinfoj=voltageinfo.to_json
+   socket.puts voltageinfoj
+   puts voltageinfoj
+   
+   result = "Volatege : "+Voltagevalue.to_s+"<br>"
+
+else
+  #do_something_other
+end
+
+
+#return ajax-engine::create HTML code
+puts "Content-type: text/html\n\n"
+puts ""
+
+puts result
index 4725b53..c1d84f7 100755 (executable)
--- a/vem.html
+++ b/vem.html
@@ -8,6 +8,9 @@
     <script type ="text/javascript" src="JS/TemControl.js"></script>
     <script type ="text/javascript" src="JS/filecontrol.js"></script>
     <script type ="text/javascript" src="JS/filedownload.js"></script>
+    <script type ="text/javascript" src="JS/stagecontrol.js"></script>
+    <script type ="text/javascript" src="JS/mscontrol.js"></script>
+    <script type="text/javascript"></script>
   </head>
   <body>
 
              <input type="button" style="width:150px;" name="submit" value="TakePhoto" onclick="TemControl('TakePhoto',document.cameracontrol.input.value+':'+document.cameracontrol.output.value);">
            </div>
            <p class ="clearRight" />
+           
          </div>
 
          <div id="download">
+
            <div id="left">
              <p>Mode<input type="text" name="mode" class="box" size="30"></input>
              <br>
            </div>
            <p class ="clearRight" />
          </div>
-
+         
+   <div id="stagecontrol">
+      <div id="left">
+        <br>
+        Absolute coordinate
+        <p>move x <input type="text" name="x" class="box" size="30" ></input>
+        <br>
+        move y <input type="text" name="y" class="box" size="30"></input>
+        <br>
+        move z <input type="text" name="z"= class="box" size="30"></input>
+        <br>
+        tilt a <input type="text" name="a" class="box" size="30"></input>
+        <br>
+        </p>
+        <br>
+        <p>Brightnessset(0~200)
+        <input type="text" name="brightness"></p> 
+        <p>Voltageset (0~120kV)
+        <input type="text" name="voltage"></p> 
+        </p>   
+      </div>
+      
+      <div id="right">
+      <br>
+      <br>
+      <br>
+      <br>
+         <input type="button" style="width:150px;" name="submit" value="Detailset" onclick="stagecontrol('detailcatch',x.value,y.value,z.value,a.value)"></input> 
+          <br>
+         <input type="button" style="width:150px;" name="submit" value="Autoset" onclick="alert('Under construction! Only use Detailset!')"></input>
+      <br>
+      <br>
+      <br>
+      <br>
+         <input type="button" style="widrh:150px;" name="submit" value="Brightnessset" onclick="mscontrol('Brightnessset',brightness.value)"></input>
+         <br>
+          <br>
+         <input type="button" style="widrh:150px;" name="submit" value="Voltageset" onclick="mscontrol('Voltageset',voltage.value)"></input>                
+      </div>
+         
+   </div>
+         
+         </div>
+         
+         
        </form>
-
-       <br>
+       
       </div>
 
       <div id="rightside">
-
        <p>TEM Control Command</p>
-       <div id="command" style="width:340px; height:570px; padding:10px; border:6px outset">The EM-control commandset.</div>
-
+       <div id="command" style="width:340px; height:570px; padding:10px; border:6px outset">The EM-control commandset.
+       <br>
+       <br>
+       <div id="detail"></div>         
+       </div>
+
+   <br>
+       
+       <p>Current condition</p>
+       <div id="condition" style="width:340px; height:250; padding:10px; border:6px outset">
+       <div id="Position">Position: </div>
+       <div id="Magnificant">Magnificant: </div>
+       <div id="Brightness">Brightness:</div>          
+       <div id="Contrast">Contrast: </div>
+       <div id="Forcus">Forcus:  </div>
+       <div id="Voltage">Voltage: </div>
+       </div>  
+       
+       
       </div>
-
     </div>
 
   </body>
diff --git a/vem.html~ b/vem.html~
new file mode 100755 (executable)
index 0000000..77b4b0e
--- /dev/null
+++ b/vem.html~
@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>VEM Control Interface</title>
+    <link rel="stylesheet" type="text/css" href="CSS/vemclient.css">
+    <script type ="text/javascript" src="JS/ajax.js"></script>
+    <script type ="text/javascript" src="JS/TemControl.js"></script>
+    <script type ="text/javascript" src="JS/filecontrol.js"></script>
+    <script type ="text/javascript" src="JS/filedownload.js"></script>
+    <script type ="text/javascript" src="JS/stagecontrol.js"></script>
+    <script type ="text/javascript" src="JS/mscontrol.js"></script>
+    <script type="text/javascript"></script>
+  </head>
+  <body>
+
+    <b>V</b>irtual <b>E</b>lectron <b>M</b>icroscope Client
+
+    <form id="temselect" name="temselect" action="#" onsubmit="return false;">
+      <input type="hidden" id="teminfo" name="teminfo" value="none"></input>
+      <input type="button" name="submit" id="HITACHI" onclick="TemControl('Connect','HITACHI');"></input>
+      <input type="button" name="submit" id="FEI" onclick="TemControl('Connect','FEI');"></input>
+      <input type="button" name="submit" id="JEOL" onclick="TemControl('Connect','JEOL');"></input>
+    </form>
+    <br>
+    <div id="connection" style="width:600px; height:20px; border:3px inset; margin:0 auto">
+
+    </div>
+
+
+    <div id="container">
+
+      <div id="leftside">
+
+       <p>The EM Image</p>
+       <div id="result" style="margin:0 auto; width:400px; height:400px; padding:10px; border:3px solid">The EM-Image from instrument.</div>
+
+       <form id="cameracontrol" name="cameracontrol" action="#" onsubmit="return false;">
+         <input type="hidden" id="fileurl" name="fileurl" value="none"></input>
+
+         <br>
+         <input type="button" style="width:150px;" name="submit" value="Initialization" onclick="TemControl('Control','initialization');"></input>
+         <input type="button" style="width:150px;" name="submit" value="Finalization" onclick="TemControl('Control','finalization');"></input>
+         <br>
+
+         <div id="takephoto">
+           <div id="left">
+             <p>Input<input type="text" name="input" class="box" size="30"></input>
+             <br>
+             Output<input type="text" name="output" class="box" size="30"></input>
+             </p>
+           </div>
+           <br>
+           <div id="right">
+             <input type="button" style="width:150px;" name="submit" value="TakePhoto" onclick="TemControl('TakePhoto',document.cameracontrol.input.value+':'+document.cameracontrol.output.value);">
+           </div>
+           <p class ="clearRight" />
+           
+         </div>
+
+         <div id="download">
+
+           <div id="left">
+             <p>Mode<input type="text" name="mode" class="box" size="30"></input>
+             <br>
+             DL<input type="text" name="dlname" class="box" size="30"></input>
+             </p>
+           </div>
+           <br>
+           <div id="right">
+             <input type="button" style="width:150px;" name="submit" value="Download" onclick="filewrite();">
+             <p id="link"></p>
+           </div>
+           <p class ="clearRight" />
+         </div>
+         
+   <div id="stagecontrol">
+      <div id="left">
+        <br>
+        Absolute coordinate
+        <p>move x <input type="text" name="x" class="box" size="30" ></input>
+        <br>
+        move y <input type="text" name="y" class="box" size="30"></input>
+        <br>
+        move z <input type="text" name="z"= class="box" size="30"></input>
+        <br>
+        tilt a <input type="text" name="a" class="box" size="30"></input>
+        <br>
+        </p>
+        <br>
+        <p>Brightnessset(0~200)
+        <input type="text" name="brightness"></p> 
+        <p>Voltageset (0~120kV)
+        <input type="text" name="voltage"></p> 
+        </p>   
+      </div>
+      
+      <div id="right">
+      <br>
+      <br>
+      <br>
+      <br>
+         <input type="button" style="width:150px;" name="submit" value="Detailset" onclick="stagecontrol('detailcatch',x.value,y.value,z.value,a.value)"></input> 
+          <br>
+         <input type="button" style="width:150px;" name="submit" value="Autoset" onclick="alert('Under construction! Only use Detailset!')"></input>
+      <br>
+      <br>
+      <br>
+      <br>
+         <input type="button" style="widrh:150px;" name="submit" value="Brightnessset" onclick="mscontrol('Brightnessset',brightness.value)"></input>
+         <br>
+          <br>
+         <input type="button" style="widrh:150px;" name="submit" value="Voltageset" onclick="mscontrol('Voltageset',voltage.value)"></input>                
+      </div>
+         
+   </div>
+         
+         </div>
+         
+         
+       </form>
+       
+      </div>
+
+      <div id="rightside">
+       <p>TEM Control Command</p>
+       <div id="command" style="width:340px; height:570px; padding:10px; border:6px outset">The EM-control commandset.
+       <br>
+       <br>
+       <div id="detail"></div>         
+       </div>
+
+   <br>
+       
+       <p>Current condition</p>
+       <div id="condition" style="width:340px; height:250; padding:10px; border:6px outset">
+       Position: <div id="Position"></div>
+       Magnificant: <div id="Magnificant"></div>
+       <div id="Brightness">Brightness:</div>          
+       Contrast:  <div id="Contrast"></div>
+       Forcus:  <div id="Forcus"></div>
+       Voltage: <div id="Voltage"></div>
+       </div>  
+       
+       
+      </div>
+    </div>
+
+  </body>
+</html>
index c308ed3..6a110ea 100755 (executable)
@@ -7,7 +7,7 @@ class FEIControlServer
   @@flag = true
 
   def initialize()
-    @server = TCPServer.open("192.168.4.114",11111)
+    @server = TCPServer.open("192.168.4.218",11111)
     puts @server.to_s
   end
 
diff --git a/vemserver.rb~ b/vemserver.rb~
new file mode 100755 (executable)
index 0000000..6a110ea
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/ruby
+
+require "socket"
+require "thread"
+
+class FEIControlServer
+  @@flag = true
+
+  def initialize()
+    @server = TCPServer.open("192.168.4.218",11111)
+    puts @server.to_s
+  end
+
+  def listener
+    while @@flag
+      Thread.start(@server.accept){|socket|
+       begin
+         line = socket.gets.chomp
+         puts line
+         socket.puts "Accepted!"
+         
+
+       ensure
+         socket.close
+       
+       end
+      }
+    end
+  end
+
+end
+
+fei = FEIControlServer.new
+fei.listener
+