-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScheduler.html
445 lines (385 loc) · 16.6 KB
/
Scheduler.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Service Scheduler</title>
<link rel="stylesheet" href="./css/shkwak.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="./js/jquery-1.8.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/base64.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/shkwak.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/eventemitter2.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/roslib.js"></script>
<script language="javascript">
/*============= Creat new solution ==============*/
var i = 0;
function SolutionCreate()
{ //Required : message, content
/*--GitHub 사용자 정보--*/
var owner = document.getElementById('gitUser').value;
var repo = document.getElementById('gitRepo').value;
/*--access_token--*/
var access_token = localStorage.getItem("access_token");
if (access_token == null)
{
alert("로그인을 하여야 솔루션 생성이 가능합니다.");
}
else
{
/*--생성될 솔루션 파일명(임시)--*///solution은 생성할 솔루션명이랑 같아야 할듯
var fileName = ["concert.launch", "solution.services", "package.xml", "CMakeLists.txt"];
var solutionName = document.getElementById('solutionName').value;
var box = [document.getElementById('box1').value, document.getElementById('box2').value, document.getElementById('box3').value, document.getElementById('box4').value];
//alert(box[0]); //for Test
// for (var i=0;i<fileName.length;i++)
// {
var msg = "Create new solution ";
var content = box[i];
var cmds = {message : msg, content : content};
jQuery.support.cors = true;
$.ajax({
url: "https://api.github.com/repos/" + owner + "/" + repo + "/contents/" + solutionName + "/" + fileName[i] + "?access_token=" + access_token,
type: "PUT",
data: JSON.stringify(cmds),
contentType: "application/json;charset=utf-8",
success: function (data) {
alert(fileName[i] + " FileCreate complete!");
},
error: function (x, y, z) {
alert(x + "\n" + y + "\n" + z);
//alert("동일한 Solution이 존재합니다.");
}
});
// }
var timer = setTimeout('SolutionCreate()',200);
i++;
//alert(i);
if (i==4)
{
i = 0;
var text = "https://api.github.com/repos/" + owner + "/" + repo + "/contents/" + solutionName;
var box = document.getElementById('box_result');
box.value = text;
clearTimeout(timer);
}
}
}
var ShowHide_status = false;
var ShowHide_status_callService = false;
/*-- ROSBridge --*/
var ros = "";
function ConnectROS()
{
var master_URL = document.getElementById('master_URL').value;
// Connecting to ROS
// -----------------
//var ros = new ROSLIB.Ros();
ros = new ROSLIB.Ros();
//alert('in');
// If there is an error on the backend, an 'error' emit will be emitted.
ros.on('error', function(error) {
console.log(error);
//alert(error); //Error Message
alert("WebSocket connection to \'" + master_URL + "\' failed : Connection closed before receiving a handshake response."); //Error Message
});
// Find out exactly when we made a connection.
ros.on('connection', function() {
console.log('Connection made!');
});
// Create a connection to the rosbridge WebSocket server.
// master_URL _2014-04-21_shkwak
//var master_URL = document.getElementById('master_URL').value;
ros.connect(master_URL); //'ws://192.168.0.98:9090';
//alert(master_URL);
}
// // Publishing a Topic
// // ------------------
//
// // First, we create a Topic object with details of the topic's name and message type.
// var cmdVel = new ROSLIB.Topic({
// ros : ros,
// name : '/cmd_vel',
// messageType : 'geometry_msgs/Twist'
// });
//
// // Then we create the payload to be published. The object we pass in to ros.Message matches the
// // fields defined in the geometry_msgs/Twist.msg definition.
// var twist = new ROSLIB.Message({
// linear : {
// x : 0.1,
// y : 0.2,
// z : 0.3
// },
// angular : {
// x : -0.1,
// y : -0.2,
// z : -0.3
// }
// });
//
// // And finally, publish.
// cmdVel.publish(twist);
function GetServiceList()
{
var select = document.getElementById('serviceList');
/*selectbox option 삭제*/
select.options.length = 0; //option 전체삭제
var option_line = document.createElement('option');
option_line.value = option_line.text = "-----------";
select.add(option_line);
// Connecting to ROS
ConnectROS();
//Subscribing to a Topic
//----------------------
var service_list = new ROSLIB.Topic({
ros : ros,
name : '/concert/service/list',
messageType : 'concert_msgs/Services'
});
service_list.subscribe(function(message) { // subscribe() 는 되지만 정상적인 return 이 오지는 않음
console.log('Received message on ' + service_list.name + ': ' + message.services[0].name);
//var msg = Base64.encode(message);
for (var i=0;i<message.services.length;i++)
{
//document.getElementById("service_data1").value += message.services[i].name + "\n";
var option = document.createElement('option');
option.value = option.text = message.services[i].name;
select.add(option);
}
var option = document.createElement('option');
option.value = option.text = "사용자 입력";
select.add(option);
service_list.unsubscribe();
});
}
function callService(setServiceName, bool)
{
document.getElementById("service_data2").value = "";
if (setServiceName == null){
var serviceName = document.getElementById('serviceList').value;
}else{
var serviceName = setServiceName;
}
if (bool == null){
var enabled = document.getElementById('serviceEnabled').value;
}else{
var enabled = bool;
}
// Calling a service
// -----------------
// First, we create a Service client with details of the service's name and service type.
var serviceEnable = new ROSLIB.Service({
ros : ros,
name : '/concert/service/enable',
serviceType : 'concert_msgs/EnableService'
});
// Then we create a Service Request. The object we pass in to ROSLIB.ServiceRequest matches the
// fields defined in the rospy_tutorials AddTwoInts.srv file.
if (enabled == "true")
{
var request = new ROSLIB.ServiceRequest({
//name : 'admin',
//enable : true
name : serviceName,
enable : true
});
document.getElementById("service_data2").value += "ServiceCall - enable\n";
}
else
{
var request = new ROSLIB.ServiceRequest({
name : serviceName,
enable : false
});
document.getElementById("service_data2").value += "ServiceCall - disable\n"
}
// Finally, we call the /concert/service/enable service and get back the results in the callback. The result
// is a ROSLIB.ServiceResponse object.
serviceEnable.callService(request, function(result) {
console.log('Result for service call on ' + serviceEnable.name + ': ' + result.error_message);
if (result.error_message == "")
{
document.getElementById("service_data2").value += "Success : " + result.success + "\n"; //result - success, error_message 두개 뿐!!
}
else
{
document.getElementById("service_data2").value += "Error message : " + result.error_message + "\n";
}
});
}
// // Setting a param value
// // ---------------------
//
// ros.getParams(function(params) {
// console.log(params);
// });
//
// // First, we create a Param object with the name of the param.
// var maxVelX = new ROSLIB.Param({
// ros : ros,
// name : 'max_vel_y'
// });
//
// //Then we set the value of the param, which is sent to the ROS Parameter Server.
// maxVelX.set(0.8);
// maxVelX.get(function(value) {
// console.log('MAX VAL: ' + value);
// });
//
// // Getting a param value
// // ---------------------
//
// var favoriteColor = new ROSLIB.Param({
// ros : ros,
// name : 'favorite_color'
// });
//
// favoriteColor.set('red');
// favoriteColor.get(function(value) {
// console.log('My robot\'s favorite color is ' + value);
// });
var pre_serviceName = "";
var pre_OnTime_date = "";
var pre_OnTime_time = "";
var pre_OffTime_date = "";
var pre_OffTime_time = "";
var li_count = 0;
var timer = new Array();
var setServiceName = new Array();
var setOnTime = new Array();
var setOffTime = new Array();
var setOnCmdSended = new Array(); //false
var schedule_id = "";
var timer_id = "";
var timecheck = new Array(); //override
function leadingZeros(n, digits)
{
//4->04로 변경하기
var zero = '';
n = n.toString();
if (n.length < digits)
{
for (var i=0;i<(digits-n.length);i++)
{
zero += '0';
}
}
return zero+n;
}
function nowTime()
{
//formatting yyyy-MM-dd hh:mm:ss
var today = new Date();
//"-" + today.getDay() + + ":" + today.getSeconds() + today.getMilliseconds()
var NowTime_sec = leadingZeros(today.getFullYear(),4) + "-" + leadingZeros(today.getMonth() + 1,2) + "-" + leadingZeros(today.getDate(),2) + " " + leadingZeros(today.getHours(),2) + ":" + leadingZeros(today.getMinutes(),2) + ":" + leadingZeros(today.getSeconds(),2);
alert("NowTime : " + NowTime_sec);
}
function inputNowDate()
{
var today = new Date();
var NowDate = leadingZeros(today.getFullYear(),4) + "-" + leadingZeros(today.getMonth() + 1,2) + "-" + leadingZeros(today.getDate(),2);
//return NowDate;
document.all.serviceOnDate.value = NowDate;
document.all.serviceOffDate.value = NowDate;
}
function inputNowTime()
{
var today = new Date();
var NowTime = leadingZeros(today.getHours(),2) + ":" + leadingZeros(today.getMinutes()+1,2); // + ":" + leadingZeros(today.getSeconds(),2);
document.all.serviceOnTime.value = NowTime;
var NowTime_off = leadingZeros(today.getHours(),2) + ":" + leadingZeros(today.getMinutes()+2,2);
document.all.serviceOffTime.value = NowTime_off;
}
function onLoadFunc()
{
inputNowDate(); //현재 Date
inputNowTime(); //현재 Time 보다 1분, 2분 늦은 시간
}
</script>
</head>
<body onLoad="onLoadFunc();">
<div style="font-size:24px; color:#6699cc;">Service Scheduler
<span style="font-size:12px;">master_URL</span><span id="gitUserRepo" style="font-size:12px; color:; display:none;">
<input type="text" id="master_URL" value="ws://192.168.0.137:9090" style="width:150px; font-size:12px;" spellcheck="false">
</span>
<input type="image" src="./img/settings-1.png" onclick="ShowHide('URL');" style="vertical-align:middle;" title="URL 입력창이 나타납니다."/>
</div>
<hr><br>
<div>Select a Service <br>
<span style="font-size:12px;">스케줄을 설정하고 싶은 서비스를 선택하세요.<br>
Service List :
<select id="serviceList" onchange="changeList()">
<option value="">-----------</option>
<!-- <option value="dummy_service">dummy_service</option>
<option value="service 2">service 2</option>
<option value="service 3">service 3</option>
<option value="service 4">service 4</option>
<option >사용자 입력</option> -->
</select>
<input type="text" id="serviceName" style="font-size:11px; width:210px; display:none;" placeholder="서비스명을 입력하세요.">
<!-- <input type="button" onclick="ConnectROS();" value="ConnectROS" style="width:; height:;" class="button"/> -->
<input type="button" onclick="GetServiceList();" value="GetList" style="" class="button" title="서비스 리스트를 가져옵니다."/>
<span id="span_callService" style="display:none;">
<select id="serviceEnabled">
<option value="false">false</option>
<option value="true">true</option>
</select>
<input type="button" onclick="callService();" value="callService" style="" class="button" title=""/>
<!-- <input type="button" onclick="nowTime();" value="nowTime" style="" class="button"/> -->
</span>
<input type="image" src="./img/settings-1.png" onclick="ShowHide('callService');" style="vertical-align:middle;" title=""/>
<br>
<!-- <span style="font-size:11px; color:#cc3366;">* 로그인을 하여야 서비스 스케줄링이 가능합니다.</span>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='Signin.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Sign in', top.document.getElementById('pageTitle').innerHTML='';top.ChangeSigninTitle('OUT');" value="Sign in" class="button2"/> -->
</div></span><br>
<div>Configure a Service Schedule<br>
<span style="font-size:12px;">
서비스를 실행하고자 하는 날짜와 시간을 선택하세요.<br>
ON Time :
<input type="date" style="font-size:11px;" id="serviceOnDate"/>
<input type="time" style="font-size:11px;" id="serviceOnTime"/>
OFF Time :
<input type="date" style="font-size:11px;" id="serviceOffDate">
<input type="time" style="font-size:11px;" id="serviceOffTime">
<input type="image" src="./img/icon_plus_2.png" onclick="addSchdule();" style="vertical-align:middle;" title="서비스 스케줄을 추가합니다."/>
<input type="image" src="./img/circle-left.png" onclick="onLoadFunc();" style="vertical-align:middle;" title="스케줄을 자동으로 설정해 줍니다."/><br><br>
</span>
</div><br>
<div>Result Report<br>
<span style="font-size:12px;">
서비스 스케줄 내역을 보여줍니다.
<!-- <textarea id="box_result" style="width:90%; margin-top:5px;" rows="5" title="source"></textarea> -->
<ul id="result_ul" style="">
<!-- <li>dummy_service, 2014-04-14 18:00~2014-04-14 19:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-14 16:00~2014-04-14 17:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-13 18:00~2014-04-13 19:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-13 16:00~2014-04-13 17:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-12 16:30~2014-04-12 17:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-12 15:30~2014-04-12 16:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-11 08:00~2014-04-11 09:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li>
<li>dummy_service, 2014-04-11 06:00~2014-04-11 07:00 <input type="image" src="./img/icon_minus_2.png" style="vertical-align:middle;"/></li> -->
</ul>
</span>
</div><br>
<!-- gateway_dotgraph
<textarea id="dotgraph_data1" style="width:100%;" rows="5" spellcheck="false"></textarea>
conductor_dotgraph
<textarea id="dotgraph_data2" style="width:100%;" rows="5" spellcheck="false"></textarea>
service_list
<textarea id="service_data1" style="width:100%;" rows="5" spellcheck="false"></textarea> -->
serviceEnable<br>
<textarea id="service_data2" style="font-size:11px; width:90%;" rows="5" spellcheck="false"></textarea><br><br>
<div>Other Page Link<br>
<span style="font-size:12px;">
이동하고자 하는 페이지 버튼을 클릭하면 해당 페이지로 이동합니다.<br>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='NewSolution.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Solution Manager', top.document.getElementById('pageTitle').innerHTML='Solution Configuration Manager';" value="Solution Manager" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='Webgraphviz.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Data Visualizer', top.document.getElementById('pageTitle').innerHTML='Data Visualizer';" value="Data Visualizer" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='Scheduler.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Service Scheduler', top.document.getElementById('pageTitle').innerHTML='Service Scheduler';" value="Service Scheduler" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='TemplateEdit.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Template Editor', top.document.getElementById('pageTitle').innerHTML='Template Editor';" value="Template Editor" class="button2"/>
<br>
</span>
</div><br>
<!------------------------------------------------------------------>
</body>
</html>