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

1. fixed trig bug 2. fixed restore period bug

parent 5b08f76f
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
if(!empty($available_ports)){ if(!empty($available_ports)){
$trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER)); $trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER));
$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;?>;
......
...@@ -2,100 +2,57 @@ ...@@ -2,100 +2,57 @@
var tp_old = 0; var tp_old = 0;
function take_snapshot(){ 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(); trigger();
} }
}); });
} }
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();
}
});
}
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){
ports.forEach(function(c,i){ ports.forEach(function(c,i){
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