You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2453 lines
57 KiB

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<title>
Dwingeloo console interface
</title>
</head>
<body background="achtergrond.jpg"
onKeyDown="manual_spg_keydown(event)"
onKeyUp="manual_spg_keyup(event)"
>
<p>
<!--
Basic Azimuth & Elevation status
-->
<div style="background: lightgrey; border:thin solid black">
<table border="0">
<tr>
<th>
Azimuth
</th>
<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>
<td rowspan="2">
<span id="azimuth_elevation_disable"></span>
</td>
<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
</th>
<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
</th>
<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
-->
<div style="background: lightgrey; border:thin solid black">
<table border="0" width="100%">
<tr>
<th>
Authorized:
</th>
<td width="25%">
<div id="auth_status_line">No status received</div>
</td>
<td align="right">
<span id="auth_idle"></span>
<span id="auth_azel"></span>
<span id="auth_j2000"></span>
<span id="auth_moon"></span>
<span id="auth_sun"></span>
<span id="auth_sat"></span>
<span id="auth_manual"></span>
</td>
</tr>
</table>
</div>
</p>
<p>
<table border="0">
<tr>
<td>
<!--
Azel
-->
<div style="background: grey; border:thin solid black" width="50" id="spg_azel">
<i>
Azimuth & Elevation setpoint generator
</i>
<table border=0>
<tr>
<td>
</td>
<th>
Azimuth
</th>
<th>
Elevation
</th>
</tr>
<tr>
<th>
Last Setpoint:
</th>
<td width="20%">
<div id="Azel_Azimuth_Setpoint">
<div style='background: lightgrey; border:thin solid black'></div>
</div>
</td>
<td width="20%">
<div id="Azel_Elevation_Setpoint">
<div style='background: lightgrey; border:thin solid black'></div>
</div>
</td>
</tr>
<tr>
<th>
New Setpoint:
</th>
<td>
<input type="text" width="7" id="azel_az" onchange="check_floatval('azel_az');">
</td>
<td>
<input type="text" width="7" id="azel_el" onchange="check_floatval('azel_el');">
</td>
</tr>
</table>
<div style="border:thin solid black" align="center">
<b>Actions:</b>
<br>
<span id="azel_track"></span>
<br>
<span id="azel_copy_position"></span>
<span id="azel_copy_setpoint"></span>
<p>
</div>
<table style="border:thin solid black" width="100%">
<tr>
<th colspan="3">Presets:</th>
</tr>
<tr align="center">
<td>Azimuth</td><td>Elevation</td><td>Azimuth & Elevation</td>
</tr>
<tr>
<td width="30%" style="border:thin solid black">
<center>
<input type="button" value="W -270" onclick="azel_set_az('-270');">
<input type="button" value="N -180" onclick="azel_set_az('-180');">
<input type="button" value="E -90" onclick="azel_set_az('-90');">
<input type="button" value="S 0" onclick="azel_set_az('0');"><br>
<input type="button" value="W 90" onclick="azel_set_az('90');">
<input type="button" value="N 180" onclick="azel_set_az('180');">
<input type="button" value="E 270" onclick="azel_set_az('270');">
</center>
</td>
<td valign="top" width="30%" style="border:thin solid black">
<center>
<input type="button" value="Horizon 0" onclick="azel_set_el('0');">
<input type="button" value="Show-El. 30" onclick="azel_set_el('30');">
<input type="button" value="Zenith 90" onclick="azel_set_el('90');">
</center>
</td>
<td valign="top" width="30%" style="border:thin solid black">
<center>
<input type="button" value="Focusbox 134.7,-0.05" onclick="azel_set_coord('134.7','-0.05');"><br>
<input type="button" value="Show 30,30" onclick="azel_set_coord('30','30');"><br>
</center>
</td>
</tr>
</table>
</div>
</td>
<td>
<!--
J2000
-->
<div style="background: lightgrey; border:thin solid black" width="50" id="spg_j2000">
<i>
J2000 setpoint generator
</i>
<table border=0>
<tr>
<td>
</td>
<th>
Right ascension
</th>
<th>
Declination
</th>
</tr>
<tr>
<th>
Current Position:
</th>
<td width="20%">
<div id="J2000_Ra_Position"></div>
</td>
<td width="20%">
<div id="J2000_De_Position"></div>
</td>
</tr>
<tr>
<th>
Current Setpoint:
</th>
<td width="20%">
<div id="J2000_Ra_Setpoint"></div>
</td>
<td width="20%">
<div id="J2000_De_Setpoint"></div>
</td>
</tr>
<tr>
<th>
New Setpoint:
</th>
<td>
<input type="text" width="7" id="j2000_ra">
</td>
<td>
<input type="text" width="7" id="j2000_de">
</td>
</tr>
</table>
<div style="border:thin solid black" align="center">
<b>Actions:</b>
<br>
<span id="j2000_track"></span>
<br>
<span id="j2000_copy_position"></span>
<span id="j2000_copy_setpoint"></span>
<p>
</div>
<div style="border:thin solid black" align="center">
<b>Presets:</b>
<br>
<input type="button" value="Cassiopeia A" onclick="j2000_set_coord('23h23m26.0','058d48m00.0');">
<input type="button" value="Cygnus A" onclick="j2000_set_coord('19h59m28.3565','40d40m02.099');">
<input type="button" value="PSR B0329+54" onclick="j2000_set_coord('03h32m59.4','054d34m43.6');">
</div>
<div style="border:thin solid black" align="center">
<b>Compensations:</b>
<br>
<span id="j2000_tracking_enabled"></span>
<span id="j2000_refraction_enabled"></span>
<span id="j2000_dt_model_enabled"></span>
</div>
</div>
</td>
<td>
<!--
Manual control
-->
<div style="background: grey; border:thin solid black" width="50%" id="spg_manual">
<i>
Manual control
</i>
<center>
<table border="0" width="100%">
<tr>
<td rowspan="2"></td>
<td></td>
<th height="40" width="40" id="manual_spg_elp" style="background: #f0f0f0; border: thin solid black">
El +
</th><td></td>
<td rowspan="2"></td>
<td rowspan="2" style="border: thin solid black" width="1">
<center><b>Speed:</b></center><br>
<input type="button" id="manual_speed_slow" value="Slow" onClick="manual_speed_set('manual_speed_slow');"><br>
<input type="button" id="manual_speed_medium" value="Medium" onClick="manual_speed_set('manual_speed_medium');" style="background: lightgrey"><br>
<input type="button" id="manual_speed_fast" value="Fast" onClick="manual_speed_set('manual_speed_fast');" style="background: lightgrey"><br>
</td>
</tr>
<tr>
<th height="40" width="40" id="manual_spg_azm" style="background: #f0f0f0; border: thin solid black">
Az -
</th>
<th height="40" width="40" id="manual_spg_elm" style="background: #f0f0f0; border: thin solid black">
El -
</th>
<th height="40" width="40" id="manual_spg_azp" style="background: #f0f0f0; border: thin solid black">
Az +
</th>
</tr>
</table>
</center>
</div>
</td>
<td>
<!--
Sat
-->
<div style="background: lightgrey; border:thin solid black" width="50" id="spg_sat">
<i>
Satellite setpoint generator
</i>
<table border=0>
<tr>
<th>
Current TLE: <div id="Sat_TLE_name_Current"></div>
</th>
<td>
<div id="Sat_TLE_Current"></div>
</td>
<td rowspan="2">
<canvas id="sat_canvas" width="100" height="100"
style="border:thin solid black">
</canvas>
<span id="Sat_AOS"></span>
<span id="Sat_LOS"></span>
</td>
</tr>
<tr>
<th>
New TLE: <br>
<select id="Sat_TLE_select"></select>
</th>
<td>
<textarea id="Sat_TLE_new" rows="3" cols="69"></textarea>
</td>
</tr>
</table>
<div style="border:thin solid black" align="center">
<b>Actions:</b>
<span id="sat_set_tle"></span>
<span id="sat_update_tle"></span>
<p>
</div>
<div style="border:thin solid black" align="center">
<b>Compensations and switches:</b>
<span id="sat_enabled"></span>
<span id="sat_refraction_enabled"></span>
<span id="sat_dt_model_enabled"></span>
</div>
</div>
</td>
<td>
<!--
Sun
-->
<div style="background: lightgrey; border:thin solid black" width="50" id="spg_sun">
<i>
Sun setpoint generator
</i>
<div style="border:thin solid black" align="center">
<b>Compensations and switches:</b>
<br>
<span id="sun_enabled"></span>
<span id="sun_dt_model_enabled"></span>
</div>
</div>
</td>
<td>
<!--
Moon
-->
<div style="background: lightgrey; border:thin solid black" width="50" id="spg_moon">
<i>
Moon setpoint generator
</i>
<div style="border:thin solid black" align="center">
<b>Compensations and switches:</b>
<br>
<span id="moon_enabled"></span>
<span id="moon_dt_model_enabled"></span>
</div>
</div>
</td>
<!--
Offset
-->
<td>
<div style="background: lightgrey; border:thin solid black" width="50%"
id="Offset">
<i>
Offset
</i>
<div id="Offset_show" align="right" style="float:right"></div>
<table border="0" id="Offset_table">
<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>
</td>
<!--
DT model
-->
<td>
<div style="background: lightgrey; border:thin solid black" width="50%"
id="DT_model">
<i>
DT model
</i>
<div id="DT_model_show" align="right" style="float:right"></div>
<table border="0" id="DT_model_table">
<tr><th>Name</th><td><div id="DT_model_name"></div></td></tr>
<tr><th>a0</th><td><div id="DT_model_a0"></div></td></tr>
<tr><th>c1</th><td><div id="DT_model_c1"></div></td></tr>
<tr><th>c2</th><td><div id="DT_model_c2"></div></td></tr>
<tr><th>e0</th><td><div id="DT_model_e0"></div></td></tr>
<tr><th>b</th><td><div id="DT_model_b"></div></td></tr>
<tr><th>za</th><td><div id="DT_model_za"></div></td></tr>
<tr><th>aa</th><td><div id="DT_model_aa"></div></td></tr>
<tr><th colspan="2"><span id="DT_model_reload"></span></th></tr>
</table>
</p>
</div>
<!--
end of box row
-->
</td>
</tr>
</table>
<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;
font-family: monospace; font-size:100%; white-space: pre ;
overflow:scroll'>
</div>
</div>
<p>
<div>
<table width="100%" border="0">
<tr>
<td>
<a href="mech.html" target="_blank">Mechanics</a>
</td>
<td align="center">
<b>
<a href="help.html" target="_blank">Help</a>
</b>
</td>
<td align="right">
<script type="text/javascript" src="console_version.js"></script>
</td>
</div>
</center>
</div>
</td>
<td>
</td>
</tr>
</table>
</p>
</body>
<script src="load.js" type="text/javascript"></script>
<script type="text/javascript">
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009, 2011, 2012,
2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009,
2011, 2012, 2013
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"));
eval(load("auth.js"));
eval(load("auth_status.js"));
eval(load("azel_command.js"));
eval(load("j2000_status.js"));
eval(load("j2000_command.js"));
eval(load("status.js"));
eval(load("command.js"));
eval(load("manual_command.js"));
eval(load("dt_view.js"));
eval(load("utils.js"));
eval(load("offset.js"));
/*
'constants'
*/
var trace_url = "trace.cgi";
var url_red = "light_red.gif";
var url_green = "light_green.gif";
var shell_url = "shell.cgi";
var auth_url = "command.cgi";
var auth_status_url = "status.cgi";
var offset_url = "command.cgi";
var azel_command_url = "command.cgi";
var j2000_status_url = "status.cgi";
var j2000_command_url = "command.cgi";
var sat_status_url = "status.cgi";
var sat_command_url = "command.cgi";
var sun_status_url = "status.cgi";
var sun_command_url = "command.cgi";
var moon_status_url = "status.cgi";
var moon_command_url = "command.cgi";
var manual_command_url = "command.cgi";
/*
*/
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
*/
var azimuth_enable_param = 'controller \'params { { "azimuth_servo_state", "enabled", (int)1 } } \' ';
var azimuth_elevation_disable_param = 'controller \'params { { "azimuth_servo_state", "enabled", (int)0 } { "elevation_servo_state", "enabled", (int)0 } { "elevation_safety", "recover", (int)0 } } \' ';
var azimuth_disable = new dt_button("azimuth_elevation_disable");
azimuth_disable.background("red");
azimuth_disable.value("Disable");
azimuth_disable.click(function() { do_auth('console/idle'); do_shell(azimuth_elevation_disable_param); } );
var azimuth_enable = new dt_button("azimuth_enable");
azimuth_enable.background("springgreen");
azimuth_enable.value("Enable");
azimuth_enable.click(function() { do_auth('console/idle'); do_shell(azimuth_enable_param); } );
function bool_priv()
{
this.doc;
this.lastval = -1;
this.truetext="true";
this.falsetext="false";
}
function bool_value(obj, time, value, unit)
{
var text;
if (value == obj.private.lastval)
return;
obj.private.lastval = value;
if (value == 0.0)
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.open(trace_url, 'Azimuth_Enabled', 2);
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";
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.open(trace_url, 'Azimuth_Safe', 2);
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";
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);
if (decimals(Azimuth_Pos, 0) != az_position_value_last)
update = 1;
if (decimals(setpointdeg, 0) != az_setpoint_value_last)
update = 1;
if (!update)
return;
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.open(trace_url, 'Elevation_Enabled', 2);
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";
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.open(trace_url, 'Elevation_Safe', 2);
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";
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;
var elevation_enable_param = 'controller \'params { { "elevation_servo_state", "enabled", (int)1 } { "elevation_safety", "recover", (int)0 } } \' ';
var elevation_enable = new dt_button("elevation_enable");
elevation_enable.background("springgreen");
elevation_enable.value("Enable");
elevation_enable.click(function() { do_auth('console/idle'); do_shell(elevation_enable_param); } );
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);
if (decimals(Elevation_Pos, 0) != el_position_value_last)
update = 1;
if (decimals(setpointdeg, 0) != el_setpoint_value_last)
update = 1;
if (!update)
return;
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");
focusbox_position.number_set(true, 0);
focusbox_position.highlight_set(true, "yellow", "white");
function Focusbox_Position_trace_value(obj, time, value, unit)
{
focusbox_position.value(value * 10);
}
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
*
******************************************************************/
var auth_idle = new dt_button("auth_idle");
auth_idle.background("#b0b0b0");
auth_idle.value("Idle");
auth_idle.click(function() { do_auth('console/idle');} );
var auth_azel = new dt_button("auth_azel");
auth_azel.background("#b0b0b0");
auth_azel.value("Azimuth & Elevation");
auth_azel.click(function() { do_auth('console/azel');} );
var auth_j2000 = new dt_button("auth_j2000");
auth_j2000.background("#b0b0b0");
auth_j2000.value("J2000");
auth_j2000.click(function() { do_auth('console/j2000tracker');} );
var auth_moon = new dt_button("auth_moon");
auth_moon.background("#b0b0b0");
auth_moon.value("Moon");
auth_moon.click(function() { do_auth('console/moontracker');} );
var auth_sun = new dt_button("auth_sun");
auth_sun.background("#b0b0b0");
auth_sun.value("Sun");
auth_sun.click(function() { do_auth('console/suntracker');} );
var auth_sat = new dt_button("auth_sat");
auth_sat.background("#b0b0b0");
auth_sat.value("Satellite");
auth_sat.click(function() { do_auth('console/sattracker');} );
var auth_manual = new dt_button("auth_manual");
auth_manual.background("#b0b0b0");
auth_manual.value("Manual");
auth_manual.click(function() { do_auth('console/manual');} );
var do_auth_obj = new auth(auth_url, "auth");
var set_offset_obj = new offset(offset_url, "offset");
var auth_last_line = "no spg";
function do_auth(command)
{
j2000_set_switch("enabled", 0);
if (command == "console/j2000tracker") {
j2000_do_cp_pos();
j2000_do_track();
}
sat_set_switch("enabled", 0);
sun_set_switch("enabled", 0);
moon_set_switch("enabled", 0);
do_auth_obj.open(command);
}
var auth_last_line = "no spg";
var auth_last_scriptline = "-";
function my_event() {
this.keyCode = 0;
};
var fake_event = new my_event();
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();
}
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;
}
set_offset_obj.open(deg2rad(offset_az_set), deg2rad(offset_el_set));
}
var Azimuth_Offset;
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");
offset_show_set(offset_visible, false);
}
}
var Elevation_Offset;
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");
offset_show_set(offset_visible, false);
}
}
var auth_status_line = new dt_traceval("auth_status_line");
auth_status_line.background("white");
function dt_auth_status_line(obj, line, azimuth_off, elevation_off)
{
Azimuth_Offset_value(azimuth_off);
Elevation_Offset_value(elevation_off);
if (auth_last_line == line)
return;
var spg_azel = document.getElementById('spg_azel');
var spg_j2000 = document.getElementById('spg_j2000');
var spg_sat = document.getElementById('spg_sat');
var spg_sun = document.getElementById('spg_sun');
var spg_moon = document.getElementById('spg_moon');
var spg_manual = document.getElementById('spg_manual');
if (line == "\n") {
line = "No spg selected";
}
auth_last_line = line;
auth_status_line.value(line);
spg_azel.style.background = "grey";
spg_j2000.style.background = "grey";
spg_sat.style.background = "grey";
spg_sun.style.background = "grey";
spg_moon.style.background = "grey";
spg_manual.style.background = "grey";
auth_idle.background("#b0b0b0");
auth_azel.background("#b0b0b0");
auth_j2000.background("#b0b0b0");
auth_sat.background("#b0b0b0");
auth_moon.background("#b0b0b0");
auth_sun.background("#b0b0b0");
auth_manual.background("#b0b0b0");
if (line == "console/azel") {
azel_do_cp_pos();
spg_azel.style.background = "lightgrey";
auth_azel.background("lightgreen");
spg_azel.style.display = 'block';
} else {
spg_azel.style.display = 'none';
}
if (line == "console/j2000tracker") {
j2000_do_cp_pos();
spg_j2000.style.background = "lightgrey";
auth_j2000.background("lightgreen");
spg_j2000.style.display = 'block';
} else {
spg_j2000.style.display = 'none';
}
if (line == "console/sattracker") {
spg_sat.style.background = "lightgrey";
auth_sat.background("lightgreen");
spg_sat.style.display = 'block';
} else {
spg_sat.style.display = 'none';
}
if (line == "console/idle") {
auth_idle.background("lightgreen");
}
if (line == "console/moontracker") {
spg_moon.style.background = "lightgrey";
auth_moon.background("lightgreen");
spg_moon.style.display = 'block';
} else {
spg_moon.style.display = 'none';
}
if (line == "console/suntracker") {
spg_sun.style.background = "lightgrey";
auth_sun.background("lightgreen");
spg_sun.style.display = 'block';
} else {
spg_sun.style.display = 'none';
}
if (line == "console/manual") {
auth_manual.background("lightgreen");
spg_manual.style.background = "lightgrey";
manual_spg_active = 1;
spg_manual.style.display = 'block';
} else {
manual_spg_active = 0;
manual_spg_keyup(fake_event);
spg_manual.style.display = 'none';
}
}
dt_auth_status = new auth_status(auth_status_url, "auth");
dt_auth_status.callback = dt_auth_status_line;
dt_auth_status.open();
/******************************************************************
*
* Azel spg control
*
******************************************************************/
var azel_track = new dt_button("azel_track");
azel_track.value("Track");
azel_track.click(function() { azel_do_track(); } );
var azel_copy_position = new dt_button("azel_copy_position");
azel_copy_position.value("Copy current position");
azel_copy_position.click(function() { azel_do_cp_pos(); } );
var azel_copy_setpoint = new dt_button("azel_copy_setpoint");
azel_copy_setpoint.value("Copy current setpoint");
azel_copy_setpoint.click(function() { azel_do_cp_setp(); } );
var azel_az_set = "??"
var azel_el_set = "??"
azelcommand = new azel_command(azel_command_url, "azel");
var azel_azimuth_setpoint = new dt_traceval("Azel_Azimuth_Setpoint");
var azel_elevation_setpoint = new dt_traceval("Azel_Elevation_Setpoint");
azel_azimuth_setpoint.background("white");
azel_elevation_setpoint.background("white");
function azel_do_track()
{
check_floatval('azel_az');
check_floatval('azel_el');
azel_az_set = document.getElementById('azel_az').value;
azel_el_set = document.getElementById('azel_el').value;
if (azel_az_set > 270 || azel_az_set < -270 ||
azel_el_set > 91 || azel_el_set < -1) {
alert(azel_az_set + "," + azel_el_set + " is not a valid position.");
} else {
azelcommand.open(azel_az_set, azel_el_set);
azel_azimuth_setpoint.value(azel_az_set);
azel_elevation_setpoint.value(azel_el_set);
}
}
function azel_do_cp_pos()
{
var az_text = document.getElementById('azel_az');
var el_text = document.getElementById('azel_el');
az_text.value = Azimuth_Pos;
el_text.value = Elevation_Pos;
}
function azel_do_cp_setp()
{
var az_text = document.getElementById('azel_az');
var el_text = document.getElementById('azel_el');
az_text.value = azel_az_set;
el_text.value = azel_el_set;
}
function azel_set_coord(az, el)
{
var az_text = document.getElementById('azel_az');
var el_text = document.getElementById('azel_el');
az_text.value = az;
el_text.value = el;
}
function azel_set_az(az)
{
var az_text = document.getElementById('azel_az');
az_text.value = az;
}
function azel_set_el(el)
{
var el_text = document.getElementById('azel_el');
el_text.value = el;
}
/******************************************************************
*
* J2000 spg control
*
******************************************************************/
var j2000_tracking_enabled = new dt_button("j2000_tracking_enabled");
j2000_tracking_enabled.background("white");
j2000_tracking_enabled.value("Tracking enabled");
j2000_tracking_enabled.click(function() { j2000_toggle_switch('enabled'); } );
var j2000_refraction_enabled = new dt_button("j2000_refraction_enabled");
j2000_refraction_enabled.background("white");
j2000_refraction_enabled.value("Refraction");
j2000_refraction_enabled.click(function() { j2000_toggle_switch('refraction'); } );
var j2000_dt_model_enabled = new dt_button("j2000_dt_model_enabled");
j2000_dt_model_enabled.background("white");
j2000_dt_model_enabled.value("DT model");
j2000_dt_model_enabled.click(function() { j2000_toggle_switch('dt_model'); } );
var j2000_track = new dt_button("j2000_track");
j2000_track.value("Track");
j2000_track.click(function() { j2000_do_track(); } );
var j2000_copy_position = new dt_button("j2000_copy_position");
j2000_copy_position.value("Copy current position");
j2000_copy_position.click(function() { j2000_do_cp_pos(); } );
var j2000_copy_setpoint = new dt_button("j2000_copy_setpoint");
j2000_copy_setpoint.value("Copy current setpoint");
j2000_copy_setpoint.click(function() { j2000_do_cp_setp(); } );
var j2000_ra_set = "??"
var j2000_de_set = "??"
var j2000_ra_now = "??"
var j2000_de_now = "??"
var j2000_switches = "??"
var j2000_ra_position = new dt_traceval("J2000_Ra_Position");
var j2000_de_position = new dt_traceval("J2000_De_Position");
var j2000_ra_setpoint = new dt_traceval("J2000_Ra_Setpoint");
var j2000_de_setpoint = new dt_traceval("J2000_De_Setpoint");
function j2000_status_cb(
new_ra_set, new_dec_set,
new_ra_now, new_dec_now,
ut, switches)
{
if (new_ra_now != j2000_ra_now) {
j2000_ra_position.value(new_ra_now);
j2000_ra_now = new_ra_now;
}
if (new_dec_now != j2000_de_now) {
j2000_de_position.value(new_dec_now);
j2000_de_now = new_dec_now;
}
if (new_ra_set != j2000_ra_set) {
j2000_ra_setpoint.value(new_ra_set);
j2000_ra_set = new_ra_set;
}
if (new_dec_set != j2000_de_set) {
j2000_de_setpoint.value(new_dec_set);
j2000_de_set = new_dec_set;
}
if (switches != j2000_switches) {
var switch_array = new Array();
j2000_switches = switches;
switch_array[0] = switches.split(',')[0];
switch_array[1] = switches.split(',')[1];
switch_array[2] = switches.split(',')[2];
for (i = 0; i < 3; i++) {
var switchtype;
if (switch_array[i].split('=')[0] == 'enabled')
switchtype=j2000_tracking_enabled;
else if (switch_array[i].split('=')[0] == 'dt_model')
switchtype=j2000_dt_model_enabled;
else if (switch_array[i].split('=')[0] == 'refraction')
switchtype=j2000_refraction_enabled;
if (switch_array[i].split('=')[1].charAt(0) == '1')
switchtype.background("lightgreen");
else
switchtype.background("red");
}
}
}
j2000status = new j2000_status(j2000_status_url, "j2000");
j2000status.callback = j2000_status_cb;
j2000status.open();
j2000command = new j2000_command(j2000_command_url, "j2000");
function j2000_do_track(switchval)
{
if (switchval == null)
switchval = "";
j2000command.open(
document.getElementById('j2000_ra').value,
document.getElementById('j2000_de').value,
switchval);
}
function j2000_do_cp_setp()
{
var ra_text = document.getElementById('j2000_ra');
var de_text = document.getElementById('j2000_de');
ra_text.value = j2000_ra_set;
de_text.value = j2000_de_set;
}
function j2000_toggle_switch(switchname)
{
var value;
var switch_array = new Array();
var i;
switch_array[0] = j2000_switches.split(',')[0];
switch_array[1] = j2000_switches.split(',')[1];
switch_array[2] = j2000_switches.split(',')[2];
for (i = 0; i < 3; i++) {
if (switch_array[i].split('=')[0] == switchname)
value = switch_array[i].split('=')[1].charAt(0);
}
if (value == '1') {
value = '0';
} else {
value = '1';
}
j2000_do_cp_setp();
j2000_do_track(switchname + '=' + value);
}
function j2000_set_switch(switchname, value)
{
j2000_do_cp_setp();
j2000_do_track(switchname + '=' + value);
}
function j2000_do_cp_pos()
{
var ra_text = document.getElementById('j2000_ra');
var de_text = document.getElementById('j2000_de');
ra_text.value = j2000_ra_now;
de_text.value = j2000_de_now;
}
function j2000_set_coord(ra, de)
{
var ra_text = document.getElementById('j2000_ra');
var de_text = document.getElementById('j2000_de');
ra_text.value = ra;
de_text.value = de;
}
/******************************************************************
*
* Satellite spg control
*
******************************************************************/
var sat_enabled = new dt_button("sat_enabled");
sat_enabled.background("white");
sat_enabled.value("Tracking enabled");
sat_enabled.click(function() { sat_toggle_switch('enabled'); } );
var sat_refraction_enabled = new dt_button("sat_refraction_enabled");
sat_refraction_enabled.background("white");
sat_refraction_enabled.value("Refraction");
sat_refraction_enabled.click(function() { sat_toggle_switch('refraction'); } );
var sat_dt_model_enabled = new dt_button("sat_dt_model_enabled");
sat_dt_model_enabled.background("white");
sat_dt_model_enabled.value("DT model");
sat_dt_model_enabled.click(function() { sat_toggle_switch('dt_model'); } );
var sat_set_tle = new dt_button("sat_set_tle");
sat_set_tle.value("Set new TLE");
sat_set_tle.click(function() { sat_send_command(); } );
var sat_update_tle = new dt_button("sat_update_tle");
sat_update_tle.value("Update TLE from Celestrak");
sat_update_tle.click(function() { sat_update(); } );
var sat_switches = "??";
var sat_tle_now = "??";
var sat_tle_name_now = "??";
satstatus = new status(sat_status_url, "sat");
satstatus.callback = sat_status_cb;
satstatus.open();
var sat_tle_current = new dt_traceval("Sat_TLE_Current");
sat_tle_current.background("white");
var sat_tle_name_current = new dt_traceval("Sat_TLE_name_Current");
sat_tle_name_current.background("white");
var sat_view = new satellite_view("sat_canvas");
var sat_aos = new dt_traceval("Sat_AOS");
sat_aos.background("white");
var sat_los = new dt_traceval("Sat_LOS");
sat_los.background("white");
function sat_tle_view_parse(line)
{
var i;
var sat_coord = new Array();
if (line == "unknown") {
sat_view.draw(null);
sat_aos.value("unknown");
sat_los.value("unknown");
return;
}
var coord = line.split(' ');
for (i = 0; i < coord.length; i++) {
var t = coord[i].split(':')[0];
var az = coord[i].split(':')[1];
var el = coord[i].split(':')[2];
if (t < 1)
break;
sat_coord.push( new function() {
this.t = t;
this.az = az;
this.el = el;
});
// alert("i " + i + " t " + sat_coord[i].t + " az " + sat_coord[i].az +
// " el " + sat_coord[i].el);
}
sat_view.draw(sat_coord);
var t_aos = new Date();
var t_los = new Date();
t_aos.setTime(sat_coord[0].t * 1000);
t_los.setTime(sat_coord[sat_coord.length - 1].t * 1000);
sat_aos.value(
("0" + t_aos.getUTCHours()).slice(-2) +":"+
("0" + t_aos.getUTCMinutes()).slice(-2) +":"+
("0" + t_aos.getUTCSeconds()).slice(-2) + " UTC");
sat_los.value(
("0" + t_los.getUTCHours()).slice(-2) +":"+
("0" + t_los.getUTCMinutes()).slice(-2) +":"+
("0" + t_los.getUTCSeconds()).slice(-2) + " UTC");
}
function sat_status_cb(switches)
{
var tle = sat_tle_now;
var tle_name = sat_tle_name_now;
if (switches != sat_switches) {
var switch_array = new Array();
sat_switches = switches;
switch_array = switches.split(',');
for (i = 0; i < switch_array.length; i++) {
var switchtype;
var switchset = true;
if (switch_array[i].split('=')[0] == 'dt_model')
switchtype=sat_dt_model_enabled;
else if (switch_array[i].split('=')[0] == 'refraction')
switchtype=sat_refraction_enabled;
else if (switch_array[i].split('=')[0] == 'enabled')
switchtype=sat_enabled;
else if (switch_array[i].split('=')[0] == 'tle') {
switchset = false;
tle = switch_array[i].split('=')[1];
} else if (switch_array[i].split('=')[0] == 'name') {
switchset = false;
tle_name = switch_array[i].split('=')[1];
} else if (switch_array[i].split('=')[0] == 'pass') {
switchset = false;
sat_tle_view_parse(switch_array[i].split('=')[1]);
} else {
switchset = false;
}
if (switchset == true) {
if (switch_array[i].split('=')[1].charAt(0) == '1')
switchtype.background("lightgreen");
else
switchtype.background("red");
}
}
}
if (tle != sat_tle_now) {
var tle1 = tle.substr(0,69);
var tle2 = tle.substr(69,69);
sat_tle_current.value("" + tle1 + "\n" + tle2 + "");
}
if (tle_name != sat_tle_name_now) {
sat_tle_name_current.value(tle_name);
}
sat_tle_now = tle;
sat_tle_name_now = tle_name;
}
satcommand = new command(sat_command_url, "sat");
function sat_send_command(switchval)
{
var command;
var i;
if (switchval == null) {
var tle = document.getElementById('Sat_TLE_new').value;
// var tle1 = tle.substr(0,69);
// var tle2;
// for (i = 70; i < tle.length && tle.charAt(i) != '2'; i++);
// tle2 = tle.substr(i, 69);
// command = "tle=" + tle1 + tle2;
command = "tle=" + tle.split('\n').join('');
} else {
command = switchval;
}
satcommand.send(command);
}
function sat_set_switch(switchname, value)
{
var switch_array = new Array();
sat_send_command(switchname + '=' + value);
}
function sat_toggle_switch(switchname)
{
var value;
var switch_array = new Array();
var i;
switch_array[0] = sat_switches.split(',')[0];
switch_array[1] = sat_switches.split(',')[1];
switch_array[2] = sat_switches.split(',')[2];
switch_array[3] = sat_switches.split(',')[3];
for (i = 0; i < 4; i++) {
if (switch_array[i].split('=')[0] == switchname)
value = switch_array[i].split('=')[1].charAt(0);
}
if (value == '1') {
value = '0';
} else {
value = '1';
}
sat_set_switch(switchname, value);
}
sat_tle_select = document.getElementById("Sat_TLE_select");
var sat_tle = new Array();
function sat_select_click(name)
{
for (i = 0; i < sat_tle.length; i++) {
if (name == sat_tle[i].name) {
tle =
sat_tle[i].name + "\n" +
sat_tle[i].tle1 + "\n" +
sat_tle[i].tle2;
document.getElementById('Sat_TLE_new').value = tle;
}
}
}
function sat_tle_sortname(a, b)
{
return a.name > b.name;
}
function sat_reload()
{
var element_lines = new Array();
while (sat_tle_select.options.length)
sat_tle_select.remove(0);
sat_tle.length = 0;
amateur = load("tle/amateur.txt").split('\n');
tle_new = load("tle/tle-new.txt").split('\n');
gps_ops = load("tle/gps-ops.txt").split('\n');
amateur.length -= amateur.length % 3;
tle_new.length -= tle_new.length % 3;
gps_ops.length -= gps_ops.length % 3;
element_lines = amateur.concat(tle_new).concat(gps_ops);
for (i = 0; i < element_lines.length - 2; i += 3) {
var ti = sat_tle.length;
sat_tle[ti] = new function () {
this.name = element_lines[i+0];
this.tle1 = element_lines[i+1];
this.tle2 = element_lines[i+2];
this.option = document.createElement("option");
this.option.text = this.name;
this.option.onclick = function() {
sat_select_click(this.text);
}
this.name = this.option.text;
}
}
sat_tle.sort(sat_tle_sortname);
for (i = 0; i < sat_tle.length; i++) {
sat_tle_select.add(sat_tle[i].option, null);
}
}
function sat_update()
{
update_ret = load("tle_update.cgi");
alert("ret: " + update_ret);
sat_reload();
}
sat_reload();
sat_tle_select.onchange = function() {
sat_select_click(this.options[this.selectedIndex].text);
}
/******************************************************************
*
* Sun spg control
*
******************************************************************/
var sun_enabled = new dt_button("sun_enabled");
sun_enabled.background("white");
sun_enabled.value("Tracking enabled");
sun_enabled.click(function() { sun_toggle_switch('enabled'); } );
var sun_dt_model_enabled = new dt_button("sun_dt_model_enabled");
sun_dt_model_enabled.background("white");
sun_dt_model_enabled.value("DT model");
sun_dt_model_enabled.click(function() { sun_toggle_switch('dt_model'); } );
var sun_switches = "??";
sunstatus = new status(sun_status_url, "sun");
sunstatus.callback = sun_status_cb;
sunstatus.open();
function sun_status_cb(switches)
{
if (switches != sun_switches) {
var switch_array = new Array();
sun_switches = switches;
switch_array[0] = switches.split(',')[0];
switch_array[1] = switches.split(',')[1];
for (i = 0; i < 2; i++) {
var switchtype;
var switchset = true;
if (switch_array[i].split('=')[0] == 'dt_model')
switchtype=sun_dt_model_enabled;
else if (switch_array[i].split('=')[0] == 'enabled')
switchtype=sun_enabled;
else
switchset = false;
if (switchset == true) {
if (switch_array[i].split('=')[1].charAt(0) == '1')
switchtype.background("lightgreen");
else
switchtype.background("red");
}
}
}
}
suncommand = new command(sun_command_url, "sun");
function sun_send_command(switchval)
{
suncommand.send(switchval);
}
function sun_set_switch(switchname, value)
{
var switch_array = new Array();
sun_send_command(switchname + '=' + value);
}
function sun_toggle_switch(switchname)
{
var value;
var switch_array = new Array();
var i;
switch_array[0] = sun_switches.split(',')[0];
switch_array[1] = sun_switches.split(',')[1];
for (i = 0; i < 2; i++) {
if (switch_array[i].split('=')[0] == switchname)
value = switch_array[i].split('=')[1].charAt(0);
}
if (value == '1') {
value = '0';
} else {
value = '1';
}
sun_set_switch(switchname, value);
}
/******************************************************************
*
* Moon spg control
*
******************************************************************/
var moon_enabled = new dt_button("moon_enabled");
moon_enabled.background("white");
moon_enabled.value("Tracking enabled");
moon_enabled.click(function() { moon_toggle_switch('enabled'); } );
var moon_dt_model_enabled = new dt_button("moon_dt_model_enabled");
moon_dt_model_enabled.background("white");
moon_dt_model_enabled.value("DT model");
moon_dt_model_enabled.click(function() { moon_toggle_switch('dt_model'); } );
var moon_switches = "??";
moonstatus = new status(moon_status_url, "moon");
moonstatus.callback = moon_status_cb;
moonstatus.open();
function moon_status_cb(switches)
{
if (switches != moon_switches) {
var switch_array = new Array();
moon_switches = switches;
switch_array[0] = switches.split(',')[0];
switch_array[1] = switches.split(',')[1];
for (i = 0; i < 2; i++) {
var switchtype;
var switchset = true;
if (switch_array[i].split('=')[0] == 'dt_model')
switchtype=moon_dt_model_enabled;
else if (switch_array[i].split('=')[0] == 'enabled')
switchtype=moon_enabled;
else
switchset = false;
if (switchset == true) {
if (switch_array[i].split('=')[1].charAt(0) == '1')
switchtype.background("lightgreen");
else
switchtype.background("red");
}
}
}
}
mooncommand = new command(moon_command_url, "moon");
function moon_send_command(switchval)
{
mooncommand.send(switchval);
}
function moon_set_switch(switchname, value)
{
var switch_array = new Array();
moon_send_command(switchname + '=' + value);
}
function moon_toggle_switch(switchname)
{
var value;
var switch_array = new Array();
var i;
switch_array[0] = moon_switches.split(',')[0];
switch_array[1] = moon_switches.split(',')[1];
for (i = 0; i < 2; i++) {
if (switch_array[i].split('=')[0] == switchname)
value = switch_array[i].split('=')[1].charAt(0);
}
if (value == '1') {
value = '0';
} else {
value = '1';
}
moon_set_switch(switchname, value);
}
/******************************************************************
*
* Manual spg control
*
******************************************************************/
var manual_spg_active = 0;
var manual_azp = 0;
var manual_azm = 0;
var manual_elp = 0;
var manual_elm = 0;
var manual_slow = 0.0001;
var manual_medium = 0.0003;
var manual_fast = 0.001;
var manual_speed = manual_slow;
var manual_speed_slow = document.getElementById('manual_speed_slow');
var manual_speed_medium = document.getElementById('manual_speed_medium');
var manual_speed_fast = document.getElementById('manual_speed_fast');
manualcommand = new manual_command(manual_command_url, "manual");
function manual_speed_set(button)
{
manual_speed_slow.style.background = 'lightgrey';
manual_speed_medium.style.background = 'lightgrey';
manual_speed_fast.style.background = 'lightgrey';
if (button == "manual_speed_slow") {
manual_speed = manual_slow
manual_speed_slow.style.background = '#f0f0f0';
}
if (button == "manual_speed_medium") {
manual_speed = manual_medium
manual_speed_medium.style.background = '#f0f0f0';
}
if (button == "manual_speed_fast") {
manual_speed = manual_fast
manual_speed_fast.style.background = '#f0f0f0';
}
}
function manual_spg_keydown(e)
{
if (!manual_spg_active)
return;
else {
var sendcommand = 0;
if (e.keyCode == 38) {
var elp = document.getElementById('manual_spg_elp');
elp.style.background='#4040ff';
manual_elp = manual_speed;
sendcommand = 1;
}
if (e.keyCode == 37) {
var azm = document.getElementById('manual_spg_azm');
azm.style.background='#4040ff';
manual_azm = manual_speed;
sendcommand = 1;
}
if (e.keyCode == 40) {
var elm = document.getElementById('manual_spg_elm');
elm.style.background='#4040ff';
manual_elm = manual_speed;
sendcommand = 1;
}
if (e.keyCode == 39) {
var azp = document.getElementById('manual_spg_azp');
azp.style.background='#4040ff';
manual_azp = manual_speed;
sendcommand = 1;
}
if (sendcommand) {
manualcommand.open(
manual_azp - manual_azm,
manual_elp - manual_elm);
}
}
}
function manual_spg_keyup(e)
{
var sendcommand = 0;
if (manual_spg_active) {
if (e.keyCode == 38) {
var elp = document.getElementById('manual_spg_elp');
elp.style.background='#f0f0f0';
manual_elp = 0;
sendcommand = 1;
}
if (e.keyCode == 37) {
var azm = document.getElementById('manual_spg_azm');
azm.style.background='#f0f0f0';
manual_azm = 0;
sendcommand = 1;
}
if (e.keyCode == 40) {
var elm = document.getElementById('manual_spg_elm');
elm.style.background='#f0f0f0';
manual_elm = 0;
sendcommand = 1;
}
if (e.keyCode == 39) {
var azp = document.getElementById('manual_spg_azp');
azp.style.background='#f0f0f0';
manual_azp = 0;
sendcommand = 1;
}
} else {
if (manual_azp || manual_azm || manual_elm || manual_elp) {
var elm = document.getElementById('manual_spg_elm');
var elp = document.getElementById('manual_spg_elp');
var azm = document.getElementById('manual_spg_azm');
var azp = document.getElementById('manual_spg_azp');
sendcommand = 1;
manual_azp = 0;
manual_azm = 0;
manual_elp = 0;
manual_elm = 0;
elp.style.background='#f0f0f0';
elm.style.background='#f0f0f0';
azm.style.background='#f0f0f0';
azp.style.background='#f0f0f0';
}
}
if (sendcommand) {
manualcommand.open(
manual_azp - manual_azm,
manual_elp - manual_elm);
}
}
/****************************
Log
*/
var log_elem = document.getElementById('log');
log.innerHTML = "log:";
function log_status_cb(data)
{
log.innerHTML = log.innerHTML + "\n" + data;
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()
{
log.innerHTML = 'cleared';
}
log_draw();
/****************************
DT model
*/
var DT_model_status_url = "status.cgi";
var DT_model_command_url = "command.cgi";
var DT_model_table = document.getElementById('DT_model_table');
var DT_model_show = document.getElementById('DT_model_show');
var DT_model_visible = false;
function DT_model_draw()
{
if (DT_model_visible) {
DT_model_show.innerHTML=
'<input type="button" value="hide" onclick="DT_model_show_set(0, true)">';
DT_model_table.style.display='block';
} else {
DT_model_show.innerHTML=
'<input type="button" value="show" onclick="DT_model_show_set(1, true)">';
DT_model_table.style.display='none';
}
}
function DT_model_show_set(show, interactive)
{
DT_model_visible = show;
DT_model_draw();
}
var DT_model_name_val = new dt_traceval("DT_model_name");
var DT_model_a0_val = new dt_traceval("DT_model_a0");
var DT_model_c1_val = new dt_traceval("DT_model_c1");
var DT_model_c2_val = new dt_traceval("DT_model_c2");
var DT_model_e0_val = new dt_traceval("DT_model_e0");
var DT_model_b_val = new dt_traceval("DT_model_b");
var DT_model_za_val = new dt_traceval("DT_model_za");
var DT_model_aa_val = new dt_traceval("DT_model_aa");
DT_model_draw();
var DT_model_vars = "0";
function DT_model_status_cb(vars)
{
if (vars != DT_model_vars) {
var vars_array = vars.split(',');
var i;
DT_model_vars = vars;
for (i = 0; i < vars_array.length; i++) {
var varname = vars_array[i].split('=')[0];
var varvalue = vars_array[i].split('=')[1];
if (varname == 'name') {
DT_model_name_val.value(varvalue);
DT_model_name_val.background("white");
}
if (varname == 'a0') {
DT_model_a0_val.value(varvalue);
DT_model_a0_val.background("white");
}
if (varname == 'c1') {
DT_model_c1_val.value(varvalue);
DT_model_c1_val.background("white");
}
if (varname == 'c2') {
DT_model_c2_val.value(varvalue);
DT_model_c2_val.background("white");
}
if (varname == 'e0') {
DT_model_e0_val.value(varvalue);
DT_model_e0_val.background("white");
}
if (varname == 'b') {
DT_model_b_val.value(varvalue);
DT_model_b_val.background("white");
}
if (varname == 'za') {
DT_model_za_val.value(varvalue);
DT_model_za_val.background("white");
}
if (varname == 'aa') {
DT_model_aa_val.value(varvalue);
DT_model_aa_val.background("white");
}
}
}
}
DT_model_status = new status(DT_model_status_url, "dt_model");
DT_model_status.callback = DT_model_status_cb;
DT_model_status.open();
DT_model_command = new command(DT_model_command_url, "dt_model");
var DT_model_reload_button = new dt_button("DT_model_reload");
DT_model_reload_button.value("Reload");
DT_model_reload_button.click(function(){DT_model_command.send("reload=1")});
</script>
</html>