width:1000px;
margin-left:auto;
margin-right:auto;
-
}
#leftside{
div#left{
float:left;
position:absolute;
- left:100px;
+ left:200px;
+ text-align:left;
}
div#right{
position:relative;
--- /dev/null
+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;
+}
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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)+"¶meter="+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...";
+ }
+ }
+
+}
--- /dev/null
+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;
+}
--- /dev/null
+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();
+}
+
--- /dev/null
+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!";
+ }
+ }
+
+}
+
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+
+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
--- /dev/null
+
+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
-$activehost = '192.168.4.114'
-$activeport = '33333'
+$activehost = '192.168.4.218'
+$activeport = '11111'
--- /dev/null
+$activehost = '192.168.4.218'
+$activeport = '22222'
-#!/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'
}
}
--- /dev/null
+#!/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'
+ }
+}
+
-#!/usr/bin/ruby
+#!/usr/local/bin/ruby
require "socket"
require "./cgi-bin/implementation"
--- /dev/null
+#!/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
+
-#!/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
parameter = cgi['parameter']
parameter = CGI.unescapeHTML(parameter)
+
case command
when "Connect" 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 "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(":")
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
--- /dev/null
+#!/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
<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>
--- /dev/null
+<!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>
@@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
--- /dev/null
+#!/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
+