From 8b463f2f6b0ae131734b391cdacabf7ef8aafc5e Mon Sep 17 00:00:00 2001 From: yonghong1969 Date: Thu, 24 Mar 2016 17:46:23 +0900 Subject: [PATCH] all files of WITs --- JS/em.js | 95 ++++++++++++-- JS/realtimeCamera.js | 173 +++++++++++++++++++++++--- JS/userSetting.js | 167 ++++++++++++++++++++++--- index.html | 67 ++++------ simplePhoto.html | 346 ++++++++++++++++++++++----------------------------- 5 files changed, 559 insertions(+), 289 deletions(-) diff --git a/JS/em.js b/JS/em.js index c07ba30..d4c9334 100644 --- a/JS/em.js +++ b/JS/em.js @@ -4,6 +4,23 @@ var UrlElement = userSetting.GetUrlElementInstance(); var hello = userSetting.sayHello; console.log(UrlElement['sendIpAddress']); +var LoadLogMemory = new LogMemory(); +var GETLogMemory = LoadLogMemory.LogMemoryInstance(); +var MemoryAll = LoadLogMemory.GETLog(); + +/* +getCurrentParams() +clickMove() +setStage() +setSpotSize() +setMagnificationA() +setMagnificationR() +correntConditionText() +setSpotSize() +setMagnificationR() +setMagnificationA() +nowCondition() +*/ function getCurrentParams(){ @@ -22,8 +39,6 @@ console.log("getcurrentparams"); }); } - - function clickMove(direction){ var movingdistance = $("#movingdistance").val(); var movexr = $("#movex").val(); @@ -47,23 +62,21 @@ switch(directionSwitch){ break; case "Left": - movexr = parseInt(movexr) - (parseInt(movingdistance)); + movexr = parseInt(movexr) + (parseInt(movingdistance)); $("#movex").val(String(movexr)); break; case "Right": - movexr = parseInt(movexr) + (parseInt(movingdistance)); + movexr = parseInt(movexr) - (parseInt(movingdistance)); $("#movex").val(String(movexr)); $("#currentx").val(String(movexr)); break; } $.ajax({ type:"GET", - //電子顕微鏡通信時 - // url:"http://192.168.4.146:9090/fei/set/stagea?x="+encodeURIComponent(movexr)+ - //モック url:"http://" +UrlElement['sendIpAddress']+ - ":"+UrlElement['sendPortNumber']+"/fei/set/stagea?x="+encodeURIComponent(movexr)+ + ":"+UrlElement['sendPortNumber']+"/"+UrlElement['sendManufacturer']+ + "/set/stagea?x="+encodeURIComponent(movexr)+ "&y="+encodeURIComponent(moveyr)+ "&z="+encodeURIComponent(movezr)+ "&a="+encodeURIComponent(movezr), @@ -78,9 +91,6 @@ function setStage(){ var movexr = $("#movex").val(); var moveyr = $("#movey").val(); var movezr = $("#movez").val(); -console.log("movingdistance="+movingdistance); -console.log("movex="+movexr); -console.log("movey="+moveyr); $("#movey").keydown(function(e){ console.log(e.keyCode); @@ -99,6 +109,8 @@ console.log("movey="+moveyr); }); $("#movex").keydown(function(e){ + console.log(e.keyCode); + console.log(typeof(e.keyCode)); //RIGHT(→,a,k) if (e.keyCode == 39 || e.keyCode == 68 || e.keyCode == 76) { movexr = parseInt(movexr) + (parseInt(movingdistance)-1); @@ -117,7 +129,7 @@ console.log("movey="+moveyr); // url:"http://192.168.4.146:9090/fei/set/stagea?x="+encodeURIComponent(movexr)+ url:"http://"+UrlElement['sendIpAddress']+ ":"+UrlElement['sendPortNumber']+ - "/"+UrlElement['sendElectronMicroscopeName']+ + "/"+UrlElement['sendManufacturer']+ "/set/stagea?x="+encodeURIComponent(movexr)+ "&y="+encodeURIComponent(moveyr)+ "&z="+encodeURIComponent(movezr)+ @@ -136,3 +148,62 @@ function currentConditionText(){ console.log("currentcondition"); $("#Currentcondition").innerHTML='x:"movexr" y:"moveyr" z:"movezr"' } + +function setSpotSize(){ + var setSpotSize = $("#SpotSize").val(); + $.ajax({ + type:"GET", + url:"http://"+UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+ + "/"+UrlElement['sendManufacturer']+ + "/set/spotsizea?sps="+encodeURIComponent(setSpotSize), + success: function(data){ + console.log(data); + } + }); +} + +function setMagnificationA(){ + var magnificationA = $("#magnificationA").val(); + $.ajax({ + type:"GET", + url:"http://"+UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+ + "/"+UrlElement['sendManufacturer']+ + "/set/magnificationa?mag="+encodeURIComponent(magnificationA), + success: function(data){ + console.log(data); + } + }); +} +function setMagnificationR(){ + var magnificationR = $("#magnificationR").val(); + $.ajax({ + type:"GET", + url:"http://"+UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+ + "/"+UrlElement['sendManufacturer']+ + "/set/magnificationr?mag="+encodeURIComponent(magnificationR), + success: function(data){ + console.log(data); + } + }); +} + +function nowCondition(){ + var movexr = $("#movex").val(); + var moveyr = $("#movey").val(); + var movezr = $("#movez").val(); + var movea = $("#movea").val(); + var spotSize = $("#spotSize").val(); + var exptime = $("#exptime").val(); + var manufacturer = UrlElement['sendElectronMicroscopeName']; + document.getElementById("tem").innerHTML = manufacturer; + document.getElementById("currentx").innerHTML = parseInt(movexr); + document.getElementById("currenty").innerHTML = parseInt(moveyr); + document.getElementById("currentz").innerHTML = parseInt(movezr); + document.getElementById("currenta").innerHTML = parseInt(movea); + document.getElementById("SpotSizeIndex").innerHTML = parseInt(spotSize); + document.getElementById("MagIndex").innerHTML = parseInt(magnificationA); + +} diff --git a/JS/realtimeCamera.js b/JS/realtimeCamera.js index 9e2a82f..e633aba 100644 --- a/JS/realtimeCamera.js +++ b/JS/realtimeCamera.js @@ -1,6 +1,6 @@ - var ws ; var i = 0; +var toggleSwitch =0; var params = { size : 0, binninb : 1, @@ -12,29 +12,89 @@ var UrlElement = userSetting.GetUrlElementInstance(); var hello = userSetting.sayHello; console.log(UrlElement['sendIpAddress']); -function conectionStart(){ +/*function +wsConnectionSwitch(); +apiConnectionSwitch(); +setParams(); +settings() +connection() +image() +simplePhotoCamera() + +*/ + + + +function wsConnectionSwitch(){ + setParams(); + var data; + toggleSwitch ^= 1 ; + switch(toggleSwitch){ + case 1: ws = new WebSocket("ws://"+UrlElement['sendIpAddress']+":3001"); ws.onopen = function(){ + console.log('websocket connected') // ws.send('req'); }; -/* ws.onerror = function(error){ - console.log('websocket error' + error); - };*/ + document.getElementById("wsConnectBtn").value = "websocket close"; ws.onmessage = function(ture){ data = JSON.parse(ture.data) console.log('server:' +data["type"]); - switch(data["type"]){ - case "connection": - connection(data); - break; - - case "img": - image(data); - break; - } + switch(data["type"]){ + case "connection": + connection(data); + break; + + case "img": + image(data); + break; + } +}; + break; + + case 0: + ws.close(); + console.log('closed'); + document.getElementById("wsConnectBtn").value = "websocket start"; + break; } } +function apiConnectionSwitch(){ +toggleSwitch ^= 1; +switch(toggleSwitch){ + case 1: + //start + $.ajax({ + type:"GET", + url:"http://" +UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+"/"+UrlElement['sendManufacturer']+ + "/set/", + success: function(data){ + console.log(data);//string型 + } + }); + document.getElementById("apiConnectBtn").value = "API close"; + break; + + case 0: +//stop + $.ajax({ + type:"GET", + url:"http://" +UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+"/"+UrlElement['sendManufacturer']+ + "/set/", + success: function(data){ + console.log(data);//string型 + } + }); + document.getElementById("apiConnectBtn").value = "API start"; + break; +}; +} + + + function setParams(){ settings(); } @@ -48,7 +108,7 @@ function settings(){ } $.ajax({ type:"GET", - url:"http://"+$ipAddress+":"+$port+"/fei/set/acq_init?bng="+params["binning"]+"&&exp="+params["exptime"]+"&&size="+params["size"], + url:"http://"+UrlElement["sendipAddress"]+":"+UrlElement["sendPortNumber"]+"/"+UrlElement["sendManufacturer"]+"/set/acq_init?bng="+params["binning"]+"&&exp="+params["exptime"]+"&&size="+params["size"], success: function(data){ } }); @@ -59,21 +119,94 @@ ws.send('{"type":"req", "data":"img"}'); } function image(data){ -console.log(data); ws.send('{"type":"req", "data":"img"}'); drawMycrograph(data.data); } -function connectionClose(){ - ws.close(); + +function simplePhotoCamera(){ + var simplePhotoImage = $("canvasOne").val(); } +window.onload=canvasMap; +function canvasMap(){ + var canvas = document.getElementById("canvasMap"); + var ctx = canvas.getContext("2d"); + var x = $("#movex").val(); + var y = $("#movey").val(); + var z = $("#movez").val(); + var a = $("#movea").val(); + ctx.beginPath(); + ctx.fillStyle = "#808080"; + ctx.arc(100,100,100,0,Math.PI*2,true); + ctx.fill(); + ctx.closePath(); -function simplePhotoCamera(){ - var simplePhotoImage = $("canvasOne").val(); + canvas.addEventListener("mousedown",function(e){ + $.ajax({ + type:"GET", + url:"http://"+UrlElement['sendIpAddress']+ + ":"+UrlElement['sendPortNumber']+ + "/"+UrlElement['sendManufacturer']+ + "/set/stagea?x="+encodeURIComponent(movexr)+ + "&y="+encodeURIComponent(moveyr)+ + "&z="+encodeURIComponent(movezr)+ + "&a="+encodeURIComponent(movezr), + success: function(data){ + console.log(data); + } + }); + }); +} +/* +function canvasMapDraw(){ + var step = (1/2000);//倍率変化はここの通知を変化 + var canvas = document.getElementById("canvasMap"); + var ctx = canvas.getContext("2d"); + var x = $("#movex").val(); + var y = $("#movey").val(); + if(x == 0 || y==0){ + ctx.beginPath(); + ctx.fillStyle = "#000000"; + ctx.moveTo(100,100); + ctx.lineTo((parseInt(x)*step+100,-(parseInt(y)*step)+100); + //ctx.lineTo(150,100) + ctx.closePath(); + ctx.stroke(); + moveX = (parseInt(x)*step)+100; + moveY = -(parseInt(y)*step)+100; +} + else if(x !=0 || y!= 0){ + ctx.beginPath(); + ctx.fillStyle = "#000000"; + ctx.moveTo(moveX,moveY); + ctx.lineTo((parseInt(x)*step+100,-(parseInt(y)*step)+100); + //ctx.lineTo(150,100) + ctx.closePath(); + ctx.stroke(); + moveX = (parseInt(x)*step)+100; + moveY = -(parseInt(y)*step)+100; +} +} +*/ +/*window.onload = drawCanvasMap; +function drawCanvasMap(){ + var drawCanvas = document.getElementById("canvasMap"); + var ctx = drawCanvas.getContext("2D"); +// if(canvas.getContext){ + var x = $("#movex").val(); + var y = $("#movey").val(); + ctx.fillStyle = "#000000"; + ctx.beginPath(); + ctx.moveTo(parseInt(x)+100,parseInt(y)+100); + ctx.lineTo(150,100); + ctx.closePath(); + ctx.stroke(); +//} } +*/ diff --git a/JS/userSetting.js b/JS/userSetting.js index 0894187..27bb71a 100644 --- a/JS/userSetting.js +++ b/JS/userSetting.js @@ -1,20 +1,22 @@ +/* +UserSetting() +GetUrlElement() +IndexReadEmCondtionText +SaveEmConditionFile() +IndexSaveEmConditionFile() +IndexReadEmCondtionTextArg() +*/ + + + function UserSetting(){ - var $ipAddress = $("#ipAddress").val(); - var $port = $("#portNumber").val(); - var $manufacturer = $("#manufacturer").val(); - var $electoronMicroscopeName = $("#electoronMicroscopeName").val(); - console.log($port); - console.log($ipAddress); -/* - $.ajax({ - type:"GET", - url:"//" +$ipAddress+ ":" +$port+ "/"+manufacturer+"/get", - success: function(data){ - console.log(data); - } - });*/ + var $ipAddress = $("#ipAddress").val(); + var $port = $("#portNumber").val(); + var $manufacturer = $("#manufacturer").val(); + var $electronMicroscopeName = $("#electronMicroscopeName").val(); + } function GetUrlElement(){ @@ -25,12 +27,147 @@ function GetUrlElement(){ arg[kv[0]]=kv[1]; } -$(".div2 h1 p").text(arg['sendElectronMicroscopeName']) + $(".div2 h1 p").text(arg['sendElectronMicroscopeName']) + return { GetUrlElementInstance: function() { return arg; }, sayHello: "Hello" } +} + +function IndexSaveEmConditionFile(){ + var date = new Date(); + var $ipAddress = $("#ipAddress").val(); + var $port = $("#portNumber").val(); + var $manufacturer = $("#manufacturer").val(); + var $electronMicroscopeName = $("#electronMicroscopeName").val(); + var Year = date.getFullYear(); + var Month = date.getMonth() + 1; + var day = date.getDate(); + + //文字を取得ファイルにはいるやつ + var text = "TEM:"+$manufacturer+ + ",portNumber:"+$port+ + ",ipAddress:"+$ipAddress+ + ",electronMicroscopeName:"+$electronMicroscopeName+ + ",Date:"+Year+ + +Month+ + +day+ + ""; +// var name = document.getElementById('saveEmConditionFileName').value = 'mytext'; + //テキストファイルを作成 + var blob = new Blob([text], {type: 'text/plain'}); + //リンクを取得 + var linkcondition = document.getElementById('DL_link_condition'); + //リンクにダウンロードするファイルをセット + linkcondition.href = window.URL.createObjectURL(blob); + //もしダウンロード属性に対応していたら + if ('download' in linkcondition) { + var data = $manufacturer + Year.toString() +'_'+ Month.toString() +'_'+ day.toString(); + //リンクにダウンロードする名前をセット + linkcondition.download = data + '.txt'; + //リンクをクリックしてダウンロードさせる + linkcondition.click(); + //もし対応してなかったら + } else { + //メッセージを表示する + linkcondition.textContent = '右クリックから名前を付けて保存してください'; + } +} + +function SaveEmConditionFile(){ + var date = new Date(); + var $manufacturer = $("#manufacturer").val(); + var movex = $("#movex").val(); + var movey = $("#movey").val(); + var movez = $("#movez").val(); + var movea = $("#movea").val(); + var spotSize = $("#spotSize").val(); + var magnificationA = $("#magnificationA").val(); + var magnificationR = $("#magnificationR").val(); + var binning = $("#binnig").val(); + var size = $("#size").val(); + var exptime = $("#exptime").val(); + var Year = date.getFullYear(); + var Month = date.getMonth() + 1; + var day = date.getDate(); + var Hours = date.getHours(); + var Minutes = date.getMinutes(); + + //文字を取得ファイルにはいるやつ + var text = "{'x':'"+movex+ + "','y':'"+movey+ + "','z':'"+movez+ + "','a':'"+movea+ + "','spotSize':'"+spotSize+ + "','magnificationA':'"+magnificationA+ + "','magnificationR':'"+magnificationR+ + "','binning':'"+binning+ + "','size':'"+size+ + "','exptime':'"+exptime+ + "','Date':'"+Year+ + '/'+Month+ + '/'+day+ + "'}"; + //ファイル名を取得、デフォルトは「mytext」 + // var name = document.getElementById('saveEmConditionFileName').value = 'mytext'; + //テキストファイルを作成 + var blob = new Blob([text], {type: 'text/plain'}); + //リンクを取得 + var linkcondition = document.getElementById('DL_link_condition'); + //リンクにダウンロードするファイルをセット + linkcondition.href = window.URL.createObjectURL(blob); + //もしダウンロード属性に対応していたら + if ('download' in linkcondition) { + var data = "EMcondition" + Year.toString() +'_'+ Month.toString() +'_'+ day.toString()+'_'+Hours.toString()+'_'+Minutes.toString(); + //リンクにダウンロードする名前をセット + linkcondition.download = data + '.txt'; + //リンクをクリックしてダウンロードさせる + linkcondition.click(); + //もし対応してなかったら + } else { + //メッセージを表示する + linkcondition.textContent = '右クリックから名前を付けて保存してください'; + } +} + +function IndexReadEmCondtionText(){ + var obj1 = document.getElementById("selfile"); + obj1.addEventListener("change",function(evt){ + var file = evt.target.files; + var arg = {}; + var reader = new FileReader(); + reader.readAsText(file[0]); + reader.onload = function(ev){ + console.log(reader.result); + document.selectFile.txt.value = reader.result; + var pair = reader.result.split(','); + for(var i=0;pair[i];i++) { + var kv = pair[i].split(':'); + arg[kv[0]]=kv[1]; + } + console.log(arg['Date']); + console.log(arg['ipAddress']); + console.log(arg['portNumber']); + console.log(arg['TEM']); + IndexReadEmCondtionTextArg(arg); + } + console.log(arg['Date']); + },false); +} + +function IndexReadEmCondtionTextArg(arg){ + var ipAddress = arg['ipAddress']; + var manufacturer = arg['TEM']; + var portNumber = arg['portNumber']; + var manufacturerName = arg['electronMicroscopeName']; + var res = confirm("Would that be OK with you?"); + if(res == true){ + window.location = "http://"+ipAddress+":3000/simplePhoto.html?sendIpAddress="+ipAddress+"&sendPortNumber="+portNumber+"&sendManufacturer="+manufacturer+"&sendElectronMicroscopeName="+manufacturerName+"" + }else{ + return false; + } } diff --git a/index.html b/index.html index e98eba1..e966521 100644 --- a/index.html +++ b/index.html @@ -15,56 +15,39 @@
-

Please Select Electron Microscopes!

-

Proin eu leo non metus vulputate viverra. Curabitur ac augue ante. Praesent nisl diam, iaculis eget ipsum at, blandit laoreet eros. Nam hendrerit, erat commodo varius consequat, dolor massa tempor massa, vel cursus enim neque pellentesque augue. Aenean ullamcorper et lacus at hendrerit. Phasellus id lectus luctus, congue quam id, tempor justo. Mauris sodales imperdiet nisi eget lacinia. Nulla vehicula eleifend nibh sed malesuada. Praesent eget tortor erat. Nullam a sapien sit amet enim tempor cursus. Sed vehicula nisl sed odio gravida aliquam. Sed metus lorem, vestibulum vel pulvinar vel, condimentum vitae risus. Curabitur in odio ut nisl convallis dapibus sollicitudin vitae orci. Aenean vel molestie massa. Nam vehicula porta arcu, at dapibus nulla pulvinar fermentum. Nam orci enim, elementum ac risus vestibulum, imperdiet placerat mi.

-
+

Please Input Your Electron Microscopes Data!

+
- +
-

IP Address :

-

port number :

-

manufacturer :

+

IP Address :

+

port number :

+

manufacturer : + +

electron microscope name :

-

+

+ +

em condition save

+ File name:.txt +     + +
+ + +
diff --git a/simplePhoto.html b/simplePhoto.html index 2076ddd..16ff4be 100644 --- a/simplePhoto.html +++ b/simplePhoto.html @@ -1,230 +1,176 @@ - - - - - - - Websystem Integrated Tems - - - - - - + + + + + Websystem Integrated Tems + + + + +
-
-
-
-
- Websystem Integrated Tems - -
-
+
+
+
+
+ Websystem Integrated Tems
+
+
- -
+
-
-
-
-
-

-

display

-

-
- -
+
+
+
+
+

+

display

+

+
+
+
+
+
+
+
+
+ +
+
+
+

Control Electron Microscopy

+

+ +

+
+
-
-
-
-
-
- -
-
-
-

Control Electron Microscopy

- -

- -

-
- image size: - +

+ +

+
+ image size: + - binning: - + binning: + - ecptime: - + ecptime: + -

- -

+

+ +

- +
+

+ moving distance + nm +
- Control mode select:Key(ex.↑↓→←,wsad,hjkl) - +

+ move x + nm + + +
+
+ move y + nm + + +
+
-

- moving distance - nm -
+
+
+ move z(keep magnificance) +    + nm

+ change current(keep stage) +    + %  Current lenz: +
+
+
+ spot size + +
+

+ magnification absolute value + +

+
+ magnification relative value + +
+
+
+

+ +

+ + +
+

+

+ File name:.tif +    
+ -

- move x - nm - - -
-
- move y - nm - - - -
-
- move z(keep magnificance) -    - nm

- change current(keep stage) -    - %  Current lenz: -
-
-

- -

-

- - -
-

+

- Save Photo -    - File name:.tif -    
- - -
-

-      -
-

- File name:.txt -     - -
-
- TEM: - Position:x=,y=,z=,a=
- SpotSizeIndex: - MagIndex: - Obj: - BeamTiltX: - BeamTiltY: - Speed: -
-

- +

+      +

+ File name:.txt +     + +
+ LogFile name:.txt +    
-
+ +
+ TEM: + Position:x=,y=,z=,a=
+ SpotSizeIndex: + MagIndex: + Obj: + BeamTiltX: + BeamTiltY: + Speed: +
+ +
+
-
+
+ - + + -- 2.11.0