OSDN Git Service

979285ef04372a81a483bf0dd76029e5f05cdb56
[vem/WITs.git] / JS / em.js
1 // インスタンス化
2 var userSetting = new GetUrlElement();
3 var UrlElement = userSetting.GetUrlElementInstance();
4 var hello = userSetting.sayHello;
5 console.log(UrlElement['sendIpAddress']);
6
7 var LoadLogMemory = new LogMemory();
8 var GETLogMemory = LoadLogMemory.LogMemoryInstance();
9 var MemoryAll = LoadLogMemory.GETLog();
10
11 /*
12 getCurrentParams()
13 clickMove()
14 setStage()
15 setSpotSize()
16 setMagnificationA()
17 setMagnificationR()
18 correntConditionText()
19 setSpotSize()
20 setMagnificationR()
21 setMagnificationA()
22 nowCondition()
23 */
24
25
26 function getCurrentParams(){
27   var parameter;
28 console.log("getcurrentparams");
29   $.ajax({
30     type:"GET",
31     url:"//"+UrlElement['sendIpAddress']+
32         ":"+UrlElement['sendPortNumber']+
33         "/"+UrlElement['sendElectronMicroscopeName']+
34         "/get",
35 //    url:"http://192.168.4.146:9090/fei/get",
36     success: function(data){
37       console.log(data);
38     }
39   });
40 }
41
42 function clickMove(direction){
43   var movingdistance = $("#movingdistance").val();
44   var movexr = $("#movex").val();
45   var moveyr = $("#movey").val();
46   var movezr = $("#movez").val();
47   var directionSwitch = direction;
48
49 console.log("movingdistance="+movingdistance);
50 console.log("movex="+movexr);
51 console.log("movey="+moveyr);
52 switch(directionSwitch){
53
54     case 'Up':
55       moveyr = parseInt(moveyr) + (parseInt(movingdistance));
56       $("#movey").val(String(moveyr));
57       $('#movey').change();
58     break;
59
60     case 'Down':
61       moveyr = parseInt(moveyr) - (parseInt(movingdistance));
62       $("#movey").val(String(moveyr));
63       $('#movey').change();
64     break;
65
66     case 'Left':
67       movexr = parseInt(movexr) + (parseInt(movingdistance));
68       $("#movex").val(String(movexr));
69       $('#movex').change();
70     break;
71
72     case 'Right':
73     movexr = parseInt(movexr) - (parseInt(movingdistance));
74     $("#movex").val(String(movexr));
75     $("#currentx").val(String(movexr));
76     $('#movex').change();
77     break;
78     }
79     $.ajax({
80       type:"GET",
81       url:"http://" +UrlElement['sendIpAddress']+
82       ":"+UrlElement['sendPortNumber']+"/"+UrlElement['sendManufacturer']+
83       "/set/stagea?x="+encodeURIComponent(movexr)+
84       "&y="+encodeURIComponent(moveyr)+
85       "&z="+encodeURIComponent(movezr)+
86       "&a="+encodeURIComponent(movezr),
87       success: function(data){
88         console.log(data);//string型
89       }
90     });
91   }
92
93 function setStage(){
94   var movingdistance = $("#movingdistance").val();
95   var movexr = $("#movex").val();
96   var moveyr = $("#movey").val();
97   var movezr = $("#movez").val();
98
99   $("#movey").keydown(function(e){
100     console.log(e.keyCode);
101     console.log(typeof(e.keyCode));
102
103     //UP(↑,w,h)
104     if (e.keyCode == 38 || e.keyCode == 87 || e.keyCode == 72) {
105         moveyr = parseInt(moveyr) + (parseInt(movingdistance)-1);
106         $("#movey").val(String(moveyr));
107     }
108     //DOWN(↓,s,j)
109     else if (e.keyCode == 40 || e.keyCode == 83 || e.keyCode == 74) {
110       moveyr = parseInt(moveyr) - (parseInt(movingdistance)-1);
111       $("#movey").val(String(moveyr));
112     }
113   });
114
115   $("#movex").keydown(function(e){
116     console.log(e.keyCode);
117     console.log(typeof(e.keyCode));
118     //RIGHT(→,a,k)
119     if (e.keyCode == 39 || e.keyCode == 68 || e.keyCode == 76) {
120     movexr = parseInt(movexr) + (parseInt(movingdistance)-1);
121     $("#movex").val(String(movexr));
122     }
123     //LEFT(←,d,l)
124     else if (e.keyCode == 37 || e.keyCode == 65 || e.keyCode == 75) {
125       movexr = parseInt(movexr) - (parseInt(movingdistance)-1);
126       $("#movex").val(String(movexr));
127     }
128   });
129
130   $.ajax({
131     type:"GET",
132     //電子顕微鏡通信時
133 //    url:"http://192.168.4.146:9090/fei/set/stagea?x="+encodeURIComponent(movexr)+
134     url:"http://"+UrlElement['sendIpAddress']+
135     ":"+UrlElement['sendPortNumber']+
136     "/"+UrlElement['sendManufacturer']+
137     "/set/stagea?x="+encodeURIComponent(movexr)+
138     "&y="+encodeURIComponent(moveyr)+
139     "&z="+encodeURIComponent(movezr)+
140     "&a="+encodeURIComponent(movezr),
141     success: function(data){
142       console.log(data);
143     }
144   });
145 }
146
147 function currentConditionText(){
148   var movingdistance = $("#movingdistance").val();
149   var movexr = $("#movex").val();
150   var moveyr = $("#movey").val();
151   var movezr = $("#movez").val();
152   console.log("currentcondition");
153   $("#Currentcondition").innerHTML='x:"movexr" y:"moveyr" z:"movezr"'
154 }
155
156 function setSpotSize(){
157   var setSpotSize = $("#SpotSize").val();
158   $.ajax({
159     type:"GET",
160     url:"http://"+UrlElement['sendIpAddress']+
161     ":"+UrlElement['sendPortNumber']+
162     "/"+UrlElement['sendManufacturer']+
163     "/set/spotsizea?sps="+encodeURIComponent(setSpotSize),
164     success: function(data){
165       console.log(data);
166     }
167   });
168 }
169
170 function setMagnificationA(){
171   var magnificationA = $("#magnificationA").val();
172   $.ajax({
173     type:"GET",
174     url:"http://"+UrlElement['sendIpAddress']+
175     ":"+UrlElement['sendPortNumber']+
176     "/"+UrlElement['sendManufacturer']+
177     "/set/magnificationa?mag="+encodeURIComponent(magnificationA),
178     success: function(data){
179       console.log(data);
180     }
181   });
182 }
183 function setMagnificationR(){
184   var magnificationR = $("#magnificationR").val();
185   $.ajax({
186     type:"GET",
187     url:"http://"+UrlElement['sendIpAddress']+
188     ":"+UrlElement['sendPortNumber']+
189     "/"+UrlElement['sendManufacturer']+
190     "/set/magnificationr?mag="+encodeURIComponent(magnificationR),
191     success: function(data){
192       console.log(data);
193     }
194   });
195 }
196
197 function nowCondition(){
198   var movexr = $("#movex").val();
199   var moveyr = $("#movey").val();
200   var movezr = $("#movez").val();
201   var movea = $("#movea").val();
202   var spotSize = $("#spotSize").val();
203   var exptime = $("#exptime").val();
204   var manufacturer = UrlElement['sendElectronMicroscopeName'];
205   document.getElementById("tem").innerHTML = manufacturer;
206   document.getElementById("currentx").innerHTML = parseInt(movexr);
207   document.getElementById("currenty").innerHTML = parseInt(moveyr);
208   document.getElementById("currentz").innerHTML = parseInt(movezr);
209   document.getElementById("currenta").innerHTML = parseInt(movea);
210   document.getElementById("SpotSizeIndex").innerHTML = parseInt(spotSize);
211   document.getElementById("MagIndex").innerHTML = parseInt(magnificationA);
212
213 }