Commit 047f4253 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. fixed trig bug 2. fixed restore period bug

parent 5b08f76f
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
$trig_master_port = $trig_master + $port0; $trig_master_port = $trig_master + $port0;
} }
if ($trig_master>0){ if ($trig_master>=0){
if (isset($_GET['trig'])){ if (isset($_GET['trig'])){
// just in case one wants to override master // just in case one wants to override master
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
$f = fopen("http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers", 'r'); $f = fopen("http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers", 'r');
fclose($f); fclose($f);
die(); die("trigger ok: http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers");
} }
} }
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
<script> <script>
var ip = location.origin; var ip = location.origin;
var href = location.href;
var ports = [<?php echo implode(",",$available_ports);?>]; var ports = [<?php echo implode(",",$available_ports);?>];
var trig_master = <?php echo $trig_master;?>; var trig_master = <?php echo $trig_master;?>;
var trig_master_port = <?php echo $trig_master_port;?>; var trig_master_port = <?php echo $trig_master_port;?>;
......
...@@ -6,46 +6,23 @@ function take_snapshot(){ ...@@ -6,46 +6,23 @@ function take_snapshot(){
$("#snapshot").attr("disabled",true); $("#snapshot").attr("disabled",true);
if(ports.length!=0){ if(ports.length!=0){
if ($("#synced").prop("checked")){
if ($("#synced").attr("checked")){
read_trig_master(); read_trig_master();
}else{ }else{
download_all(false); download_all(false);
} }
}else{ }else{
console.log("No ports detected"); console.log("No ports detected");
} }
} }
function read_trig_master(){ function read_trig_master(){
var param = "TRIG_MASTER"; var param = "TRIG_MASTER";
$.ajax({ $.ajax({
url: ip+"/parsedit.php?immediate&"+param, url: ip+"/parsedit.php?immediate&"+param,
success:function(data){ success:function(data){
trig_master = parseInt($(data).find(param)); trig_master = parseInt($(data).find(param).text());
read_tp();
}
});
}
function read_tp(){
var param = "TRIG_PERIOD";
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
tp_old = parseInt($(data).find(param));
trigger();
}
});
}
// channel independent or lowest?
function read_par(param,callback){
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
tp_old = parseInt($(data).find("TRIG_MASTER"));
trigger(); trigger();
} }
}); });
...@@ -53,36 +30,15 @@ function read_par(param,callback){ ...@@ -53,36 +30,15 @@ function read_par(param,callback){
function trigger(){ function trigger(){
$.ajax({ $.ajax({
url:ip+"?trig", url:href+"?trig",
success:function(){ success:function(){
setTimeout(function(){ setTimeout(function(){
download_all(true); download_all(true);
},500); },200);
}
});
}
function restore_trig_period(){
$.ajax({
url: ip+"/parsedit.php?immediate&TRIG_PERIOD="+(tp_old+1)+"*-2&sensor_port="+trig_master,
success: function(){
$.ajax({
url: ip+"/parsedit.php?immediate&TRIG_PERIOD="+(tp_old)+"*-2&sensor_port="+trig_master,
success: function(){
console.log("Done!");
$("#snapshot").attr("disabled",false);
}
});
} }
}); });
} }
function download_all(rtp){ function download_all(rtp){
...@@ -91,11 +47,12 @@ function download_all(rtp){ ...@@ -91,11 +47,12 @@ function download_all(rtp){
download_single(ip+":"+c+"/img"); download_single(ip+":"+c+"/img");
}); });
// give 500ms (?)
if (rtp) { if (rtp) {
setTimeout(function(){ setTimeout(function(){
restore_trig_period(); read_tp();
},200); },200);
}else{
$("#snapshot").attr("disabled",false);
} }
} }
...@@ -116,6 +73,34 @@ function download_single(addr){ ...@@ -116,6 +73,34 @@ function download_single(addr){
} }
function read_tp(){
var param = "TRIG_PERIOD";
$.ajax({
url: ip+"/parsedit.php?immediate&"+param,
success:function(data){
tp_old = parseInt($(data).find(param).text());
restore_trig_period();
}
});
}
function restore_trig_period(){
console.log("restore period");
$.ajax({
url: ip+"/parsedit.php?immediate&TRIG_PERIOD="+(tp_old)+"*-2&sensor_port="+trig_master,
success: function(){
console.log("Done!");
$("#snapshot").attr("disabled",false);
}
});
}
function toggle_help(){ function toggle_help(){
$("#help").toggle(); $("#help").toggle();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment