Newer
Older
//////////////////
/// Telescope
//////////////////
/// Telescope init
$('[data-control="telescope-lamp"]').click(function(){
$(this).crud("GET", "/api/telescope/lamp").then(function(e){
$(this).crud("PUT", "/api/telescope/lamp", !e.raw)
})
})
$('[data-control="telescope-power"]').click(function(){
$(this).crud("GET", "/api/telescope/power").then(function(e){
$(this).crud("PUT", "/api/telescope/power", !e.raw)
})
})
$('[data-control="telescope-connection"]').click(function(){
$(this).crud("GET", "/api/telescope/connection").then(function(e){
$(this).crud("PUT", "/api/telescope/connection", !e.raw)
})
})
$('[data-control="telescope-unpark"]').click(function(){
$(this).crud("POST", "/api/telescope/coordinates/movement/unpark")
})
$('[data-control="telescope-park"]').click(function(){
$(this).crud("POST", "/api/telescope/coordinates/movement/park")
})
$('[data-control="telescope-cover"]').click(function(){
var data = $(this).data("value")
$(this).crud("POST", "/api/telescope/cover/movement", data)
})
$('[data-control="telescope-error"]').click(function(){
var data = $('[data-parameter="telescope-error"]').val()
$(this).crud("DELETE", "/api/telescope/error", data)
})
$('[data-control="telescope-offset-zd-az"]').click(function(e){
var zd = $('[data-parameter="telescope-offset-zd"]').val() / 3600.0
var az = $('[data-parameter="telescope-offset-az"]').val() / 3600.0
$(this).crud("PUT", "/api/telescope/coordinates/offset", [zd, az])
})
$('[data-control="telescope-offset-rotator"]').click(function(e){
var data = $('[data-parameter="telescope-offset-rotator"]').val()
$(this).crud("POST", "/api/telescope/rotator/movement", data)
})
$('[data-control="telescope-focuser"]').click(function(e){
var data = $('[data-parameter="telescope-focuser"]').val()
$(this).crud("PUT", "/api/telescope/focuser/movement", data*1.0)
})
/// Telescope coordinates
$('[data-control="telescope-coordinates-radec"]').click(function(){
var data_in_button = $(this).data("value")
if (data_in_button) {
var data = data_in_button
} else {
var data = [$('[data-parameter="telescope-coordinates-radec"]').val()]
}
$(this).crud("POST", "/api/telescope/coordinates/movement/radec", data)
})
$('[data-control="telescope-coordinates-altaz"]').click(function(){
var data_in_button = $(this).data("value")
if (data_in_button) {
var data = data_in_button
} else {
var data = [$('[data-parameter="telescope-coordinates-altitude"]').val(),
$('[data-parameter="telescope-coordinates-azimuth"]').val()]
$(this).crud("POST", "/api/telescope/coordinates/movement/altaz", data)
})
$("#coordinates-slew").on("click", function(){
if ($("#altaz_tab").hasClass("active")){
var data = [$('[data-parameter="telescope-coordinates-altitude"]').val(),
$('[data-parameter="telescope-coordinates-azimuth"]').val()]
$(this).crud("POST", "/api/telescope/coordinates/movement/altaz", data)
}
if ($("#radec_tab").hasClass("active")){
var data = $('[data-parameter="telescope-coordinates-radec"]').val()
$(this).crud("POST", "/api/telescope/coordinates/movement/radec", data)
}
})
$("#coordinates-stop").on("click", function(){
$(this).crud("DELETE", "/api/telescope/coordinates/movement")
})
//////////////////
/// Dome
//////////////////
$('[data-control="dome-connection"]').click(function(){
$(this).crud("GET", "/api/dome/connection").then(function(e){
$(this).crud("PUT", "/api/dome/connection", !e.raw)
})
})
$('[data-control="dome-light"]').click(function(){
$(this).crud("GET", "/api/dome/light").then(function(e){
$(this).crud("PUT", "/api/dome/light", !e.raw)
})
})
$('[data-control="dome-azimuth"]').click(function(){
var data = $('[data-parameter="dome-azimuth"]').val()
$(this).crud("POST", "/api/dome/position/movement/azimuth", data)
})
$('[data-control="dome-sync"]').click(function(){
var data = $('[data-parameter="dome-azimuth"]').val()
$(this).crud("PUT", "/api/dome/position/sync", data)
})
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var data = $(this).prop("checked")
$('[data-control="dome-azimuth"]').prop("disabled", data)
$('[data-parameter="dome-azimuth"]').prop("disabled", data)
$(this).crud("PUT", "/api/dome/position/slaved", data)
})
$('[data-control="dome-stop"]').click(function(){
$(this).crud("DELETE", "/api/dome/position/movement")
})
$('[data-control="dome-park"]').click(function(){
$(this).crud("POST", "/api/dome/position/movement/park")
})
$('[data-control="dome-shutter"]').click(function(){
var data = $(this).data("value")
$(this).crud("POST", "/api/dome/shutter/movement", data)
})
//////////////////
/// Camera
//////////////////
/// Camera init
$('[data-control="camera-power"]').click(function(){
$(this).crud("GET", "/api/camera/power").then(function(e){
$(this).crud("PUT", "/api/camera/power", !e.raw)
})
})
$('[data-control="camera-cooler"]').change(function(){
var data = $(this).prop("checked")
$(this).crud("PUT", "/api/camera/cooler", data)
})
$('[data-control="camera-temperature"]').click(function(){
var data = $('[data-parameter="camera-temperature"]').val()
$(this).crud("PUT", "/api/camera/cooler/temperature/setpoint", data)
})
/// Camera controls
function update_subframe(xrange, yrange, binning) {
if (binning) {
$("#binning").val(binning[0])
}
$("#x0").val(xrange[0])
$("#xf").val(xrange[1])
$("#y0").val(yrange[0])
$("#yf").val(yrange[1])
}
$("#binning").on("change", function(){
var data = $(this).val()
$(this).crud("PUT", "/api/camera/frame/binning", [data, data]).then(function(b){
var binning = b.response
$(this).crud("GET", "/api/camera/settings").then(function(e){
var frame = e.response
update_subframe(frame.xrange, frame.yrange, binning)
})
})
$("#frame-full").on("click", function(){
$(this).crud("PUT", "/api/camera/frame/full").then(function(e){
var frame = e.response
update_subframe(frame.xrange, frame.yrange)
})
$("#frame-half").on("click", function(){
$(this).crud("PUT", "/api/camera/frame/half").then(function(e){
var frame = e.response
update_subframe(frame.xrange, frame.yrange)
})
$("#frame-small").on("click", function(){
$(this).crud("PUT", "/api/camera/frame/small").then(function(e){
var frame = e.response
update_subframe(frame.xrange, frame.yrange)
})
var exp_value = 0
$("#frametyp").on("load, change", function(){
var frametyp = $(this).val()
if (frametyp=="Bias") {
exp_value = $("#exptime").val()
$("#exptime").val(0).prop("disabled", true)
} else {
$("#exptime").val(exp_value).prop("disabled", false)
}
if (frametyp=="Light") {
$('[data-control="recenter"]').prop("checked",true)
$('[data-parameter="recenter-box"]').prop("disabled", false)
} else {
$('[data-control="recenter"]').prop("checked",false)
$('[data-parameter="recenter-box"]').prop("disabled", true)
}
if (frametyp=="Light") {
$('[data-control="domeslewing"]').prop("checked",true)
} else {
$('[data-control="domeslewing"]').prop("checked",false)
}
$('[data-control="recenter"]').change(function(){
var data = $(this).prop("checked")
var box = $('[data-parameter="recenter-box"]')
var size = Number(box.val())
box.prop("disabled", !data)
if(data){
$(this).crud("POST", "/api/camera/snapshot/recenter").then(function(e){
$(this).crud("PUT", "/api/camera/snapshot/recenter", size)
})
} else {
$(this).crud("DELETE", "/api/camera/snapshot/recenter")
}
Andrea Damonte
committed
Andrea Damonte
committed
$('[data-parameter="recenter-box"]').change(function(){
Andrea Damonte
committed
var size = Number($(this).val())
$(this).crud("PUT", "/api/camera/snapshot/recenter", size)
Andrea Damonte
committed
$('[data-control="domeslewing"]').change(function(){
var data = $(this).prop("checked")
if(data){
$(this).crud("POST", "/api/camera/snapshot/domeslewing")
} else {
$(this).crud("DELETE", "/api/camera/snapshot/domeslewing")
}
})
$("#camera-start").on("click", function(){
var data = {
Davide Ricci
committed
"template": "observation",
"params": {
"object": $("#object").val(),
"frametype": $("#frametyp").val(),
"filter": $("#filter").val(),
"exptime": Number($("#exptime").val()),
"repeat": Number($("#repeat").val()),
}
Davide Ricci
committed
$(this).crud("POST", "/api/sequencer/run", data)
})
$("#camera-stop").on("click", function(){
Davide Ricci
committed
$(this).crud("DELETE", "/api/sequencer/run")
Davide Ricci
committed
//////////////////
/// Sequencer
Davide Ricci
committed
//////////////////
$('[data-control="start-sequencer"]').on("click", function(e){
var data = $('[data-parameter="ob-list-options"]').val()
$(this).crud("POST", "/api/sequencer/run", data)
})
$('[data-control="pause-sequencer"]').on("click", function(e){
$(this).crud("PUT", "/api/sequencer/run", false)
})
$('[data-control="resume-sequencer"]').on("click", function(e){
$(this).crud("PUT", "/api/sequencer/run", true)
})
Andrea Damonte
committed
$('[data-control="stop-sequencer"]').on("click", function(e){
$(this).crud("DELETE", "/api/sequencer/run")
})
Andrea Damonte
committed
Davide Ricci
committed
//////////////////
/// Blocks
Davide Ricci
committed
//////////////////
$(document).on("click", "#create-ob", function(e){
e.preventDefault();
var data = $("#new-ob-name").val()
$(this).crud("POST", "/api/blocks/", data).then(function(e){
location.href = data;
})
});
Davide Ricci
committed
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
$(document).on("click","#update-ob", function(e){
e.preventDefault();
var data = []
$("fieldset").each(function() {
data.push({"template": $(this).data("template"),
"params": serializeObject($(this))
})
})
var name = $("form").data("name")
$(this).crud("PUT", "/api/blocks/"+name, data)
});
$(document).on("click", "#delete-ob", function(e){
e.preventDefault();
var data = $("form").data("name")
var form = $("form[data-name='"+name+"']")
$(this).crud("DELETE", "/api/blocks/", data).then(function(e){
form.fadeOut(500, function(){ $(this).remove()})
location.href = "./"
})
});
$(document).on("click",'[data-control="delete-template-instance"]', function(e){
e.preventDefault();
var name = $(this).data("name")
var data = $(this).data("parameter") // starting from 0?
console.log("clic", name, data)
var fieldset = $("fieldset[data-parameter="+data+"]")
$(this).crud("DELETE", "/api/blocks/"+name, data).then(function(e){
$("input", fieldset).css("border","1px solid red")
fieldset.fadeOut(500, function(){ $(this).remove()})
})
});
// Reload on list selection
$(document).on("change","#tpl-list-options", function(e){
e.preventDefault();
var name = $("form").data("name")
var data = $(this).val()
$(this).crud("POST", "/api/blocks/"+name, data).then(function(e){
location.reload()
})
});
// Reload on list selection
$('[data-parameter="blocks-list-options"]').on("change", function(e){
var val = $(this).val()
if (val!=null){
$.get(val, {included:true}, function(data){
$("#ob-list").html(data)
})
}
}).trigger("change")
//////////////////
/// Display output test
//////////////////