index.html 21.6 KB
Newer Older
Jeroen Vreeken's avatar
Jeroen Vreeken committed
1
<html>
2
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Jeroen Vreeken's avatar
Jeroen Vreeken committed
3
4
5
6
7
8
9

<head>
 <title>
  Dwingeloo console interface
 </title>
</head>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
10
<body background="achtergrond.jpg" >
Jeroen Vreeken's avatar
Jeroen Vreeken committed
11
12
13
14
15
16
17

<p>

<!-- 

	Basic Azimuth & Elevation status

Michel Roelofs's avatar
Michel Roelofs committed
18
  -->
Jeroen Vreeken's avatar
Jeroen Vreeken committed
19
20
21
22
23
24

 <div style="background: lightgrey; border:thin solid black">
  <table border="0">
   <tr>
    <th>
     Azimuth
Michel Roelofs's avatar
Michel Roelofs committed
25
    </th>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    <td>
     Position:
    </td>
    <td width="30%">
     <div id="Azimuth_Position" style=" float:left; width:150px"></div>
    </td>
    <td rowspan="3">
     <canvas id="el_canvas" width="100" height="100"
         style="border:thin solid black">
     </canvas>
    </td>
    <td rowspan="3">
     <canvas id="az_canvas" width="100" height="100"
         style="border:thin solid black">
     </canvas>
    </td>
    <td>
     <span id="azimuth_enable"></span>
    </td>
45
46
    <td rowspan="2">
     <span id="azimuth_elevation_disable"></span>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
47
    </td>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
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
    <td>
     Status:
    </td>
    <td width="30%">
     <div id="Azimuth_Enabled">
      <center>
       ----------
      </center>
     </div>
    </td>
    <td>
     Safety:
    </td>
    <td width="30%">
     <div id="Azimuth_Safe">
      <center>
       ----------
      </center>
     </div>
    </td>
   </tr>

   <tr>
    <th>
     Elevation
Michel Roelofs's avatar
Michel Roelofs committed
73
    </th>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
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
    <td>
     Position:
    </td>
    <td width="30%">
     <div id="Elevation_Position" style=" float:left; width:150px"></div>
    </td>
    <td>
     <span id="elevation_enable"></span>
    </td>
    <td>
     Status:
    </td>
    <td width="30%">
     <div id="Elevation_Enabled">
      <center>
       ----------
      </center>
     </div>
    </td>
    <td>
     Safety:
    </td>
    <td width="30%">
     <div id="Elevation_Safe">
      <center>
       ----------
      </center>
     </div>
    </td>
   </tr>

   <tr>
    <th>
     Focusbox
Michel Roelofs's avatar
Michel Roelofs committed
108
    </th>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
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
    <td>
     Position:
    </td>
    <td width="30%">
     <div id="Focusbox_Position" style=" float:left; width:150px"></div>
    </td>
    <td>
    </td>
    <td>
    </td>
    <td>
    </td>
    <td>
    </td>
    <td>
    </td>
    <td>
    </td>
   </tr>
  </table>
 </div>

</p>
<p>

<!-- 

	Authorization

Michel Roelofs's avatar
Michel Roelofs committed
138
  -->
Jeroen Vreeken's avatar
Jeroen Vreeken committed
139

140
  <div id="authorization"></div>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
141
142
143
144
145
146
147
148
149
150

</p>

<p>

 <table border="0">
  <tr>
 
  <td>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
151
152
153
154
<!-- 

	Sun
	Moon
Jeroen Vreeken's avatar
Jeroen Vreeken committed
155
	Manual control
156
157
	Azel
	Satellite
Jeroen Vreeken's avatar
Jeroen Vreeken committed
158

Michel Roelofs's avatar
Michel Roelofs committed
159
  -->
Jeroen Vreeken's avatar
Jeroen Vreeken committed
160

Jeroen Vreeken's avatar
Jeroen Vreeken committed
161
162
163
 <div id="spg_sun"></div>
 <div id="spg_moon"></div>
 <div id="spg_manual"></div>
164
165
166
167
168
 <div id="spg_azel"></div>
 <div id="spg_j2000"></div>
 <div id="spg_sat"></div>
 
 </td>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
169
170
171
172

  </td>


Jeroen Vreeken's avatar
Jeroen Vreeken committed
173
174
175
176
<!-- 

	Offset

Michel Roelofs's avatar
Michel Roelofs committed
177
  -->
Jeroen Vreeken's avatar
Jeroen Vreeken committed
178

179
180
  <td>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
181
182
183
184
185
186
 <div style="background: lightgrey; border:thin solid black" width="50%"
  id="Offset">

  <i>
   Offset
  </i>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
187
  <div id="Offset_show" align="right" style="float:right"></div>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
188

Jeroen Vreeken's avatar
Jeroen Vreeken committed
189
  <table border="0" id="Offset_table">
Jeroen Vreeken's avatar
Jeroen Vreeken committed
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
   <tr>
    <td></td>
    <th>Azimuth</th>
    <th>Elevation</th>
   </tr>
   <tr>
    <th>
     Current Offset:
    </th>
    <td>
     <div id="Azimuth_Offset"></div>
    </td>
    <td>
     <div id="Elevation_Offset"></div>
    </td>
   </tr>
   <tr>
    <th colspan="3">
     New Offset:
    </th>
   </tr>
   <tr>
    <th colspan="3">
     <span id="Offset_Reset"></span>
    </th>
   </tr>
   <tr>
    <th>
     <span id="Offset_Set1"></span>
    </th>
    <td>
     <input type="text" width="4" id="az_offset1"
      onchange="check_floatval('az_offset1');">
    </td>
    <td>
     <input type="text" width="4" id="el_offset1"
      onchange="check_floatval('el_offset1');">
    </td>
   </tr>
   <tr>
    <th>
     <span id="Offset_Set2"></span>
    </th>
    <td>
     <input type="text" width="4" id="az_offset2"
      onchange="check_floatval('az_offset2');">
    </td>
    <td>
     <input type="text" width="4" id="el_offset2"
      onchange="check_floatval('el_offset2');">
    </td>
   </tr>
   <tr>
    <th>
     <span id="Offset_Set3"></span>
    </th>
    <td>
     <input type="text" width="4" id="az_offset3"
      onchange="check_floatval('az_offset3');">
    </td>
    <td>
     <input type="text" width="4" id="el_offset3"
      onchange="check_floatval('el_offset3');">
    </td>
   </tr>
   <tr>
    <th>
     <span id="Offset_Set4"></span>
    </th>
    <td>
     <input type="text" width="4" id="az_offset4"
      onchange="check_floatval('az_offset4');">
    </td>
    <td>
     <input type="text" width="4" id="el_offset4"
      onchange="check_floatval('el_offset4');">
    </td>
   </tr>
  </table>

  </p>

 </div>
273
274
275
276
277
278
 </td>

<!-- 

	DT model

Michel Roelofs's avatar
Michel Roelofs committed
279
  -->
280
281
 <td>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
282
283
 <div id="model"></div>
 
284
285
286
287
288
289


<!-- 

	end of box row

Michel Roelofs's avatar
Michel Roelofs committed
290
  -->
Jeroen Vreeken's avatar
Jeroen Vreeken committed
291
292
293
294
295

  </td>
 </tr>
 </table>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
296
297
298
299
300
301
302
303
304
305
306
307
308
309
 <div style="background: lightgrey; border:thin solid black"
  id="Log_box">

  <div style="height: 30px">
   <div id="Log_show" align="right" style="float:right">show</div>

   <i>
    Controller log<br>
   </i>

  </div>

  <div id="log" 
   style='background: white; border:thin solid black; height:150px;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
310
      font-family: monospace; font-size:100%; white-space: pre ;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
311
312
313
314
      overflow:scroll'>
  </div>

 </div>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
315
316
317
 
 <p>

Jeroen Vreeken's avatar
Jeroen Vreeken committed
318
  <div>
319
320
321
   <table width="100%" border="0">
   <tr>
   <td>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
322
   <a href="mech.html" target="_blank">Mechanics</a>
323
   </td>
Michel Roelofs's avatar
Michel Roelofs committed
324
325
326
327
328
   <td align="center">
   <b>
   <a href="help.html" target="_blank">Help</a>
   </b>
   </td>
329
330
331
   <td align="right">
	<script type="text/javascript" src="console_version.js"></script>
   </td>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
332
  </div>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348

</center>


 </div>

   </td>
   <td>
   </td>
  </tr>
 </table>
 
</p>

</body>

Michel Roelofs's avatar
Michel Roelofs committed
349
<script src="load.js" type="text/javascript"></script>
Jeroen Vreeken's avatar
Jeroen Vreeken committed
350
351
352
353

<script type="text/javascript">

/*
Jeroen Vreeken's avatar
Jeroen Vreeken committed
354
355
	Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009, 2011, 2012,
	2013
Jeroen Vreeken's avatar
Jeroen Vreeken committed
356
	Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009,
Jeroen Vreeken's avatar
Jeroen Vreeken committed
357
	2011, 2012, 2013
Jeroen Vreeken's avatar
Jeroen Vreeken committed
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

 */

/* 'includes' */
eval(load("dt_ui.js"));
eval(load("trace.js"));
eval(load("shell.js"));
378
eval(load("azel.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
379
eval(load("j2000.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
380
381
eval(load("status.js"));
eval(load("command.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
382
383
384
eval(load("manual.js"));
eval(load("sun.js"));
eval(load("moon.js"));
385
eval(load("sat.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
386
eval(load("dt_view.js"));
387
eval(load("authorization.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
388
389
eval(load("utils.js"));
eval(load("offset.js"));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
390
eval(load("model.js"));
391
392
eval(load("dt_websocket.js"));

393
new dt_websocket("ws://"+ window.location.hostname +"/dt");
Jeroen Vreeken's avatar
Jeroen Vreeken committed
394
395
396
397
398
399
400

/*
	'constants'
 */

var trace_url = "trace.cgi";
var shell_url = "shell.cgi";
401
var offset_url = "command.cgi_offset";
Jeroen Vreeken's avatar
Jeroen Vreeken committed
402

Jeroen Vreeken's avatar
Jeroen Vreeken committed
403
404


Jeroen Vreeken's avatar
Jeroen Vreeken committed
405

Jeroen Vreeken's avatar
Jeroen Vreeken committed
406
407
/******************************************************************
 *
408
 * Manual, sun and moon, azimuth & elevation
Jeroen Vreeken's avatar
Jeroen Vreeken committed
409
410
411
412
 *
 ******************************************************************/

var manual_spg = new manual("spg_manual");
413
414
415
416
417
var sun_spg = new sun("spg_sun");
var moon_spg = new moon("spg_moon");
var azel_spg = new azel("spg_azel");
var j2000_spg = new j2000("spg_j2000");
var sat_spg = new sat("spg_sat");
418
419
var auth_win = new authorization("authorization");

Jeroen Vreeken's avatar
Jeroen Vreeken committed
420
421
var model_win = new model("model");

422
423
424
425
426
427
428
429
430
431
432
433
434
435
function offset_cb(azimuth_off, elevation_off)
{
	Azimuth_Offset_value(azimuth_off);
	Elevation_Offset_value(elevation_off);
}

auth_win.offset_cb = offset_cb;

auth_win.tracker_window_set("console/azel", azel_spg);
auth_win.tracker_window_set("console/j2000tracker", j2000_spg);
auth_win.tracker_window_set("console/moontracker", moon_spg);
auth_win.tracker_window_set("console/suntracker", sun_spg);
auth_win.tracker_window_set("console/sattracker", sat_spg);
auth_win.tracker_window_set("console/manual", manual_spg);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503

/*

 */

function check_floatval(element)
{
	var val = document.getElementById(element).value;
	var i;
	var newval = "";
	var dotfound = 0;
	var numberafterdot;
	var digitfound = 0;
	
	if (val==null)
		alert(element);
	
	for (i = 0; i < val.length; i++)
	{
		switch (val.charAt(i)) {
			case ',':
			case '.':
				if (!dotfound) {
					dotfound = 1;
					digitfound = 0;
					newval += '.';
				}
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				newval += val.charAt(i);
				digitfound = 1;
				break;
			case '-':
				if (newval.length == 0) {
					newval = "-";
				}
				break;
			default:
				break;
		}
	}
	if (!digitfound && !dotfound) {
		newval = "0";
	}
	if (!dotfound) {
		newval += ".";
		digitfound = 0;
	}
	if (!digitfound) {
		newval += "0";
	}
	
	document.getElementById(element).value = newval;
}

/*
	Azimuth
 */

Jeroen Vreeken's avatar
Jeroen Vreeken committed
504
var azimuth_enable_param =  'controller \'params { { "azimuth_servo_state", "enabled", (int)1 } } \' ';
505
var azimuth_elevation_disable_param = 'controller \'params { { "azimuth_servo_state", "enabled", (int)0 } { "elevation_servo_state", "enabled", (int)0 } { "elevation_safety", "recover", (int)0 } } \' ';
Jeroen Vreeken's avatar
Jeroen Vreeken committed
506

507
var azimuth_disable = new dt_button("azimuth_elevation_disable");
Jeroen Vreeken's avatar
Jeroen Vreeken committed
508
509
azimuth_disable.background("red");
azimuth_disable.value("Disable");
510
azimuth_disable.click(function() { auth_win.idle(); do_shell(azimuth_elevation_disable_param); } );
Jeroen Vreeken's avatar
Jeroen Vreeken committed
511
512
513
514

var azimuth_enable = new dt_button("azimuth_enable");
azimuth_enable.background("springgreen");
azimuth_enable.value("Enable");
515
azimuth_enable.click(function() { auth_win.idle(); do_shell(azimuth_enable_param); } );
Jeroen Vreeken's avatar
Jeroen Vreeken committed
516
517
518
519
520
521
522
523
524
525
526
527

function bool_priv()
{
	this.doc;
	this.lastval = -1;
	this.truetext="true";
	this.falsetext="false";
}

function bool_value(obj, time, value, unit)
{
	var text;
528

Jeroen Vreeken's avatar
Jeroen Vreeken committed
529
530
531
532
	if (value == obj.private.lastval)
		return;
	obj.private.lastval = value;
	
533
	if (value == 0)
Jeroen Vreeken's avatar
Jeroen Vreeken committed
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
	    text =
	        "<div style='background: red; border:thin solid black'>" +
	        "<center>" + obj.private.falsetext + "</center>" +
	        "</div>";
	else
	    text =
	        "<div style='background: lightgreen; border:thin solid black'>" +
	        "<center>" + obj.private.truetext + "</center>" +
	        "</div>";
	obj.private.doc.innerHTML = text;
}

function bool_timeout(obj)
{
	obj.private.lastval = -1;
	obj.private.doc.innerHTML =
	    "<div style='background: silver; border:thin solid black'>" +
	    "<center>No connection</center>" +
	    "</div>";
}

Azimuth_Enabled_trace = new trace();
Azimuth_Enabled_trace.timeout = 3000;
Azimuth_Enabled_trace.callback = bool_value;
Azimuth_Enabled_trace.timeout_callback = bool_timeout;
Azimuth_Enabled_trace.private = new bool_priv();
Azimuth_Enabled_trace.private.doc = document.getElementById('Azimuth_Enabled');
Azimuth_Enabled_trace.private.truetext = "Enabled";
Azimuth_Enabled_trace.private.falsetext = "Disabled";
563
Azimuth_Enabled_trace.open(trace_url, 'Azimuth_Enabled', 0);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
564
565
566
567
568
569
570
571
572

Azimuth_Safe_trace = new trace();
Azimuth_Safe_trace.timeout = 3000;
Azimuth_Safe_trace.callback = bool_value;
Azimuth_Safe_trace.timeout_callback = bool_timeout;
Azimuth_Safe_trace.private = new bool_priv();
Azimuth_Safe_trace.private.doc = document.getElementById('Azimuth_Safe');
Azimuth_Safe_trace.private.truetext = "Safe";
Azimuth_Safe_trace.private.falsetext = "Unsafe";
573
Azimuth_Safe_trace.open(trace_url, 'Azimuth_Safe', 0);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602

var Azimuth_Pos = 1000;

var az_view = new azimuth_view("az_canvas");

var az_position_value = 0.0;
var az_setpoint_value = 360.0;
var az_position_value_last = 0.0;
var az_setpoint_value_last = 360.0;

var azimuth_position = new dt_traceval("Azimuth_Position");
azimuth_position.number_set(true, 4);
azimuth_position.highlight_set(true, "yellow", "white");

function Azimuth_Position_trace_value(obj, time, value, unit)
{
	var newval = rad2deg(value);

	if (azimuth_position.value(newval)) {
		Azimuth_Pos = decimals(newval, 4);
		az_position_value = value * 1.0;
	}
}

function Azimuth_Setpoint_trace_value(obj, time, value, unit)
{
	var update = 0;
	var setpointdeg = rad2deg(value);
	
603
604
605
606
//	if (decimals(Azimuth_Pos, 0) != az_position_value_last)
//		update = 1;
//	if (decimals(setpointdeg, 0) != az_setpoint_value_last)
//		update = 1;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
607

608
609
//	if (!update)
//		return;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656

	diff = decimals(rad2deg(az_position_value - value), 0);
	
	if (diff != 0)
		az_view.draw_err(az_position_value, value * 1.0);
	else
		az_view.draw(az_position_value);
	
	az_position_value_last = decimals(Azimuth_Pos, 0);
	az_setpoint_value_last = decimals(setpointdeg, 0);
}

function Azimuth_Position_trace_timeout(obj)
{
	Azimuth_Pos = 1000;
	
	azimuth_position.background("silver");
	azimuth_position.value("No connection");
}

Azimuth_Position_trace = new trace();
Azimuth_Position_trace.timeout = 3000;
Azimuth_Position_trace.timeout_callback = Azimuth_Position_trace_timeout;
Azimuth_Position_trace.callback = Azimuth_Position_trace_value;
Azimuth_Position_trace.open(trace_url, 'Azimuth_Position', 4);

Azimuth_Setpoint_trace = new trace();
Azimuth_Setpoint_trace.timeout = 3000;
//Azimuth_Setpoint_trace.timeout_callback = Azimuth_Setpoint_trace_timeout;
Azimuth_Setpoint_trace.callback = Azimuth_Setpoint_trace_value;
Azimuth_Setpoint_trace.open(trace_url, 'Azimuth_Setpoint', 4);

/*
	Elevation
 */


var el_view = new elevation_view("el_canvas");

Elevation_Enabled_trace = new trace();
Elevation_Enabled_trace.timeout = 3000;
Elevation_Enabled_trace.callback = bool_value;
Elevation_Enabled_trace.timeout_callback = bool_timeout;
Elevation_Enabled_trace.private = new bool_priv();
Elevation_Enabled_trace.private.doc = document.getElementById('Elevation_Enabled');
Elevation_Enabled_trace.private.truetext = "Enabled";
Elevation_Enabled_trace.private.falsetext = "Disabled";
657
Elevation_Enabled_trace.open(trace_url, 'Elevation_Enabled', 0);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
658
659
660
661
662
663
664
665
666
667


Elevation_Safe_trace = new trace();
Elevation_Safe_trace.timeout = 3000;
Elevation_Safe_trace.callback = bool_value;
Elevation_Safe_trace.timeout_callback = bool_timeout;
Elevation_Safe_trace.private = new bool_priv();
Elevation_Safe_trace.private.doc = document.getElementById('Elevation_Safe');
Elevation_Safe_trace.private.truetext = "Safe";
Elevation_Safe_trace.private.falsetext = "Unsafe";
668
Elevation_Safe_trace.open(trace_url, 'Elevation_Safe', 0);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
669
670
671
672
673
674
675
676

var Elevation_Pos = 1000;

var el_position_value = 0;
var el_position_value_last = -30;
var el_setpoint_value = 0;
var el_setpoint_value_last = -30;

Jeroen Vreeken's avatar
Jeroen Vreeken committed
677
var elevation_enable_param = 'controller \'params { { "elevation_servo_state", "enabled", (int)1 } { "elevation_safety", "recover", (int)0 } } \' ';
Jeroen Vreeken's avatar
Jeroen Vreeken committed
678
679
680
681

var elevation_enable = new dt_button("elevation_enable");
elevation_enable.background("springgreen");
elevation_enable.value("Enable");
682
elevation_enable.click(function() { auth_win.idle(); do_shell(elevation_enable_param); } );
Jeroen Vreeken's avatar
Jeroen Vreeken committed
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702

var elevation_position = new dt_traceval("Elevation_Position");
elevation_position.number_set(true, 4);
elevation_position.highlight_set(true, "yellow", "white");

function Elevation_Position_trace_value(obj, time, value, unit)
{
	var newval = rad2deg(value);

	if (elevation_position.value(newval)) {
		Elevation_Pos = decimals(newval, 4);
		el_position_value = value * 1.0;
	}
}

function Elevation_Setpoint_trace_value(obj, time, value, unit)
{
	var update = 0;
	var setpointdeg = rad2deg(value);
	
703
704
705
706
//	if (decimals(Elevation_Pos, 0) != el_position_value_last)
//		update = 1;
//	if (decimals(setpointdeg, 0) != el_setpoint_value_last)
//		update = 1;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
707

708
709
//	if (!update)
//		return;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746

	diff = decimals(rad2deg(el_position_value - value), 0);
	
	if (diff != 0)
		el_view.draw_err(el_position_value, value * 1.0);
	else
		el_view.draw(el_position_value);
	
	el_position_value_last = decimals(Elevation_Pos, 0);
	el_setpoint_value_last = decimals(setpointdeg, 0);
}

function Elevation_Position_trace_timeout(obj)
{
	Elevation_Pos = 1000;
	
	elevation_position.value("No connection");
	elevation_position.background("silver");
}

Elevation_Position_trace = new trace();
Elevation_Position_trace.timeout = 3000;
Elevation_Position_trace.timeout_callback = Elevation_Position_trace_timeout;
Elevation_Position_trace.callback = Elevation_Position_trace_value;
Elevation_Position_trace.open(trace_url, 'Elevation_Position', 2);

Elevation_Setpoint_trace = new trace();
Elevation_Setpoint_trace.timeout = 3000;
//Elevation_Setpoint_trace.timeout_callback = Elevation_Setpoint_trace_timeout;
Elevation_Setpoint_trace.callback = Elevation_Setpoint_trace_value;
Elevation_Setpoint_trace.open(trace_url, 'Elevation_Setpoint', 2);

/*
	Focusbox
 */

var focusbox_position = new dt_traceval("Focusbox_Position");
747
focusbox_position.number_set(true, 0);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
748
749
750
751
focusbox_position.highlight_set(true, "yellow", "white");

function Focusbox_Position_trace_value(obj, time, value, unit)
{
752
	focusbox_position.value(value * 10);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
}

function Focusbox_Position_trace_timeout(obj)
{
	focusbox_position.value("No connection");
	focusbox_position.background("silver");
}

Focusbox_Position_trace = new trace();
Focusbox_Position_trace.timeout = 3000;
Focusbox_Position_trace.timeout_callback = Focusbox_Position_trace_timeout;
Focusbox_Position_trace.callback = Focusbox_Position_trace_value;
Focusbox_Position_trace.open(trace_url, 'Focusbox_Position', 4);



/******************************************************************
 *
 * Shell access (for enable & disable)
 *
 ******************************************************************/

var do_shell_obj = new shell();

function do_shell(command)
{
	do_shell_obj.open(shell_url, command);
}


/******************************************************************
 *
 * Authorization
 *
 ******************************************************************/

Jeroen Vreeken's avatar
Jeroen Vreeken committed
789
790
var set_offset_obj = new offset(offset_url, "offset");

Jeroen Vreeken's avatar
Jeroen Vreeken committed
791
792
793
794
795
796
797

function my_event() {
	this.keyCode = 0;
};
var fake_event = new my_event();


Jeroen Vreeken's avatar
Jeroen Vreeken committed
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
var offset_table = document.getElementById('Offset_table');
var offset_show = document.getElementById('Offset_show');
var offset_visible = false;

function offset_draw()
{
	if (offset_visible) {
     		offset_show.innerHTML=
		    '<input type="button" value="hide" onclick="offset_show_set(0, true)">';
		offset_table.style.display='block';
	} else {
     		offset_show.innerHTML=
		    '<input type="button" value="show" onclick="offset_show_set(1, true)">';
		offset_table.style.display='none';
	}
}


function offset_show_set(show, interactive) 
{
	if (!show) {
		if ((Azimuth_Offset != 0 && Azimuth_Offset != null) ||
		    (Elevation_Offset != 0 && Elevation_Offset != null)) {
			if (interactive) alert(
			    "Hidding the offset block while an offset is active is not allowed.\n"+
			    "Please set both Azimuth and Elevation to a zero offset first.");
			show = true;
		}
	}
	offset_visible = show;
	offset_draw();
}

Jeroen Vreeken's avatar
Jeroen Vreeken committed
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
var offset_reset_button = new dt_button("Offset_Reset");
var offset_set1_button = new dt_button("Offset_Set1");
var offset_set2_button = new dt_button("Offset_Set2");
var offset_set3_button = new dt_button("Offset_Set3");
var offset_set4_button = new dt_button("Offset_Set4");
offset_reset_button.value("Reset");
offset_set1_button.value("Set");
offset_set2_button.value("Set");
offset_set3_button.value("Set");
offset_set4_button.value("Set");
offset_reset_button.click(function(){set_offset(0);});
offset_set1_button.click(function(){set_offset(1);});
offset_set2_button.click(function(){set_offset(2);});
offset_set3_button.click(function(){set_offset(3);});
offset_set4_button.click(function(){set_offset(4);});


function set_offset(nr)
{
	var az_val_id;
	var el_val_id;
	var offset_az_set;
	var offset_el_set;
	
	if (nr == 0) {
		offset_az_set = 0;
		offset_el_set = 0;
	} else {
		az_val_id = 'az_offset' + nr;
		el_val_id = 'el_offset' + nr;

		check_floatval(az_val_id);
		check_floatval(el_val_id);

		offset_az_set = document.getElementById(az_val_id).value;
		offset_el_set = document.getElementById(el_val_id).value;
	}

Jeroen Vreeken's avatar
Jeroen Vreeken committed
869
	set_offset_obj.open(deg2rad(offset_az_set), deg2rad(offset_el_set));
Jeroen Vreeken's avatar
Jeroen Vreeken committed
870
871
}

Jeroen Vreeken's avatar
Jeroen Vreeken committed
872
var Azimuth_Offset;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
873
874
875
876
877
878
879
880
881
882
883
var azimuth_offset = new dt_traceval("Azimuth_Offset");

function Azimuth_Offset_value(value)
{
	var newval = decimals(rad2deg(value), 4);
	
	if (newval != Azimuth_Offset) {
		Azimuth_Offset = newval;

		azimuth_offset.value(Azimuth_Offset);
		azimuth_offset.background("white");
Jeroen Vreeken's avatar
Jeroen Vreeken committed
884
885

		offset_show_set(offset_visible, false);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
886
887
888
	}
}

Jeroen Vreeken's avatar
Jeroen Vreeken committed
889
var Elevation_Offset;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
890
891
892
893
894
895
896
897
898
899
900
var elevation_offset = new dt_traceval("Elevation_Offset");

function Elevation_Offset_value(value)
{
	var newval = decimals(rad2deg(value), 4);
	
	if (newval != Elevation_Offset) {
		Elevation_Offset = newval;

		elevation_offset.value(Elevation_Offset);
		elevation_offset.background("white");
Jeroen Vreeken's avatar
Jeroen Vreeken committed
901
902

		offset_show_set(offset_visible, false);
Jeroen Vreeken's avatar
Jeroen Vreeken committed
903
904
905
906
907
908
909
910
911
912
	}
}


/******************************************************************
 *
 * Azel spg control
 *
 ******************************************************************/

913
914
azel_spg.azimuth_position_get = function() { return Azimuth_Pos; }
azel_spg.elevation_position_get = function() { return Elevation_Pos; }
Jeroen Vreeken's avatar
Jeroen Vreeken committed
915
916
917
918




Jeroen Vreeken's avatar
Jeroen Vreeken committed
919
920
921
922
923
924
925
926
927

/****************************

	Log
	
 */
 
var log_elem = document.getElementById('log');

Jeroen Vreeken's avatar
Jeroen Vreeken committed
928
log.innerHTML = "log:\n";
Jeroen Vreeken's avatar
Jeroen Vreeken committed
929
930
931

function log_status_cb(data)
{
932
933
934
935
936
937
938
939
940
941
	if (data.match(/ERROR:/g)) {
		data = '<span style="color: Red;">' + data + '</span>';
	}
	if (data.match(/WARNING:/g)) {
		data = '<span style="color: DarkOrange;">' + data + '</span>';
	}
	if (data.match(/INFO:/g)) {
		data = '<span style="color: DarkBlue;">' + data + '</span>';
	}

Jeroen Vreeken's avatar
Jeroen Vreeken committed
942
	log.innerHTML = log.innerHTML + data;
Jeroen Vreeken's avatar
Jeroen Vreeken committed
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
	log.scrollTop = log.scrollHeight;
}

log_status = new status("status.cgi", "log");
log_status.callback = log_status_cb;
log_status.open();


var log_show = document.getElementById('Log_show');
var log_visible = false;

function log_draw()
{
	var html = '<input type="button" value="clear" onclick="log_clear()">'

	if (log_visible) {
     		html = html + 
		    '<input type="button" value="hide" onclick="log_show_set(0)">';
		log.style.display='block';
	} else {
     		html = html +
		    '<input type="button" value="show" onclick="log_show_set(1)">';
		log.style.display='none';
	}
	log_show.innerHTML = html;
}


function log_show_set(show) 
{
	log_visible = show;
	log_draw();
}

function log_clear()
{
Jeroen Vreeken's avatar
Jeroen Vreeken committed
979
	log.innerHTML = 'cleared\n';
Jeroen Vreeken's avatar
Jeroen Vreeken committed
980
981
982
983
}

log_draw();

984
985


Jeroen Vreeken's avatar
Jeroen Vreeken committed
986
987
988
</script>

</html>