Commit bd8e93da authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

All trackers rewritten to use the dt_ui UI elements

parent 5cb13f3c
/*
Javascript sending azimuth & elevation coordinates over XMLHttp
Javascript sending azimuth & elevation coordinates
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2014
Copyright Stichting C.A. Muller Radioastronomiestation, 2008
This program is free software: you can redistribute it and/or modify
......@@ -30,3 +30,281 @@ function azel_command (url, ident)
}
}
var azel_loaded;
if (!azel_loaded) {
azel_loaded = true;
eval(load("utils.js"));
eval(load("dt_websocket.js"));
eval(load("dt_ui.js"));
function azel(element_name) {
var azel_this = this;
/*
Create all the UI elements
*/
this.window = new dt_ui_window(element_name);
this.window.title_set("Azimuth & Elevation tracker");
this.lbl_filler = new dt_ui_element(element_name + "_lbl_filler");
this.lbl_azimuth = new dt_ui_element(element_name + "_lbl_azimuth");
this.lbl_elevation = new dt_ui_element(element_name + "_lbl_elevation");
this.lbl_last_setpoint = new dt_ui_element(element_name + "_lbl_last_setpoint");
this.lbl_new_setpoint = new dt_ui_element(element_name + "_lbl_new_setpoint");
this.val_last_azimuth = new dt_ui_value(element_name + "_val_last_azimuth");
this.val_last_elevation = new dt_ui_value(element_name + "_val_last_elevation");
this.txt_new_azimuth = new dt_ui_text(element_name + "_txt_new_azimuth");
this.txt_new_elevation = new dt_ui_text(element_name + "_txt_new_elevation");
this.pos_v1 = new dt_ui_element(element_name + "_pos_v1");
this.pos_v2 = new dt_ui_element(element_name + "_pos_v2");
this.pos_v3 = new dt_ui_element(element_name + "_pos_v3");
this.position_elem = new dt_ui_element(element_name + "_position_elem");
this.action_elem = new dt_ui_element(element_name + "_action_elem");
this.button_track = new dt_ui_button(element_name + "_track");
this.button_copy_pos = new dt_ui_button(element_name + "_copy_pos");
this.button_copy_last = new dt_ui_button(element_name + "_copy_last");
this.lbl_preset_az = new dt_ui_element(element_name + "_lbl_preset_az");
this.button_az_n270 = new dt_ui_button(element_name + "_az_n270");
this.button_az_n180 = new dt_ui_button(element_name + "_az_n180");
this.button_az_n90 = new dt_ui_button(element_name + "_az_n90");
this.button_az_0 = new dt_ui_button(element_name + "_az_0");
this.button_az_p90 = new dt_ui_button(element_name + "_az_p90");
this.button_az_p180 = new dt_ui_button(element_name + "_az_p180");
this.button_az_p270 = new dt_ui_button(element_name + "_az_p270");
this.preset_az = new dt_ui_element(element_name + "_preset_az");
this.lbl_preset_el = new dt_ui_element(element_name + "_lbl_preset_el");
this.button_el_0 = new dt_ui_button(element_name + "_el_0");
this.button_el_30 = new dt_ui_button(element_name + "_el_30");
this.button_el_90 = new dt_ui_button(element_name + "_el_90");
this.preset_el = new dt_ui_element(element_name + "_preset_el");
this.lbl_preset_azel = new dt_ui_element(element_name + "_lbl_preset_azel");
this.button_azel_focus = new dt_ui_button(element_name + "_azel_focus");
this.button_azel_show = new dt_ui_button(element_name + "_azel_show");
this.preset_azel = new dt_ui_element(element_name + "_preset_azel");
this.window.add(
[this.position_elem, this.action_elem,
this.preset_az, this.preset_el, this.preset_azel]);
this.position_elem.add([this.pos_v1, this.pos_v2, this.pos_v3]);
this.pos_v1.add(
[this.lbl_filler, this.lbl_last_setpoint, this.lbl_new_setpoint]);
this.pos_v2.add(
[this.lbl_azimuth, this.val_last_azimuth, this.txt_new_azimuth]);
this.pos_v3.add(
[this.lbl_elevation, this.val_last_elevation, this.txt_new_elevation]);
this.action_elem.add(
[this.button_track, this.button_copy_pos, this.button_copy_last]);
this.preset_az.add(
[this.lbl_preset_az,
this.button_az_n270, this.button_az_n180, this.button_az_n90,
this.button_az_0,
this.button_az_p90, this.button_az_p180, this.button_az_p270]);
this.preset_el.add(
[this.lbl_preset_el,
this.button_el_0, this.button_el_30, this.button_el_90]);
this.preset_azel.add(
[this.lbl_preset_azel,
this.button_azel_focus, this.button_azel_show]);
this.lbl_azimuth.wrap_set(false);
this.lbl_azimuth.text_set("Azimuth");
this.lbl_elevation.wrap_set(false);
this.lbl_elevation.text_set("Elevation");
this.lbl_last_setpoint.wrap_set(false);
this.lbl_last_setpoint.text_set("Last Setpoint:");
this.lbl_new_setpoint.wrap_set(false);
this.lbl_new_setpoint.text_set("New Setpoint:");
this.val_last_azimuth.value_set("-----");
this.val_last_elevation.value_set("-----");
this.txt_new_azimuth.length_set(9);
this.txt_new_elevation.length_set(9);
this.button_track.text_set("Track new setpoint");
this.button_copy_pos.text_set("Copy current position");
this.button_copy_last.text_set("Copy last setpoint");
this.lbl_preset_az.text_set("Azimuth:");
this.button_az_n270.text_set("W -270");
this.button_az_n180.text_set("N -180");
this.button_az_n90.text_set("E -90");
this.button_az_0.text_set("S 0");
this.button_az_p90.text_set("W 90");
this.button_az_p180.text_set("N 180");
this.button_az_p270.text_set("E 270");
this.lbl_preset_el.text_set("Elevation:");
this.button_el_0.text_set("Horizon 0");
this.button_el_30.text_set("Show 30");
this.button_el_90.text_set("Zenith 90");
this.lbl_preset_azel.wrap_set(false);
this.lbl_preset_azel.text_set("Azimuth & Elevation:");
this.button_azel_focus.text_set("Focusbox 134.7, -0.05");
this.button_azel_show.text_set("Show -6, 30");
this.position_elem.resize_equal(
[this.lbl_filler,
this.lbl_azimuth, this.lbl_elevation,
this.lbl_last_setpoint, this.lbl_new_setpoint,
this.val_last_azimuth, this.val_last_elevation,
this.txt_new_azimuth, this.txt_new_elevation]);
this.pos_v1.align_vertical(
[this.lbl_filler, this.lbl_last_setpoint, this.lbl_new_setpoint], 5);
this.pos_v2.align_vertical(
[this.lbl_azimuth, this.val_last_azimuth, this.txt_new_azimuth], 5);
this.pos_v3.align_vertical(
[this.lbl_elevation, this.val_last_elevation, this.txt_new_elevation], 5);
this.position_elem.align_horizontal(
[this.pos_v1, this.pos_v2, this.pos_v3], 5);
this.action_elem.align_vertical(
[this.button_track, this.button_copy_pos], 10);
this.action_elem.align_horizontal(
[this.button_copy_pos, this.button_copy_last], 10);
this.window.align_vertical(
[this.position_elem, this.action_elem], 5);
this.preset_az.resize_equal(
[this.lbl_preset_az,
this.button_az_n270, this.button_az_n180, this.button_az_n90,
this.button_az_0,
this.button_az_p90, this.button_az_p180, this.button_az_p270]);
this.preset_az.align_vertical(
[this.lbl_preset_az,
this.button_az_n270, this.button_az_n180, this.button_az_n90,
this.button_az_0,
this.button_az_p90, this.button_az_p180, this.button_az_p270]);
this.preset_el.resize_equal(
[this.lbl_preset_el,
this.button_el_0, this.button_el_30, this.button_el_90]);
this.preset_el.align_vertical(
[this.lbl_preset_el,
this.button_el_0, this.button_el_30, this.button_el_90]);
this.preset_azel.resize_equal(
[this.lbl_preset_azel,
this.button_azel_focus, this.button_azel_show]);
this.preset_azel.align_vertical(
[this.lbl_preset_azel,
this.button_azel_focus, this.button_azel_show]);
this.window.align_horizontal(
[this.position_elem,
this.preset_az, this.preset_el, this.preset_azel], 10);
/*
block behaviour.
*/
this.do_track = function()
{
var az = azel_this.txt_new_azimuth.value_get();
var el = azel_this.txt_new_elevation.value_get();
az = floatval(az);
el = floatval(el);
azel_this.txt_new_azimuth.value_set(az);
azel_this.txt_new_elevation.value_set(el);
if (az > 270 || az < -270 || el > 91 || el < -1) {
alert("("+ az + "," + el + ") is not a vlid position.");
} else {
dt_websocket_send("command azel " +
az + " " + el);
azel_this.val_last_azimuth.value_set(az);
azel_this.val_last_elevation.value_set(el);
}
}
this.set_az = function(az)
{
this.txt_new_azimuth.value_set(az);
}
this.set_el = function(el)
{
this.txt_new_elevation.value_set(el);
}
this.button_track.onclick = function() { azel_this.do_track() }
this.button_copy_last.onclick = function() {
azel_this.set_el(azel_this.val_last_elevation.value_get());
azel_this.set_az(azel_this.val_last_azimuth.value_get());
}
this.azimuth_position_get = function() { return 0; }
this.elevation_position_get = function() { return 0; }
this.copy_position = function()
{
azel_this.set_el(azel_this.elevation_position_get());
azel_this.set_az(azel_this.azimuth_position_get());
}
this.button_copy_pos.onclick = function() { azel_this.copy_position() }
this.button_az_n270.onclick = function() { azel_this.set_az(-270) }
this.button_az_n180.onclick = function() { azel_this.set_az(-180) }
this.button_az_n90.onclick = function() { azel_this.set_az(-90) }
this.button_az_0.onclick = function() { azel_this.set_az(0) }
this.button_az_p90.onclick = function() { azel_this.set_az(90) }
this.button_az_p180.onclick = function() { azel_this.set_az(180) }
this.button_az_p270.onclick = function() { azel_this.set_az(270) }
this.button_el_0.onclick = function() { azel_this.set_el(0) }
this.button_el_30.onclick = function() { azel_this.set_el(30) }
this.button_el_90.onclick = function() { azel_this.set_el(90) }
this.button_azel_focus.onclick = function() {
azel_this.set_el(-0.05);
azel_this.set_az(134.7)
}
this.button_azel_show.onclick = function() {
azel_this.set_el(30);
azel_this.set_az(-6)
}
/*
The complete 'azel' block can be switched on and off.
*/
this.visible_set = function(visible)
{
azel_this.window.visible_set(visible);
}
}
} /* azel_loaded */
/*
Javascript with DT UI elements
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2011
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2011, 2014
Copyright Stichting C.A. Muller Radioastronomiestation, 2011
This program is free software: you can redistribute it and/or modify
......@@ -24,8 +24,10 @@ var dt_ui_loaded;
if (!dt_ui_loaded) {
dt_ui_loaded = true;
dt_ui_color_text = "black";
dt_ui_color_text_title = "blue";
dt_ui_color_background = "lightgrey";
dt_ui_color_background_value = "white";
dt_ui_color_background_title = "silver";
dt_ui_color_indicator_off = "grey";
dt_ui_color_indicator_green = "#00ff00";
......@@ -134,21 +136,35 @@ dt_ui_element.prototype.left_get = function()
l = 0;
return l;
}
dt_ui_element.prototype.resize_equal = function(elements)
dt_ui_element.prototype.resize_equal_width = function(elements)
{
var i;
var maxw = 0;
var maxh = 0;
for (i = 0; i < elements.length; i++) {
maxw = Math.max(maxw, elements[i].element.offsetWidth);
maxh = Math.max(maxh, elements[i].element.offsetHeight);
}
for (i = 0; i < elements.length; i++) {
elements[i].width_set(maxw);
}
}
dt_ui_element.prototype.resize_equal_height = function(elements)
{
var i;
var maxh = 0;
for (i = 0; i < elements.length; i++) {
maxh = Math.max(maxh, elements[i].element.offsetHeight);
}
for (i = 0; i < elements.length; i++) {
elements[i].height_set(maxh);
}
}
dt_ui_element.prototype.resize_equal = function(elements)
{
this.resize_equal_width(elements);
this.resize_equal_height(elements);
}
dt_ui_element.prototype.room = function(element)
{
var w;
......@@ -215,7 +231,36 @@ dt_ui_element.prototype.visible_set = function(visible)
this.element.style.display = "none";
}
}
dt_ui_element.prototype.text_set = function (text)
{
this.element.innerHTML = text;
this.element.style.color = dt_ui_color_text;
if (this.parent)
this.parent.room(this);
}
dt_ui_element.prototype.wrap_set = function (wrap, pre)
{
if (!wrap) {
this.element.style.whiteSpace = "nowrap";
return;
}
if (!pre){
this.element.style.whiteSpace = "normal";
return;
}
this.element.style.whiteSpace = "pre";
}
function dt_ui_canvas(elementid)
{
this.element = document.createElement("canvas");
this.element.id = elementid;
dt_ui_element.call(this, elementid);
}
dt_ui_canvas.prototype = new dt_ui_element();
function dt_ui_title(elementid)
......@@ -286,7 +331,7 @@ function dt_ui_value(elementid)
this.element.style.borderStyle = "solid";
this.element.style.borderWidth = "1px";
this.element.style.borderColor = "black";
this.element.style.background = dt_ui_color_background;
this.element.style.background = dt_ui_color_background_value;
this.element.style.alignContent = "center";
this.element.style.textAlign = this.align;
this.element.style.display = "block";
......@@ -302,6 +347,116 @@ dt_ui_value.prototype.value_set = function(value)
if (this.parent)
this.parent.room(this);
}
dt_ui_value.prototype.value_get = function(value)
{
return this.element.innerHTML;
}
function dt_ui_select(elementid)
{
this.element = document.createElement("select");
dt_ui_element.call(this, elementid);
this.element.onchange = function() {
var opt = this.options[this.selectedIndex];
if (opt.dt_ui_onclick)
opt.dt_ui_onclick(opt.dt_ui_elem);
}
}
dt_ui_select.prototype = new dt_ui_element();
dt_ui_select.prototype.option_add = function(name, onclick, elem)
{
var option = document.createElement("option");
option.text = name;
option.onclick = function() {
if (onclick)
onclick(elem);
}
option.dt_ui_onclick = onclick;
option.dt_ui_elem = elem;
this.element.add(option, null);
}
dt_ui_select.prototype.option_clear = function()
{
while (this.element.options.length)
this.element.remove(0);
}
function dt_ui_text(elementid)
{
this.element = document.createElement("input");
this.element.type = "text";
this.element.id = elementid;
this.text_length;
this.text_height = 1;
dt_ui_element.call(this, elementid);
}
dt_ui_text.prototype = new dt_ui_element();
dt_ui_text.prototype.value_set = function(value)
{
this.element.value = value;
if (this.parent)
this.parent.room(this);
}
dt_ui_text.prototype.value_get = function()
{
return this.element.value;
}
dt_ui_text.prototype.value_set = function(val)
{
this.element.value = val;
}
dt_ui_text.prototype.length_set = function(len)
{
if (this.textheight == 1) {
this.element.size = len;
} else {
this.element.cols = len;
}
this.text_length = len;
}
function dt_ui_textarea(elementid)
{
this.element = document.createElement("textarea");
this.element.id = elementid;
this.text_length;
dt_ui_element.call(this, elementid);
}
dt_ui_textarea.prototype = new dt_ui_element();
dt_ui_textarea.prototype.value_set = function(value)
{
this.element.value = value;
if (this.parent)
this.parent.room(this);
}
dt_ui_textarea.prototype.value_get = function()
{
return this.element.value;
}
dt_ui_textarea.prototype.value_set = function(val)
{
this.element.value = val;
}
dt_ui_textarea.prototype.text_length_set = function(len)
{
this.element.cols = len;
}
dt_ui_textarea.prototype.text_height_set = function(height)
{
this.element.rows = height;
}
function dt_button(element)
......
......@@ -17,6 +17,9 @@
*/
var dt_view_loaded;
if (!dt_view_loaded) {
dt_view_loaded = true;
function azimuth_view(element)
{
......@@ -288,6 +291,7 @@ function satellite_view(element)
var s_v_this = this;
this.canvas = document.getElementById(element);
this.ctx = this.canvas.getContext("2d");
this.ctx.scale(
......@@ -394,3 +398,6 @@ function satellite_view(element)
}
}
} /* dt_view_loaded */
This diff is collapsed.
/*
Javascript for j2000 tracker control
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009, 2011, 2013
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009, 2011, 2013,
2014
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009,
2011, 2013
......@@ -28,6 +29,7 @@ j2000_loaded = true;
Communication with the tracker
*/
eval(load("dt_ui.js"));
eval(load("status.js"));
function j2000_command (url, ident)
......@@ -87,4 +89,271 @@ function j2000_status(url, ident)
}
var j2000_status_url = "status.cgi";
var j2000_command_url = "command.cgi_j2000";
function j2000(element_name) {
var j2000_this = this;
/*
Create all the UI elements
*/
this.window = new dt_ui_window(element_name);
this.window.title_set("J2000 tracker");
this.elem_filler = new dt_ui_element(element_name + "_filler");
this.lbl_ra = new dt_ui_element(element_name + "_lbl_ra");
this.lbl_dec = new dt_ui_element(element_name + "_lbl_dec");
this.lbl_pos_cur = new dt_ui_element(element_name + "_lbl_pos_cur");
this.lbl_sp_cur = new dt_ui_element(element_name + "_lbl_sp_cur");
this.lbl_sp_new = new dt_ui_element(element_name + "_lbl_sp_new");
this.val_ra_cur = new dt_ui_value(element_name + "_val_ra_cur");
this.val_dec_cur = new dt_ui_value(element_name + "_val_dec_cur");
this.val_ra_sp = new dt_ui_value(element_name + "_val_ra_sp");
this.val_dec_sp = new dt_ui_value(element_name + "_val_dec_sp");
this.txt_ra_sp = new dt_ui_text(element_name + "_txt_ra_sp");
this.txt_dec_sp = new dt_ui_text(element_name + "_txt_dec_sp");
this.button_enabled = new dt_ui_button_indicator(element_name + "_enabled");
this.button_dt_model_enabled = new dt_ui_button_indicator(element_name + "_dt_model_enabled");
this.button_refraction = new dt_ui_button_indicator(element_name + "_dt_model_refraction");
this.button_track = new dt_ui_button(element_name + "_track");
this.button_copy_pos = new dt_ui_button(element_name + "_copy_pos");
this.button_copy_sp = new dt_ui_button(element_name + "_copy_sp");
this.button_preset_0 = new dt_ui_button(element_name + "_preset_0");
this.button_preset_1 = new dt_ui_button(element_name + "_preset_1");
this.button_preset_2 = new dt_ui_button(element_name + "_preset_2");
this.window.add([
this.elem_filler, this.lbl_ra, this.lbl_dec,
this.lbl_pos_cur, this.val_ra_cur, this.val_dec_cur,