5 require "./cgi-bin/settem"
6 require "./cgi-bin/activetem"
13 command = cgi['command']
14 command = CGI.unescapeHTML(command)
16 parameter = cgi['parameter']
17 parameter = CGI.unescapeHTML(parameter)
23 temset = SetTem.new(parameter)
24 result = temset.connect
26 when "StageSet", "MagnificationSet", "ImageShift" then
27 socket = TCPSocket.open($activehost,$activeport)
31 result = socket.gets.chomp
32 if result == "Accepted!" then
33 tiff2gif = "source Eos/env/Eos_env;tiff2mrc -i images/download.tif -o images/download.mrc;mrc2gif -i images/download.mrc -o images/download.gif"
36 result = "<img src = 'images/download.gif' height=200 width=400><br>"
44 socket = TCPSocket.open($activehost,$activeport)
46 control={"Command"=>"Connect","Parameter"=>parameter}
47 controlj=control.to_json
53 when "detailcatch" then
55 socket = TCPSocket.open($activehost,$activeport)
58 movex=CGI.unescapeHTML(movex)
60 movey=CGI.unescapeHTML(movey)
62 movez=CGI.unescapeHTML(movez)
64 tilta=CGI.unescapeHTML(tilta)
66 position={"Command"=>"Control","Parameter"=>"StagesetA","GonionXA"=>movex.to_i,"GonionYA"=>movey.to_i,"GonionZA"=>movez.to_i,"GonionAA"=>tilta.to_i}
68 =begin .to_json not use!
69 socket.puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
70 puts "{'Command':'Control','Parameter':'StargesetA','GonionX':"+movex.to_s+",'GonionY':"+movey.to_s+",'GonionZ':"+movez.to_s+",'GonionA':"+tilta.to_s+"}"
73 positionj=position.to_json
79 result = "move x ="+movex.to_s+" move y ="+movey.to_s+" move z ="+movez.to_s+" tilt a ="+tilta.to_s+"<br>"
82 socket = TCPSocket.open($activehost,$activeport)
83 request = {"Command"=>"Request"}
84 requestj = request.to_json
89 currentcondition=socket.gets
90 currentcondition = JSON.parse(currentcondition)
94 filename = parameter.split(":")
95 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"
98 result = "<img src = 'images/#{filename[1]}.gif' height=400 width=400><br>"
100 when "Brightnessset" then
102 socket = TCPSocket.open($activehost,$activeport)
104 Bv=CGI.unescapeHTML(Bv)
106 brightinfo={"Command"=>"Control","Parameter"=>"Brightnessset","Brightvalue"=>Bv.to_i}
108 brightinfoj=brightinfo.to_json
109 socket.puts brightinfoj
111 result = "Brightness: "+Bv.to_s
113 when "Voltageset" then
115 socket = TCPSocket.open($activehost,$activeport)
116 Voltagevalue=cgi['catchvalue']
117 Voltagevalue=CGI.unescapeHTML(Voltagevalue)
119 voltageinfo={"Command"=>"Control","Parameter"=>"Voltageset","Voltagevalue"=>Voltagevalue.to_i}
121 voltageinfoj=voltageinfo.to_json
122 socket.puts voltageinfoj
125 result = "Volatege : "+Voltagevalue.to_s+"<br>"
127 when "EucentricHeight" then
128 socket = TCPSocket.open($activehost,$activeport)
130 max=CGI.unescapeHTML(max)
132 speed=CGI.unescapeHTML(speed)
134 place=CGI.unescapeHTML(place)
136 currentcondition={"ap"=>0}
137 currentcondition["ap"]=currentcondition["ap"].to_i+place.to_i
139 eucentricheightinfo={"Command"=>"Control","Parameter"=>"EucentricHeight","max"=>max.to_i,"speed"=>speed.to_i,"place"=>currentcondition["ap"].to_i}
141 eucentricheightinfoj=eucentricheightinfo.to_json
142 socket.puts eucentricheightinfoj
143 puts eucentricheightinfoj
145 result = eucentricheightinfoj
152 #return ajax-engine::create HTML code
153 puts "Content-type: text/html\n\n"